Giter Site home page Giter Site logo

gameinputjs's People

Contributors

lunarcloud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

zacharysarette

gameinputjs's Issues

Change Button Mapping

Numbered buttons are not helpful in all situations.
Developers want to know both buttons as direction and buttons as ordinal.

"button#" was originally supposed to be used for the differences between Nintendo and Sega-family button names/uses.
I ended up implementing it as directional.
Developers need both.

Proposal

GamepadMapping 
{
    dpad: [up, right, down, left], // css-style clockwise order
    leftStick: [up, right, down, left],
    rightStick: [up, right, down, left],
    face: [up, right, down, left],

    faceDirection: "ltr" | "rtl", // left-to-right (default) is "hedgehog", right-to-left is "plumber" 
    faceExtra: [upper, lower], // C and Z or Black and White buttons

    shoulder: [left, right],
    trigger: [left, right],
    center: [menu, select] // don't map "OS/Home" button because it'll likely do something actually OS-level
}

// The following must pass/be true for this implementation to be good
test('button mappings to direction', () => {
    expect(mapping.face[0]).toBe(mapping.faceDirection("up"))
    expect(mapping.face[1].toBe(mapping.faceDirection("right"))
    expect(mapping.face[2].toBe(mapping.faceDirection("down"))
    expect(mapping.face[3].toBe(mapping.faceDirection("left"))
});

test('button mappings directions to ordinal', () => {
    if (mapping.faceDirection === "ltr") {
        expect(mapping.faceOrdinal(0).toBe(mapping.faceDirection("down"))
        expect(mapping.faceOrdinal(1).toBe(mapping.faceDirection("right"))
        expect(mapping.faceOrdinal(2).toBe(mapping.faceDirection("left"))
        expect(mapping.faceOrdinal(3).toBe(mapping.faceDirection("up"))
    } else { // "rtl"
        expect(mapping.faceOrdinal(0).toBe(mapping.faceDirection("right"))
        expect(mapping.faceOrdinal(1).toBe(mapping.faceDirection("down"))
        expect(mapping.faceOrdinal(2).toBe(mapping.faceDirection("up"))
        expect(mapping.faceOrdinal(3).toBe(mapping.faceDirection("left"))
    }
});

Also, buttons/axes should be 0-index defined, to match the actual Gamepad API (way easier when creating new mapping to not have to mentally +1)

Probably will need to re-work the demo page.

Add deadzones to analog sticks

Create a "rawAnalogState" with the actual value and set "analogState" values to 0 unless they exceed the "deadzone" value threshold.

Add ImpactJS Plugin

Since a dirty-hacked-not-pretty impactjs plugin exists already, it should be cleaned up and officially included in this repository.

Add new model

new gi.Model(
gi.Type.Plumber,
"nintendo-generic",
"BUFFALO BGC-FC801 USB Gamepad (Vendor: 0411 Product: 00c6)",
"macOS",
new gi.Schema.GamePadAPI(
/* d_up / new gi.Schema.AxisButton(-2),
/
d_down / new gi.Schema.AxisButton(2),
/
d_left / new gi.Schema.AxisButton(-1),
/
d_right / new gi.Schema.AxisButton(1),
/
menu / 8,
/
button0 / 1,
/
button1 / 2,
/
button2 / 3,
/
button3 / 4,
/
l_up / undefined,
/
l_down / undefined,
/
l_left / undefined,
/
l_right / undefined,
/
r_up / new gi.Schema.AxisButton(-4),
/
r_down / new gi.Schema.AxisButton(4),
/
r_left / new gi.Schema.AxisButton(-3),
/
r_right / new gi.Schema.AxisButton(3),
/
l_button / 5,
/
r_button / 6,
/
l_trigger / undefined,
/
r_trigger */ undefined
)
),

Investigate Alternative model matcher

Instead of matching exact id, use a regex on the id to find the vendor id, product id, and whether "STANDARD GAMEPAD" is present.
Firefox uses "VID-PID-name" Chromuim browers use "name ([STANDARD GAMEPAD]? Vendor: VID, Product: PID)"

This way we can maybe apply themes to entire vendors (all nintendo devices are 'plumber', etc)

Add New Model

new gi.Model(
gi.Type.Plumber,
"nintendo-generic",
"USB,2-axis 8-button gamepad (STANDARD GAMEPAD Vendor: 0583 Product: 2060)",
"macOS",
new gi.Schema.GamePadAPI(
/* d_up / 13,
/
d_down / 14,
/
d_left / 15,
/
d_right / 16,
/
menu / 10,
/
button0 / 1,
/
button1 / 2,
/
button2 / 3,
/
button3 / 4,
/
l_up / undefined,
/
l_down / undefined,
/
l_left / undefined,
/
l_right / undefined,
/
r_up / new gi.Schema.AxisButton(-4),
/
r_down / new gi.Schema.AxisButton(4),
/
r_left / new gi.Schema.AxisButton(-3),
/
r_right / new gi.Schema.AxisButton(3),
/
l_button / 5,
/
r_button / 6,
/
l_trigger / undefined,
/
r_trigger */ undefined
)
),

Add Model/ Numbered Generic

new gi.Model(
gi.Type.Hedgehog,
"generic",
"USB Joystick (Vendor: 1345 Product: 1030)",
"macOS",
new gi.Schema.GamePadAPI(
/* d_up / new gi.Schema.AxisButton(-2),
/
d_down / new gi.Schema.AxisButton(2),
/
d_left / new gi.Schema.AxisButton(-1),
/
d_right / new gi.Schema.AxisButton(1),
/
menu / 10,
/
button0 / 1,
/
button1 / 2,
/
button2 / 3,
/
button3 / 4,
/
l_up / undefined,
/
l_down / undefined,
/
l_left / undefined,
/
l_right / undefined,
/
r_up / new gi.Schema.AxisButton(-4),
/
r_down / new gi.Schema.AxisButton(4),
/
r_left / new gi.Schema.AxisButton(-3),
/
r_right / new gi.Schema.AxisButton(3),
/
l_button / 5,
/
r_button / 6,
/
l_trigger / 7,
/
r_trigger */ 8
)
),

dsc_0210
dsc_0211
dsc_0212

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.