usbkvm_fw.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. usbkvm_fw.h
  3. Author: tobychui
  4. */
  5. #ifndef _usbkvm_
  6. #define _usbkvm_
  7. /* ----------- Hardware Configurations -----------*/
  8. #define MIN_KEY_EVENTS_DELAY 20 //ms
  9. #define USB_SW_SEL 32 // Switching pin number for connecting / disconnecting USB Mass Storage Drive
  10. #define HID_SW_SEL 11 // Switching pin number for connecting / disconnecting USB HID
  11. /* ----------- Operation Types -----------*/
  12. #define OPR_TYPE_RESERVED 0x00 // Reserved
  13. #define OPR_TYPE_KEYBOARD_WRITE 0x01 // Keyboard-related operation
  14. #define OPR_TYPE_MOUSE_WRITE 0x02 // Mouse-related operation
  15. #define OPR_TYPE_MOUSE_MOVE 0x03 // Mouse-move operation (Notes: When opr_type is OPR_TYPE_MOUSE_MOVE, opr_subtype is the X position value)
  16. #define OPR_TYPE_MOUSE_SCROLL 0x04 // Mouse scroll (Notes: when opr_type is OPR_TYPE_MOUSE_SCROLL, opr_subtype is up/down and payload is scroll tilt valie (max 127))
  17. #define OPR_TYPE_SWITCH_SET 0x05 // Switch/button operation
  18. #define OPR_TYPE_RESET_INSTR_COUNT 0xFE // Reset instruction counter
  19. #define OPR_TYPE_DATA_RESET 0xFF //Reset opr data queue, if state of device is unknown, clear before use
  20. /* Operation Sub-types */
  21. #define SUBTYPE_RESERVED 0x00
  22. /* ----------- Keyboard Subtypes ----------- */
  23. #define SUBTYPE_KEYBOARD_ASCII_WRITE 0x01 // Write ASCII characters (32-127)
  24. #define SUBTYPE_KEYBOARD_ASCII_PRESS 0x02 // Press a key (ASCII 32-127)
  25. #define SUBTYPE_KEYBOARD_ASCII_RELEASE 0x03 // Release a key (ASCII 32-127)
  26. #define SUBTYPE_KEYBOARD_MODIFIER_PRESS 0x04 // Modifier key write (bit flags)
  27. #define SUBTYPE_KEYBOARD_MODIFIER_RELEASE 0x05 // Modifier key press (bit flags)
  28. #define SUBTYPE_KEYBOARD_FUNCTKEY_PRESS 0x06 //Function key press
  29. #define SUBTYPE_KEYBOARD_FUNCTKEY_RELEASE 0x07 //Function key release
  30. #define SUBTYPE_KEYBOARD_OTHERKEY_PRESS 0x08 //Other keys press
  31. #define SUBTYPE_KEYBOARD_OTHERKEY_RELEASE 0x09 //Other keys release
  32. #define SUBTYPE_KEYBOARD_NUMPAD_PRESS 0x0A //Numpad numeric press
  33. #define SUBTYPE_KEYBOARD_NUMPAD_RELEASE 0x0B //Numpad numeric release
  34. #define SUBTYPE_KEYBOARD_SPECIAL_PAUSE 0xF9 //Pause | Break (hardware offload)
  35. #define SUBTYPE_KEYBOARD_SPECIAL_PRINT_SCREEN 0xFA //Print Screen (hardware offload)
  36. #define SUBTYPE_KEYBOARD_SPECIAL_SCROLL_LOCK 0xFB //Scroll Lock (hardware offload)
  37. #define SUBTYPE_KEYBOARD_SPECIAL_NUMLOCK 0xFC //Toggle NumLock (hardware offload)
  38. #define SUBTYPE_KEYBOARD_SPECIAL_CTRLALTDEL 0xFD //Ctrl + Alt + Del (hardware offload)
  39. #define SUBTYPE_KEYBOARD_SPECIAL_RESET 0xFE //Reset all keypress state
  40. #define SUBTYPE_KEYBOARD_SPECIAL_RESERVED 0xFF //Reserved
  41. /* Modifier Keys IDs */
  42. #define PAYLOAD_KEY_LEFT_CTRL 0x00
  43. #define PAYLOAD_KEY_LEFT_SHIFT 0x01
  44. #define PAYLOAD_KEY_LEFT_ALT 0x02
  45. #define PAYLOAD_KEY_LEFT_GUI 0x03
  46. #define PAYLOAD_KEY_RIGHT_CTRL 0x04
  47. #define PAYLOAD_KEY_RIGHT_SHIFT 0x05
  48. #define PAYLOAD_KEY_RIGHT_ALT 0x06
  49. #define PAYLOAD_KEY_RIGHT_GUI 0x07
  50. /* Numpad Buttons IDs */
  51. #define PAYLOAD_NUMPAD_0 0x00
  52. #define PAYLOAD_NUMPAD_1 0x01
  53. #define PAYLOAD_NUMPAD_2 0x02
  54. #define PAYLOAD_NUMPAD_3 0x03
  55. #define PAYLOAD_NUMPAD_4 0x04
  56. #define PAYLOAD_NUMPAD_5 0x05
  57. #define PAYLOAD_NUMPAD_6 0x06
  58. #define PAYLOAD_NUMPAD_7 0x07
  59. #define PAYLOAD_NUMPAD_8 0x08
  60. #define PAYLOAD_NUMPAD_9 0x09
  61. #define PAYLOAD_NUMPAD_DOT 0x0A
  62. #define PAYLOAD_NUMPAD_TIMES 0x0B
  63. #define PAYLOAD_NUMPAD_DIV 0x0C
  64. #define PAYLOAD_NUMPAD_PLUS 0x0D
  65. #define PAYLOAD_NUMPAD_MINUS 0x0E
  66. #define PAYLOAD_NUMPAD_ENTER 0x0F
  67. #define PAYLOAD_NUMPAD_NUMLOCK 0x10
  68. /* ----------- Mouse Subtypes -----------*/
  69. #define SUBTYPE_MOUSE_CLICK 0x01
  70. #define SUBTYPE_MOUSE_PRESS 0x02
  71. #define SUBTYPE_MOUSE_RELEASE 0x03
  72. #define SUBTYPE_MOUSE_SETPOS 0x04
  73. #define SUBTYPE_MOUSE_RESET 0x05
  74. /* Mouse Buttons IDs */
  75. #define PAYLOAD_MOUSE_BTN_LEFT 0x01
  76. #define PAYLOAD_MOUSE_BTN_RIGHT 0x02
  77. #define PAYLOAD_MOUSE_BTN_MID 0x03
  78. /* ----------- Switches Subtypes -----------*/
  79. #define SUBTYPE_SWITCH_USBHID 0x01
  80. #define SUBTYPE_SWITCH_USBMASS 0x02
  81. /* ----------- Response Codes ----------- */
  82. #define resp_ok 0x00
  83. #define resp_unknown_opr 0x01
  84. #define resp_invalid_opr_type 0x02
  85. #define resp_invalid_key_value 0x03
  86. #define resp_not_implemented 0x04
  87. /* Debug */
  88. #define resp_start_of_info_msg 0xED
  89. #define resp_end_of_msg 0xEF
  90. #endif