CoreInput.js 6.0 KB

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