GithubHelp home page GithubHelp logo

boomstick's Introduction

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

boomstick's People

Contributors

lanamoore avatar strd6 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.