xboxGamepad.d.ts 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. import { Observable } from "../Misc/observable";
  2. import { Gamepad } from "../Gamepads/gamepad";
  3. /**
  4. * Defines supported buttons for XBox360 compatible gamepads
  5. */
  6. export declare enum Xbox360Button {
  7. /** A */
  8. A = 0,
  9. /** B */
  10. B = 1,
  11. /** X */
  12. X = 2,
  13. /** Y */
  14. Y = 3,
  15. /** Left button */
  16. LB = 4,
  17. /** Right button */
  18. RB = 5,
  19. /** Back */
  20. Back = 8,
  21. /** Start */
  22. Start = 9,
  23. /** Left stick */
  24. LeftStick = 10,
  25. /** Right stick */
  26. RightStick = 11
  27. }
  28. /** Defines values for XBox360 DPad */
  29. export declare enum Xbox360Dpad {
  30. /** Up */
  31. Up = 12,
  32. /** Down */
  33. Down = 13,
  34. /** Left */
  35. Left = 14,
  36. /** Right */
  37. Right = 15
  38. }
  39. /**
  40. * Defines a XBox360 gamepad
  41. */
  42. export declare class Xbox360Pad extends Gamepad {
  43. private _leftTrigger;
  44. private _rightTrigger;
  45. private _onlefttriggerchanged;
  46. private _onrighttriggerchanged;
  47. private _onbuttondown;
  48. private _onbuttonup;
  49. private _ondpaddown;
  50. private _ondpadup;
  51. /** Observable raised when a button is pressed */
  52. onButtonDownObservable: Observable<Xbox360Button>;
  53. /** Observable raised when a button is released */
  54. onButtonUpObservable: Observable<Xbox360Button>;
  55. /** Observable raised when a pad is pressed */
  56. onPadDownObservable: Observable<Xbox360Dpad>;
  57. /** Observable raised when a pad is released */
  58. onPadUpObservable: Observable<Xbox360Dpad>;
  59. private _buttonA;
  60. private _buttonB;
  61. private _buttonX;
  62. private _buttonY;
  63. private _buttonBack;
  64. private _buttonStart;
  65. private _buttonLB;
  66. private _buttonRB;
  67. private _buttonLeftStick;
  68. private _buttonRightStick;
  69. private _dPadUp;
  70. private _dPadDown;
  71. private _dPadLeft;
  72. private _dPadRight;
  73. private _isXboxOnePad;
  74. /**
  75. * Creates a new XBox360 gamepad object
  76. * @param id defines the id of this gamepad
  77. * @param index defines its index
  78. * @param gamepad defines the internal HTML gamepad object
  79. * @param xboxOne defines if it is a XBox One gamepad
  80. */
  81. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  82. /**
  83. * Defines the callback to call when left trigger is pressed
  84. * @param callback defines the callback to use
  85. */
  86. onlefttriggerchanged(callback: (value: number) => void): void;
  87. /**
  88. * Defines the callback to call when right trigger is pressed
  89. * @param callback defines the callback to use
  90. */
  91. onrighttriggerchanged(callback: (value: number) => void): void;
  92. /**
  93. * Gets the left trigger value
  94. */
  95. get leftTrigger(): number;
  96. /**
  97. * Sets the left trigger value
  98. */
  99. set leftTrigger(newValue: number);
  100. /**
  101. * Gets the right trigger value
  102. */
  103. get rightTrigger(): number;
  104. /**
  105. * Sets the right trigger value
  106. */
  107. set rightTrigger(newValue: number);
  108. /**
  109. * Defines the callback to call when a button is pressed
  110. * @param callback defines the callback to use
  111. */
  112. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  113. /**
  114. * Defines the callback to call when a button is released
  115. * @param callback defines the callback to use
  116. */
  117. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  118. /**
  119. * Defines the callback to call when a pad is pressed
  120. * @param callback defines the callback to use
  121. */
  122. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  123. /**
  124. * Defines the callback to call when a pad is released
  125. * @param callback defines the callback to use
  126. */
  127. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  128. private _setButtonValue;
  129. private _setDPadValue;
  130. /**
  131. * Gets the value of the `A` button
  132. */
  133. get buttonA(): number;
  134. /**
  135. * Sets the value of the `A` button
  136. */
  137. set buttonA(value: number);
  138. /**
  139. * Gets the value of the `B` button
  140. */
  141. get buttonB(): number;
  142. /**
  143. * Sets the value of the `B` button
  144. */
  145. set buttonB(value: number);
  146. /**
  147. * Gets the value of the `X` button
  148. */
  149. get buttonX(): number;
  150. /**
  151. * Sets the value of the `X` button
  152. */
  153. set buttonX(value: number);
  154. /**
  155. * Gets the value of the `Y` button
  156. */
  157. get buttonY(): number;
  158. /**
  159. * Sets the value of the `Y` button
  160. */
  161. set buttonY(value: number);
  162. /**
  163. * Gets the value of the `Start` button
  164. */
  165. get buttonStart(): number;
  166. /**
  167. * Sets the value of the `Start` button
  168. */
  169. set buttonStart(value: number);
  170. /**
  171. * Gets the value of the `Back` button
  172. */
  173. get buttonBack(): number;
  174. /**
  175. * Sets the value of the `Back` button
  176. */
  177. set buttonBack(value: number);
  178. /**
  179. * Gets the value of the `Left` button
  180. */
  181. get buttonLB(): number;
  182. /**
  183. * Sets the value of the `Left` button
  184. */
  185. set buttonLB(value: number);
  186. /**
  187. * Gets the value of the `Right` button
  188. */
  189. get buttonRB(): number;
  190. /**
  191. * Sets the value of the `Right` button
  192. */
  193. set buttonRB(value: number);
  194. /**
  195. * Gets the value of the Left joystick
  196. */
  197. get buttonLeftStick(): number;
  198. /**
  199. * Sets the value of the Left joystick
  200. */
  201. set buttonLeftStick(value: number);
  202. /**
  203. * Gets the value of the Right joystick
  204. */
  205. get buttonRightStick(): number;
  206. /**
  207. * Sets the value of the Right joystick
  208. */
  209. set buttonRightStick(value: number);
  210. /**
  211. * Gets the value of D-pad up
  212. */
  213. get dPadUp(): number;
  214. /**
  215. * Sets the value of D-pad up
  216. */
  217. set dPadUp(value: number);
  218. /**
  219. * Gets the value of D-pad down
  220. */
  221. get dPadDown(): number;
  222. /**
  223. * Sets the value of D-pad down
  224. */
  225. set dPadDown(value: number);
  226. /**
  227. * Gets the value of D-pad left
  228. */
  229. get dPadLeft(): number;
  230. /**
  231. * Sets the value of D-pad left
  232. */
  233. set dPadLeft(value: number);
  234. /**
  235. * Gets the value of D-pad right
  236. */
  237. get dPadRight(): number;
  238. /**
  239. * Sets the value of D-pad right
  240. */
  241. set dPadRight(value: number);
  242. /**
  243. * Force the gamepad to synchronize with device values
  244. */
  245. update(): void;
  246. /**
  247. * Disposes the gamepad
  248. */
  249. dispose(): void;
  250. }