dualShockGamepad.d.ts 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. import { Observable } from "../Misc/observable";
  2. import { Gamepad } from "./gamepad";
  3. /**
  4. * Defines supported buttons for DualShock compatible gamepads
  5. */
  6. export declare enum DualShockButton {
  7. /** Cross */
  8. Cross = 0,
  9. /** Circle */
  10. Circle = 1,
  11. /** Square */
  12. Square = 2,
  13. /** Triangle */
  14. Triangle = 3,
  15. /** L1 */
  16. L1 = 4,
  17. /** R1 */
  18. R1 = 5,
  19. /** Share */
  20. Share = 8,
  21. /** Options */
  22. Options = 9,
  23. /** Left stick */
  24. LeftStick = 10,
  25. /** Right stick */
  26. RightStick = 11
  27. }
  28. /** Defines values for DualShock DPad */
  29. export declare enum DualShockDpad {
  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 DualShock gamepad
  41. */
  42. export declare class DualShockPad 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<DualShockButton>;
  53. /** Observable raised when a button is released */
  54. onButtonUpObservable: Observable<DualShockButton>;
  55. /** Observable raised when a pad is pressed */
  56. onPadDownObservable: Observable<DualShockDpad>;
  57. /** Observable raised when a pad is released */
  58. onPadUpObservable: Observable<DualShockDpad>;
  59. private _buttonCross;
  60. private _buttonCircle;
  61. private _buttonSquare;
  62. private _buttonTriangle;
  63. private _buttonShare;
  64. private _buttonOptions;
  65. private _buttonL1;
  66. private _buttonR1;
  67. private _buttonLeftStick;
  68. private _buttonRightStick;
  69. private _dPadUp;
  70. private _dPadDown;
  71. private _dPadLeft;
  72. private _dPadRight;
  73. /**
  74. * Creates a new DualShock gamepad object
  75. * @param id defines the id of this gamepad
  76. * @param index defines its index
  77. * @param gamepad defines the internal HTML gamepad object
  78. */
  79. constructor(id: string, index: number, gamepad: any);
  80. /**
  81. * Defines the callback to call when left trigger is pressed
  82. * @param callback defines the callback to use
  83. */
  84. onlefttriggerchanged(callback: (value: number) => void): void;
  85. /**
  86. * Defines the callback to call when right trigger is pressed
  87. * @param callback defines the callback to use
  88. */
  89. onrighttriggerchanged(callback: (value: number) => void): void;
  90. /**
  91. * Gets the left trigger value
  92. */
  93. get leftTrigger(): number;
  94. /**
  95. * Sets the left trigger value
  96. */
  97. set leftTrigger(newValue: number);
  98. /**
  99. * Gets the right trigger value
  100. */
  101. get rightTrigger(): number;
  102. /**
  103. * Sets the right trigger value
  104. */
  105. set rightTrigger(newValue: number);
  106. /**
  107. * Defines the callback to call when a button is pressed
  108. * @param callback defines the callback to use
  109. */
  110. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  111. /**
  112. * Defines the callback to call when a button is released
  113. * @param callback defines the callback to use
  114. */
  115. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  116. /**
  117. * Defines the callback to call when a pad is pressed
  118. * @param callback defines the callback to use
  119. */
  120. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  121. /**
  122. * Defines the callback to call when a pad is released
  123. * @param callback defines the callback to use
  124. */
  125. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  126. private _setButtonValue;
  127. private _setDPadValue;
  128. /**
  129. * Gets the value of the `Cross` button
  130. */
  131. get buttonCross(): number;
  132. /**
  133. * Sets the value of the `Cross` button
  134. */
  135. set buttonCross(value: number);
  136. /**
  137. * Gets the value of the `Circle` button
  138. */
  139. get buttonCircle(): number;
  140. /**
  141. * Sets the value of the `Circle` button
  142. */
  143. set buttonCircle(value: number);
  144. /**
  145. * Gets the value of the `Square` button
  146. */
  147. get buttonSquare(): number;
  148. /**
  149. * Sets the value of the `Square` button
  150. */
  151. set buttonSquare(value: number);
  152. /**
  153. * Gets the value of the `Triangle` button
  154. */
  155. get buttonTriangle(): number;
  156. /**
  157. * Sets the value of the `Triangle` button
  158. */
  159. set buttonTriangle(value: number);
  160. /**
  161. * Gets the value of the `Options` button
  162. */
  163. get buttonOptions(): number;
  164. /**
  165. * Sets the value of the `Options` button
  166. */
  167. set buttonOptions(value: number);
  168. /**
  169. * Gets the value of the `Share` button
  170. */
  171. get buttonShare(): number;
  172. /**
  173. * Sets the value of the `Share` button
  174. */
  175. set buttonShare(value: number);
  176. /**
  177. * Gets the value of the `L1` button
  178. */
  179. get buttonL1(): number;
  180. /**
  181. * Sets the value of the `L1` button
  182. */
  183. set buttonL1(value: number);
  184. /**
  185. * Gets the value of the `R1` button
  186. */
  187. get buttonR1(): number;
  188. /**
  189. * Sets the value of the `R1` button
  190. */
  191. set buttonR1(value: number);
  192. /**
  193. * Gets the value of the Left joystick
  194. */
  195. get buttonLeftStick(): number;
  196. /**
  197. * Sets the value of the Left joystick
  198. */
  199. set buttonLeftStick(value: number);
  200. /**
  201. * Gets the value of the Right joystick
  202. */
  203. get buttonRightStick(): number;
  204. /**
  205. * Sets the value of the Right joystick
  206. */
  207. set buttonRightStick(value: number);
  208. /**
  209. * Gets the value of D-pad up
  210. */
  211. get dPadUp(): number;
  212. /**
  213. * Sets the value of D-pad up
  214. */
  215. set dPadUp(value: number);
  216. /**
  217. * Gets the value of D-pad down
  218. */
  219. get dPadDown(): number;
  220. /**
  221. * Sets the value of D-pad down
  222. */
  223. set dPadDown(value: number);
  224. /**
  225. * Gets the value of D-pad left
  226. */
  227. get dPadLeft(): number;
  228. /**
  229. * Sets the value of D-pad left
  230. */
  231. set dPadLeft(value: number);
  232. /**
  233. * Gets the value of D-pad right
  234. */
  235. get dPadRight(): number;
  236. /**
  237. * Sets the value of D-pad right
  238. */
  239. set dPadRight(value: number);
  240. /**
  241. * Force the gamepad to synchronize with device values
  242. */
  243. update(): void;
  244. /**
  245. * Disposes the gamepad
  246. */
  247. dispose(): void;
  248. }