CoreInput.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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.MOUSE_BUTTON1 = 0
  17. CoreInput.MOUSE_BUTTON2 = 1
  18. CoreInput.MOUSE_BUTTON3 = 2
  19. CoreInput.prototype = Object.create(EventDispatcher.prototype)
  20. CoreInput.prototype.__get_simulateTouchWithMouse = function() {
  21. return Polycode.CoreInput__get_simulateTouchWithMouse(this.__ptr)
  22. }
  23. CoreInput.prototype.__set_simulateTouchWithMouse = function(val) {
  24. Polycode.CoreInput__set_simulateTouchWithMouse(this.__ptr, val)
  25. }
  26. CoreInput.prototype.__get_simulateTouchAsPen = function() {
  27. return Polycode.CoreInput__get_simulateTouchAsPen(this.__ptr)
  28. }
  29. CoreInput.prototype.__set_simulateTouchAsPen = function(val) {
  30. Polycode.CoreInput__set_simulateTouchAsPen(this.__ptr, val)
  31. }
  32. CoreInput.prototype.__get_simulateMouseWithTouch = function() {
  33. return Polycode.CoreInput__get_simulateMouseWithTouch(this.__ptr)
  34. }
  35. CoreInput.prototype.__set_simulateMouseWithTouch = function(val) {
  36. Polycode.CoreInput__set_simulateMouseWithTouch(this.__ptr, val)
  37. }
  38. CoreInput.prototype.__get_ignoreOffScreenTouch = function() {
  39. return Polycode.CoreInput__get_ignoreOffScreenTouch(this.__ptr)
  40. }
  41. CoreInput.prototype.__set_ignoreOffScreenTouch = function(val) {
  42. Polycode.CoreInput__set_ignoreOffScreenTouch(this.__ptr, val)
  43. }
  44. CoreInput.prototype.__get_keyRepeat = function() {
  45. return Polycode.CoreInput__get_keyRepeat(this.__ptr)
  46. }
  47. CoreInput.prototype.__set_keyRepeat = function(val) {
  48. Polycode.CoreInput__set_keyRepeat(this.__ptr, val)
  49. }
  50. CoreInput.prototype.__get_mousePosition = function() {
  51. var retVal = new Vector2("__skip_ptr__")
  52. retVal.__ptr = Polycode.CoreInput__get_mousePosition(this.__ptr)
  53. return retVal
  54. }
  55. CoreInput.prototype.__set_mousePosition = function(val) {
  56. Polycode.CoreInput__set_mousePosition(this.__ptr, val.__ptr)
  57. }
  58. CoreInput.prototype.__get_deltaMousePosition = function() {
  59. var retVal = new Vector2("__skip_ptr__")
  60. retVal.__ptr = Polycode.CoreInput__get_deltaMousePosition(this.__ptr)
  61. return retVal
  62. }
  63. CoreInput.prototype.__set_deltaMousePosition = function(val) {
  64. Polycode.CoreInput__set_deltaMousePosition(this.__ptr, val.__ptr)
  65. }
  66. Duktape.fin(CoreInput.prototype, function (x) {
  67. if (x === CoreInput.prototype) {
  68. return;
  69. }
  70. Polycode.CoreInput__delete(x.__ptr)
  71. })
  72. CoreInput.prototype.getMousePosition = function() {
  73. var retVal = new Vector2("__skip_ptr__")
  74. retVal.__ptr = Polycode.CoreInput_getMousePosition(this.__ptr)
  75. return retVal
  76. }
  77. CoreInput.prototype.getKeyState = function(keyCode) {
  78. return Polycode.CoreInput_getKeyState(this.__ptr, keyCode)
  79. }
  80. CoreInput.prototype.getJoystickButtonState = function(joystickIndex,button) {
  81. return Polycode.CoreInput_getJoystickButtonState(this.__ptr, joystickIndex, button)
  82. }
  83. CoreInput.prototype.getJoystickAxisValue = function(joystickIndex,axis) {
  84. return Polycode.CoreInput_getJoystickAxisValue(this.__ptr, joystickIndex, axis)
  85. }
  86. CoreInput.prototype.getMouseDelta = function() {
  87. var retVal = new Vector2("__skip_ptr__")
  88. retVal.__ptr = Polycode.CoreInput_getMouseDelta(this.__ptr)
  89. return retVal
  90. }
  91. CoreInput.prototype.getMouseButtonState = function(mouseButton) {
  92. return Polycode.CoreInput_getMouseButtonState(this.__ptr, mouseButton)
  93. }
  94. CoreInput.prototype.getNumJoysticks = function() {
  95. return Polycode.CoreInput_getNumJoysticks(this.__ptr)
  96. }
  97. CoreInput.prototype.addJoystick = function(deviceID) {
  98. Polycode.CoreInput_addJoystick(this.__ptr, deviceID)
  99. }
  100. CoreInput.prototype.removeJoystick = function(deviceID) {
  101. Polycode.CoreInput_removeJoystick(this.__ptr, deviceID)
  102. }
  103. CoreInput.prototype.joystickAxisMoved = function(axisID,value,deviceID) {
  104. Polycode.CoreInput_joystickAxisMoved(this.__ptr, axisID, value, deviceID)
  105. }
  106. CoreInput.prototype.joystickButtonDown = function(buttonID,deviceID) {
  107. Polycode.CoreInput_joystickButtonDown(this.__ptr, buttonID, deviceID)
  108. }
  109. CoreInput.prototype.joystickButtonUp = function(buttonID,deviceID) {
  110. Polycode.CoreInput_joystickButtonUp(this.__ptr, buttonID, deviceID)
  111. }
  112. CoreInput.prototype.mouseWheelUp = function(ticks) {
  113. Polycode.CoreInput_mouseWheelUp(this.__ptr, ticks)
  114. }
  115. CoreInput.prototype.mouseWheelDown = function(ticks) {
  116. Polycode.CoreInput_mouseWheelDown(this.__ptr, ticks)
  117. }
  118. CoreInput.prototype.setMouseButtonState = function(mouseButton,state,ticks) {
  119. Polycode.CoreInput_setMouseButtonState(this.__ptr, mouseButton, state, ticks)
  120. }
  121. CoreInput.prototype.setMousePosition = function(x,y,ticks) {
  122. Polycode.CoreInput_setMousePosition(this.__ptr, x, y, ticks)
  123. }
  124. CoreInput.prototype.setKeyState = function(keyCode,newState,ticks) {
  125. Polycode.CoreInput_setKeyState(this.__ptr, keyCode, newState, ticks)
  126. }
  127. CoreInput.prototype.setDeltaPosition = function(x,y) {
  128. Polycode.CoreInput_setDeltaPosition(this.__ptr, x, y)
  129. }
  130. CoreInput.prototype.touchesBegan = function(touch,touches,ticks) {
  131. Polycode.CoreInput_touchesBegan(this.__ptr, touch, touches, ticks)
  132. }
  133. CoreInput.prototype.touchesMoved = function(touch,touches,ticks) {
  134. Polycode.CoreInput_touchesMoved(this.__ptr, touch, touches, ticks)
  135. }
  136. CoreInput.prototype.touchesEnded = function(touch,touches,ticks) {
  137. Polycode.CoreInput_touchesEnded(this.__ptr, touch, touches, ticks)
  138. }
  139. CoreInput.prototype.textInput = function(text) {
  140. Polycode.CoreInput_textInput(this.__ptr, text)
  141. }
  142. CoreInput.prototype.clearInput = function() {
  143. Polycode.CoreInput_clearInput(this.__ptr)
  144. }