InputEvent.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. require('Polycode/Event')
  2. function InputEvent() {
  3. if(arguments[0] != "__skip_ptr__") {
  4. this.__ptr = Polycode.InputEvent()
  5. }
  6. Object.defineProperties(this, {
  7. 'mouseButton': { enumerable: true, configurable: true, get: InputEvent.prototype.__get_mouseButton, set: InputEvent.prototype.__set_mouseButton},
  8. 'mousePosition': { enumerable: true, configurable: true, get: InputEvent.prototype.__get_mousePosition, set: InputEvent.prototype.__set_mousePosition},
  9. 'key': { enumerable: true, configurable: true, get: InputEvent.prototype.__get_key, set: InputEvent.prototype.__set_key},
  10. 'timestamp': { enumerable: true, configurable: true, get: InputEvent.prototype.__get_timestamp, set: InputEvent.prototype.__set_timestamp},
  11. 'text': { enumerable: true, configurable: true, get: InputEvent.prototype.__get_text, set: InputEvent.prototype.__set_text},
  12. 'touch': { enumerable: true, configurable: true, get: InputEvent.prototype.__get_touch, set: InputEvent.prototype.__set_touch},
  13. 'touchType': { enumerable: true, configurable: true, get: InputEvent.prototype.__get_touchType, set: InputEvent.prototype.__set_touchType},
  14. 'joystickDeviceID': { enumerable: true, configurable: true, get: InputEvent.prototype.__get_joystickDeviceID, set: InputEvent.prototype.__set_joystickDeviceID},
  15. 'joystickAxisValue': { enumerable: true, configurable: true, get: InputEvent.prototype.__get_joystickAxisValue, set: InputEvent.prototype.__set_joystickAxisValue},
  16. 'joystickButton': { enumerable: true, configurable: true, get: InputEvent.prototype.__get_joystickButton, set: InputEvent.prototype.__set_joystickButton},
  17. 'joystickAxis': { enumerable: true, configurable: true, get: InputEvent.prototype.__get_joystickAxis, set: InputEvent.prototype.__set_joystickAxis},
  18. 'joystickIndex': { enumerable: true, configurable: true, get: InputEvent.prototype.__get_joystickIndex, set: InputEvent.prototype.__set_joystickIndex},
  19. 'hitDistance': { enumerable: true, configurable: true, get: InputEvent.prototype.__get_hitDistance, set: InputEvent.prototype.__set_hitDistance}
  20. })
  21. }
  22. InputEvent.EVENTBASE_INPUTEVENT = 0x400
  23. InputEvent.EVENT_MOUSEDOWN = EVENTBASE_INPUTEVENT + 0
  24. InputEvent.EVENT_MOUSEUP = EVENTBASE_INPUTEVENT + 1
  25. InputEvent.EVENT_MOUSEMOVE = EVENTBASE_INPUTEVENT + 2
  26. InputEvent.EVENT_MOUSEOVER = EVENTBASE_INPUTEVENT + 3
  27. InputEvent.EVENT_MOUSEOUT = EVENTBASE_INPUTEVENT + 4
  28. InputEvent.EVENT_DOUBLECLICK = EVENTBASE_INPUTEVENT + 5
  29. InputEvent.EVENT_MOUSEUP_OUTSIDE = EVENTBASE_INPUTEVENT + 6
  30. InputEvent.EVENT_MOUSEWHEEL_UP = EVENTBASE_INPUTEVENT + 7
  31. InputEvent.EVENT_MOUSEWHEEL_DOWN = EVENTBASE_INPUTEVENT + 8
  32. InputEvent.EVENT_KEYDOWN = EVENTBASE_INPUTEVENT + 13
  33. InputEvent.EVENT_KEYUP = EVENTBASE_INPUTEVENT + 14
  34. InputEvent.EVENT_JOYBUTTON_DOWN = EVENTBASE_INPUTEVENT + 15
  35. InputEvent.EVENT_JOYBUTTON_UP = EVENTBASE_INPUTEVENT + 16
  36. InputEvent.EVENT_JOYAXIS_MOVED = EVENTBASE_INPUTEVENT + 17
  37. InputEvent.EVENT_JOYDEVICE_ATTACHED = EVENTBASE_INPUTEVENT + 18
  38. InputEvent.EVENT_JOYDEVICE_DETACHED = EVENTBASE_INPUTEVENT + 19
  39. InputEvent.EVENT_TOUCHES_BEGAN = EVENTBASE_INPUTEVENT + 20
  40. InputEvent.EVENT_TOUCHES_MOVED = EVENTBASE_INPUTEVENT + 21
  41. InputEvent.EVENT_TOUCHES_ENDED = EVENTBASE_INPUTEVENT + 22
  42. InputEvent.EVENT_TEXTINPUT = EVENTBASE_INPUTEVENT + 23
  43. InputEvent.prototype = Object.create(Event.prototype)
  44. InputEvent.prototype.__get_mouseButton = function() {
  45. return Polycode.InputEvent__get_mouseButton(this.__ptr)
  46. }
  47. InputEvent.prototype.__set_mouseButton = function(val) {
  48. Polycode.InputEvent__set_mouseButton(this.__ptr, val)
  49. }
  50. InputEvent.prototype.__get_mousePosition = function() {
  51. var retVal = new Vector2()
  52. retVal.__ptr = Polycode.InputEvent__get_mousePosition(this.__ptr)
  53. return retVal
  54. }
  55. InputEvent.prototype.__set_mousePosition = function(val) {
  56. Polycode.InputEvent__set_mousePosition(this.__ptr, val.__ptr)
  57. }
  58. InputEvent.prototype.__get_key = function() {
  59. return Polycode.InputEvent__get_key(this.__ptr)
  60. }
  61. InputEvent.prototype.__set_key = function(val) {
  62. Polycode.InputEvent__set_key(this.__ptr, val)
  63. }
  64. InputEvent.prototype.__get_timestamp = function() {
  65. return Polycode.InputEvent__get_timestamp(this.__ptr)
  66. }
  67. InputEvent.prototype.__set_timestamp = function(val) {
  68. Polycode.InputEvent__set_timestamp(this.__ptr, val)
  69. }
  70. InputEvent.prototype.__get_text = function() {
  71. return Polycode.InputEvent__get_text(this.__ptr)
  72. }
  73. InputEvent.prototype.__set_text = function(val) {
  74. Polycode.InputEvent__set_text(this.__ptr, val)
  75. }
  76. InputEvent.prototype.__get_touch = function() {
  77. var retVal = new TouchInfo()
  78. retVal.__ptr = Polycode.InputEvent__get_touch(this.__ptr)
  79. return retVal
  80. }
  81. InputEvent.prototype.__set_touch = function(val) {
  82. Polycode.InputEvent__set_touch(this.__ptr, val.__ptr)
  83. }
  84. InputEvent.prototype.__get_touchType = function() {
  85. return Polycode.InputEvent__get_touchType(this.__ptr)
  86. }
  87. InputEvent.prototype.__set_touchType = function(val) {
  88. Polycode.InputEvent__set_touchType(this.__ptr, val)
  89. }
  90. InputEvent.prototype.__get_joystickDeviceID = function() {
  91. return Polycode.InputEvent__get_joystickDeviceID(this.__ptr)
  92. }
  93. InputEvent.prototype.__set_joystickDeviceID = function(val) {
  94. Polycode.InputEvent__set_joystickDeviceID(this.__ptr, val)
  95. }
  96. InputEvent.prototype.__get_joystickAxisValue = function() {
  97. return Polycode.InputEvent__get_joystickAxisValue(this.__ptr)
  98. }
  99. InputEvent.prototype.__set_joystickAxisValue = function(val) {
  100. Polycode.InputEvent__set_joystickAxisValue(this.__ptr, val)
  101. }
  102. InputEvent.prototype.__get_joystickButton = function() {
  103. return Polycode.InputEvent__get_joystickButton(this.__ptr)
  104. }
  105. InputEvent.prototype.__set_joystickButton = function(val) {
  106. Polycode.InputEvent__set_joystickButton(this.__ptr, val)
  107. }
  108. InputEvent.prototype.__get_joystickAxis = function() {
  109. return Polycode.InputEvent__get_joystickAxis(this.__ptr)
  110. }
  111. InputEvent.prototype.__set_joystickAxis = function(val) {
  112. Polycode.InputEvent__set_joystickAxis(this.__ptr, val)
  113. }
  114. InputEvent.prototype.__get_joystickIndex = function() {
  115. return Polycode.InputEvent__get_joystickIndex(this.__ptr)
  116. }
  117. InputEvent.prototype.__set_joystickIndex = function(val) {
  118. Polycode.InputEvent__set_joystickIndex(this.__ptr, val)
  119. }
  120. InputEvent.prototype.__get_hitDistance = function() {
  121. return Polycode.InputEvent__get_hitDistance(this.__ptr)
  122. }
  123. InputEvent.prototype.__set_hitDistance = function(val) {
  124. Polycode.InputEvent__set_hitDistance(this.__ptr, val)
  125. }
  126. Duktape.fin(InputEvent.prototype, function (x) {
  127. if (x === InputEvent.prototype) {
  128. return;
  129. }
  130. Polycode.InputEvent__delete(x.__ptr)
  131. })
  132. InputEvent.prototype.getMousePosition = function() {
  133. var retVal = new Vector2()
  134. retVal.__ptr = Polycode.InputEvent_getMousePosition(this.__ptr)
  135. return retVal
  136. }
  137. InputEvent.prototype.getKey = function() {
  138. return Polycode.InputEvent_getKey(this.__ptr)
  139. }
  140. InputEvent.prototype.getMouseButton = function() {
  141. return Polycode.InputEvent_getMouseButton(this.__ptr)
  142. }
  143. InputEvent.prototype.keyCode = function() {
  144. return Polycode.InputEvent_keyCode(this.__ptr)
  145. }