Kiibohd Controller
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

output_com.h 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* Copyright (C) 2013-2015 by Jacob Alexander
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4. * of this software and associated documentation files (the "Software"), to deal
  5. * in the Software without restriction, including without limitation the rights
  6. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. * copies of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. * THE SOFTWARE.
  20. */
  21. #ifndef __output_com_h
  22. #define __output_com_h
  23. // ----- Includes -----
  24. // Compiler Includes
  25. #include <stdint.h>
  26. // Local Includes
  27. #include <buildvars.h> // Defines USB Parameters, partially generated by CMake
  28. // ----- Defines -----
  29. // Max size of key buffer needed for NKRO
  30. // Boot mode uses only the first 6 bytes
  31. #define USB_NKRO_BITFIELD_SIZE_KEYS 26
  32. #define USB_BOOT_MAX_KEYS 6
  33. // ----- Enumerations -----
  34. // USB NKRO state transitions (indicates which Report ID's need refreshing)
  35. // Boot mode just checks if any keys were changed (as everything is sent every time)
  36. typedef enum USBKeyChangeState {
  37. USBKeyChangeState_None = 0x00,
  38. USBKeyChangeState_Modifiers = 0x01,
  39. USBKeyChangeState_MainKeys = 0x02,
  40. USBKeyChangeState_SecondaryKeys = 0x04,
  41. USBKeyChangeState_System = 0x08,
  42. USBKeyChangeState_Consumer = 0x10,
  43. } USBKeyChangeState;
  44. // ----- Variables -----
  45. // Variables used to communciate to the output module
  46. // XXX Even if the output module is not USB, this is internally understood keymapping scheme
  47. extern uint8_t USBKeys_Modifiers;
  48. extern uint8_t USBKeys_Keys[USB_NKRO_BITFIELD_SIZE_KEYS];
  49. extern uint8_t USBKeys_Sent;
  50. extern volatile uint8_t USBKeys_LEDs;
  51. extern uint8_t USBKeys_SysCtrl; // 1KRO container for System Control HID table
  52. extern uint16_t USBKeys_ConsCtrl; // 1KRO container for Consumer Control HID table
  53. extern volatile uint8_t USBKeys_Protocol; // 0 - Boot Mode, 1 - NKRO Mode
  54. // Misc variables (XXX Some are only properly utilized using AVR)
  55. extern uint8_t USBKeys_Idle_Config;
  56. extern uint8_t USBKeys_Idle_Count;
  57. extern USBKeyChangeState USBKeys_Changed;
  58. extern uint8_t Output_Available; // 0 - Output module not fully functional, 1 - Output module working
  59. // ----- Capabilities -----
  60. void Output_usbCodeSend_capability( uint8_t state, uint8_t stateType, uint8_t *args );
  61. // ----- Functions -----
  62. void Output_setup();
  63. void Output_send();
  64. void Output_firmwareReload();
  65. void Output_softReset();
  66. // Relies on USB serial module
  67. unsigned int Output_availablechar();
  68. int Output_getchar();
  69. int Output_putchar( char c );
  70. int Output_putstr( char* str );
  71. #endif