2
0

input_event.cpp 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273
  1. /*************************************************************************/
  2. /* input_event.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "input_event.h"
  31. #include "core/input_map.h"
  32. #include "core/os/keyboard.h"
  33. void InputEvent::set_device(int p_device) {
  34. device = p_device;
  35. }
  36. int InputEvent::get_device() const {
  37. return device;
  38. }
  39. bool InputEvent::is_action(const StringName &p_action) const {
  40. return InputMap::get_singleton()->event_is_action(Ref<InputEvent>((InputEvent *)this), p_action);
  41. }
  42. bool InputEvent::is_action_pressed(const StringName &p_action) const {
  43. bool pressed;
  44. bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>((InputEvent *)this), p_action, &pressed);
  45. return valid && pressed && !is_echo();
  46. }
  47. bool InputEvent::is_action_released(const StringName &p_action) const {
  48. bool pressed;
  49. bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>((InputEvent *)this), p_action, &pressed);
  50. return valid && !pressed;
  51. }
  52. float InputEvent::get_action_strength(const StringName &p_action) const {
  53. bool pressed;
  54. float strength;
  55. bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>((InputEvent *)this), p_action, &pressed, &strength);
  56. return valid ? strength : 0.0f;
  57. }
  58. bool InputEvent::is_pressed() const {
  59. return false;
  60. }
  61. bool InputEvent::is_echo() const {
  62. return false;
  63. }
  64. Ref<InputEvent> InputEvent::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
  65. return Ref<InputEvent>((InputEvent *)this);
  66. }
  67. String InputEvent::as_text() const {
  68. return String();
  69. }
  70. bool InputEvent::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
  71. return false;
  72. }
  73. bool InputEvent::shortcut_match(const Ref<InputEvent> &p_event) const {
  74. return false;
  75. }
  76. bool InputEvent::is_action_type() const {
  77. return false;
  78. }
  79. void InputEvent::_bind_methods() {
  80. ClassDB::bind_method(D_METHOD("set_device", "device"), &InputEvent::set_device);
  81. ClassDB::bind_method(D_METHOD("get_device"), &InputEvent::get_device);
  82. ClassDB::bind_method(D_METHOD("is_action", "action"), &InputEvent::is_action);
  83. ClassDB::bind_method(D_METHOD("is_action_pressed", "action"), &InputEvent::is_action_pressed);
  84. ClassDB::bind_method(D_METHOD("is_action_released", "action"), &InputEvent::is_action_released);
  85. ClassDB::bind_method(D_METHOD("get_action_strength", "action"), &InputEvent::get_action_strength);
  86. ClassDB::bind_method(D_METHOD("is_pressed"), &InputEvent::is_pressed);
  87. ClassDB::bind_method(D_METHOD("is_echo"), &InputEvent::is_echo);
  88. ClassDB::bind_method(D_METHOD("as_text"), &InputEvent::as_text);
  89. ClassDB::bind_method(D_METHOD("shortcut_match", "event"), &InputEvent::shortcut_match);
  90. ClassDB::bind_method(D_METHOD("is_action_type"), &InputEvent::is_action_type);
  91. ClassDB::bind_method(D_METHOD("accumulate", "with_event"), &InputEvent::accumulate);
  92. ClassDB::bind_method(D_METHOD("xformed_by", "xform", "local_ofs"), &InputEvent::xformed_by, DEFVAL(Vector2()));
  93. ADD_PROPERTY(PropertyInfo(Variant::INT, "device"), "set_device", "get_device");
  94. }
  95. InputEvent::InputEvent() {
  96. device = 0;
  97. }
  98. //////////////////
  99. void InputEventWithModifiers::set_shift(bool p_enabled) {
  100. shift = p_enabled;
  101. }
  102. bool InputEventWithModifiers::get_shift() const {
  103. return shift;
  104. }
  105. void InputEventWithModifiers::set_alt(bool p_enabled) {
  106. alt = p_enabled;
  107. }
  108. bool InputEventWithModifiers::get_alt() const {
  109. return alt;
  110. }
  111. void InputEventWithModifiers::set_control(bool p_enabled) {
  112. control = p_enabled;
  113. }
  114. bool InputEventWithModifiers::get_control() const {
  115. return control;
  116. }
  117. void InputEventWithModifiers::set_metakey(bool p_enabled) {
  118. meta = p_enabled;
  119. }
  120. bool InputEventWithModifiers::get_metakey() const {
  121. return meta;
  122. }
  123. void InputEventWithModifiers::set_command(bool p_enabled) {
  124. command = p_enabled;
  125. }
  126. bool InputEventWithModifiers::get_command() const {
  127. return command;
  128. }
  129. void InputEventWithModifiers::set_modifiers_from_event(const InputEventWithModifiers *event) {
  130. set_alt(event->get_alt());
  131. set_shift(event->get_shift());
  132. set_control(event->get_control());
  133. set_metakey(event->get_metakey());
  134. }
  135. void InputEventWithModifiers::_bind_methods() {
  136. ClassDB::bind_method(D_METHOD("set_alt", "enable"), &InputEventWithModifiers::set_alt);
  137. ClassDB::bind_method(D_METHOD("get_alt"), &InputEventWithModifiers::get_alt);
  138. ClassDB::bind_method(D_METHOD("set_shift", "enable"), &InputEventWithModifiers::set_shift);
  139. ClassDB::bind_method(D_METHOD("get_shift"), &InputEventWithModifiers::get_shift);
  140. ClassDB::bind_method(D_METHOD("set_control", "enable"), &InputEventWithModifiers::set_control);
  141. ClassDB::bind_method(D_METHOD("get_control"), &InputEventWithModifiers::get_control);
  142. ClassDB::bind_method(D_METHOD("set_metakey", "enable"), &InputEventWithModifiers::set_metakey);
  143. ClassDB::bind_method(D_METHOD("get_metakey"), &InputEventWithModifiers::get_metakey);
  144. ClassDB::bind_method(D_METHOD("set_command", "enable"), &InputEventWithModifiers::set_command);
  145. ClassDB::bind_method(D_METHOD("get_command"), &InputEventWithModifiers::get_command);
  146. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "alt"), "set_alt", "get_alt");
  147. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shift"), "set_shift", "get_shift");
  148. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "control"), "set_control", "get_control");
  149. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "meta"), "set_metakey", "get_metakey");
  150. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "command"), "set_command", "get_command");
  151. }
  152. InputEventWithModifiers::InputEventWithModifiers() {
  153. alt = false;
  154. shift = false;
  155. control = false;
  156. meta = false;
  157. }
  158. //////////////////////////////////
  159. void InputEventKey::set_pressed(bool p_pressed) {
  160. pressed = p_pressed;
  161. }
  162. bool InputEventKey::is_pressed() const {
  163. return pressed;
  164. }
  165. void InputEventKey::set_scancode(uint32_t p_scancode) {
  166. scancode = p_scancode;
  167. }
  168. uint32_t InputEventKey::get_scancode() const {
  169. return scancode;
  170. }
  171. void InputEventKey::set_unicode(uint32_t p_unicode) {
  172. unicode = p_unicode;
  173. }
  174. uint32_t InputEventKey::get_unicode() const {
  175. return unicode;
  176. }
  177. void InputEventKey::set_echo(bool p_enable) {
  178. echo = p_enable;
  179. }
  180. bool InputEventKey::is_echo() const {
  181. return echo;
  182. }
  183. uint32_t InputEventKey::get_scancode_with_modifiers() const {
  184. uint32_t sc = scancode;
  185. if (get_control())
  186. sc |= KEY_MASK_CTRL;
  187. if (get_alt())
  188. sc |= KEY_MASK_ALT;
  189. if (get_shift())
  190. sc |= KEY_MASK_SHIFT;
  191. if (get_metakey())
  192. sc |= KEY_MASK_META;
  193. return sc;
  194. }
  195. String InputEventKey::as_text() const {
  196. String kc = keycode_get_string(scancode);
  197. if (kc == String())
  198. return kc;
  199. if (get_metakey()) {
  200. kc = find_keycode_name(KEY_META) + ("+" + kc);
  201. }
  202. if (get_alt()) {
  203. kc = find_keycode_name(KEY_ALT) + ("+" + kc);
  204. }
  205. if (get_shift()) {
  206. kc = find_keycode_name(KEY_SHIFT) + ("+" + kc);
  207. }
  208. if (get_control()) {
  209. kc = find_keycode_name(KEY_CONTROL) + ("+" + kc);
  210. }
  211. return kc;
  212. }
  213. bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
  214. Ref<InputEventKey> key = p_event;
  215. if (key.is_null())
  216. return false;
  217. uint32_t code = get_scancode_with_modifiers();
  218. uint32_t event_code = key->get_scancode_with_modifiers();
  219. bool match = get_scancode() == key->get_scancode() && (!key->is_pressed() || (code & event_code) == code);
  220. if (match) {
  221. if (p_pressed != NULL)
  222. *p_pressed = key->is_pressed();
  223. if (p_strength != NULL)
  224. *p_strength = (*p_pressed) ? 1.0f : 0.0f;
  225. }
  226. return match;
  227. }
  228. bool InputEventKey::shortcut_match(const Ref<InputEvent> &p_event) const {
  229. Ref<InputEventKey> key = p_event;
  230. if (key.is_null())
  231. return false;
  232. uint32_t code = get_scancode_with_modifiers();
  233. uint32_t event_code = key->get_scancode_with_modifiers();
  234. return code == event_code;
  235. }
  236. void InputEventKey::_bind_methods() {
  237. ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventKey::set_pressed);
  238. ClassDB::bind_method(D_METHOD("set_scancode", "scancode"), &InputEventKey::set_scancode);
  239. ClassDB::bind_method(D_METHOD("get_scancode"), &InputEventKey::get_scancode);
  240. ClassDB::bind_method(D_METHOD("set_unicode", "unicode"), &InputEventKey::set_unicode);
  241. ClassDB::bind_method(D_METHOD("get_unicode"), &InputEventKey::get_unicode);
  242. ClassDB::bind_method(D_METHOD("set_echo", "echo"), &InputEventKey::set_echo);
  243. ClassDB::bind_method(D_METHOD("get_scancode_with_modifiers"), &InputEventKey::get_scancode_with_modifiers);
  244. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
  245. ADD_PROPERTY(PropertyInfo(Variant::INT, "scancode"), "set_scancode", "get_scancode");
  246. ADD_PROPERTY(PropertyInfo(Variant::INT, "unicode"), "set_unicode", "get_unicode");
  247. ADD_PROPERTY(PropertyInfo(Variant::INT, "echo"), "set_echo", "is_echo");
  248. }
  249. InputEventKey::InputEventKey() {
  250. pressed = false;
  251. scancode = 0;
  252. unicode = 0; ///unicode
  253. echo = false;
  254. }
  255. ////////////////////////////////////////
  256. void InputEventMouse::set_button_mask(int p_mask) {
  257. button_mask = p_mask;
  258. }
  259. int InputEventMouse::get_button_mask() const {
  260. return button_mask;
  261. }
  262. void InputEventMouse::set_position(const Vector2 &p_pos) {
  263. pos = p_pos;
  264. }
  265. Vector2 InputEventMouse::get_position() const {
  266. return pos;
  267. }
  268. void InputEventMouse::set_global_position(const Vector2 &p_global_pos) {
  269. global_pos = p_global_pos;
  270. }
  271. Vector2 InputEventMouse::get_global_position() const {
  272. return global_pos;
  273. }
  274. void InputEventMouse::_bind_methods() {
  275. ClassDB::bind_method(D_METHOD("set_button_mask", "button_mask"), &InputEventMouse::set_button_mask);
  276. ClassDB::bind_method(D_METHOD("get_button_mask"), &InputEventMouse::get_button_mask);
  277. ClassDB::bind_method(D_METHOD("set_position", "position"), &InputEventMouse::set_position);
  278. ClassDB::bind_method(D_METHOD("get_position"), &InputEventMouse::get_position);
  279. ClassDB::bind_method(D_METHOD("set_global_position", "global_position"), &InputEventMouse::set_global_position);
  280. ClassDB::bind_method(D_METHOD("get_global_position"), &InputEventMouse::get_global_position);
  281. ADD_PROPERTY(PropertyInfo(Variant::INT, "button_mask"), "set_button_mask", "get_button_mask");
  282. ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position");
  283. ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_position"), "set_global_position", "get_global_position");
  284. }
  285. InputEventMouse::InputEventMouse() {
  286. button_mask = 0;
  287. }
  288. ///////////////////////////////////////
  289. void InputEventMouseButton::set_factor(float p_factor) {
  290. factor = p_factor;
  291. }
  292. float InputEventMouseButton::get_factor() {
  293. return factor;
  294. }
  295. void InputEventMouseButton::set_button_index(int p_index) {
  296. button_index = p_index;
  297. }
  298. int InputEventMouseButton::get_button_index() const {
  299. return button_index;
  300. }
  301. void InputEventMouseButton::set_pressed(bool p_pressed) {
  302. pressed = p_pressed;
  303. }
  304. bool InputEventMouseButton::is_pressed() const {
  305. return pressed;
  306. }
  307. void InputEventMouseButton::set_doubleclick(bool p_doubleclick) {
  308. doubleclick = p_doubleclick;
  309. }
  310. bool InputEventMouseButton::is_doubleclick() const {
  311. return doubleclick;
  312. }
  313. Ref<InputEvent> InputEventMouseButton::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
  314. Vector2 g = p_xform.xform(get_global_position());
  315. Vector2 l = p_xform.xform(get_position() + p_local_ofs);
  316. Ref<InputEventMouseButton> mb;
  317. mb.instance();
  318. mb->set_device(get_device());
  319. mb->set_modifiers_from_event(this);
  320. mb->set_position(l);
  321. mb->set_global_position(g);
  322. mb->set_button_mask(get_button_mask());
  323. mb->set_pressed(pressed);
  324. mb->set_doubleclick(doubleclick);
  325. mb->set_factor(factor);
  326. mb->set_button_index(button_index);
  327. return mb;
  328. }
  329. bool InputEventMouseButton::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
  330. Ref<InputEventMouseButton> mb = p_event;
  331. if (mb.is_null())
  332. return false;
  333. bool match = mb->button_index == button_index;
  334. if (match) {
  335. if (p_pressed != NULL)
  336. *p_pressed = mb->is_pressed();
  337. if (p_strength != NULL)
  338. *p_strength = (*p_pressed) ? 1.0f : 0.0f;
  339. }
  340. return match;
  341. }
  342. String InputEventMouseButton::as_text() const {
  343. String button_index_string = "";
  344. switch (get_button_index()) {
  345. case BUTTON_LEFT:
  346. button_index_string = "BUTTON_LEFT";
  347. break;
  348. case BUTTON_RIGHT:
  349. button_index_string = "BUTTON_RIGHT";
  350. break;
  351. case BUTTON_MIDDLE:
  352. button_index_string = "BUTTON_MIDDLE";
  353. break;
  354. case BUTTON_WHEEL_UP:
  355. button_index_string = "BUTTON_WHEEL_UP";
  356. break;
  357. case BUTTON_WHEEL_DOWN:
  358. button_index_string = "BUTTON_WHEEL_DOWN";
  359. break;
  360. case BUTTON_WHEEL_LEFT:
  361. button_index_string = "BUTTON_WHEEL_LEFT";
  362. break;
  363. case BUTTON_WHEEL_RIGHT:
  364. button_index_string = "BUTTON_WHEEL_RIGHT";
  365. break;
  366. case BUTTON_XBUTTON1:
  367. button_index_string = "BUTTON_XBUTTON1";
  368. break;
  369. case BUTTON_XBUTTON2:
  370. button_index_string = "BUTTON_XBUTTON2";
  371. break;
  372. default:
  373. button_index_string = itos(get_button_index());
  374. break;
  375. }
  376. return "InputEventMouseButton : button_index=" + button_index_string + ", pressed=" + (pressed ? "true" : "false") + ", position=(" + String(get_position()) + "), button_mask=" + itos(get_button_mask()) + ", doubleclick=" + (doubleclick ? "true" : "false");
  377. }
  378. void InputEventMouseButton::_bind_methods() {
  379. ClassDB::bind_method(D_METHOD("set_factor", "factor"), &InputEventMouseButton::set_factor);
  380. ClassDB::bind_method(D_METHOD("get_factor"), &InputEventMouseButton::get_factor);
  381. ClassDB::bind_method(D_METHOD("set_button_index", "button_index"), &InputEventMouseButton::set_button_index);
  382. ClassDB::bind_method(D_METHOD("get_button_index"), &InputEventMouseButton::get_button_index);
  383. ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventMouseButton::set_pressed);
  384. // ClassDB::bind_method(D_METHOD("is_pressed"), &InputEventMouseButton::is_pressed);
  385. ClassDB::bind_method(D_METHOD("set_doubleclick", "doubleclick"), &InputEventMouseButton::set_doubleclick);
  386. ClassDB::bind_method(D_METHOD("is_doubleclick"), &InputEventMouseButton::is_doubleclick);
  387. ADD_PROPERTY(PropertyInfo(Variant::REAL, "factor"), "set_factor", "get_factor");
  388. ADD_PROPERTY(PropertyInfo(Variant::INT, "button_index"), "set_button_index", "get_button_index");
  389. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
  390. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "doubleclick"), "set_doubleclick", "is_doubleclick");
  391. }
  392. InputEventMouseButton::InputEventMouseButton() {
  393. factor = 1;
  394. button_index = 0;
  395. pressed = false;
  396. doubleclick = false;
  397. }
  398. ////////////////////////////////////////////
  399. void InputEventMouseMotion::set_relative(const Vector2 &p_relative) {
  400. relative = p_relative;
  401. }
  402. Vector2 InputEventMouseMotion::get_relative() const {
  403. return relative;
  404. }
  405. void InputEventMouseMotion::set_speed(const Vector2 &p_speed) {
  406. speed = p_speed;
  407. }
  408. Vector2 InputEventMouseMotion::get_speed() const {
  409. return speed;
  410. }
  411. Ref<InputEvent> InputEventMouseMotion::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
  412. Vector2 g = p_xform.xform(get_global_position());
  413. Vector2 l = p_xform.xform(get_position() + p_local_ofs);
  414. Vector2 r = p_xform.basis_xform(get_relative());
  415. Vector2 s = p_xform.basis_xform(get_speed());
  416. Ref<InputEventMouseMotion> mm;
  417. mm.instance();
  418. mm->set_device(get_device());
  419. mm->set_modifiers_from_event(this);
  420. mm->set_position(l);
  421. mm->set_global_position(g);
  422. mm->set_button_mask(get_button_mask());
  423. mm->set_relative(r);
  424. mm->set_speed(s);
  425. return mm;
  426. }
  427. String InputEventMouseMotion::as_text() const {
  428. String button_mask_string = "";
  429. switch (get_button_mask()) {
  430. case BUTTON_MASK_LEFT:
  431. button_mask_string = "BUTTON_MASK_LEFT";
  432. break;
  433. case BUTTON_MASK_MIDDLE:
  434. button_mask_string = "BUTTON_MASK_MIDDLE";
  435. break;
  436. case BUTTON_MASK_RIGHT:
  437. button_mask_string = "BUTTON_MASK_RIGHT";
  438. break;
  439. case BUTTON_MASK_XBUTTON1:
  440. button_mask_string = "BUTTON_MASK_XBUTTON1";
  441. break;
  442. case BUTTON_MASK_XBUTTON2:
  443. button_mask_string = "BUTTON_MASK_XBUTTON2";
  444. break;
  445. default:
  446. button_mask_string = itos(get_button_mask());
  447. break;
  448. }
  449. return "InputEventMouseMotion : button_mask=" + button_mask_string + ", position=(" + String(get_position()) + "), relative=(" + String(get_relative()) + "), speed=(" + String(get_speed()) + ")";
  450. }
  451. bool InputEventMouseMotion::accumulate(const Ref<InputEvent> &p_event) {
  452. Ref<InputEventMouseMotion> motion = p_event;
  453. if (motion.is_null())
  454. return false;
  455. if (is_pressed() != motion->is_pressed()) {
  456. return false;
  457. }
  458. if (get_button_mask() != motion->get_button_mask()) {
  459. return false;
  460. }
  461. if (get_shift() != motion->get_shift()) {
  462. return false;
  463. }
  464. if (get_control() != motion->get_control()) {
  465. return false;
  466. }
  467. if (get_alt() != motion->get_alt()) {
  468. return false;
  469. }
  470. if (get_metakey() != motion->get_metakey()) {
  471. return false;
  472. }
  473. set_position(motion->get_position());
  474. set_global_position(motion->get_global_position());
  475. set_speed(motion->get_speed());
  476. relative += motion->get_relative();
  477. return true;
  478. }
  479. void InputEventMouseMotion::_bind_methods() {
  480. ClassDB::bind_method(D_METHOD("set_relative", "relative"), &InputEventMouseMotion::set_relative);
  481. ClassDB::bind_method(D_METHOD("get_relative"), &InputEventMouseMotion::get_relative);
  482. ClassDB::bind_method(D_METHOD("set_speed", "speed"), &InputEventMouseMotion::set_speed);
  483. ClassDB::bind_method(D_METHOD("get_speed"), &InputEventMouseMotion::get_speed);
  484. ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "relative"), "set_relative", "get_relative");
  485. ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "speed"), "set_speed", "get_speed");
  486. }
  487. InputEventMouseMotion::InputEventMouseMotion() {
  488. }
  489. ////////////////////////////////////////
  490. void InputEventJoypadMotion::set_axis(int p_axis) {
  491. axis = p_axis;
  492. }
  493. int InputEventJoypadMotion::get_axis() const {
  494. return axis;
  495. }
  496. void InputEventJoypadMotion::set_axis_value(float p_value) {
  497. axis_value = p_value;
  498. }
  499. float InputEventJoypadMotion::get_axis_value() const {
  500. return axis_value;
  501. }
  502. bool InputEventJoypadMotion::is_pressed() const {
  503. return Math::abs(axis_value) >= 0.5f;
  504. }
  505. bool InputEventJoypadMotion::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
  506. Ref<InputEventJoypadMotion> jm = p_event;
  507. if (jm.is_null())
  508. return false;
  509. bool match = (axis == jm->axis); // Matches even if not in the same direction, but returns a "not pressed" event.
  510. if (match) {
  511. bool same_direction = (((axis_value < 0) == (jm->axis_value < 0)) || jm->axis_value == 0);
  512. bool pressed = same_direction ? Math::abs(jm->get_axis_value()) >= p_deadzone : false;
  513. if (p_pressed != NULL)
  514. *p_pressed = pressed;
  515. if (p_strength != NULL)
  516. *p_strength = pressed ? CLAMP(Math::inverse_lerp(p_deadzone, 1.0f, Math::abs(jm->get_axis_value())), 0.0f, 1.0f) : 0.0f;
  517. }
  518. return match;
  519. }
  520. String InputEventJoypadMotion::as_text() const {
  521. return "InputEventJoypadMotion : axis=" + itos(axis) + ", axis_value=" + String(Variant(axis_value));
  522. }
  523. void InputEventJoypadMotion::_bind_methods() {
  524. ClassDB::bind_method(D_METHOD("set_axis", "axis"), &InputEventJoypadMotion::set_axis);
  525. ClassDB::bind_method(D_METHOD("get_axis"), &InputEventJoypadMotion::get_axis);
  526. ClassDB::bind_method(D_METHOD("set_axis_value", "axis_value"), &InputEventJoypadMotion::set_axis_value);
  527. ClassDB::bind_method(D_METHOD("get_axis_value"), &InputEventJoypadMotion::get_axis_value);
  528. ADD_PROPERTY(PropertyInfo(Variant::INT, "axis"), "set_axis", "get_axis");
  529. ADD_PROPERTY(PropertyInfo(Variant::REAL, "axis_value"), "set_axis_value", "get_axis_value");
  530. }
  531. InputEventJoypadMotion::InputEventJoypadMotion() {
  532. axis = 0;
  533. axis_value = 0;
  534. }
  535. /////////////////////////////////
  536. void InputEventJoypadButton::set_button_index(int p_index) {
  537. button_index = p_index;
  538. }
  539. int InputEventJoypadButton::get_button_index() const {
  540. return button_index;
  541. }
  542. void InputEventJoypadButton::set_pressed(bool p_pressed) {
  543. pressed = p_pressed;
  544. }
  545. bool InputEventJoypadButton::is_pressed() const {
  546. return pressed;
  547. }
  548. void InputEventJoypadButton::set_pressure(float p_pressure) {
  549. pressure = p_pressure;
  550. }
  551. float InputEventJoypadButton::get_pressure() const {
  552. return pressure;
  553. }
  554. bool InputEventJoypadButton::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
  555. Ref<InputEventJoypadButton> jb = p_event;
  556. if (jb.is_null())
  557. return false;
  558. bool match = button_index == jb->button_index;
  559. if (match) {
  560. if (p_pressed != NULL)
  561. *p_pressed = jb->is_pressed();
  562. if (p_strength != NULL)
  563. *p_strength = (*p_pressed) ? 1.0f : 0.0f;
  564. }
  565. return match;
  566. }
  567. bool InputEventJoypadButton::shortcut_match(const Ref<InputEvent> &p_event) const {
  568. Ref<InputEventJoypadButton> button = p_event;
  569. if (button.is_null())
  570. return false;
  571. return button_index == button->button_index;
  572. }
  573. String InputEventJoypadButton::as_text() const {
  574. return "InputEventJoypadButton : button_index=" + itos(button_index) + ", pressed=" + (pressed ? "true" : "false") + ", pressure=" + String(Variant(pressure));
  575. }
  576. void InputEventJoypadButton::_bind_methods() {
  577. ClassDB::bind_method(D_METHOD("set_button_index", "button_index"), &InputEventJoypadButton::set_button_index);
  578. ClassDB::bind_method(D_METHOD("get_button_index"), &InputEventJoypadButton::get_button_index);
  579. ClassDB::bind_method(D_METHOD("set_pressure", "pressure"), &InputEventJoypadButton::set_pressure);
  580. ClassDB::bind_method(D_METHOD("get_pressure"), &InputEventJoypadButton::get_pressure);
  581. ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventJoypadButton::set_pressed);
  582. // ClassDB::bind_method(D_METHOD("is_pressed"), &InputEventJoypadButton::is_pressed);
  583. ADD_PROPERTY(PropertyInfo(Variant::INT, "button_index"), "set_button_index", "get_button_index");
  584. ADD_PROPERTY(PropertyInfo(Variant::REAL, "pressure"), "set_pressure", "get_pressure");
  585. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
  586. }
  587. InputEventJoypadButton::InputEventJoypadButton() {
  588. button_index = 0;
  589. pressure = 0;
  590. pressed = false;
  591. }
  592. //////////////////////////////////////////////
  593. void InputEventScreenTouch::set_index(int p_index) {
  594. index = p_index;
  595. }
  596. int InputEventScreenTouch::get_index() const {
  597. return index;
  598. }
  599. void InputEventScreenTouch::set_position(const Vector2 &p_pos) {
  600. pos = p_pos;
  601. }
  602. Vector2 InputEventScreenTouch::get_position() const {
  603. return pos;
  604. }
  605. void InputEventScreenTouch::set_pressed(bool p_pressed) {
  606. pressed = p_pressed;
  607. }
  608. bool InputEventScreenTouch::is_pressed() const {
  609. return pressed;
  610. }
  611. Ref<InputEvent> InputEventScreenTouch::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
  612. Ref<InputEventScreenTouch> st;
  613. st.instance();
  614. st->set_device(get_device());
  615. st->set_index(index);
  616. st->set_position(p_xform.xform(pos + p_local_ofs));
  617. st->set_pressed(pressed);
  618. return st;
  619. }
  620. String InputEventScreenTouch::as_text() const {
  621. return "InputEventScreenTouch : index=" + itos(index) + ", pressed=" + (pressed ? "true" : "false") + ", position=(" + String(get_position()) + ")";
  622. }
  623. void InputEventScreenTouch::_bind_methods() {
  624. ClassDB::bind_method(D_METHOD("set_index", "index"), &InputEventScreenTouch::set_index);
  625. ClassDB::bind_method(D_METHOD("get_index"), &InputEventScreenTouch::get_index);
  626. ClassDB::bind_method(D_METHOD("set_position", "position"), &InputEventScreenTouch::set_position);
  627. ClassDB::bind_method(D_METHOD("get_position"), &InputEventScreenTouch::get_position);
  628. ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventScreenTouch::set_pressed);
  629. //ClassDB::bind_method(D_METHOD("is_pressed"),&InputEventScreenTouch::is_pressed);
  630. ADD_PROPERTY(PropertyInfo(Variant::INT, "index"), "set_index", "get_index");
  631. ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position");
  632. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
  633. }
  634. InputEventScreenTouch::InputEventScreenTouch() {
  635. index = 0;
  636. pressed = false;
  637. }
  638. /////////////////////////////
  639. void InputEventScreenDrag::set_index(int p_index) {
  640. index = p_index;
  641. }
  642. int InputEventScreenDrag::get_index() const {
  643. return index;
  644. }
  645. void InputEventScreenDrag::set_position(const Vector2 &p_pos) {
  646. pos = p_pos;
  647. }
  648. Vector2 InputEventScreenDrag::get_position() const {
  649. return pos;
  650. }
  651. void InputEventScreenDrag::set_relative(const Vector2 &p_relative) {
  652. relative = p_relative;
  653. }
  654. Vector2 InputEventScreenDrag::get_relative() const {
  655. return relative;
  656. }
  657. void InputEventScreenDrag::set_speed(const Vector2 &p_speed) {
  658. speed = p_speed;
  659. }
  660. Vector2 InputEventScreenDrag::get_speed() const {
  661. return speed;
  662. }
  663. Ref<InputEvent> InputEventScreenDrag::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
  664. Ref<InputEventScreenDrag> sd;
  665. sd.instance();
  666. sd->set_device(get_device());
  667. sd->set_index(index);
  668. sd->set_position(p_xform.xform(pos + p_local_ofs));
  669. sd->set_relative(p_xform.basis_xform(relative));
  670. sd->set_speed(p_xform.basis_xform(speed));
  671. return sd;
  672. }
  673. String InputEventScreenDrag::as_text() const {
  674. return "InputEventScreenDrag : index=" + itos(index) + ", position=(" + String(get_position()) + "), relative=(" + String(get_relative()) + "), speed=(" + String(get_speed()) + ")";
  675. }
  676. void InputEventScreenDrag::_bind_methods() {
  677. ClassDB::bind_method(D_METHOD("set_index", "index"), &InputEventScreenDrag::set_index);
  678. ClassDB::bind_method(D_METHOD("get_index"), &InputEventScreenDrag::get_index);
  679. ClassDB::bind_method(D_METHOD("set_position", "position"), &InputEventScreenDrag::set_position);
  680. ClassDB::bind_method(D_METHOD("get_position"), &InputEventScreenDrag::get_position);
  681. ClassDB::bind_method(D_METHOD("set_relative", "relative"), &InputEventScreenDrag::set_relative);
  682. ClassDB::bind_method(D_METHOD("get_relative"), &InputEventScreenDrag::get_relative);
  683. ClassDB::bind_method(D_METHOD("set_speed", "speed"), &InputEventScreenDrag::set_speed);
  684. ClassDB::bind_method(D_METHOD("get_speed"), &InputEventScreenDrag::get_speed);
  685. ADD_PROPERTY(PropertyInfo(Variant::INT, "index"), "set_index", "get_index");
  686. ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position");
  687. ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "relative"), "set_relative", "get_relative");
  688. ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "speed"), "set_speed", "get_speed");
  689. }
  690. InputEventScreenDrag::InputEventScreenDrag() {
  691. index = 0;
  692. }
  693. /////////////////////////////
  694. void InputEventAction::set_action(const StringName &p_action) {
  695. action = p_action;
  696. }
  697. StringName InputEventAction::get_action() const {
  698. return action;
  699. }
  700. void InputEventAction::set_pressed(bool p_pressed) {
  701. pressed = p_pressed;
  702. }
  703. bool InputEventAction::is_pressed() const {
  704. return pressed;
  705. }
  706. bool InputEventAction::shortcut_match(const Ref<InputEvent> &p_event) const {
  707. if (p_event.is_null())
  708. return false;
  709. return p_event->is_action(action);
  710. }
  711. bool InputEventAction::is_action(const StringName &p_action) const {
  712. return action == p_action;
  713. }
  714. bool InputEventAction::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
  715. Ref<InputEventAction> act = p_event;
  716. if (act.is_null())
  717. return false;
  718. bool match = action == act->action;
  719. if (match) {
  720. if (p_pressed != NULL)
  721. *p_pressed = act->pressed;
  722. if (p_strength != NULL)
  723. *p_strength = (*p_pressed) ? 1.0f : 0.0f;
  724. }
  725. return match;
  726. }
  727. String InputEventAction::as_text() const {
  728. return "InputEventAction : action=" + action + ", pressed=(" + (pressed ? "true" : "false");
  729. }
  730. void InputEventAction::_bind_methods() {
  731. ClassDB::bind_method(D_METHOD("set_action", "action"), &InputEventAction::set_action);
  732. ClassDB::bind_method(D_METHOD("get_action"), &InputEventAction::get_action);
  733. ClassDB::bind_method(D_METHOD("set_pressed", "pressed"), &InputEventAction::set_pressed);
  734. //ClassDB::bind_method(D_METHOD("is_pressed"), &InputEventAction::is_pressed);
  735. // ClassDB::bind_method(D_METHOD("is_action", "name"), &InputEventAction::is_action);
  736. ADD_PROPERTY(PropertyInfo(Variant::STRING, "action"), "set_action", "get_action");
  737. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "pressed"), "set_pressed", "is_pressed");
  738. }
  739. InputEventAction::InputEventAction() {
  740. pressed = false;
  741. }
  742. /////////////////////////////
  743. void InputEventGesture::set_position(const Vector2 &p_pos) {
  744. pos = p_pos;
  745. }
  746. void InputEventGesture::_bind_methods() {
  747. ClassDB::bind_method(D_METHOD("set_position", "position"), &InputEventGesture::set_position);
  748. ClassDB::bind_method(D_METHOD("get_position"), &InputEventGesture::get_position);
  749. ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position");
  750. }
  751. Vector2 InputEventGesture::get_position() const {
  752. return pos;
  753. }
  754. /////////////////////////////
  755. void InputEventMagnifyGesture::set_factor(real_t p_factor) {
  756. factor = p_factor;
  757. }
  758. real_t InputEventMagnifyGesture::get_factor() const {
  759. return factor;
  760. }
  761. Ref<InputEvent> InputEventMagnifyGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
  762. Ref<InputEventMagnifyGesture> ev;
  763. ev.instance();
  764. ev->set_device(get_device());
  765. ev->set_modifiers_from_event(this);
  766. ev->set_position(p_xform.xform(get_position() + p_local_ofs));
  767. ev->set_factor(get_factor());
  768. return ev;
  769. }
  770. String InputEventMagnifyGesture::as_text() const {
  771. return "InputEventMagnifyGesture : factor=" + rtos(get_factor()) + ", position=(" + String(get_position()) + ")";
  772. }
  773. void InputEventMagnifyGesture::_bind_methods() {
  774. ClassDB::bind_method(D_METHOD("set_factor", "factor"), &InputEventMagnifyGesture::set_factor);
  775. ClassDB::bind_method(D_METHOD("get_factor"), &InputEventMagnifyGesture::get_factor);
  776. ADD_PROPERTY(PropertyInfo(Variant::REAL, "factor"), "set_factor", "get_factor");
  777. }
  778. InputEventMagnifyGesture::InputEventMagnifyGesture() {
  779. factor = 1.0;
  780. }
  781. /////////////////////////////
  782. void InputEventPanGesture::set_delta(const Vector2 &p_delta) {
  783. delta = p_delta;
  784. }
  785. Vector2 InputEventPanGesture::get_delta() const {
  786. return delta;
  787. }
  788. Ref<InputEvent> InputEventPanGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
  789. Ref<InputEventPanGesture> ev;
  790. ev.instance();
  791. ev->set_device(get_device());
  792. ev->set_modifiers_from_event(this);
  793. ev->set_position(p_xform.xform(get_position() + p_local_ofs));
  794. ev->set_delta(get_delta());
  795. return ev;
  796. }
  797. String InputEventPanGesture::as_text() const {
  798. return "InputEventPanGesture : delta=(" + String(get_delta()) + "), position=(" + String(get_position()) + ")";
  799. }
  800. void InputEventPanGesture::_bind_methods() {
  801. ClassDB::bind_method(D_METHOD("set_delta", "delta"), &InputEventPanGesture::set_delta);
  802. ClassDB::bind_method(D_METHOD("get_delta"), &InputEventPanGesture::get_delta);
  803. ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "delta"), "set_delta", "get_delta");
  804. }
  805. InputEventPanGesture::InputEventPanGesture() {
  806. delta = Vector2(0, 0);
  807. }
  808. /////////////////////////////
  809. void InputEventMIDI::set_channel(const int p_channel) {
  810. channel = p_channel;
  811. }
  812. int InputEventMIDI::get_channel() const {
  813. return channel;
  814. }
  815. void InputEventMIDI::set_message(const int p_message) {
  816. message = p_message;
  817. }
  818. int InputEventMIDI::get_message() const {
  819. return message;
  820. }
  821. void InputEventMIDI::set_pitch(const int p_pitch) {
  822. pitch = p_pitch;
  823. }
  824. int InputEventMIDI::get_pitch() const {
  825. return pitch;
  826. }
  827. void InputEventMIDI::set_velocity(const int p_velocity) {
  828. velocity = p_velocity;
  829. }
  830. int InputEventMIDI::get_velocity() const {
  831. return velocity;
  832. }
  833. void InputEventMIDI::set_instrument(const int p_instrument) {
  834. instrument = p_instrument;
  835. }
  836. int InputEventMIDI::get_instrument() const {
  837. return instrument;
  838. }
  839. void InputEventMIDI::set_pressure(const int p_pressure) {
  840. pressure = p_pressure;
  841. }
  842. int InputEventMIDI::get_pressure() const {
  843. return pressure;
  844. }
  845. void InputEventMIDI::set_controller_number(const int p_controller_number) {
  846. controller_number = p_controller_number;
  847. }
  848. int InputEventMIDI::get_controller_number() const {
  849. return controller_number;
  850. }
  851. void InputEventMIDI::set_controller_value(const int p_controller_value) {
  852. controller_value = p_controller_value;
  853. }
  854. int InputEventMIDI::get_controller_value() const {
  855. return controller_value;
  856. }
  857. String InputEventMIDI::as_text() const {
  858. return "InputEventMIDI : channel=(" + itos(get_channel()) + "), message=(" + itos(get_message()) + ")";
  859. }
  860. void InputEventMIDI::_bind_methods() {
  861. ClassDB::bind_method(D_METHOD("set_channel", "channel"), &InputEventMIDI::set_channel);
  862. ClassDB::bind_method(D_METHOD("get_channel"), &InputEventMIDI::get_channel);
  863. ClassDB::bind_method(D_METHOD("set_message", "message"), &InputEventMIDI::set_message);
  864. ClassDB::bind_method(D_METHOD("get_message"), &InputEventMIDI::get_message);
  865. ClassDB::bind_method(D_METHOD("set_pitch", "pitch"), &InputEventMIDI::set_pitch);
  866. ClassDB::bind_method(D_METHOD("get_pitch"), &InputEventMIDI::get_pitch);
  867. ClassDB::bind_method(D_METHOD("set_velocity", "velocity"), &InputEventMIDI::set_velocity);
  868. ClassDB::bind_method(D_METHOD("get_velocity"), &InputEventMIDI::get_velocity);
  869. ClassDB::bind_method(D_METHOD("set_instrument", "instrument"), &InputEventMIDI::set_instrument);
  870. ClassDB::bind_method(D_METHOD("get_instrument"), &InputEventMIDI::get_instrument);
  871. ClassDB::bind_method(D_METHOD("set_pressure", "pressure"), &InputEventMIDI::set_pressure);
  872. ClassDB::bind_method(D_METHOD("get_pressure"), &InputEventMIDI::get_pressure);
  873. ClassDB::bind_method(D_METHOD("set_controller_number", "controller_number"), &InputEventMIDI::set_controller_number);
  874. ClassDB::bind_method(D_METHOD("get_controller_number"), &InputEventMIDI::get_controller_number);
  875. ClassDB::bind_method(D_METHOD("set_controller_value", "controller_value"), &InputEventMIDI::set_controller_value);
  876. ClassDB::bind_method(D_METHOD("get_controller_value"), &InputEventMIDI::get_controller_value);
  877. ADD_PROPERTY(PropertyInfo(Variant::INT, "channel"), "set_channel", "get_channel");
  878. ADD_PROPERTY(PropertyInfo(Variant::INT, "message"), "set_message", "get_message");
  879. ADD_PROPERTY(PropertyInfo(Variant::INT, "pitch"), "set_pitch", "get_pitch");
  880. ADD_PROPERTY(PropertyInfo(Variant::INT, "velocity"), "set_velocity", "get_velocity");
  881. ADD_PROPERTY(PropertyInfo(Variant::INT, "instrument"), "set_instrument", "get_instrument");
  882. ADD_PROPERTY(PropertyInfo(Variant::INT, "pressure"), "set_pressure", "get_pressure");
  883. ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_number"), "set_controller_number", "get_controller_number");
  884. ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_value"), "set_controller_value", "get_controller_value");
  885. }
  886. InputEventMIDI::InputEventMIDI() {
  887. channel = 0;
  888. message = 0;
  889. pitch = 0;
  890. velocity = 0;
  891. instrument = 0;
  892. pressure = 0;
  893. controller_number = 0;
  894. controller_value = 0;
  895. }