fusb_hid.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. /*
  2. * Copyright : (C) 2022 Phytium Information Technology, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is OPEN SOURCE software: you can redistribute it and/or modify it
  6. * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd,
  7. * either version 1.0 of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY;
  10. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. * See the Phytium Public License for more details.
  12. *
  13. *
  14. * FilePath: fusb_hid.h
  15. * Date: 2022-02-11 13:33:09
  16. * LastEditTime: 2022-02-17 17:49:20
  17. * Description:  This files is for definition of USB hub device function
  18. *
  19. * Modify History:
  20. * Ver   Who        Date         Changes
  21. * ----- ------     --------    --------------------------------------
  22. * 1.0 Zhugengyu 2022/9/28 init commit
  23. */
  24. #ifndef DRIVERS_USB_HID_H
  25. #define DRIVERS_USB_HID_H
  26. #ifdef __cplusplus
  27. extern "C"
  28. {
  29. #endif
  30. /***************************** Include Files *********************************/
  31. #include "fusb.h"
  32. /************************** Constant Definitions *****************************/
  33. /*----------------------------------------------------------------------
  34. *
  35. * Function and Keypad Key Definitions.
  36. * Many are just for compatibility.
  37. *
  38. */
  39. #define KEY_CODE_YES 0x100 /* If get_wch() gives a key code */
  40. #define KEY_BREAK 0x101 /* Not on PC KBD */
  41. #define KEY_DOWN 0x102 /* Down arrow key */
  42. #define KEY_UP 0x103 /* Up arrow key */
  43. #define KEY_LEFT 0x104 /* Left arrow key */
  44. #define KEY_RIGHT 0x105 /* Right arrow key */
  45. #define KEY_HOME 0x106 /* home key */
  46. #define KEY_BACKSPACE 0x107 /* not on pc */
  47. #define KEY_F0 0x108 /* function keys; 64 reserved */
  48. #define KEY_DL 0x148 /* delete line */
  49. #define KEY_IL 0x149 /* insert line */
  50. #define KEY_DC 0x14a /* delete character */
  51. #define KEY_IC 0x14b /* insert char or enter ins mode */
  52. #define KEY_EIC 0x14c /* exit insert char mode */
  53. #define KEY_CLEAR 0x14d /* clear screen */
  54. #define KEY_EOS 0x14e /* clear to end of screen */
  55. #define KEY_EOL 0x14f /* clear to end of line */
  56. #define KEY_SF 0x150 /* scroll 1 line forward */
  57. #define KEY_SR 0x151 /* scroll 1 line back (reverse) */
  58. #define KEY_NPAGE 0x152 /* next page */
  59. #define KEY_PPAGE 0x153 /* previous page */
  60. #define KEY_STAB 0x154 /* set tab */
  61. #define KEY_CTAB 0x155 /* clear tab */
  62. #define KEY_CATAB 0x156 /* clear all tabs */
  63. #define KEY_ENTER 0x157 /* enter or send (unreliable) */
  64. #define KEY_SRESET 0x158 /* soft/reset (partial/unreliable) */
  65. #define KEY_RESET 0x159 /* reset/hard reset (unreliable) */
  66. #define KEY_PRINT 0x15a /* print/copy */
  67. #define KEY_LL 0x15b /* home down/bottom (lower left) */
  68. #define KEY_ABORT 0x15c /* abort/terminate key (any) */
  69. #define KEY_SHELP 0x15d /* short help */
  70. #define KEY_LHELP 0x15e /* long help */
  71. #define KEY_BTAB 0x15f /* Back tab key */
  72. #define KEY_BEG 0x160 /* beg(inning) key */
  73. #define KEY_CANCEL 0x161 /* cancel key */
  74. #define KEY_CLOSE 0x162 /* close key */
  75. #define KEY_COMMAND 0x163 /* cmd (command) key */
  76. #define KEY_COPY 0x164 /* copy key */
  77. #define KEY_CREATE 0x165 /* create key */
  78. #define KEY_END 0x166 /* end key */
  79. #define KEY_EXIT 0x167 /* exit key */
  80. #define KEY_FIND 0x168 /* find key */
  81. #define KEY_HELP 0x169 /* help key */
  82. #define KEY_MARK 0x16a /* mark key */
  83. #define KEY_MESSAGE 0x16b /* message key */
  84. #define KEY_MOVE 0x16c /* move key */
  85. #define KEY_NEXT 0x16d /* next object key */
  86. #define KEY_OPEN 0x16e /* open key */
  87. #define KEY_OPTIONS 0x16f /* options key */
  88. #define KEY_PREVIOUS 0x170 /* previous object key */
  89. #define KEY_REDO 0x171 /* redo key */
  90. #define KEY_REFERENCE 0x172 /* ref(erence) key */
  91. #define KEY_REFRESH 0x173 /* refresh key */
  92. #define KEY_REPLACE 0x174 /* replace key */
  93. #define KEY_RESTART 0x175 /* restart key */
  94. #define KEY_RESUME 0x176 /* resume key */
  95. #define KEY_SAVE 0x177 /* save key */
  96. #define KEY_SBEG 0x178 /* shifted beginning key */
  97. #define KEY_SCANCEL 0x179 /* shifted cancel key */
  98. #define KEY_SCOMMAND 0x17a /* shifted command key */
  99. #define KEY_SCOPY 0x17b /* shifted copy key */
  100. #define KEY_SCREATE 0x17c /* shifted create key */
  101. #define KEY_SDC 0x17d /* shifted delete char key */
  102. #define KEY_SDL 0x17e /* shifted delete line key */
  103. #define KEY_SELECT 0x17f /* select key */
  104. #define KEY_SEND 0x180 /* shifted end key */
  105. #define KEY_SEOL 0x181 /* shifted clear line key */
  106. #define KEY_SEXIT 0x182 /* shifted exit key */
  107. #define KEY_SFIND 0x183 /* shifted find key */
  108. #define KEY_SHOME 0x184 /* shifted home key */
  109. #define KEY_SIC 0x185 /* shifted input key */
  110. #define KEY_SLEFT 0x187 /* shifted left arrow key */
  111. #define KEY_SMESSAGE 0x188 /* shifted message key */
  112. #define KEY_SMOVE 0x189 /* shifted move key */
  113. #define KEY_SNEXT 0x18a /* shifted next key */
  114. #define KEY_SOPTIONS 0x18b /* shifted options key */
  115. #define KEY_SPREVIOUS 0x18c /* shifted prev key */
  116. #define KEY_SPRINT 0x18d /* shifted print key */
  117. #define KEY_SREDO 0x18e /* shifted redo key */
  118. #define KEY_SREPLACE 0x18f /* shifted replace key */
  119. #define KEY_SRIGHT 0x190 /* shifted right arrow */
  120. #define KEY_SRSUME 0x191 /* shifted resume key */
  121. #define KEY_SSAVE 0x192 /* shifted save key */
  122. #define KEY_SSUSPEND 0x193 /* shifted suspend key */
  123. #define KEY_SUNDO 0x194 /* shifted undo key */
  124. #define KEY_SUSPEND 0x195 /* suspend key */
  125. #define KEY_UNDO 0x196 /* undo key */
  126. /* PDCurses-specific key definitions -- PC only */
  127. #define ALT_0 0x197
  128. #define ALT_1 0x198
  129. #define ALT_2 0x199
  130. #define ALT_3 0x19a
  131. #define ALT_4 0x19b
  132. #define ALT_5 0x19c
  133. #define ALT_6 0x19d
  134. #define ALT_7 0x19e
  135. #define ALT_8 0x19f
  136. #define ALT_9 0x1a0
  137. #define ALT_A 0x1a1
  138. #define ALT_B 0x1a2
  139. #define ALT_C 0x1a3
  140. #define ALT_D 0x1a4
  141. #define ALT_E 0x1a5
  142. #define ALT_F 0x1a6
  143. #define ALT_G 0x1a7
  144. #define ALT_H 0x1a8
  145. #define ALT_I 0x1a9
  146. #define ALT_J 0x1aa
  147. #define ALT_K 0x1ab
  148. #define ALT_L 0x1ac
  149. #define ALT_M 0x1ad
  150. #define ALT_N 0x1ae
  151. #define ALT_O 0x1af
  152. #define ALT_P 0x1b0
  153. #define ALT_Q 0x1b1
  154. #define ALT_R 0x1b2
  155. #define ALT_S 0x1b3
  156. #define ALT_T 0x1b4
  157. #define ALT_U 0x1b5
  158. #define ALT_V 0x1b6
  159. #define ALT_W 0x1b7
  160. #define ALT_X 0x1b8
  161. #define ALT_Y 0x1b9
  162. #define ALT_Z 0x1ba
  163. #define CTL_LEFT 0x1bb /* Control-Left-Arrow */
  164. #define CTL_RIGHT 0x1bc
  165. #define CTL_PGUP 0x1bd
  166. #define CTL_PGDN 0x1be
  167. #define CTL_HOME 0x1bf
  168. #define CTL_END 0x1c0
  169. #define KEY_A1 0x1c1 /* upper left on Virtual keypad */
  170. #define KEY_A2 0x1c2 /* upper middle on Virt. keypad */
  171. #define KEY_A3 0x1c3 /* upper right on Vir. keypad */
  172. #define KEY_B1 0x1c4 /* middle left on Virt. keypad */
  173. #define KEY_B2 0x1c5 /* center on Virt. keypad */
  174. #define KEY_B3 0x1c6 /* middle right on Vir. keypad */
  175. #define KEY_C1 0x1c7 /* lower left on Virt. keypad */
  176. #define KEY_C2 0x1c8 /* lower middle on Virt. keypad */
  177. #define KEY_C3 0x1c9 /* lower right on Vir. keypad */
  178. #define PADSLASH 0x1ca /* slash on keypad */
  179. #define PADENTER 0x1cb /* enter on keypad */
  180. #define CTL_PADENTER 0x1cc /* ctl-enter on keypad */
  181. #define ALT_PADENTER 0x1cd /* alt-enter on keypad */
  182. #define PADSTOP 0x1ce /* stop on keypad */
  183. #define PADSTAR 0x1cf /* star on keypad */
  184. #define PADMINUS 0x1d0 /* minus on keypad */
  185. #define PADPLUS 0x1d1 /* plus on keypad */
  186. #define CTL_PADSTOP 0x1d2 /* ctl-stop on keypad */
  187. #define CTL_PADCENTER 0x1d3 /* ctl-enter on keypad */
  188. #define CTL_PADPLUS 0x1d4 /* ctl-plus on keypad */
  189. #define CTL_PADMINUS 0x1d5 /* ctl-minus on keypad */
  190. #define CTL_PADSLASH 0x1d6 /* ctl-slash on keypad */
  191. #define CTL_PADSTAR 0x1d7 /* ctl-star on keypad */
  192. #define ALT_PADPLUS 0x1d8 /* alt-plus on keypad */
  193. #define ALT_PADMINUS 0x1d9 /* alt-minus on keypad */
  194. #define ALT_PADSLASH 0x1da /* alt-slash on keypad */
  195. #define ALT_PADSTAR 0x1db /* alt-star on keypad */
  196. #define ALT_PADSTOP 0x1dc /* alt-stop on keypad */
  197. #define CTL_INS 0x1dd /* ctl-insert */
  198. #define ALT_DEL 0x1de /* alt-delete */
  199. #define ALT_INS 0x1df /* alt-insert */
  200. #define CTL_UP 0x1e0 /* ctl-up arrow */
  201. #define CTL_DOWN 0x1e1 /* ctl-down arrow */
  202. #define CTL_TAB 0x1e2 /* ctl-tab */
  203. #define ALT_TAB 0x1e3
  204. #define ALT_MINUS 0x1e4
  205. #define ALT_EQUAL 0x1e5
  206. #define ALT_HOME 0x1e6
  207. #define ALT_PGUP 0x1e7
  208. #define ALT_PGDN 0x1e8
  209. #define ALT_END 0x1e9
  210. #define ALT_UP 0x1ea /* alt-up arrow */
  211. #define ALT_DOWN 0x1eb /* alt-down arrow */
  212. #define ALT_RIGHT 0x1ec /* alt-right arrow */
  213. #define ALT_LEFT 0x1ed /* alt-left arrow */
  214. #define ALT_ENTER 0x1ee /* alt-enter */
  215. #define ALT_ESC 0x1ef /* alt-escape */
  216. #define ALT_BQUOTE 0x1f0 /* alt-back quote */
  217. #define ALT_LBRACKET 0x1f1 /* alt-left bracket */
  218. #define ALT_RBRACKET 0x1f2 /* alt-right bracket */
  219. #define ALT_SEMICOLON 0x1f3 /* alt-semi-colon */
  220. #define ALT_FQUOTE 0x1f4 /* alt-forward quote */
  221. #define ALT_COMMA 0x1f5 /* alt-comma */
  222. #define ALT_STOP 0x1f6 /* alt-stop */
  223. #define ALT_FSLASH 0x1f7 /* alt-forward slash */
  224. #define ALT_BKSP 0x1f8 /* alt-backspace */
  225. #define CTL_BKSP 0x1f9 /* ctl-backspace */
  226. #define PAD0 0x1fa /* keypad 0 */
  227. #define CTL_PAD0 0x1fb /* ctl-keypad 0 */
  228. #define CTL_PAD1 0x1fc
  229. #define CTL_PAD2 0x1fd
  230. #define CTL_PAD3 0x1fe
  231. #define CTL_PAD4 0x1ff
  232. #define CTL_PAD5 0x200
  233. #define CTL_PAD6 0x201
  234. #define CTL_PAD7 0x202
  235. #define CTL_PAD8 0x203
  236. #define CTL_PAD9 0x204
  237. #define ALT_PAD0 0x205 /* alt-keypad 0 */
  238. #define ALT_PAD1 0x206
  239. #define ALT_PAD2 0x207
  240. #define ALT_PAD3 0x208
  241. #define ALT_PAD4 0x209
  242. #define ALT_PAD5 0x20a
  243. #define ALT_PAD6 0x20b
  244. #define ALT_PAD7 0x20c
  245. #define ALT_PAD8 0x20d
  246. #define ALT_PAD9 0x20e
  247. #define CTL_DEL 0x20f /* clt-delete */
  248. #define ALT_BSLASH 0x210 /* alt-back slash */
  249. #define CTL_ENTER 0x211 /* ctl-enter */
  250. #define SHF_PADENTER 0x212 /* shift-enter on keypad */
  251. #define SHF_PADSLASH 0x213 /* shift-slash on keypad */
  252. #define SHF_PADSTAR 0x214 /* shift-star on keypad */
  253. #define SHF_PADPLUS 0x215 /* shift-plus on keypad */
  254. #define SHF_PADMINUS 0x216 /* shift-minus on keypad */
  255. #define SHF_UP 0x217 /* shift-up on keypad */
  256. #define SHF_DOWN 0x218 /* shift-down on keypad */
  257. #define SHF_IC 0x219 /* shift-insert on keypad */
  258. #define SHF_DC 0x21a /* shift-delete on keypad */
  259. #define KEY_MOUSE 0x21b /* "mouse" key */
  260. #define KEY_SHIFT_L 0x21c /* Left-shift */
  261. #define KEY_SHIFT_R 0x21d /* Right-shift */
  262. #define KEY_CONTROL_L 0x21e /* Left-control */
  263. #define KEY_CONTROL_R 0x21f /* Right-control */
  264. #define KEY_ALT_L 0x220 /* Left-alt */
  265. #define KEY_ALT_R 0x221 /* Right-alt */
  266. #define KEY_RESIZE 0x222 /* Window resize */
  267. #define KEY_SUP 0x223 /* Shifted up arrow */
  268. #define KEY_SDOWN 0x224 /* Shifted down arrow */
  269. #define KEY_MIN KEY_BREAK /* Minimum curses key value */
  270. #define KEY_MAX KEY_SDOWN /* Maximum curses key */
  271. #define KEY_F(n) (KEY_F0 + (n))
  272. /**************************** Type Definitions *******************************/
  273. enum
  274. {
  275. FUSB_HID_SUBCLASS_NONE = 0,
  276. FUSB_HID_SUBCLASS_BOOT = 1
  277. };
  278. typedef enum
  279. {
  280. FUSB_HID_PROTOCOL_BOOT = 0,
  281. FUSB_HID_PROTOCOL_REPORT = 1
  282. } FUsbHidProtocol;
  283. enum
  284. {
  285. FUSB_HID_BOOT_PROTOCOL_NONE = 0,
  286. FUSB_HID_BOOT_PROTOCOL_KEYBOARD = 1,
  287. FUSB_HID_BOOT_PROTOCOL_MOUSE = 2
  288. };
  289. /************************** Variable Definitions *****************************/
  290. /***************** Macros (Inline Functions) Definitions *********************/
  291. /************************** Function Prototypes ******************************/
  292. /* USB HID的初始化函数,由应用程序注册到FUSB框架中 */
  293. void FUsbHidInit(FUsbDev *dev);
  294. int FUsbHidCheckInput(FUsbDev *dev, int times);
  295. #ifdef __cplusplus
  296. }
  297. #endif
  298. #endif