Giter VIP home page Giter VIP logo

input.js's Introduction

Attempting to node-ify this project

TODO: TESTSSSSS

Input.js

Input.js is a JavaScript library to map controller and OS-specific USB enumerations provided by the Gamepad API in Mozilla Firefox to an ideal virtual gamepad. While developed for use in Paladin, Mozilla's open source 3D gaming initiative, Input.js is designed to be used by any web application.

Info

Supported Controllers

  • Logitech Chillstream on Windows
  • Playstation 3 on Mac OS X
  • Xbox 360 on Mac OS X and Windows

How to use Input.js in three steps

  • Load your copy of Input.js into your webpage:
<script type="text/javascript" src="input.js"></script>
  • Create the Device object:
var gamepad;
window.addEventListener("MozGamepadConnected", function(e) {
  gamepad = new Input.Device(e.gamepad);
});
  • Use it:
if (gamepad.buttons.BUTTON_A) {
  player.jump();
}
player.move(gamepad.buttons.LEFT_STICK_X, gamepad.buttons.LEFT_STICK_Y);

The API

You should read the Gamepad API as a background primer. There are 5 properties on the Input.Device object:

  • axes - An object that holds all of axis properties. They each return a value from -1.0 to +1.0.
    • Left_Stick_X
    • Left_Stick_Y
    • Right_Stick_X
    • Right_Stick_X
  • buttons - An object that holds all of the button properties. They each return a value from 0.0 to 1.0. Buttons can be digital or analog
    • A_Button - Cross on the PS3
    • B_Button - Circle on the PS3
    • X_Button - Triangle on the PS3
    • Y_Button - Square on the PS3
    • Left_Stick_Button - L3 on the PS3
    • Right_Stick_Button - R3 on the PS3
    • Start_Button -
    • Back_Button - Select on the PS3
    • Home_Button - Xbox or PS button in the middle of the controller
    • Pad_Up - Up on the digital pad
    • Pad_Down - Down on the digital pad
    • Pad_Left - Left on the digital pad
    • Pad_Right - Right on the digital pad
    • Left_Trigger_1 - Left Bumper on the Xbox 360, L1 on the PS3
    • Right_Trigger_1 - Right Bumper on the Xbox 360, R1 on the PS3
    • Left_Trigger_2 - Left Trigger on the Xbox 360, L2 on the PS3
    • Right_Trigger_2 - Right Trigger on the Xbox 360, R2 on the PS3
  • connected - A boolean that returns the current connected state of the device
  • id - A string with the USB vendor ID, USB device ID, and OS device name
  • index - A number starting at zero that represents the order the device was plugged in. Persists across reconnects.

input.js's People

Contributors

jbuck avatar buddyp450 avatar rhung avatar

Watchers

James Cloos 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.