CoreInput.js 6.4 KB

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