Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ffi = require("ffi")
- local vjoy = ffi.load("vJoyInterface.dll")
- ffi.cdef [[
- typedef int BOOL;
- typedef short SHORT;
- typedef unsigned short USHORT;
- typedef int INT;
- typedef unsigned int UINT;
- typedef long LONG;
- typedef unsigned short WORD;
- typedef unsigned long DWORD;
- typedef void *PVOID;
- typedef unsigned char UCHAR;
- typedef void (__stdcall *RemovalCB)(BOOL, BOOL, PVOID);
- SHORT GetvJoyVersion(void);
- BOOL vJoyEnabled(void);
- PVOID GetvJoyProductString(void);
- PVOID GetvJoyManufacturerString(void);
- PVOID GetvJoySerialNumberString(void);
- BOOL DriverMatch(WORD * DllVer, WORD * DrvVer);
- void RegisterRemovalCB(RemovalCB cb, PVOID data);
- BOOL vJoyFfbCap(BOOL * Supported); // Is this version of vJoy capable of FFB?
- BOOL GetvJoyMaxDevices(int * n); // What is the maximum possible number of vJoy devices
- BOOL GetNumberExistingVJD(int * n); // What is the number of vJoy devices currently enabled
- enum VjdStat /* Declares an enumeration data type */
- {
- VJD_STAT_OWN, // The vJoy Device is owned by this application.
- VJD_STAT_FREE, // The vJoy Device is NOT owned by any application (including this one).
- VJD_STAT_BUSY, // The vJoy Device is owned by another application. It cannot be acquired by this application.
- VJD_STAT_MISS, // The vJoy Device is missing. It either does not exist or the driver is down.
- VJD_STAT_UNKN // Unknown
- };
- ///// vJoy Device properties
- int GetVJDButtonNumber(UINT rID); // Get the number of buttons defined in the specified VDJ
- int GetVJDDiscPovNumber(UINT rID); // Get the number of descrete-type POV hats defined in the specified VDJ
- int GetVJDContPovNumber(UINT rID); // Get the number of descrete-type POV hats defined in the specified VDJ
- BOOL GetVJDAxisExist(UINT rID, UINT Axis); // Test if given axis defined in the specified VDJ
- BOOL GetVJDAxisMax(UINT rID, UINT Axis, LONG * Max); // Get logical Maximum value for a given axis defined in the specified VDJ
- BOOL GetVJDAxisMin(UINT rID, UINT Axis, LONG * Min); // Get logical Minimum value for a given axis defined in the specified VDJ
- enum VjdStat GetVJDStatus(UINT rID); // Get the status of the specified vJoy Device.
- // Added in 2.1.6
- BOOL isVJDExists(UINT rID); // TRUE if the specified vJoy Device exists
- // Added in 2.1.8
- int GetOwnerPid(UINT rID); // Reurn owner's Process ID if the specified vJoy Device exists
- ///// Write access to vJoy Device - Basic
- BOOL AcquireVJD(UINT rID); // Acquire the specified vJoy Device.
- void RelinquishVJD(UINT rID); // Relinquish the specified vJoy Device.
- BOOL UpdateVJD(UINT rID, PVOID pData); // Update the position data of the specified vJoy Device.
- ///// Write access to vJoy Device - Modifyiers
- // This group of functions modify the current value of the position data
- // They replace the need to create a structure of position data then call UpdateVJD
- //// Reset functions
- BOOL ResetVJD(UINT rID); // Reset all controls to predefined values in the specified VDJ
- void ResetAll(void); // Reset all controls to predefined values in all VDJ
- BOOL ResetButtons(UINT rID); // Reset all buttons (To 0) in the specified VDJ
- BOOL ResetPovs(UINT rID); // Reset all POV Switches (To -1) in the specified VDJ
- // Write data
- BOOL SetAxis(LONG Value, UINT rID, UINT Axis); // Write Value to a given axis defined in the specified VDJ
- BOOL SetBtn(BOOL Value, UINT rID, UCHAR nBtn); // Write Value to a given button defined in the specified VDJ
- BOOL SetDiscPov(int Value, UINT rID, UCHAR nPov); // Write Value to a given descrete POV defined in the specified VDJ
- BOOL SetContPov(DWORD Value, UINT rID, UCHAR nPov); // Write Value to a given continuous POV defined in the specified VDJ
- ]]
- if vjoy.vJoyEnabled() then
- print(ffi.string(vjoy.GetvJoyManufacturerString()))
- print(ffi.string(vjoy.GetvJoyProductString()))
- print(ffi.string(vjoy.GetvJoySerialNumberString()))
- local dllVer = ffi.new("WORD[1]")
- local drvVer = ffi.new("WORD[1]")
- local match = vjoy.DriverMatch(dllVer, drvVer)
- if match then
- print(string.format("VJOY: Driver version %i matches DLL version %i", tonumber(drvVer[0]), tonumber(dllVer[0])))
- else
- print(string.format("VJOY: Driver version %i MISMATCHES DLL version %i", tonumber(drvVer[0]), tonumber(dllVer[0])))
- end
- end
- return vjoy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement