Follows #34
mapping.analog is specially for mapping analog buttons or pressure-sensitive buttons from an axis location to a button location. This is for things like the L2 and R2 analog triggers, and pressure sensitive D-pad and face buttons on a PS3 controller. Here's how it might look for remapping L2 and R2 triggers on a wired XBox 360 controller:
{
"axes" : [ 0, 1, 3, 4 ],
"buttons" : [ 11, 12, 13, 14, 8, 9, -1, -1, 5, 4, 6, 7, 0, 1, 2, 3, 10 ],
"analog" : [ -1, -1, -1, -1, -1, -1, 2, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1 ]
}
This will fill in that gap in the buttons array during remapping. A little extra code is necessary to combine the axis and the button to produce a meaningful result.
Some mapping test reports:
Chrome (45+) :
Firefox (39+) :
Wiimote on Mac requires a driver: https://github.com/alxn1/wjoy
I haven't mapped it out, yet. But initial testing shows a huge caveat; this driver reports the gamepad id as a string containing a MAC address (which is unique for each device). For this reason, I want to defer Wiimote support to a melonJS plugin; which is better suited to doing things like RegExp over gamepad id.
Ouya gamepad on Mac requires a driver: http://ouyaforum.com/showthread.php?3185-Ouya-controller-input-on-computer-macosx&p=78432&viewfull=1#post78432 This driver is unsigned, so requires disabling KEXT signature checking on OSX 10.10+:
$ sudo nvram boot-args=kext-dev-mode=1
After restarting, load the driver:
$ sudo kextload /System/Library/Extensions/OUYAGameController.kext
Follows #34
examples; for validating mappingsaxes[4]andaxes[5]extension (L2 and R2 analog triggers) tobuttons[me.GAMEPAD.L2].valueandbuttons[me.GAMEPAD.R2].valueme.input.isActionSet(action)(wasme.input.isKeyPressed)me.input.getActionState(action)(wasme.input.keyState)me.input.getActionValue(action)(NEW; returns action analog value)me.input.getAction(action)(NEW; returns action analog value, digital state, and digital edge)me.input.setAction(action, state, value)(NEW; sets action analog value and digital state)me.input.setGamepadMapping(id, mapping)mappingis a hash table containing the following keys:mapping.axesStandard analog control stick axis locationsmapping.buttonsStandard digital button locations[mapping.analog]Analog axis locations for buttons. See: https://developer.mozilla.org/en-US/docs/Web/API/GamepadButton[mapping.normalize_fn]will be called on an unmapped axis or button with the following parameters:valueThe raw value read from the gamepad driveraxisThe axis index from the standard mapping, or -1 if not an axisbuttonThe button index from the standard mapping, or -1 if not a buttonnormalize_fnmust return a normalized value in range[-1.0..1.0], or0.0if the axis is unknown.mapping.analogis specially for mapping analog buttons or pressure-sensitive buttons from an axis location to a button location. This is for things like the L2 and R2 analog triggers, and pressure sensitive D-pad and face buttons on a PS3 controller. Here's how it might look for remapping L2 and R2 triggers on a wired XBox 360 controller:This will fill in that gap in the
buttonsarray during remapping. A little extra code is necessary to combine the axis and the button to produce a meaningful result.Some mapping test reports:
Chrome (45+) :
Wii Remote(not recognised by the browser)Wii "Classic" Gamepad(not recognised by the browser)Firefox (39+) :
Wii Remote(not recognised by the browser)Wii "Classic" Gamepad(not recognised by the browser)Wiimote on Mac requires a driver: https://github.com/alxn1/wjoy
I haven't mapped it out, yet. But initial testing shows a huge caveat; this driver reports the gamepad
idas a string containing a MAC address (which is unique for each device). For this reason, I want to defer Wiimote support to a melonJS plugin; which is better suited to doing things like RegExp over gamepadid.Ouya gamepad on Mac requires a driver: http://ouyaforum.com/showthread.php?3185-Ouya-controller-input-on-computer-macosx&p=78432&viewfull=1#post78432 This driver is unsigned, so requires disabling KEXT signature checking on OSX 10.10+:
After restarting, load the driver: