interface GamepadMapping {
axes: number[];
buttons: number[];
analog: number[];
normalize_fn: (value: number, axis: number, button: number) => number;
}
/**
* Namespace for standard gamepad mapping constants
*/
export declare const GAMEPAD: {
/**
* Standard gamepad mapping information for axes
*
* - Left control stick:
LX (horizontal), LY (vertical)
* - Right control stick:
RX (horizontal), RY (vertical)
* - Extras:
EXTRA_1, EXTRA_2, EXTRA_3, EXTRA_4
*
* @see {@link https://w3c.github.io/gamepad/#remapping}
*/
readonly AXES: {
readonly LX: 0;
readonly LY: 1;
readonly RX: 2;
readonly RY: 3;
readonly EXTRA_1: 4;
readonly EXTRA_2: 5;
readonly EXTRA_3: 6;
readonly EXTRA_4: 7;
};
/**
* Standard gamepad mapping information for buttons
*
* - Face buttons:
FACE_1, FACE_2, FACE_3, FACE_4
* - D-Pad:
UP, DOWN, LEFT, RIGHT
* - Shoulder buttons:
L1, L2, R1, R2
* - Analog stick (clicks):
L3, R3
* - Navigation:
SELECT (BACK), START (FORWARD), HOME
* - Extras:
EXTRA_1, EXTRA_2, EXTRA_3, EXTRA_4
*
* @see {@link https://w3c.github.io/gamepad/#remapping}
*/
readonly BUTTONS: {
readonly FACE_1: 0;
readonly FACE_2: 1;
readonly FACE_3: 2;
readonly FACE_4: 3;
readonly L1: 4;
readonly R1: 5;
readonly L2: 6;
readonly R2: 7;
readonly SELECT: 8;
readonly BACK: 8;
readonly START: 9;
readonly FORWARD: 9;
readonly L3: 10;
readonly R3: 11;
readonly UP: 12;
readonly DOWN: 13;
readonly LEFT: 14;
readonly RIGHT: 15;
readonly HOME: 16;
readonly EXTRA_1: 17;
readonly EXTRA_2: 18;
readonly EXTRA_3: 19;
readonly EXTRA_4: 20;
};
};
/**
* Associate a gamepad event to a keycode
* @param index - Gamepad index
* @param button - Button/Axis definition
* @param button.type - "buttons" or "axes"
* @param button.code - button or axis code id
* @param button.threshold - value indicating when the axis should trigger the keycode
* @param keyCode - (See {@link input.KEY})
* @example
* // enable the keyboard
* me.input.bindKey(me.input.KEY.X, "shoot");
* ...
* // map the lower face button on the first gamepad to the X key
* me.input.bindGamepad(0, {type:"buttons", code: me.input.GAMEPAD.BUTTONS.FACE_1}, me.input.KEY.X);
* // map the left axis value on the first gamepad to the LEFT key
* me.input.bindGamepad(0, {type:"axes", code: me.input.GAMEPAD.AXES.LX, threshold: -0.5}, me.input.KEY.LEFT);
* @category Input
*/
export declare function bindGamepad(index: number, button: {
type: "buttons" | "axes";
code: number;
threshold?: number;
}, keyCode: number): void;
/**
* unbind the defined keycode
* @param index - Gamepad index
* @param button - (See {@link input.GAMEPAD})
* @example
* me.input.unbindGamepad(0, me.input.GAMEPAD.BUTTONS.FACE_1);
* @category Input
*/
export declare function unbindGamepad(index: number, button: number): void;
/**
* Set deadzone for analog gamepad inputs
* The default deadzone is 0.1 (10%) Analog values less than this will be ignored
* @param value - Deadzone value
* @category Input
*/
export declare function setGamepadDeadzone(value: number): void;
/**
* specify a custom mapping for a specific gamepad id
* see below for the default mapping :
* 
* @param id - Gamepad id string
* @param mapping - A hash table
* @example
* // A weird controller that has its axis mappings reversed
* me.input.setGamepadMapping("Generic USB Controller", {
* "axes" : [ 3, 2, 1, 0 ],
* "buttons" : [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ]
* });
*
* // Mapping extra axes to analog buttons
* me.input.setGamepadMapping("Generic Analog Controller", {
* "axes" : [ 0, 1, 2, 3 ],
* "buttons" : [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ],
*
* // Raw axis 4 is mapped to GAMEPAD.BUTTONS.FACE_1
* // Raw axis 5 is mapped to GAMEPAD.BUTTONS.FACE_2
* // etc...
* // Also maps left and right triggers
* "analog" : [ 4, 5, 6, 7, -1, -1, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1 ],
*
* // Normalize the value of button L2: [-1.0..1.0] => [0.0..1.0]
* "normalize_fn" : function (value, axis, button) {
* return ((button === me.input.GAMEPAD.BUTTONS.L2) ? ((value + 1) / 2) : value) || 0;
* }
* });
*/
export declare const setGamepadMapping: (id: string, mapping: Partial) => void;
export {};
//# sourceMappingURL=gamepad.d.ts.map