UNPKG

shimi

Version:

A JS framework for building complex MIDI applications

109 lines (108 loc) 4.29 kB
import ButtonInput from './ButtonInput'; import SliderInput from './SliderInput'; import { IGamepad } from './Gamepads'; /** * The PS4Controller class models a single PS4 controller connected to the computer, providing ButtonInput & SliderInput properties for the various inputs on the controller. * * @category User Inputs */ export default class PS4Controller implements IGamepad { /** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */ get typeName(): string; /** The collection of all buttons on the gamepad. */ get buttons(): ButtonInput[]; private _buttons; /** The collection of all axes on the gamepad. */ get axes(): SliderInput[]; private _axes; /** ButtonInput for L1. */ get L1(): ButtonInput; private _l1; /** ButtonInput for L2. Supports pressure sensitivity. */ get L2(): ButtonInput; private _l2; /** ButtonInput for R1. */ get R1(): ButtonInput; private _r1; /** ButtonInput for R2. Supports pressure sensitivity. */ get R2(): ButtonInput; private _r2; /** ButtonInput for X. */ get x(): ButtonInput; private _x; /** ButtonInput for Square. */ get square(): ButtonInput; private _square; /** ButtonInput for Circle. */ get circle(): ButtonInput; private _circle; /** ButtonInput for Triangle. */ get triangle(): ButtonInput; private _triangle; /** ButtonInput for Up on the D-Pad. */ get up(): ButtonInput; private _up; /** ButtonInput for Left on the D-Pad. */ get left(): ButtonInput; private _left; /** ButtonInput for Right on the D-Pad. */ get right(): ButtonInput; private _right; /** ButtonInput for Down on the D-Pad. */ get down(): ButtonInput; private _down; /** ButtonInput for Share. */ get share(): ButtonInput; private _share; /** ButtonInput for Options. */ get options(): ButtonInput; private _options; /** ButtonInput for L3 (when you push in the left analog stick). */ get L3(): ButtonInput; private _l3; /** SliderInput for the X-axis of the left analog stick. -1 = fully left, +1 = fully right */ get L3_X(): SliderInput; private _l3_x; /** SliderInput for the Y-axis of the left analog stick. -1 = fully up, +1 = fully down */ get L3_Y(): SliderInput; private _l3_y; /** How far away from center the L3 analog stick is. Value ranges from 0 to 1. */ get L3_magnitude(): SliderInput; private _l3_magnitude; /** The angle of the L3 analog stick, measured clockwise in degrees from the stick pointing directly upwards. Values fall in the range (-180, 180] */ get L3_rotation(): SliderInput; private _l3_rotation; /** ButtonInput for R3 (when you push in the right analog stick). */ get R3(): ButtonInput; private _r3; /** SliderInput for the X-axis of the right analog stick. -1 = fully left, +1 = fully right */ get R3_X(): SliderInput; private _r3_x; /** SliderInput for the Y-axis of the right analog stick. -1 = fully up, +1 = fully down */ get R3_Y(): SliderInput; private _r3_y; /** How far away from center the R3 analog stick is. Value ranges from 0 to 1. */ get R3_magnitude(): SliderInput; private _r3_magnitude; /** The angle of the R3 analog stick, measured clockwise in degrees from the stick pointing directly upwards. Values fall in the range (-180, 180] */ get R3_rotation(): SliderInput; private _r3_rotation; /** ButtonInput for PS button. */ get PS(): ButtonInput; private _ps; /** ButtonInput for touchpad. */ get touchpad(): ButtonInput; private _touchpad; constructor(); /** * Automatically called by the system, shouldn't be called by consumers of the library. Updates each button and slider on the controller. * @param deltaMs How many milliseconds since the last update cycle */ update(deltaMs: number): void; /** * Checks if the passed in Gamepad API object can be matched to this PS4 controller, requiring that it have 16 buttons & 4 axes. * @param gamepadObject The Gamepad API object to potentially be matched to. * @returns */ canMatch(gamepadObject: Gamepad): boolean; }