hci.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. 'use strict';
  2. goog.provide('Blockly.Blocks.hci');
  3. goog.require('Blockly.Blocks');
  4. /*
  5. * HID
  6. * setup
  7. */
  8. Blockly.Blocks['HID_setup'] = {
  9. init: function() {
  10. this.appendDummyInput()
  11. .appendField(new Blockly.FieldImage("./../blockly/media/computer.png", 50, 40, "15"));
  12. this.appendDummyInput()
  13. .appendField(Blockly.Msg.HID_SETUP);
  14. this.setColour("#ff8b2c");
  15. this.setTooltip("");
  16. this.setHelpUrl("");
  17. },
  18. }
  19. /*
  20. * HID
  21. * Mouse move
  22. */
  23. Blockly.Blocks['HID_mouse_move'] = {
  24. init: function() {
  25. this.appendDummyInput()
  26. .appendField(Blockly.Msg.HID_MOUSE_MOVE)
  27. .appendField(new Blockly.FieldDropdown([
  28. ["↑", "KEYPAD_UP"],
  29. ["↓", "KEYPAD_DOWN"],
  30. ["←", "KEYPAD_LEFT"],
  31. ["→", "KEYPAD_RIGHT"]
  32. ]), "mouse_towards")
  33. .appendField(Blockly.Msg.HID_MOUSE_MOVE_FOR)
  34. .appendField(new Blockly.FieldTextInput("10"), "mouse_distance")
  35. .appendField(Blockly.Msg.HID_MOUSE_MOVE_DISTANCE)
  36. this.setPreviousStatement(true, null);
  37. this.setNextStatement(true, null);
  38. this.setColour("#ff8b2c");
  39. this.setTooltip("");
  40. this.setHelpUrl("");
  41. },
  42. }
  43. /*
  44. * HID
  45. * mouse click
  46. */
  47. Blockly.Blocks['HID_mouse_click'] = {
  48. init: function() {
  49. this.appendDummyInput()
  50. .appendField(Blockly.Msg.HID_MOUSE_CLICK)
  51. .appendField(new Blockly.FieldDropdown([
  52. [Blockly.Msg.HID_MOUSE_CLICK_LEFT, "MOUSE_LEFT"],
  53. [Blockly.Msg.HID_MOUSE_CLICK_RIGHT, "MOUSE_RIGHT"]
  54. ]), "CLICK");
  55. this.setPreviousStatement(true, null);
  56. this.setNextStatement(true, null);
  57. this.setColour("#ff8b2c");
  58. this.setTooltip("");
  59. this.setHelpUrl("");
  60. },
  61. }
  62. /*
  63. * HID
  64. * mouse press
  65. */
  66. Blockly.Blocks['HID_mouse_press'] = {
  67. init: function() {
  68. this.appendDummyInput()
  69. .appendField(Blockly.Msg.HID_MOUSE_PRESS)
  70. .appendField(new Blockly.FieldDropdown([
  71. [Blockly.Msg.HID_MOUSE_CLICK_LEFT, "MOUSE_LEFT"],
  72. [Blockly.Msg.HID_MOUSE_CLICK_RIGHT, "MOUSE_RIGHT"]
  73. ]), "CLICK");
  74. this.setPreviousStatement(true, null);
  75. this.setNextStatement(true, null);
  76. this.setColour("#ff8b2c");
  77. this.setTooltip("");
  78. this.setHelpUrl("");
  79. },
  80. }
  81. /*
  82. * HID
  83. * mouse press
  84. */
  85. Blockly.Blocks['HID_mouse_release'] = {
  86. init: function() {
  87. this.appendDummyInput()
  88. .appendField(Blockly.Msg.HID_MOUSE_RELEASE)
  89. .appendField(new Blockly.FieldDropdown([
  90. [Blockly.Msg.HID_MOUSE_CLICK_LEFT, "MOUSE_LEFT"],
  91. [Blockly.Msg.HID_MOUSE_CLICK_RIGHT, "MOUSE_RIGHT"]
  92. ]), "CLICK");
  93. this.setPreviousStatement(true, null);
  94. this.setNextStatement(true, null);
  95. this.setColour("#ff8b2c");
  96. this.setTooltip("");
  97. this.setHelpUrl("");
  98. },
  99. }
  100. /*
  101. * HID
  102. * keyboard press
  103. * Dropdown for special KEY {KEY_LEFT_CTRL , KEY_LEFT_SHIFT ,KEY_LEFT_ALT,
  104. * KEY_UP_ARROW,KEY_DOWN_ARROW,KEY_LEFT_ARROW,KEY_RIGHT_ARROW,
  105. * KEY_BACKSPACE,KEY_ESC }
  106. */
  107. Blockly.Blocks['HID_keyboard_press'] = {
  108. init: function() {
  109. this.appendDummyInput()
  110. .appendField(Blockly.Msg.HID_KEYBOARD_PRESS)
  111. .appendField(new Blockly.FieldDropdown([
  112. ["Space", "32"],
  113. ["Enter", "KEY_RETURN"],
  114. ["UP", "KEY_UP_ARROW"],
  115. ["DOWN", "KEY_DOWN_ARROW"],
  116. ["LEFT", "KEY_LEFT_ARROW"],
  117. ["RIGHT", "KEY_RIGHT_ARROW"],
  118. ["DELETE", "KEY_DELETE"],
  119. ["0", "'0'"],
  120. ["1", "'1'"],
  121. ["2", "'2'"],
  122. ["3", "'3'"],
  123. ["4", "'4'"],
  124. ["5", "'5'"],
  125. ["6", "'6'"],
  126. ["7", "'7'"],
  127. ["8", "'8'"],
  128. ["9", "'9'"],
  129. ["A", "'A'"],
  130. ["B", "'B'"],
  131. ["C", "'C'"],
  132. ["D", "'D'"],
  133. ["E", "'E'"],
  134. ["F", "'F'"],
  135. ["G", "'G'"],
  136. ["H", "'H'"],
  137. ["I", "'I'"],
  138. ["J", "'J'"],
  139. ["K", "'K'"],
  140. ["L", "'L'"],
  141. ["M", "'M'"],
  142. ["N", "'N'"],
  143. ["O", "'O'"],
  144. ["P", "'P'"],
  145. ["Q", "'Q'"],
  146. ["R", "'R'"],
  147. ["S", "'S'"],
  148. ["T", "'T'"],
  149. ["U", "'U'"],
  150. ["V", "'V'"],
  151. ["W", "'W'"],
  152. ["X", "'X'"],
  153. ["Y", "'Y'"],
  154. ["Z", "'Z'"],
  155. ]), "keyboard_press");
  156. this.setPreviousStatement(true, null);
  157. this.setNextStatement(true, null);
  158. this.setColour("#ff8b2c");
  159. this.setTooltip("");
  160. this.setHelpUrl("");
  161. },
  162. }
  163. /*
  164. * HID
  165. * keyboard release
  166. * Dropdown for special KEY {KEY_LEFT_CTRL , KEY_LEFT_SHIFT ,KEY_LEFT_ALT,
  167. * KEY_UP_ARROW,KEY_DOWN_ARROW,KEY_LEFT_ARROW,KEY_RIGHT_ARROW,
  168. * KEY_BACKSPACE,KEY_ESC }
  169. */
  170. Blockly.Blocks['HID_keyboard_release'] = {
  171. init: function() {
  172. this.appendDummyInput()
  173. .appendField(Blockly.Msg.HID_KEYBOARD_RELEASE)
  174. .appendField(new Blockly.FieldDropdown([
  175. ["Space", "32"],
  176. ["Enter", "KEY_RETURN"],
  177. ["UP", "KEY_UP_ARROW"],
  178. ["DOWN", "KEY_DOWN_ARROW"],
  179. ["LEFT", "KEY_LEFT_ARROW"],
  180. ["RIGHT", "KEY_RIGHT_ARROW"],
  181. ["DELETE", "KEY_DELETE"],
  182. ["0", "'0'"],
  183. ["1", "'1'"],
  184. ["2", "'2'"],
  185. ["3", "'3'"],
  186. ["4", "'4'"],
  187. ["5", "'5'"],
  188. ["6", "'6'"],
  189. ["7", "'7'"],
  190. ["8", "'8'"],
  191. ["9", "'9'"],
  192. ["A", "'A'"],
  193. ["B", "'B'"],
  194. ["C", "'C'"],
  195. ["D", "'D'"],
  196. ["E", "'E'"],
  197. ["F", "'F'"],
  198. ["G", "'G'"],
  199. ["H", "'H'"],
  200. ["I", "'I'"],
  201. ["J", "'J'"],
  202. ["K", "'K'"],
  203. ["L", "'L'"],
  204. ["M", "'M'"],
  205. ["N", "'N'"],
  206. ["O", "'O'"],
  207. ["P", "'P'"],
  208. ["Q", "'Q'"],
  209. ["R", "'R'"],
  210. ["S", "'S'"],
  211. ["T", "'T'"],
  212. ["U", "'U'"],
  213. ["V", "'V'"],
  214. ["W", "'W'"],
  215. ["X", "'X'"],
  216. ["Y", "'Y'"],
  217. ["Z", "'Z'"],
  218. ]), "keyboard_press");
  219. this.setPreviousStatement(true, null);
  220. this.setNextStatement(true, null);
  221. this.setColour("#ff8b2c");
  222. this.setTooltip("");
  223. this.setHelpUrl("");
  224. },
  225. }
  226. /*
  227. * HID
  228. * keyboard releaseAll
  229. * release all keyboard
  230. */
  231. Blockly.Blocks['HID_keyboard_releaseAll'] = {
  232. init: function() {
  233. this.appendDummyInput()
  234. .appendField(Blockly.Msg.HID_KEYBOARD_RELEASEALL)
  235. this.setPreviousStatement(true, null);
  236. this.setNextStatement(true, null);
  237. this.setColour("#ff8b2c");
  238. this.setTooltip("");
  239. this.setHelpUrl("");
  240. },
  241. }