Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/STRd6/Boomstick
Cross-browser multiplatform JavaScript joystick Input.
https://github.com/STRd6/Boomstick
Last synced: 9 days ago
JSON representation
Cross-browser multiplatform JavaScript joystick Input.
- Host: GitHub
- URL: https://github.com/STRd6/Boomstick
- Owner: STRd6
- License: mit
- Created: 2011-06-18T05:47:47.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2012-04-20T16:48:26.000Z (over 12 years ago)
- Last Synced: 2024-11-01T00:09:11.076Z (11 days ago)
- Language: C++
- Homepage:
- Size: 11.7 MB
- Stars: 42
- Watchers: 4
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Boomstick [Alpha] enables HTML5 and JavaScript games to access native joysticks.
By using FireBreath to handle cross-browser, multi-platform plugin generation
and OIS to handle multi-platform joystick input, Boomstick gives JavaScript
applications total access to joysticks and gamepads.Works on all platforms.
Windows
[Windows Installer][1]OS X, Linux
[Chrome Extension][2]
TODO: Firefox ExtensionSample HTML
var joysticks = JSON.parse(plugin.joysticksJSON());
Calling .joysticksJSON() returns a JSON string containing the current state of all joysticks.
'[
{"axes":[0,0,0,0,0],"buttons":0,"pov":0},
{"axes":[0,0],"buttons":0,"pov":0},
...
]'
// Read thusly
joysticks = JSON.parse(plugin.joysticksJSON())The axes property is an array of all the axes. Usually the order is x, y, of primary stick first, but different drivers and gamepads may report them differently.
joysticks[0].axes[0] // Returns x axis position in range [-32768, 32767]
joysticks[0].axes[1] // Returns y axis position in range [-32768, 32767]
joysticks[0].axes[2] // ... likewise for additional axesThe buttons are returned as a bitfield
BUTTON_0 = 1
BUTTON_1 = 2
BUTTON_2 = 4
BUTTON_3 = 8
...// Check the buttons as follows
joysticks[0].buttons & BUTTON_0 // Button 0 is down
joysticks[0].buttons & BUTTON_2 // Button 2 is downAll joysticks currently return one POV property regardless of how many POV inputs the physical device actually has. Like the buttons is a bitfield.
UP = 1
DOWN = 16
RIGHT = 256
LEFT = 4096[1]: https://github.com/downloads/STRd6/Boomstick/windows_install.zip "Windows Installer"
[2]: https://chrome.google.com/webstore/detail/ibghgpidpbpnhdgmncpbhioaohmgkigo