CoreInput.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. require('Polycode/EventDispatcher')
  2. function CoreInput() {
  3. if(arguments[0] != "__skip_ptr__") {
  4. this.__ptr = Polycode.CoreInput()
  5. }
  6. Object.defineProperties(this, {
  7. 'simulateTouchWithMouse': { enumerable: true, configurable: true, get: CoreInput.prototype.__get_simulateTouchWithMouse, set: CoreInput.prototype.__set_simulateTouchWithMouse},
  8. 'simulateTouchAsPen': { enumerable: true, configurable: true, get: CoreInput.prototype.__get_simulateTouchAsPen, set: CoreInput.prototype.__set_simulateTouchAsPen},
  9. 'simulateMouseWithTouch': { enumerable: true, configurable: true, get: CoreInput.prototype.__get_simulateMouseWithTouch, set: CoreInput.prototype.__set_simulateMouseWithTouch},
  10. 'ignoreOffScreenTouch': { enumerable: true, configurable: true, get: CoreInput.prototype.__get_ignoreOffScreenTouch, set: CoreInput.prototype.__set_ignoreOffScreenTouch},
  11. 'keyRepeat': { enumerable: true, configurable: true, get: CoreInput.prototype.__get_keyRepeat, set: CoreInput.prototype.__set_keyRepeat},
  12. 'mousePosition': { enumerable: true, configurable: true, get: CoreInput.prototype.__get_mousePosition, set: CoreInput.prototype.__set_mousePosition},
  13. 'deltaMousePosition': { enumerable: true, configurable: true, get: CoreInput.prototype.__get_deltaMousePosition, set: CoreInput.prototype.__set_deltaMousePosition}
  14. })
  15. }
  16. CoreInput.prototype = Object.create(EventDispatcher.prototype);
  17. CoreInput.prototype.__get_simulateTouchWithMouse = function() {
  18. return Polycode.CoreInput__get_simulateTouchWithMouse(this.__ptr)
  19. }
  20. CoreInput.prototype.__set_simulateTouchWithMouse = function(val) {
  21. Polycode.CoreInput__set_simulateTouchWithMouse(this.__ptr, val)
  22. }
  23. CoreInput.prototype.__get_simulateTouchAsPen = function() {
  24. return Polycode.CoreInput__get_simulateTouchAsPen(this.__ptr)
  25. }
  26. CoreInput.prototype.__set_simulateTouchAsPen = function(val) {
  27. Polycode.CoreInput__set_simulateTouchAsPen(this.__ptr, val)
  28. }
  29. CoreInput.prototype.__get_simulateMouseWithTouch = function() {
  30. return Polycode.CoreInput__get_simulateMouseWithTouch(this.__ptr)
  31. }
  32. CoreInput.prototype.__set_simulateMouseWithTouch = function(val) {
  33. Polycode.CoreInput__set_simulateMouseWithTouch(this.__ptr, val)
  34. }
  35. CoreInput.prototype.__get_ignoreOffScreenTouch = function() {
  36. return Polycode.CoreInput__get_ignoreOffScreenTouch(this.__ptr)
  37. }
  38. CoreInput.prototype.__set_ignoreOffScreenTouch = function(val) {
  39. Polycode.CoreInput__set_ignoreOffScreenTouch(this.__ptr, val)
  40. }
  41. CoreInput.prototype.__get_keyRepeat = function() {
  42. return Polycode.CoreInput__get_keyRepeat(this.__ptr)
  43. }
  44. CoreInput.prototype.__set_keyRepeat = function(val) {
  45. Polycode.CoreInput__set_keyRepeat(this.__ptr, val)
  46. }
  47. CoreInput.prototype.__get_mousePosition = function() {
  48. var retVal = new Vector2()
  49. retVal.__ptr = Polycode.CoreInput__get_mousePosition(this.__ptr)
  50. return retVal
  51. }
  52. CoreInput.prototype.__set_mousePosition = function(val) {
  53. Polycode.CoreInput__set_mousePosition(this.__ptr, val.__ptr)
  54. }
  55. CoreInput.prototype.__get_deltaMousePosition = function() {
  56. var retVal = new Vector2()
  57. retVal.__ptr = Polycode.CoreInput__get_deltaMousePosition(this.__ptr)
  58. return retVal
  59. }
  60. CoreInput.prototype.__set_deltaMousePosition = function(val) {
  61. Polycode.CoreInput__set_deltaMousePosition(this.__ptr, val.__ptr)
  62. }
  63. Duktape.fin(CoreInput.prototype, function (x) {
  64. if (x === CoreInput.prototype) {
  65. return;
  66. }
  67. Polycode.CoreInput__delete(x.__ptr)
  68. })
  69. CoreInput.prototype.getMousePosition = function() {
  70. var retVal = new Vector2()
  71. retVal.__ptr = Polycode.CoreInput_getMousePosition(this.__ptr)
  72. return retVal
  73. }
  74. CoreInput.prototype.getKeyState = function(keyCode) {
  75. return Polycode.CoreInput_getKeyState(this.__ptr, keyCode)
  76. }
  77. CoreInput.prototype.getJoystickButtonState = function(joystickIndex,button) {
  78. return Polycode.CoreInput_getJoystickButtonState(this.__ptr, joystickIndex, button)
  79. }
  80. CoreInput.prototype.getJoystickAxisValue = function(joystickIndex,axis) {
  81. return Polycode.CoreInput_getJoystickAxisValue(this.__ptr, joystickIndex, axis)
  82. }
  83. CoreInput.prototype.getMouseDelta = function() {
  84. var retVal = new Vector2()
  85. retVal.__ptr = Polycode.CoreInput_getMouseDelta(this.__ptr)
  86. return retVal
  87. }
  88. CoreInput.prototype.getMouseButtonState = function(mouseButton) {
  89. return Polycode.CoreInput_getMouseButtonState(this.__ptr, mouseButton)
  90. }
  91. CoreInput.prototype.getNumJoysticks = function() {
  92. return Polycode.CoreInput_getNumJoysticks(this.__ptr)
  93. }
  94. CoreInput.prototype.getJoystickInfoByIndex = function(index) {
  95. var retVal = new JoystickInfo()
  96. retVal.__ptr = Polycode.CoreInput_getJoystickInfoByIndex(this.__ptr, index)
  97. return retVal
  98. }
  99. CoreInput.prototype.getJoystickInfoByID = function(deviceID) {
  100. var retVal = new JoystickInfo()
  101. retVal.__ptr = Polycode.CoreInput_getJoystickInfoByID(this.__ptr, deviceID)
  102. return retVal
  103. }
  104. CoreInput.prototype.addJoystick = function(deviceID) {
  105. Polycode.CoreInput_addJoystick(this.__ptr, deviceID)
  106. }
  107. CoreInput.prototype.removeJoystick = function(deviceID) {
  108. Polycode.CoreInput_removeJoystick(this.__ptr, deviceID)
  109. }
  110. CoreInput.prototype.joystickAxisMoved = function(axisID,value,deviceID) {
  111. Polycode.CoreInput_joystickAxisMoved(this.__ptr, axisID, value, deviceID)
  112. }
  113. CoreInput.prototype.joystickButtonDown = function(buttonID,deviceID) {
  114. Polycode.CoreInput_joystickButtonDown(this.__ptr, buttonID, deviceID)
  115. }
  116. CoreInput.prototype.joystickButtonUp = function(buttonID,deviceID) {
  117. Polycode.CoreInput_joystickButtonUp(this.__ptr, buttonID, deviceID)
  118. }
  119. CoreInput.prototype.mouseWheelUp = function(ticks) {
  120. Polycode.CoreInput_mouseWheelUp(this.__ptr, ticks)
  121. }
  122. CoreInput.prototype.mouseWheelDown = function(ticks) {
  123. Polycode.CoreInput_mouseWheelDown(this.__ptr, ticks)
  124. }
  125. CoreInput.prototype.setMouseButtonState = function(mouseButton,state,ticks) {
  126. Polycode.CoreInput_setMouseButtonState(this.__ptr, mouseButton, state, ticks)
  127. }
  128. CoreInput.prototype.setMousePosition = function(x,y,ticks) {
  129. Polycode.CoreInput_setMousePosition(this.__ptr, x, y, ticks)
  130. }
  131. CoreInput.prototype.setKeyState = function(keyCode,code,newState,ticks) {
  132. Polycode.CoreInput_setKeyState(this.__ptr, keyCode, code, newState, ticks)
  133. }
  134. CoreInput.prototype.setDeltaPosition = function(x,y) {
  135. Polycode.CoreInput_setDeltaPosition(this.__ptr, x, y)
  136. }
  137. CoreInput.prototype.touchesBegan = function(touch,touches,ticks) {
  138. Polycode.CoreInput_touchesBegan(this.__ptr, touch, touches, ticks)
  139. }
  140. CoreInput.prototype.touchesMoved = function(touch,touches,ticks) {
  141. Polycode.CoreInput_touchesMoved(this.__ptr, touch, touches, ticks)
  142. }
  143. CoreInput.prototype.touchesEnded = function(touch,touches,ticks) {
  144. Polycode.CoreInput_touchesEnded(this.__ptr, touch, touches, ticks)
  145. }
  146. CoreInput.prototype.createEvent = function(event) {
  147. var retVal = new InputEvent()
  148. retVal.__ptr = Polycode.CoreInput_createEvent(event.__ptr)
  149. return retVal
  150. }
  151. CoreInput.prototype.clearInput = function() {
  152. Polycode.CoreInput_clearInput(this.__ptr)
  153. }