My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
API  
JavaScript API
Featured, Phase-Implementation
Updated Oct 10, 2011 by cwoffen...@gmail.com

JavaScript API

The plug-in currently works with Firefox, IE, Opera and Safari on Windows, and Safari on OS X. The API is the same across all browsers.

Methods

booleansetDevice(int index)
Select the game device the plug-in instance is connected to; returns true if a controller is connected.
int getDevice()
Returns the index of the game device currently set.
booleanisConnected()
Returns true if a controller is connected.
voidsetAutoPoll(boolean autoPoll)
Normally the device state is automatically polled every time a property is read, which may be too slow for the older analogue interface. Setting this to false only polls the device when a poll() is issued, and the property values are taken from that time. (It may also allow for better sync in longer game loops.)
voidpoll()
An explicit poll to the game device.
stringgetProductName()
Returns the OEM name of the game device.

Properties

int x
Joystick x-axis.
int y
Joystick y-axis.
int z
Throttle (or z-axis).
int r
Rudder (or r-axis).
int u
Joystick u-axis.
int v
Joystick v-axis.
booleana
true if the A button is pressed (the A button can be reassigned to any of the controller's buttons)
booleanb
true if the B button is pressed (the B button can be reassigned to any of the controller's buttons)
intbuttons
An integer representing the state of all the game controller's buttons as individual bits

Embedding

For IE (or other ActiveX containers) the class ID is 3AE9ED90-4B59-47A0-873B-7B71554B3C3E. For all other browsers the MIME-type is application/x-vnd.numfum-joystick. Sample code to follow.

Powered by Google Project Hosting