Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Cross-browser multiplatform JavaScript joystick Input.
branch: master
Failed to load latest commit information.
Mac Added OIS lib for Mac
Win Compiling and running on Win
X11 Updated to newer OIS
closure Add an externs file for use with the closure compiler.
extensions Updated OS X plugin
include/json Added JSON method to get Joystick data
lib Updated win extension and bumping version
Boomstick.cpp Renamed and refactored files to use Boomstick name
Boomstick.h
BoomstickAPI.cpp Added POV
BoomstickAPI.h Added property for maxAxes
CMakeLists.txt Added JSON method to get Joystick data
Factory.cpp Code cleanup
Joysticks.cpp Removed unused event handling methods
Joysticks.h
LICENSE.txt
PluginConfig.cmake Removing XBox360 refs from config
README.md Update README.md
jsoncpp.cpp Added JSON method to get Joystick data
test.html Added simple test html page
xbox.rb Added xboxdrv helper script

README.md

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

OS X, Linux Chrome Extension TODO: Firefox Extension

Sample HTML

<object id="plugin" type="application/x-boomstickjavascriptjoysticksupport" width="0" height="0"></object>

<script>
  var joysticks = JSON.parse(plugin.joysticksJSON());
</script>

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 axes

The 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 down

All 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
Something went wrong with that request. Please try again.