Skip to content
Clive Galway edited this page Mar 15, 2019 · 11 revisions

Setting up

Include the library.

#include <CvJoyInterface>

Instantiate the class.

vJoyInterface := new CvJoyInterface()

Check the interaface to vJoy is open OK (Optional).

if (vJoyInterface.vJoyEnabled()){
	...
}

You are now ready to rock!


Settings

SingleStickMode

By Default, SingleStickMode is On.
When SingleStickMode is On, the library will automatically Acquire a decvice if you try to issue a SetBtn or SetAxis command on an un-Acquired stick (Relinquishing any stick it currently has Acquired).
If you wish to control multiple vjoy sticks at one time, set the SingleStickMode property of the interface object to 0 like so:

vJoyInterface.SingleStickMode := 0

If you do this, you will have to manually Acquire and Relinquish sticks in accordance with the vJoy spec.

Note that this setting only limits one script from operating one stick at a time.
Multiple scripts using this library, running all at the same time, with this option on - would each be able to control one stick.


Useful Variables

The following variables are provided on the Interface object for convenience, as follows:

LibraryLoaded

After instantiation, tells you if all went OK loading the DLL.

vJoyInterface := new CvJoyInterface()
if (vJoyInterface.LibraryLoaded){
    ...
}

LoadLibraryLog

If Library loading did not go OK, get a log from this var to display to the user.

vJoyInterface := new CvJoyInterface()
if (vJoyInterface.LibraryLoaded){
    msgbox % vJoyInterface.LoadLibraryLog
    ExitApp
}

AxisNames

Lookup for axis number to axis name.
eg vJoyInterface.AxisNames[1] is "X"

AxisIndex

HID Descriptor definitions for the various axes.
eg vJoyInterface.AxisIndex[1] (X Axis) is 0x30

AxisAssoc

As per AxisIndex, but an assosiative array
eg vJoyInterface.AxisAssoc["x"] is 0x30


Commands

Base vJoy SDK commands

All of these are available via the base Interface object.
eg:vJoyInterface.vJoyEnabled()

Please see the vJoy SDK readme here, look in the Interface Function Reference section.

Additional Device-Based commands.

Within the Interface object, there are 16 Device Objects, each corresponding to one of the 16 possible vJoy sticks.
These 16 objects always exist, even if the corresponding vJoy stick does not exist. They can be accessed via the Devices[] collection - for example to call the IsAvailable() method of device 1, you could use:

vJoyInterface.Devices[1].IsAvailable()

SetAxisByIndex

Set Axis by Index number (eg x = 1, y = 2, z = 3, rx = 4)
Automatically acquires the device if not acquired.

SetAxisByIndex(value, index)
value (float):  New value for axis (0...32768)
index (int):    Number of Axis to set.

Example: Set Device 1, axis 2 (Y) to full value
vJoyInterface.Devices[1].SetAxisByIndex(32768, 2)

SetAxisByName

Sets the Axis by Name (eg "x", "y", "z", "rx")

SetAxisByName(value, name)
value (float):  New value for axis (0...32768)
name (string):  Name of Axis to set.

Example: Set Device 1, Y axis to full value
vJoyInterface.Devices[1].SetAxisByName(32768, "y")

GetStatusName

Converts Status to human readable form

GetStatusName()
Returns: "OWN", "FREE", "BUSY", "MISS" or "????"

Example:
result := vJoyInterface.Devices[1].GetStatusName()

IsAvailable

Is this device available to be Acquired?

IsAvailable()
Returns 1 or 0

Example:
result := vJoyInterface.Devices[1].IsAvailable()