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.

1221 lines
45 KiB

Update personal layouts, free up matrix_scan_user for JJ40 (#2319) * Add NIU Mini keymap from Planck keymap * Remove old keymap files * Fix README, removed Planck references * Add default layout, move Planck layout to separate folder * Update README * Add my XD60 keymap * Change RShift to slash * Fix keymap: stuck on MO(1) * Move RESET to Fn+Enter * Add: RGB saturation cycle * Add numpad layer to keymap * Fix last case * Cleanup Mechmini keymap. Once the custom RGB function is defined, there is no need to manually handle RGB code. * Change default to KEYMAP_MIT, not KEYMAP_OFFSET * Add custom RGB code for JJ40 * Reset Mechmini advertised power draw to 500. Will have to test actual maximum power draw later. * RGB working on JJ40. * Fix: saturation increase/decrease flipped * Add new directory for my custom keymap with RGB keycodes * Swap LAlt and LGUI * Update JJ40 max power draw with measured value * Update: fun40 rules.mk to enable underglow; earlier failed Travis CI * Fix: init RGB LEDs on boot. Also added HHKB-like keymap for XD60. * Super rudimentary backlight test, init RGB LEDs on boot * Backlighting works - stays on for now * Toggling working * Now can override backlight.c functions. Problem was functions in backlight.c weren't called before due to a lack of matrix_scan_quantum() in matrix.c * Timers not working * Delete global.h * Cleanup * Compiles * Good sign: LEDs stop working again * Handle timer1 overflow * Progress: fix: forgot to init * Backlighting fully working now except breathing. * Revert keymap to original keycodes * Update XD60 keymap README * Update JJ40 keymap with backlight toggles * Breathing working just fine. * Update references * Add backlight_set() call * Cleanup code to disable backlight * Fix: does not compile * Fix: missing call to rgblight_task. * Testing with BACKLIGHT_BREATHING * Cleanup * Cleanup comments * More commenting cleanup. * Do not enable BACKLIGHT_BREATHING by default * Update XD60 keymap * Update: move matrix_scan_kb out from matrix.c to jj40.c (kb-level) * Cleanup for PR * Fix conflict in readme.md for NIU mini * Restore original power consumption figure * Fix: matrix_scan_user() now has to be defined in the keymaps * Add weak `matrix_scan_user` so it does not have to be defined in keymap * Add weak matrix_init_user()
6 years ago
Merge ChibiOS and LUFA descriptor support (#2362) * Move lufa descriptor to protocol/usb_descriptor * Try to compile usb_descriptor on ChibiOS * Add lufa_utils for ChibiOS Lufa USB descriptors for ChibiOS * More lufa_util compatibility fixes * First compiling version of shared USB descriptor * Send the usb descriptors * Fix the CONSOLE output on ChibiOS * Add errors for unsupported interfaces * Enable support for vitual serial port USB descriptors * Implement virtual serial port for ChibiOS * Cleanup the lufa_utils Use the default lufa header files * Add raw hid support for ChibiOS This is completely untested * Enable midi compilation on ChibiOS * Move midi functionality out of lufa.c * Don't register sysex callback when not needed * ChibiOS compilation fixes * Update ChibiOS submodule * Fix the Midi USB descriptor It didn't work properly when both Midi and Virtual serial port was enabled. * Add MIDI support for ChibiOS * Fix USB descriptor strings on ChibiOS * Use serial usb driver for raw hid * Generalize the ChibiOS stream like drivers This makes the initialization much more simple and eliminates a lot of the code duplication. * Convert console output to chibios stream driver * Fixes for ChibiOS update * Update the ChibiOS contrib submodule To include the usb data toggle synchronization fixes * Fix duplicate reset enumeration on ChibiOS * Add missing include * Add number of endpoints check for ChibiOS * Enable serial USB driver on all keyboards * Add missing includes when API is enabled withot midi * Add another missing inlcude
6 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
Hid joystick interface (#4226) * add support for hid gamepad interface add documentation for HID joystick Add joystick_task to read analog axes values even when no key is pressed or release. update doc Update docs/feature_joystick.md Manage pin setup and read to maintain matrix scan after analog read * Incorporates patches and changes to HID reporting There are some patches provided by @a-chol incorporated on this commit, and also some changes I made to the HID Report structure. The most interesting is the one dealing with number of buttons: Linux doesn't seem to care, but Windows requires the HID structure to be byte aligned (that's in the spec). So if one declares 8/16/32... buttons they should not have any issues, but this is what happens when you have 9 buttons: ``` bits |0|1|2|3|4|5|6|7| |*|*|*|*|*|*|*|*| axis 0 (report size 8) |*|*|*|*|*|*|*|*| ... |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| axis 6 |*|*|*|*|*|*|*|*| first 8 buttons (report size 1) |*| | | | | | | | last of 9 buttons, not aligned ``` So for that I added a conditonal that will add a number of reports with size 1 to make sure it aligns to the next multiple of 8. Those reports send dummy inputs that don't do anything aside from aligning the data. Tested on Linux, Windows 10 and Street Fighter (where the joystick is recognized as direct-input) * Add save and restore of each pin used in reading joystick (AVR). Allow output pin to be JS_VIRTUAL_AXIS if the axis is connected to Vcc instead of an output pin from the MCU. Fix joystick report id Fix broken v-usb hid joystick interface. Make it more resilient to unusual settings (none multiple of eight button count, 0 buttons or 0 axes) Correct adc reading for multiple axes. Piecewise range conversion for uncentered raw value range. Input, output and ground pin configuration per axis. Documentation fixes * Fix port addressing for joystick analog read * The other required set of changes As per the PR, the changes still holding it up. Add onekey for testing. Fix ARM builds. Fix device descriptor when either axes or buttons is zero. Add compile-time check for at least one axis or button. Move definition to try to fix conflict. PR review comments. qmk cformat * avoid float functions to compute range mapping for axis adc reading * Remove V-USB support for now. Updated docs accordingly. * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Add support for joystick adc reading for stm32 MCUs. Fix joystick hid report sending for chibios * Fix HID joystick report sending for ChibiOS. Add one analog axis to the onekey:joystick keymap. Fix pin state save and restore during joystick analog read for STM32 MCUs. * Update tmk_core/protocol/chibios/usb_main.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Add missing mcuconf.h and halconf.h to onekey:joystick keymap. Add suggested fixes from PR. * Switch saveState and restoreState signature to use pin_t type. onekey:joystick : add a second axis, virtual and programmatically animated. * Update docs/feature_joystick.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Update docs/feature_joystick.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Add PR corrections * Remove halconf.h and mcuconf.h from onekey keymaps * Change ADC_PIN to A0 Co-authored-by: achol <allecooll@hotmail.com> Co-authored-by: José Júnior <jose.junior@gmail.com> Co-authored-by: a-chol <achol@notamail.com> Co-authored-by: Nick Brassel <nick@tzarc.org> Co-authored-by: Ryan <fauxpark@gmail.com>
3 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
Hid joystick interface (#4226) * add support for hid gamepad interface add documentation for HID joystick Add joystick_task to read analog axes values even when no key is pressed or release. update doc Update docs/feature_joystick.md Manage pin setup and read to maintain matrix scan after analog read * Incorporates patches and changes to HID reporting There are some patches provided by @a-chol incorporated on this commit, and also some changes I made to the HID Report structure. The most interesting is the one dealing with number of buttons: Linux doesn't seem to care, but Windows requires the HID structure to be byte aligned (that's in the spec). So if one declares 8/16/32... buttons they should not have any issues, but this is what happens when you have 9 buttons: ``` bits |0|1|2|3|4|5|6|7| |*|*|*|*|*|*|*|*| axis 0 (report size 8) |*|*|*|*|*|*|*|*| ... |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| axis 6 |*|*|*|*|*|*|*|*| first 8 buttons (report size 1) |*| | | | | | | | last of 9 buttons, not aligned ``` So for that I added a conditonal that will add a number of reports with size 1 to make sure it aligns to the next multiple of 8. Those reports send dummy inputs that don't do anything aside from aligning the data. Tested on Linux, Windows 10 and Street Fighter (where the joystick is recognized as direct-input) * Add save and restore of each pin used in reading joystick (AVR). Allow output pin to be JS_VIRTUAL_AXIS if the axis is connected to Vcc instead of an output pin from the MCU. Fix joystick report id Fix broken v-usb hid joystick interface. Make it more resilient to unusual settings (none multiple of eight button count, 0 buttons or 0 axes) Correct adc reading for multiple axes. Piecewise range conversion for uncentered raw value range. Input, output and ground pin configuration per axis. Documentation fixes * Fix port addressing for joystick analog read * The other required set of changes As per the PR, the changes still holding it up. Add onekey for testing. Fix ARM builds. Fix device descriptor when either axes or buttons is zero. Add compile-time check for at least one axis or button. Move definition to try to fix conflict. PR review comments. qmk cformat * avoid float functions to compute range mapping for axis adc reading * Remove V-USB support for now. Updated docs accordingly. * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Add support for joystick adc reading for stm32 MCUs. Fix joystick hid report sending for chibios * Fix HID joystick report sending for ChibiOS. Add one analog axis to the onekey:joystick keymap. Fix pin state save and restore during joystick analog read for STM32 MCUs. * Update tmk_core/protocol/chibios/usb_main.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Add missing mcuconf.h and halconf.h to onekey:joystick keymap. Add suggested fixes from PR. * Switch saveState and restoreState signature to use pin_t type. onekey:joystick : add a second axis, virtual and programmatically animated. * Update docs/feature_joystick.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Update docs/feature_joystick.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Add PR corrections * Remove halconf.h and mcuconf.h from onekey keymaps * Change ADC_PIN to A0 Co-authored-by: achol <allecooll@hotmail.com> Co-authored-by: José Júnior <jose.junior@gmail.com> Co-authored-by: a-chol <achol@notamail.com> Co-authored-by: Nick Brassel <nick@tzarc.org> Co-authored-by: Ryan <fauxpark@gmail.com>
3 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
Hid joystick interface (#4226) * add support for hid gamepad interface add documentation for HID joystick Add joystick_task to read analog axes values even when no key is pressed or release. update doc Update docs/feature_joystick.md Manage pin setup and read to maintain matrix scan after analog read * Incorporates patches and changes to HID reporting There are some patches provided by @a-chol incorporated on this commit, and also some changes I made to the HID Report structure. The most interesting is the one dealing with number of buttons: Linux doesn't seem to care, but Windows requires the HID structure to be byte aligned (that's in the spec). So if one declares 8/16/32... buttons they should not have any issues, but this is what happens when you have 9 buttons: ``` bits |0|1|2|3|4|5|6|7| |*|*|*|*|*|*|*|*| axis 0 (report size 8) |*|*|*|*|*|*|*|*| ... |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| axis 6 |*|*|*|*|*|*|*|*| first 8 buttons (report size 1) |*| | | | | | | | last of 9 buttons, not aligned ``` So for that I added a conditonal that will add a number of reports with size 1 to make sure it aligns to the next multiple of 8. Those reports send dummy inputs that don't do anything aside from aligning the data. Tested on Linux, Windows 10 and Street Fighter (where the joystick is recognized as direct-input) * Add save and restore of each pin used in reading joystick (AVR). Allow output pin to be JS_VIRTUAL_AXIS if the axis is connected to Vcc instead of an output pin from the MCU. Fix joystick report id Fix broken v-usb hid joystick interface. Make it more resilient to unusual settings (none multiple of eight button count, 0 buttons or 0 axes) Correct adc reading for multiple axes. Piecewise range conversion for uncentered raw value range. Input, output and ground pin configuration per axis. Documentation fixes * Fix port addressing for joystick analog read * The other required set of changes As per the PR, the changes still holding it up. Add onekey for testing. Fix ARM builds. Fix device descriptor when either axes or buttons is zero. Add compile-time check for at least one axis or button. Move definition to try to fix conflict. PR review comments. qmk cformat * avoid float functions to compute range mapping for axis adc reading * Remove V-USB support for now. Updated docs accordingly. * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Add support for joystick adc reading for stm32 MCUs. Fix joystick hid report sending for chibios * Fix HID joystick report sending for ChibiOS. Add one analog axis to the onekey:joystick keymap. Fix pin state save and restore during joystick analog read for STM32 MCUs. * Update tmk_core/protocol/chibios/usb_main.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Add missing mcuconf.h and halconf.h to onekey:joystick keymap. Add suggested fixes from PR. * Switch saveState and restoreState signature to use pin_t type. onekey:joystick : add a second axis, virtual and programmatically animated. * Update docs/feature_joystick.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Update docs/feature_joystick.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Add PR corrections * Remove halconf.h and mcuconf.h from onekey keymaps * Change ADC_PIN to A0 Co-authored-by: achol <allecooll@hotmail.com> Co-authored-by: José Júnior <jose.junior@gmail.com> Co-authored-by: a-chol <achol@notamail.com> Co-authored-by: Nick Brassel <nick@tzarc.org> Co-authored-by: Ryan <fauxpark@gmail.com>
3 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
8 years ago
8 years ago
Hid joystick interface (#4226) * add support for hid gamepad interface add documentation for HID joystick Add joystick_task to read analog axes values even when no key is pressed or release. update doc Update docs/feature_joystick.md Manage pin setup and read to maintain matrix scan after analog read * Incorporates patches and changes to HID reporting There are some patches provided by @a-chol incorporated on this commit, and also some changes I made to the HID Report structure. The most interesting is the one dealing with number of buttons: Linux doesn't seem to care, but Windows requires the HID structure to be byte aligned (that's in the spec). So if one declares 8/16/32... buttons they should not have any issues, but this is what happens when you have 9 buttons: ``` bits |0|1|2|3|4|5|6|7| |*|*|*|*|*|*|*|*| axis 0 (report size 8) |*|*|*|*|*|*|*|*| ... |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| axis 6 |*|*|*|*|*|*|*|*| first 8 buttons (report size 1) |*| | | | | | | | last of 9 buttons, not aligned ``` So for that I added a conditonal that will add a number of reports with size 1 to make sure it aligns to the next multiple of 8. Those reports send dummy inputs that don't do anything aside from aligning the data. Tested on Linux, Windows 10 and Street Fighter (where the joystick is recognized as direct-input) * Add save and restore of each pin used in reading joystick (AVR). Allow output pin to be JS_VIRTUAL_AXIS if the axis is connected to Vcc instead of an output pin from the MCU. Fix joystick report id Fix broken v-usb hid joystick interface. Make it more resilient to unusual settings (none multiple of eight button count, 0 buttons or 0 axes) Correct adc reading for multiple axes. Piecewise range conversion for uncentered raw value range. Input, output and ground pin configuration per axis. Documentation fixes * Fix port addressing for joystick analog read * The other required set of changes As per the PR, the changes still holding it up. Add onekey for testing. Fix ARM builds. Fix device descriptor when either axes or buttons is zero. Add compile-time check for at least one axis or button. Move definition to try to fix conflict. PR review comments. qmk cformat * avoid float functions to compute range mapping for axis adc reading * Remove V-USB support for now. Updated docs accordingly. * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Add support for joystick adc reading for stm32 MCUs. Fix joystick hid report sending for chibios * Fix HID joystick report sending for ChibiOS. Add one analog axis to the onekey:joystick keymap. Fix pin state save and restore during joystick analog read for STM32 MCUs. * Update tmk_core/protocol/chibios/usb_main.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Add missing mcuconf.h and halconf.h to onekey:joystick keymap. Add suggested fixes from PR. * Switch saveState and restoreState signature to use pin_t type. onekey:joystick : add a second axis, virtual and programmatically animated. * Update docs/feature_joystick.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Update docs/feature_joystick.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Add PR corrections * Remove halconf.h and mcuconf.h from onekey keymaps * Change ADC_PIN to A0 Co-authored-by: achol <allecooll@hotmail.com> Co-authored-by: José Júnior <jose.junior@gmail.com> Co-authored-by: a-chol <achol@notamail.com> Co-authored-by: Nick Brassel <nick@tzarc.org> Co-authored-by: Ryan <fauxpark@gmail.com>
3 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
Hid joystick interface (#4226) * add support for hid gamepad interface add documentation for HID joystick Add joystick_task to read analog axes values even when no key is pressed or release. update doc Update docs/feature_joystick.md Manage pin setup and read to maintain matrix scan after analog read * Incorporates patches and changes to HID reporting There are some patches provided by @a-chol incorporated on this commit, and also some changes I made to the HID Report structure. The most interesting is the one dealing with number of buttons: Linux doesn't seem to care, but Windows requires the HID structure to be byte aligned (that's in the spec). So if one declares 8/16/32... buttons they should not have any issues, but this is what happens when you have 9 buttons: ``` bits |0|1|2|3|4|5|6|7| |*|*|*|*|*|*|*|*| axis 0 (report size 8) |*|*|*|*|*|*|*|*| ... |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| axis 6 |*|*|*|*|*|*|*|*| first 8 buttons (report size 1) |*| | | | | | | | last of 9 buttons, not aligned ``` So for that I added a conditonal that will add a number of reports with size 1 to make sure it aligns to the next multiple of 8. Those reports send dummy inputs that don't do anything aside from aligning the data. Tested on Linux, Windows 10 and Street Fighter (where the joystick is recognized as direct-input) * Add save and restore of each pin used in reading joystick (AVR). Allow output pin to be JS_VIRTUAL_AXIS if the axis is connected to Vcc instead of an output pin from the MCU. Fix joystick report id Fix broken v-usb hid joystick interface. Make it more resilient to unusual settings (none multiple of eight button count, 0 buttons or 0 axes) Correct adc reading for multiple axes. Piecewise range conversion for uncentered raw value range. Input, output and ground pin configuration per axis. Documentation fixes * Fix port addressing for joystick analog read * The other required set of changes As per the PR, the changes still holding it up. Add onekey for testing. Fix ARM builds. Fix device descriptor when either axes or buttons is zero. Add compile-time check for at least one axis or button. Move definition to try to fix conflict. PR review comments. qmk cformat * avoid float functions to compute range mapping for axis adc reading * Remove V-USB support for now. Updated docs accordingly. * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Add support for joystick adc reading for stm32 MCUs. Fix joystick hid report sending for chibios * Fix HID joystick report sending for ChibiOS. Add one analog axis to the onekey:joystick keymap. Fix pin state save and restore during joystick analog read for STM32 MCUs. * Update tmk_core/protocol/chibios/usb_main.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Add missing mcuconf.h and halconf.h to onekey:joystick keymap. Add suggested fixes from PR. * Switch saveState and restoreState signature to use pin_t type. onekey:joystick : add a second axis, virtual and programmatically animated. * Update docs/feature_joystick.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Update docs/feature_joystick.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Add PR corrections * Remove halconf.h and mcuconf.h from onekey keymaps * Change ADC_PIN to A0 Co-authored-by: achol <allecooll@hotmail.com> Co-authored-by: José Júnior <jose.junior@gmail.com> Co-authored-by: a-chol <achol@notamail.com> Co-authored-by: Nick Brassel <nick@tzarc.org> Co-authored-by: Ryan <fauxpark@gmail.com>
3 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
Use a single endpoint for HID reports (#3951) * Unify multiple HID interfaces into one This reduces the number of USB endpoints required, which frees them up for other things. NKRO and EXTRAKEY always use the shared endpoint. By default, MOUSEKEY also uses it. This means it won't work as a Boot Procotol mouse in some BIOSes, etc. If you really think your keyboard needs to work as a mouse in your BIOS, set MOUSE_SHARED_EP = no in your rules.mk. By default, the core keyboard does not use the shared endpoint, as not all BIOSes are standards compliant and that's one place you don't want to find out your keyboard doesn't work.. If you are really confident, you can set KEYBOARD_SHARED_EP = yes to use the shared endpoint here too. * unify endpoints: ChibiOS protocol implementation * fixup: missing #ifdef EXTRAKEY_ENABLEs broke build on AVR with EXTRAKEY disabled * endpoints: restore error when too many endpoints required * lufa: wait up to 10ms to send keyboard input This avoids packets being dropped when two reports are sent in quick succession (eg. releasing a dual role key). * endpoints: fix compile on ARM_ATSAM * endpoint: ARM_ATSAM fixes No longer use wrong or unexpected endpoint IDs * endpoints: accommodate VUSB protocol V-USB has its own, understandably simple ideas about the report formats. It already blasts the mouse and extrakeys through one endpoint with report IDs. We just stay out of its way. * endpoints: document new endpoint configuration options * endpoints: respect keyboard_report->mods in NKRO The caller(s) of host_keyboard_send expect to be able to just drop modifiers in the mods field and not worry about whether NKRO is in use. This is a good thing. So we just shift it over if needs be. * endpoints: report.c: update for new keyboard_report format
5 years ago
Hid joystick interface (#4226) * add support for hid gamepad interface add documentation for HID joystick Add joystick_task to read analog axes values even when no key is pressed or release. update doc Update docs/feature_joystick.md Manage pin setup and read to maintain matrix scan after analog read * Incorporates patches and changes to HID reporting There are some patches provided by @a-chol incorporated on this commit, and also some changes I made to the HID Report structure. The most interesting is the one dealing with number of buttons: Linux doesn't seem to care, but Windows requires the HID structure to be byte aligned (that's in the spec). So if one declares 8/16/32... buttons they should not have any issues, but this is what happens when you have 9 buttons: ``` bits |0|1|2|3|4|5|6|7| |*|*|*|*|*|*|*|*| axis 0 (report size 8) |*|*|*|*|*|*|*|*| ... |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| axis 6 |*|*|*|*|*|*|*|*| first 8 buttons (report size 1) |*| | | | | | | | last of 9 buttons, not aligned ``` So for that I added a conditonal that will add a number of reports with size 1 to make sure it aligns to the next multiple of 8. Those reports send dummy inputs that don't do anything aside from aligning the data. Tested on Linux, Windows 10 and Street Fighter (where the joystick is recognized as direct-input) * Add save and restore of each pin used in reading joystick (AVR). Allow output pin to be JS_VIRTUAL_AXIS if the axis is connected to Vcc instead of an output pin from the MCU. Fix joystick report id Fix broken v-usb hid joystick interface. Make it more resilient to unusual settings (none multiple of eight button count, 0 buttons or 0 axes) Correct adc reading for multiple axes. Piecewise range conversion for uncentered raw value range. Input, output and ground pin configuration per axis. Documentation fixes * Fix port addressing for joystick analog read * The other required set of changes As per the PR, the changes still holding it up. Add onekey for testing. Fix ARM builds. Fix device descriptor when either axes or buttons is zero. Add compile-time check for at least one axis or button. Move definition to try to fix conflict. PR review comments. qmk cformat * avoid float functions to compute range mapping for axis adc reading * Remove V-USB support for now. Updated docs accordingly. * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Add support for joystick adc reading for stm32 MCUs. Fix joystick hid report sending for chibios * Fix HID joystick report sending for ChibiOS. Add one analog axis to the onekey:joystick keymap. Fix pin state save and restore during joystick analog read for STM32 MCUs. * Update tmk_core/protocol/chibios/usb_main.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Add missing mcuconf.h and halconf.h to onekey:joystick keymap. Add suggested fixes from PR. * Switch saveState and restoreState signature to use pin_t type. onekey:joystick : add a second axis, virtual and programmatically animated. * Update docs/feature_joystick.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Update docs/feature_joystick.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Add PR corrections * Remove halconf.h and mcuconf.h from onekey keymaps * Change ADC_PIN to A0 Co-authored-by: achol <allecooll@hotmail.com> Co-authored-by: José Júnior <jose.junior@gmail.com> Co-authored-by: a-chol <achol@notamail.com> Co-authored-by: Nick Brassel <nick@tzarc.org> Co-authored-by: Ryan <fauxpark@gmail.com>
3 years ago
Hid joystick interface (#4226) * add support for hid gamepad interface add documentation for HID joystick Add joystick_task to read analog axes values even when no key is pressed or release. update doc Update docs/feature_joystick.md Manage pin setup and read to maintain matrix scan after analog read * Incorporates patches and changes to HID reporting There are some patches provided by @a-chol incorporated on this commit, and also some changes I made to the HID Report structure. The most interesting is the one dealing with number of buttons: Linux doesn't seem to care, but Windows requires the HID structure to be byte aligned (that's in the spec). So if one declares 8/16/32... buttons they should not have any issues, but this is what happens when you have 9 buttons: ``` bits |0|1|2|3|4|5|6|7| |*|*|*|*|*|*|*|*| axis 0 (report size 8) |*|*|*|*|*|*|*|*| ... |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| axis 6 |*|*|*|*|*|*|*|*| first 8 buttons (report size 1) |*| | | | | | | | last of 9 buttons, not aligned ``` So for that I added a conditonal that will add a number of reports with size 1 to make sure it aligns to the next multiple of 8. Those reports send dummy inputs that don't do anything aside from aligning the data. Tested on Linux, Windows 10 and Street Fighter (where the joystick is recognized as direct-input) * Add save and restore of each pin used in reading joystick (AVR). Allow output pin to be JS_VIRTUAL_AXIS if the axis is connected to Vcc instead of an output pin from the MCU. Fix joystick report id Fix broken v-usb hid joystick interface. Make it more resilient to unusual settings (none multiple of eight button count, 0 buttons or 0 axes) Correct adc reading for multiple axes. Piecewise range conversion for uncentered raw value range. Input, output and ground pin configuration per axis. Documentation fixes * Fix port addressing for joystick analog read * The other required set of changes As per the PR, the changes still holding it up. Add onekey for testing. Fix ARM builds. Fix device descriptor when either axes or buttons is zero. Add compile-time check for at least one axis or button. Move definition to try to fix conflict. PR review comments. qmk cformat * avoid float functions to compute range mapping for axis adc reading * Remove V-USB support for now. Updated docs accordingly. * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Add support for joystick adc reading for stm32 MCUs. Fix joystick hid report sending for chibios * Fix HID joystick report sending for ChibiOS. Add one analog axis to the onekey:joystick keymap. Fix pin state save and restore during joystick analog read for STM32 MCUs. * Update tmk_core/protocol/chibios/usb_main.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Add missing mcuconf.h and halconf.h to onekey:joystick keymap. Add suggested fixes from PR. * Switch saveState and restoreState signature to use pin_t type. onekey:joystick : add a second axis, virtual and programmatically animated. * Update docs/feature_joystick.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Update docs/feature_joystick.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Add PR corrections * Remove halconf.h and mcuconf.h from onekey keymaps * Change ADC_PIN to A0 Co-authored-by: achol <allecooll@hotmail.com> Co-authored-by: José Júnior <jose.junior@gmail.com> Co-authored-by: a-chol <achol@notamail.com> Co-authored-by: Nick Brassel <nick@tzarc.org> Co-authored-by: Ryan <fauxpark@gmail.com>
3 years ago
  1. /*
  2. * Copyright 2012 Jun Wako <wakojun@gmail.com>
  3. * This file is based on:
  4. * LUFA-120219/Demos/Device/Lowlevel/KeyboardMouse
  5. * LUFA-120219/Demos/Device/Lowlevel/GenericHID
  6. */
  7. /*
  8. LUFA Library
  9. Copyright (C) Dean Camera, 2012.
  10. dean [at] fourwalledcubicle [dot] com
  11. www.lufa-lib.org
  12. */
  13. /*
  14. Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
  15. Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
  16. Permission to use, copy, modify, distribute, and sell this
  17. software and its documentation for any purpose is hereby granted
  18. without fee, provided that the above copyright notice appear in
  19. all copies and that both that the copyright notice and this
  20. permission notice and warranty disclaimer appear in supporting
  21. documentation, and that the name of the author not be used in
  22. advertising or publicity pertaining to distribution of the
  23. software without specific, written prior permission.
  24. The author disclaim all warranties with regard to this
  25. software, including all implied warranties of merchantability
  26. and fitness. In no event shall the author be liable for any
  27. special, indirect or consequential damages or any damages
  28. whatsoever resulting from loss of use, data or profits, whether
  29. in an action of contract, negligence or other tortious action,
  30. arising out of or in connection with the use or performance of
  31. this software.
  32. */
  33. #include "util.h"
  34. #include "report.h"
  35. #include "usb_descriptor.h"
  36. #include "usb_descriptor_common.h"
  37. #ifdef JOYSTICK_ENABLE
  38. # include "joystick.h"
  39. #endif
  40. // clang-format off
  41. /*
  42. * HID report descriptors
  43. */
  44. #ifdef KEYBOARD_SHARED_EP
  45. const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
  46. # define SHARED_REPORT_STARTED
  47. #else
  48. const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = {
  49. #endif
  50. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  51. HID_RI_USAGE(8, 0x06), // Keyboard
  52. HID_RI_COLLECTION(8, 0x01), // Application
  53. #ifdef KEYBOARD_SHARED_EP
  54. HID_RI_REPORT_ID(8, REPORT_ID_KEYBOARD),
  55. #endif
  56. // Modifiers (8 bits)
  57. HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad
  58. HID_RI_USAGE_MINIMUM(8, 0xE0), // Keyboard Left Control
  59. HID_RI_USAGE_MAXIMUM(8, 0xE7), // Keyboard Right GUI
  60. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  61. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  62. HID_RI_REPORT_COUNT(8, 0x08),
  63. HID_RI_REPORT_SIZE(8, 0x01),
  64. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  65. // Reserved (1 byte)
  66. HID_RI_REPORT_COUNT(8, 0x01),
  67. HID_RI_REPORT_SIZE(8, 0x08),
  68. HID_RI_INPUT(8, HID_IOF_CONSTANT),
  69. // Keycodes (6 bytes)
  70. HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad
  71. HID_RI_USAGE_MINIMUM(8, 0x00),
  72. HID_RI_USAGE_MAXIMUM(8, 0xFF),
  73. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  74. HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
  75. HID_RI_REPORT_COUNT(8, 0x06),
  76. HID_RI_REPORT_SIZE(8, 0x08),
  77. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
  78. // Status LEDs (5 bits)
  79. HID_RI_USAGE_PAGE(8, 0x08), // LED
  80. HID_RI_USAGE_MINIMUM(8, 0x01), // Num Lock
  81. HID_RI_USAGE_MAXIMUM(8, 0x05), // Kana
  82. HID_RI_REPORT_COUNT(8, 0x05),
  83. HID_RI_REPORT_SIZE(8, 0x01),
  84. HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
  85. // LED padding (3 bits)
  86. HID_RI_REPORT_COUNT(8, 0x01),
  87. HID_RI_REPORT_SIZE(8, 0x03),
  88. HID_RI_OUTPUT(8, HID_IOF_CONSTANT),
  89. HID_RI_END_COLLECTION(0),
  90. #ifndef KEYBOARD_SHARED_EP
  91. };
  92. #endif
  93. #ifdef MOUSE_ENABLE
  94. # ifndef MOUSE_SHARED_EP
  95. const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = {
  96. # elif !defined(SHARED_REPORT_STARTED)
  97. const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
  98. # define SHARED_REPORT_STARTED
  99. # endif
  100. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  101. HID_RI_USAGE(8, 0x02), // Mouse
  102. HID_RI_COLLECTION(8, 0x01), // Application
  103. # ifdef MOUSE_SHARED_EP
  104. HID_RI_REPORT_ID(8, REPORT_ID_MOUSE),
  105. # endif
  106. HID_RI_USAGE(8, 0x01), // Pointer
  107. HID_RI_COLLECTION(8, 0x00), // Physical
  108. // Buttons (8 bits)
  109. HID_RI_USAGE_PAGE(8, 0x09), // Button
  110. HID_RI_USAGE_MINIMUM(8, 0x01), // Button 1
  111. HID_RI_USAGE_MAXIMUM(8, 0x08), // Button 8
  112. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  113. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  114. HID_RI_REPORT_COUNT(8, 0x08),
  115. HID_RI_REPORT_SIZE(8, 0x01),
  116. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  117. // X/Y position (2 bytes)
  118. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  119. HID_RI_USAGE(8, 0x30), // X
  120. HID_RI_USAGE(8, 0x31), // Y
  121. HID_RI_LOGICAL_MINIMUM(8, -127),
  122. HID_RI_LOGICAL_MAXIMUM(8, 127),
  123. HID_RI_REPORT_COUNT(8, 0x02),
  124. HID_RI_REPORT_SIZE(8, 0x08),
  125. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
  126. // Vertical wheel (1 byte)
  127. HID_RI_USAGE(8, 0x38), // Wheel
  128. HID_RI_LOGICAL_MINIMUM(8, -127),
  129. HID_RI_LOGICAL_MAXIMUM(8, 127),
  130. HID_RI_REPORT_COUNT(8, 0x01),
  131. HID_RI_REPORT_SIZE(8, 0x08),
  132. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
  133. // Horizontal wheel (1 byte)
  134. HID_RI_USAGE_PAGE(8, 0x0C), // Consumer
  135. HID_RI_USAGE(16, 0x0238), // AC Pan
  136. HID_RI_LOGICAL_MINIMUM(8, -127),
  137. HID_RI_LOGICAL_MAXIMUM(8, 127),
  138. HID_RI_REPORT_COUNT(8, 0x01),
  139. HID_RI_REPORT_SIZE(8, 0x08),
  140. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
  141. HID_RI_END_COLLECTION(0),
  142. HID_RI_END_COLLECTION(0),
  143. # ifndef MOUSE_SHARED_EP
  144. };
  145. # endif
  146. #endif
  147. #ifdef DIGITIZER_ENABLE
  148. # ifndef DIGITIZER_SHARED_EP
  149. const USB_Descriptor_HIDReport_Datatype_t PROGMEM DigitizerReport[] = {
  150. # elif !defined(SHARED_REPORT_STARTED)
  151. const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
  152. # define SHARED_REPORT_STARTED
  153. # endif
  154. HID_RI_USAGE_PAGE(8, 0x0D), // Digitizers
  155. HID_RI_USAGE(8, 0x01), // Digitizer
  156. HID_RI_COLLECTION(8, 0x01), // Application
  157. # ifdef DIGITIZER_SHARED_EP
  158. HID_RI_REPORT_ID(8, REPORT_ID_DIGITIZER),
  159. # endif
  160. HID_RI_USAGE(8, 0x20), // Stylus
  161. HID_RI_COLLECTION(8, 0x00), // Physical
  162. // Tip Switch (1 bit)
  163. HID_RI_USAGE(8, 0x42), // Tip Switch
  164. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  165. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  166. HID_RI_REPORT_SIZE(8, 0x01),
  167. HID_RI_REPORT_COUNT(8, 0x01),
  168. HID_RI_INPUT(8, HID_IOF_VARIABLE),
  169. // In Range (1 bit)
  170. HID_RI_USAGE(8, 0x32), // In Range
  171. HID_RI_INPUT(8, HID_IOF_VARIABLE),
  172. // Padding (6 bits)
  173. HID_RI_REPORT_COUNT(8, 0x06),
  174. HID_RI_INPUT(8, HID_IOF_CONSTANT | HID_IOF_VARIABLE),
  175. // X/Y Position (4 bytes)
  176. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  177. HID_RI_LOGICAL_MAXIMUM(16, 0x7FFF),
  178. HID_RI_REPORT_SIZE(8, 0x10),
  179. HID_RI_REPORT_COUNT(8, 0x01),
  180. HID_RI_UNIT(8, 0x33), // Inch, English Linear
  181. HID_RI_UNIT_EXPONENT(8, 0x0E), // -2
  182. HID_RI_USAGE(8, 0x30), // X
  183. HID_RI_INPUT(8, HID_IOF_VARIABLE),
  184. HID_RI_USAGE(8, 0x31), // Y
  185. HID_RI_INPUT(8, HID_IOF_VARIABLE),
  186. HID_RI_END_COLLECTION(0),
  187. HID_RI_END_COLLECTION(0),
  188. # ifndef DIGITIZER_SHARED_EP
  189. };
  190. # endif
  191. #endif
  192. #if defined(SHARED_EP_ENABLE) && !defined(SHARED_REPORT_STARTED)
  193. const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
  194. #endif
  195. #ifdef EXTRAKEY_ENABLE
  196. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  197. HID_RI_USAGE(8, 0x80), // System Control
  198. HID_RI_COLLECTION(8, 0x01), // Application
  199. HID_RI_REPORT_ID(8, REPORT_ID_SYSTEM),
  200. HID_RI_USAGE_MINIMUM(8, 0x01), // Pointer
  201. HID_RI_USAGE_MAXIMUM(16, 0x00B7), // System Display LCD Autoscale
  202. HID_RI_LOGICAL_MINIMUM(8, 0x01),
  203. HID_RI_LOGICAL_MAXIMUM(16, 0x00B7),
  204. HID_RI_REPORT_COUNT(8, 1),
  205. HID_RI_REPORT_SIZE(8, 16),
  206. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
  207. HID_RI_END_COLLECTION(0),
  208. HID_RI_USAGE_PAGE(8, 0x0C), // Consumer
  209. HID_RI_USAGE(8, 0x01), // Consumer Control
  210. HID_RI_COLLECTION(8, 0x01), // Application
  211. HID_RI_REPORT_ID(8, REPORT_ID_CONSUMER),
  212. HID_RI_USAGE_MINIMUM(8, 0x01), // Consumer Control
  213. HID_RI_USAGE_MAXIMUM(16, 0x02A0), // AC Desktop Show All Applications
  214. HID_RI_LOGICAL_MINIMUM(8, 0x01),
  215. HID_RI_LOGICAL_MAXIMUM(16, 0x02A0),
  216. HID_RI_REPORT_COUNT(8, 1),
  217. HID_RI_REPORT_SIZE(8, 16),
  218. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
  219. HID_RI_END_COLLECTION(0),
  220. #endif
  221. #ifdef NKRO_ENABLE
  222. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  223. HID_RI_USAGE(8, 0x06), // Keyboard
  224. HID_RI_COLLECTION(8, 0x01), // Application
  225. HID_RI_REPORT_ID(8, REPORT_ID_NKRO),
  226. // Modifiers (8 bits)
  227. HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad
  228. HID_RI_USAGE_MINIMUM(8, 0xE0), // Keyboard Left Control
  229. HID_RI_USAGE_MAXIMUM(8, 0xE7), // Keyboard Right GUI
  230. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  231. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  232. HID_RI_REPORT_COUNT(8, 0x08),
  233. HID_RI_REPORT_SIZE(8, 0x01),
  234. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  235. // Keycodes
  236. HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad
  237. HID_RI_USAGE_MINIMUM(8, 0x00),
  238. HID_RI_USAGE_MAXIMUM(8, KEYBOARD_REPORT_BITS * 8 - 1),
  239. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  240. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  241. HID_RI_REPORT_COUNT(8, KEYBOARD_REPORT_BITS * 8),
  242. HID_RI_REPORT_SIZE(8, 0x01),
  243. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  244. // Status LEDs (5 bits)
  245. HID_RI_USAGE_PAGE(8, 0x08), // LED
  246. HID_RI_USAGE_MINIMUM(8, 0x01), // Num Lock
  247. HID_RI_USAGE_MAXIMUM(8, 0x05), // Kana
  248. HID_RI_REPORT_COUNT(8, 0x05),
  249. HID_RI_REPORT_SIZE(8, 0x01),
  250. HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
  251. // LED padding (3 bits)
  252. HID_RI_REPORT_COUNT(8, 0x01),
  253. HID_RI_REPORT_SIZE(8, 0x03),
  254. HID_RI_OUTPUT(8, HID_IOF_CONSTANT),
  255. HID_RI_END_COLLECTION(0),
  256. #endif
  257. #ifdef SHARED_EP_ENABLE
  258. };
  259. #endif
  260. #ifdef RAW_ENABLE
  261. const USB_Descriptor_HIDReport_Datatype_t PROGMEM RawReport[] = {
  262. HID_RI_USAGE_PAGE(16, RAW_USAGE_PAGE), // Vendor Defined
  263. HID_RI_USAGE(8, RAW_USAGE_ID), // Vendor Defined
  264. HID_RI_COLLECTION(8, 0x01), // Application
  265. // Data to host
  266. HID_RI_USAGE(8, 0x62), // Vendor Defined
  267. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  268. HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
  269. HID_RI_REPORT_COUNT(8, RAW_EPSIZE),
  270. HID_RI_REPORT_SIZE(8, 0x08),
  271. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  272. // Data from host
  273. HID_RI_USAGE(8, 0x63), // Vendor Defined
  274. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  275. HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
  276. HID_RI_REPORT_COUNT(8, RAW_EPSIZE),
  277. HID_RI_REPORT_SIZE(8, 0x08),
  278. HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
  279. HID_RI_END_COLLECTION(0),
  280. };
  281. #endif
  282. #ifdef CONSOLE_ENABLE
  283. const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = {
  284. HID_RI_USAGE_PAGE(16, 0xFF31), // Vendor Defined (PJRC Teensy compatible)
  285. HID_RI_USAGE(8, 0x74), // Vendor Defined (PJRC Teensy compatible)
  286. HID_RI_COLLECTION(8, 0x01), // Application
  287. // Data to host
  288. HID_RI_USAGE(8, 0x75), // Vendor Defined
  289. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  290. HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
  291. HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE),
  292. HID_RI_REPORT_SIZE(8, 0x08),
  293. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  294. // Data from host
  295. HID_RI_USAGE(8, 0x76), // Vendor Defined
  296. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  297. HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
  298. HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE),
  299. HID_RI_REPORT_SIZE(8, 0x08),
  300. HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
  301. HID_RI_END_COLLECTION(0),
  302. };
  303. #endif
  304. #ifdef JOYSTICK_ENABLE
  305. # if JOYSTICK_AXES_COUNT == 0 && JOYSTICK_BUTTON_COUNT == 0
  306. # error Need at least one axis or button for joystick
  307. # endif
  308. const USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] = {
  309. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  310. HID_RI_USAGE(8, 0x04), // Joystick
  311. HID_RI_COLLECTION(8, 0x01), // Application
  312. HID_RI_COLLECTION(8, 0x00), // Physical
  313. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  314. # if JOYSTICK_AXES_COUNT >= 1
  315. HID_RI_USAGE(8, 0x30), // X
  316. # endif
  317. # if JOYSTICK_AXES_COUNT >= 2
  318. HID_RI_USAGE(8, 0x31), // Y
  319. # endif
  320. # if JOYSTICK_AXES_COUNT >= 3
  321. HID_RI_USAGE(8, 0x32), // Z
  322. # endif
  323. # if JOYSTICK_AXES_COUNT >= 4
  324. HID_RI_USAGE(8, 0x33), // Rx
  325. # endif
  326. # if JOYSTICK_AXES_COUNT >= 5
  327. HID_RI_USAGE(8, 0x34), // Ry
  328. # endif
  329. # if JOYSTICK_AXES_COUNT >= 6
  330. HID_RI_USAGE(8, 0x35), // Rz
  331. # endif
  332. # if JOYSTICK_AXES_COUNT >= 1
  333. # if JOYSTICK_AXES_RESOLUTION == 8
  334. HID_RI_LOGICAL_MINIMUM(8, -JOYSTICK_RESOLUTION),
  335. HID_RI_LOGICAL_MAXIMUM(8, JOYSTICK_RESOLUTION),
  336. HID_RI_REPORT_COUNT(8, JOYSTICK_AXES_COUNT),
  337. HID_RI_REPORT_SIZE(8, 0x08),
  338. # else
  339. HID_RI_LOGICAL_MINIMUM(16, -JOYSTICK_RESOLUTION),
  340. HID_RI_LOGICAL_MAXIMUM(16, JOYSTICK_RESOLUTION),
  341. HID_RI_REPORT_COUNT(8, JOYSTICK_AXES_COUNT),
  342. HID_RI_REPORT_SIZE(8, 0x10),
  343. # endif
  344. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  345. # endif
  346. # if JOYSTICK_BUTTON_COUNT >= 1
  347. HID_RI_USAGE_PAGE(8, 0x09), // Button
  348. HID_RI_USAGE_MINIMUM(8, 0x01),
  349. HID_RI_USAGE_MAXIMUM(8, JOYSTICK_BUTTON_COUNT),
  350. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  351. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  352. HID_RI_REPORT_COUNT(8, JOYSTICK_BUTTON_COUNT),
  353. HID_RI_REPORT_SIZE(8, 0x01),
  354. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  355. # if (JOYSTICK_BUTTON_COUNT % 8) != 0
  356. HID_RI_REPORT_COUNT(8, 8 - (JOYSTICK_BUTTON_COUNT % 8)),
  357. HID_RI_REPORT_SIZE(8, 0x01),
  358. HID_RI_INPUT(8, HID_IOF_CONSTANT),
  359. # endif
  360. # endif
  361. HID_RI_END_COLLECTION(0),
  362. HID_RI_END_COLLECTION(0)
  363. };
  364. #endif
  365. /*
  366. * Device descriptor
  367. */
  368. const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = {
  369. .Header = {
  370. .Size = sizeof(USB_Descriptor_Device_t),
  371. .Type = DTYPE_Device
  372. },
  373. .USBSpecification = VERSION_BCD(2, 0, 0),
  374. #if VIRTSER_ENABLE
  375. .Class = USB_CSCP_IADDeviceClass,
  376. .SubClass = USB_CSCP_IADDeviceSubclass,
  377. .Protocol = USB_CSCP_IADDeviceProtocol,
  378. #else
  379. .Class = USB_CSCP_NoDeviceClass,
  380. .SubClass = USB_CSCP_NoDeviceSubclass,
  381. .Protocol = USB_CSCP_NoDeviceProtocol,
  382. #endif
  383. .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
  384. // Specified in config.h
  385. .VendorID = VENDOR_ID,
  386. .ProductID = PRODUCT_ID,
  387. .ReleaseNumber = DEVICE_VER,
  388. .ManufacturerStrIndex = 0x01,
  389. .ProductStrIndex = 0x02,
  390. #if defined(SERIAL_NUMBER)
  391. .SerialNumStrIndex = 0x03,
  392. #else
  393. .SerialNumStrIndex = 0x00,
  394. #endif
  395. .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
  396. };
  397. #ifndef USB_MAX_POWER_CONSUMPTION
  398. # define USB_MAX_POWER_CONSUMPTION 500
  399. #endif
  400. #ifndef USB_POLLING_INTERVAL_MS
  401. # define USB_POLLING_INTERVAL_MS 10
  402. #endif
  403. /*
  404. * Configuration descriptors
  405. */
  406. const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = {
  407. .Config = {
  408. .Header = {
  409. .Size = sizeof(USB_Descriptor_Configuration_Header_t),
  410. .Type = DTYPE_Configuration
  411. },
  412. .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
  413. .TotalInterfaces = TOTAL_INTERFACES,
  414. .ConfigurationNumber = 1,
  415. .ConfigurationStrIndex = NO_DESCRIPTOR,
  416. .ConfigAttributes = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_REMOTEWAKEUP),
  417. .MaxPowerConsumption = USB_CONFIG_POWER_MA(USB_MAX_POWER_CONSUMPTION)
  418. },
  419. #ifndef KEYBOARD_SHARED_EP
  420. /*
  421. * Keyboard
  422. */
  423. .Keyboard_Interface = {
  424. .Header = {
  425. .Size = sizeof(USB_Descriptor_Interface_t),
  426. .Type = DTYPE_Interface
  427. },
  428. .InterfaceNumber = KEYBOARD_INTERFACE,
  429. .AlternateSetting = 0x00,
  430. .TotalEndpoints = 1,
  431. .Class = HID_CSCP_HIDClass,
  432. .SubClass = HID_CSCP_BootSubclass,
  433. .Protocol = HID_CSCP_KeyboardBootProtocol,
  434. .InterfaceStrIndex = NO_DESCRIPTOR
  435. },
  436. .Keyboard_HID = {
  437. .Header = {
  438. .Size = sizeof(USB_HID_Descriptor_HID_t),
  439. .Type = HID_DTYPE_HID
  440. },
  441. .HIDSpec = VERSION_BCD(1, 1, 1),
  442. .CountryCode = 0x00,
  443. .TotalReportDescriptors = 1,
  444. .HIDReportType = HID_DTYPE_Report,
  445. .HIDReportLength = sizeof(KeyboardReport)
  446. },
  447. .Keyboard_INEndpoint = {
  448. .Header = {
  449. .Size = sizeof(USB_Descriptor_Endpoint_t),
  450. .Type = DTYPE_Endpoint
  451. },
  452. .EndpointAddress = (ENDPOINT_DIR_IN | KEYBOARD_IN_EPNUM),
  453. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  454. .EndpointSize = KEYBOARD_EPSIZE,
  455. .PollingIntervalMS = USB_POLLING_INTERVAL_MS
  456. },
  457. #endif
  458. #ifdef RAW_ENABLE
  459. /*
  460. * Raw HID
  461. */
  462. .Raw_Interface = {
  463. .Header = {
  464. .Size = sizeof(USB_Descriptor_Interface_t),
  465. .Type = DTYPE_Interface
  466. },
  467. .InterfaceNumber = RAW_INTERFACE,
  468. .AlternateSetting = 0x00,
  469. .TotalEndpoints = 2,
  470. .Class = HID_CSCP_HIDClass,
  471. .SubClass = HID_CSCP_NonBootSubclass,
  472. .Protocol = HID_CSCP_NonBootProtocol,
  473. .InterfaceStrIndex = NO_DESCRIPTOR
  474. },
  475. .Raw_HID = {
  476. .Header = {
  477. .Size = sizeof(USB_HID_Descriptor_HID_t),
  478. .Type = HID_DTYPE_HID
  479. },
  480. .HIDSpec = VERSION_BCD(1, 1, 1),
  481. .CountryCode = 0x00,
  482. .TotalReportDescriptors = 1,
  483. .HIDReportType = HID_DTYPE_Report,
  484. .HIDReportLength = sizeof(RawReport)
  485. },
  486. .Raw_INEndpoint = {
  487. .Header = {
  488. .Size = sizeof(USB_Descriptor_Endpoint_t),
  489. .Type = DTYPE_Endpoint
  490. },
  491. .EndpointAddress = (ENDPOINT_DIR_IN | RAW_IN_EPNUM),
  492. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  493. .EndpointSize = RAW_EPSIZE,
  494. .PollingIntervalMS = 0x01
  495. },
  496. .Raw_OUTEndpoint = {
  497. .Header = {
  498. .Size = sizeof(USB_Descriptor_Endpoint_t),
  499. .Type = DTYPE_Endpoint
  500. },
  501. .EndpointAddress = (ENDPOINT_DIR_OUT | RAW_OUT_EPNUM),
  502. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  503. .EndpointSize = RAW_EPSIZE,
  504. .PollingIntervalMS = 0x01
  505. },
  506. #endif
  507. #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP)
  508. /*
  509. * Mouse
  510. */
  511. .Mouse_Interface = {
  512. .Header = {
  513. .Size = sizeof(USB_Descriptor_Interface_t),
  514. .Type = DTYPE_Interface
  515. },
  516. .InterfaceNumber = MOUSE_INTERFACE,
  517. .AlternateSetting = 0x00,
  518. .TotalEndpoints = 1,
  519. .Class = HID_CSCP_HIDClass,
  520. .SubClass = HID_CSCP_BootSubclass,
  521. .Protocol = HID_CSCP_MouseBootProtocol,
  522. .InterfaceStrIndex = NO_DESCRIPTOR
  523. },
  524. .Mouse_HID = {
  525. .Header = {
  526. .Size = sizeof(USB_HID_Descriptor_HID_t),
  527. .Type = HID_DTYPE_HID
  528. },
  529. .HIDSpec = VERSION_BCD(1, 1, 1),
  530. .CountryCode = 0x00,
  531. .TotalReportDescriptors = 1,
  532. .HIDReportType = HID_DTYPE_Report,
  533. .HIDReportLength = sizeof(MouseReport)
  534. },
  535. .Mouse_INEndpoint = {
  536. .Header = {
  537. .Size = sizeof(USB_Descriptor_Endpoint_t),
  538. .Type = DTYPE_Endpoint
  539. },
  540. .EndpointAddress = (ENDPOINT_DIR_IN | MOUSE_IN_EPNUM),
  541. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  542. .EndpointSize = MOUSE_EPSIZE,
  543. .PollingIntervalMS = USB_POLLING_INTERVAL_MS
  544. },
  545. #endif
  546. #ifdef SHARED_EP_ENABLE
  547. /*
  548. * Shared
  549. */
  550. .Shared_Interface = {
  551. .Header = {
  552. .Size = sizeof(USB_Descriptor_Interface_t),
  553. .Type = DTYPE_Interface
  554. },
  555. .InterfaceNumber = SHARED_INTERFACE,
  556. .AlternateSetting = 0x00,
  557. .TotalEndpoints = 1,
  558. .Class = HID_CSCP_HIDClass,
  559. # ifdef KEYBOARD_SHARED_EP
  560. .SubClass = HID_CSCP_BootSubclass,
  561. .Protocol = HID_CSCP_KeyboardBootProtocol,
  562. # else
  563. .SubClass = HID_CSCP_NonBootSubclass,
  564. .Protocol = HID_CSCP_NonBootProtocol,
  565. # endif
  566. .InterfaceStrIndex = NO_DESCRIPTOR
  567. },
  568. .Shared_HID = {
  569. .Header = {
  570. .Size = sizeof(USB_HID_Descriptor_HID_t),
  571. .Type = HID_DTYPE_HID
  572. },
  573. .HIDSpec = VERSION_BCD(1, 1, 1),
  574. .CountryCode = 0x00,
  575. .TotalReportDescriptors = 1,
  576. .HIDReportType = HID_DTYPE_Report,
  577. .HIDReportLength = sizeof(SharedReport)
  578. },
  579. .Shared_INEndpoint = {
  580. .Header = {
  581. .Size = sizeof(USB_Descriptor_Endpoint_t),
  582. .Type = DTYPE_Endpoint
  583. },
  584. .EndpointAddress = (ENDPOINT_DIR_IN | SHARED_IN_EPNUM),
  585. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  586. .EndpointSize = SHARED_EPSIZE,
  587. .PollingIntervalMS = USB_POLLING_INTERVAL_MS
  588. },
  589. #endif
  590. #ifdef CONSOLE_ENABLE
  591. /*
  592. * Console
  593. */
  594. .Console_Interface = {
  595. .Header = {
  596. .Size = sizeof(USB_Descriptor_Interface_t),
  597. .Type = DTYPE_Interface
  598. },
  599. .InterfaceNumber = CONSOLE_INTERFACE,
  600. .AlternateSetting = 0x00,
  601. .TotalEndpoints = 2,
  602. .Class = HID_CSCP_HIDClass,
  603. .SubClass = HID_CSCP_NonBootSubclass,
  604. .Protocol = HID_CSCP_NonBootProtocol,
  605. .InterfaceStrIndex = NO_DESCRIPTOR
  606. },
  607. .Console_HID = {
  608. .Header = {
  609. .Size = sizeof(USB_HID_Descriptor_HID_t),
  610. .Type = HID_DTYPE_HID
  611. },
  612. .HIDSpec = VERSION_BCD(1, 1, 1),
  613. .CountryCode = 0x00,
  614. .TotalReportDescriptors = 1,
  615. .HIDReportType = HID_DTYPE_Report,
  616. .HIDReportLength = sizeof(ConsoleReport)
  617. },
  618. .Console_INEndpoint = {
  619. .Header = {
  620. .Size = sizeof(USB_Descriptor_Endpoint_t),
  621. .Type = DTYPE_Endpoint
  622. },
  623. .EndpointAddress = (ENDPOINT_DIR_IN | CONSOLE_IN_EPNUM),
  624. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  625. .EndpointSize = CONSOLE_EPSIZE,
  626. .PollingIntervalMS = 0x01
  627. },
  628. .Console_OUTEndpoint = {
  629. .Header = {
  630. .Size = sizeof(USB_Descriptor_Endpoint_t),
  631. .Type = DTYPE_Endpoint
  632. },
  633. .EndpointAddress = (ENDPOINT_DIR_OUT | CONSOLE_OUT_EPNUM),
  634. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  635. .EndpointSize = CONSOLE_EPSIZE,
  636. .PollingIntervalMS = 0x01
  637. },
  638. #endif
  639. #ifdef MIDI_ENABLE
  640. /*
  641. * MIDI
  642. */
  643. .Audio_Interface_Association = {
  644. .Header = {
  645. .Size = sizeof(USB_Descriptor_Interface_Association_t),
  646. .Type = DTYPE_InterfaceAssociation
  647. },
  648. .FirstInterfaceIndex = AC_INTERFACE,
  649. .TotalInterfaces = 2,
  650. .Class = AUDIO_CSCP_AudioClass,
  651. .SubClass = AUDIO_CSCP_ControlSubclass,
  652. .Protocol = AUDIO_CSCP_ControlProtocol,
  653. .IADStrIndex = NO_DESCRIPTOR,
  654. },
  655. .Audio_ControlInterface = {
  656. .Header = {
  657. .Size = sizeof(USB_Descriptor_Interface_t),
  658. .Type = DTYPE_Interface
  659. },
  660. .InterfaceNumber = AC_INTERFACE,
  661. .AlternateSetting = 0,
  662. .TotalEndpoints = 0,
  663. .Class = AUDIO_CSCP_AudioClass,
  664. .SubClass = AUDIO_CSCP_ControlSubclass,
  665. .Protocol = AUDIO_CSCP_ControlProtocol,
  666. .InterfaceStrIndex = NO_DESCRIPTOR
  667. },
  668. .Audio_ControlInterface_SPC = {
  669. .Header = {
  670. .Size = sizeof(USB_Audio_Descriptor_Interface_AC_t),
  671. .Type = AUDIO_DTYPE_CSInterface
  672. },
  673. .Subtype = AUDIO_DSUBTYPE_CSInterface_Header,
  674. .ACSpecification = VERSION_BCD(1, 0, 0),
  675. .TotalLength = sizeof(USB_Audio_Descriptor_Interface_AC_t),
  676. .InCollection = 1,
  677. .InterfaceNumber = AS_INTERFACE,
  678. },
  679. .Audio_StreamInterface = {
  680. .Header = {
  681. .Size = sizeof(USB_Descriptor_Interface_t),
  682. .Type = DTYPE_Interface
  683. },
  684. .InterfaceNumber = AS_INTERFACE,
  685. .AlternateSetting = 0,
  686. .TotalEndpoints = 2,
  687. .Class = AUDIO_CSCP_AudioClass,
  688. .SubClass = AUDIO_CSCP_MIDIStreamingSubclass,
  689. .Protocol = AUDIO_CSCP_StreamingProtocol,
  690. .InterfaceStrIndex = NO_DESCRIPTOR
  691. },
  692. .Audio_StreamInterface_SPC = {
  693. .Header = {
  694. .Size = sizeof(USB_MIDI_Descriptor_AudioInterface_AS_t),
  695. .Type = AUDIO_DTYPE_CSInterface
  696. },
  697. .Subtype = AUDIO_DSUBTYPE_CSInterface_General,
  698. .AudioSpecification = VERSION_BCD(1, 0, 0),
  699. .TotalLength = offsetof(USB_Descriptor_Configuration_t, MIDI_Out_Jack_Endpoint_SPC) + sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t) - offsetof(USB_Descriptor_Configuration_t, Audio_StreamInterface_SPC)
  700. },
  701. .MIDI_In_Jack_Emb = {
  702. .Header = {
  703. .Size = sizeof(USB_MIDI_Descriptor_InputJack_t),
  704. .Type = AUDIO_DTYPE_CSInterface
  705. },
  706. .Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
  707. .JackType = MIDI_JACKTYPE_Embedded,
  708. .JackID = 0x01,
  709. .JackStrIndex = NO_DESCRIPTOR
  710. },
  711. .MIDI_In_Jack_Ext = {
  712. .Header = {
  713. .Size = sizeof(USB_MIDI_Descriptor_InputJack_t),
  714. .Type = AUDIO_DTYPE_CSInterface
  715. },
  716. .Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
  717. .JackType = MIDI_JACKTYPE_External,
  718. .JackID = 0x02,
  719. .JackStrIndex = NO_DESCRIPTOR
  720. },
  721. .MIDI_Out_Jack_Emb = {
  722. .Header = {
  723. .Size = sizeof(USB_MIDI_Descriptor_OutputJack_t),
  724. .Type = AUDIO_DTYPE_CSInterface
  725. },
  726. .Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
  727. .JackType = MIDI_JACKTYPE_Embedded,
  728. .JackID = 0x03,
  729. .NumberOfPins = 1,
  730. .SourceJackID = {0x02},
  731. .SourcePinID = {0x01},
  732. .JackStrIndex = NO_DESCRIPTOR
  733. },
  734. .MIDI_Out_Jack_Ext = {
  735. .Header = {
  736. .Size = sizeof(USB_MIDI_Descriptor_OutputJack_t),
  737. .Type = AUDIO_DTYPE_CSInterface
  738. },
  739. .Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
  740. .JackType = MIDI_JACKTYPE_External,
  741. .JackID = 0x04,
  742. .NumberOfPins = 1,
  743. .SourceJackID = {0x01},
  744. .SourcePinID = {0x01},
  745. .JackStrIndex = NO_DESCRIPTOR
  746. },
  747. .MIDI_In_Jack_Endpoint = {
  748. .Endpoint = {
  749. .Header = {
  750. .Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t),
  751. .Type = DTYPE_Endpoint
  752. },
  753. .EndpointAddress = (ENDPOINT_DIR_OUT | MIDI_STREAM_OUT_EPNUM),
  754. .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  755. .EndpointSize = MIDI_STREAM_EPSIZE,
  756. .PollingIntervalMS = 0x05
  757. },
  758. .Refresh = 0,
  759. .SyncEndpointNumber = 0
  760. },
  761. .MIDI_In_Jack_Endpoint_SPC = {
  762. .Header = {
  763. .Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t),
  764. .Type = AUDIO_DTYPE_CSEndpoint
  765. },
  766. .Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
  767. .TotalEmbeddedJacks = 0x01,
  768. .AssociatedJackID = {0x01}
  769. },
  770. .MIDI_Out_Jack_Endpoint = {
  771. .Endpoint = {
  772. .Header = {
  773. .Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t),
  774. .Type = DTYPE_Endpoint
  775. },
  776. .EndpointAddress = (ENDPOINT_DIR_IN | MIDI_STREAM_IN_EPNUM),
  777. .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  778. .EndpointSize = MIDI_STREAM_EPSIZE,
  779. .PollingIntervalMS = 0x05
  780. },
  781. .Refresh = 0,
  782. .SyncEndpointNumber = 0
  783. },
  784. .MIDI_Out_Jack_Endpoint_SPC = {
  785. .Header = {
  786. .Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t),
  787. .Type = AUDIO_DTYPE_CSEndpoint
  788. },
  789. .Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
  790. .TotalEmbeddedJacks = 0x01,
  791. .AssociatedJackID = {0x03}
  792. },
  793. #endif
  794. #ifdef VIRTSER_ENABLE
  795. /*
  796. * Virtual Serial
  797. */
  798. .CDC_Interface_Association = {
  799. .Header = {
  800. .Size = sizeof(USB_Descriptor_Interface_Association_t),
  801. .Type = DTYPE_InterfaceAssociation
  802. },
  803. .FirstInterfaceIndex = CCI_INTERFACE,
  804. .TotalInterfaces = 2,
  805. .Class = CDC_CSCP_CDCClass,
  806. .SubClass = CDC_CSCP_ACMSubclass,
  807. .Protocol = CDC_CSCP_ATCommandProtocol,
  808. .IADStrIndex = NO_DESCRIPTOR,
  809. },
  810. .CDC_CCI_Interface = {
  811. .Header = {
  812. .Size = sizeof(USB_Descriptor_Interface_t),
  813. .Type = DTYPE_Interface
  814. },
  815. .InterfaceNumber = CCI_INTERFACE,
  816. .AlternateSetting = 0,
  817. .TotalEndpoints = 1,
  818. .Class = CDC_CSCP_CDCClass,
  819. .SubClass = CDC_CSCP_ACMSubclass,
  820. .Protocol = CDC_CSCP_ATCommandProtocol,
  821. .InterfaceStrIndex = NO_DESCRIPTOR
  822. },
  823. .CDC_Functional_Header = {
  824. .Header = {
  825. .Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t),
  826. .Type = CDC_DTYPE_CSInterface
  827. },
  828. .Subtype = 0x00,
  829. .CDCSpecification = VERSION_BCD(1, 1, 0),
  830. },
  831. .CDC_Functional_ACM = {
  832. .Header = {
  833. .Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t),
  834. .Type = CDC_DTYPE_CSInterface
  835. },
  836. .Subtype = 0x02,
  837. .Capabilities = 0x02,
  838. },
  839. .CDC_Functional_Union = {
  840. .Header = {
  841. .Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t),
  842. .Type = CDC_DTYPE_CSInterface
  843. },
  844. .Subtype = 0x06,
  845. .MasterInterfaceNumber = CCI_INTERFACE,
  846. .SlaveInterfaceNumber = CDI_INTERFACE,
  847. },
  848. .CDC_NotificationEndpoint = {
  849. .Header = {
  850. .Size = sizeof(USB_Descriptor_Endpoint_t),
  851. .Type = DTYPE_Endpoint
  852. },
  853. .EndpointAddress = (ENDPOINT_DIR_IN | CDC_NOTIFICATION_EPNUM),
  854. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  855. .EndpointSize = CDC_NOTIFICATION_EPSIZE,
  856. .PollingIntervalMS = 0xFF
  857. },
  858. .CDC_DCI_Interface = {
  859. .Header = {
  860. .Size = sizeof(USB_Descriptor_Interface_t),
  861. .Type = DTYPE_Interface
  862. },
  863. .InterfaceNumber = CDI_INTERFACE,
  864. .AlternateSetting = 0,
  865. .TotalEndpoints = 2,
  866. .Class = CDC_CSCP_CDCDataClass,
  867. .SubClass = CDC_CSCP_NoDataSubclass,
  868. .Protocol = CDC_CSCP_NoDataProtocol,
  869. .InterfaceStrIndex = NO_DESCRIPTOR
  870. },
  871. .CDC_DataOutEndpoint = {
  872. .Header = {
  873. .Size = sizeof(USB_Descriptor_Endpoint_t),
  874. .Type = DTYPE_Endpoint
  875. },
  876. .EndpointAddress = (ENDPOINT_DIR_OUT | CDC_OUT_EPNUM),
  877. .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  878. .EndpointSize = CDC_EPSIZE,
  879. .PollingIntervalMS = 0x05
  880. },
  881. .CDC_DataInEndpoint = {
  882. .Header = {
  883. .Size = sizeof(USB_Descriptor_Endpoint_t),
  884. .Type = DTYPE_Endpoint
  885. },
  886. .EndpointAddress = (ENDPOINT_DIR_IN | CDC_IN_EPNUM),
  887. .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  888. .EndpointSize = CDC_EPSIZE,
  889. .PollingIntervalMS = 0x05
  890. },
  891. #endif
  892. /*
  893. * Joystick
  894. */
  895. #ifdef JOYSTICK_ENABLE
  896. .Joystick_Interface = {
  897. .Header = {
  898. .Size = sizeof(USB_Descriptor_Interface_t),
  899. .Type = DTYPE_Interface
  900. },
  901. .InterfaceNumber = JOYSTICK_INTERFACE,
  902. .AlternateSetting = 0x00,
  903. .TotalEndpoints = 1,
  904. .Class = HID_CSCP_HIDClass,
  905. .SubClass = HID_CSCP_NonBootSubclass,
  906. .Protocol = HID_CSCP_NonBootProtocol,
  907. .InterfaceStrIndex = NO_DESCRIPTOR
  908. },
  909. .Joystick_HID = {
  910. .Header = {
  911. .Size = sizeof(USB_HID_Descriptor_HID_t),
  912. .Type = HID_DTYPE_HID
  913. },
  914. .HIDSpec = VERSION_BCD(1, 1, 1),
  915. .CountryCode = 0x00,
  916. .TotalReportDescriptors = 1,
  917. .HIDReportType = HID_DTYPE_Report,
  918. .HIDReportLength = sizeof(JoystickReport)
  919. },
  920. .Joystick_INEndpoint = {
  921. .Header = {
  922. .Size = sizeof(USB_Descriptor_Endpoint_t),
  923. .Type = DTYPE_Endpoint
  924. },
  925. .EndpointAddress = (ENDPOINT_DIR_IN | JOYSTICK_IN_EPNUM),
  926. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  927. .EndpointSize = JOYSTICK_EPSIZE,
  928. .PollingIntervalMS = USB_POLLING_INTERVAL_MS
  929. }
  930. #endif
  931. #if defined(DIGITIZER_ENABLE) && !defined(DIGITIZER_SHARED_EP)
  932. /*
  933. * Digitizer
  934. */
  935. .Digitizer_Interface = {
  936. .Header = {
  937. .Size = sizeof(USB_Descriptor_Interface_t),
  938. .Type = DTYPE_Interface
  939. },
  940. .InterfaceNumber = DIGITIZER_INTERFACE,
  941. .AlternateSetting = 0x00,
  942. .TotalEndpoints = 1,
  943. .Class = HID_CSCP_HIDClass,
  944. .SubClass = HID_CSCP_NonBootSubclass,
  945. .Protocol = HID_CSCP_NonBootProtocol,
  946. .InterfaceStrIndex = NO_DESCRIPTOR
  947. },
  948. .Digitizer_HID = {
  949. .Header = {
  950. .Size = sizeof(USB_HID_Descriptor_HID_t),
  951. .Type = HID_DTYPE_HID
  952. },
  953. .HIDSpec = VERSION_BCD(1, 1, 1),
  954. .CountryCode = 0x00,
  955. .TotalReportDescriptors = 1,
  956. .HIDReportType = HID_DTYPE_Report,
  957. .HIDReportLength = sizeof(DigitizerReport)
  958. },
  959. .Digitizer_INEndpoint = {
  960. .Header = {
  961. .Size = sizeof(USB_Descriptor_Endpoint_t),
  962. .Type = DTYPE_Endpoint
  963. },
  964. .EndpointAddress = (ENDPOINT_DIR_IN | DIGITIZER_IN_EPNUM),
  965. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  966. .EndpointSize = DIGITIZER_EPSIZE,
  967. .PollingIntervalMS = USB_POLLING_INTERVAL_MS
  968. },
  969. #endif
  970. };
  971. /*
  972. * String descriptors
  973. */
  974. const USB_Descriptor_String_t PROGMEM LanguageString = {
  975. .Header = {
  976. .Size = USB_STRING_LEN(1),
  977. .Type = DTYPE_String
  978. },
  979. .UnicodeString = {LANGUAGE_ID_ENG}
  980. };
  981. const USB_Descriptor_String_t PROGMEM ManufacturerString = {
  982. .Header = {
  983. .Size = USB_STRING_LEN(sizeof(STR(MANUFACTURER)) - 1), // Subtract 1 for null terminator
  984. .Type = DTYPE_String
  985. },
  986. .UnicodeString = LSTR(MANUFACTURER)
  987. };
  988. const USB_Descriptor_String_t PROGMEM ProductString = {
  989. .Header = {
  990. .Size = USB_STRING_LEN(sizeof(STR(PRODUCT)) - 1), // Subtract 1 for null terminator
  991. .Type = DTYPE_String
  992. },
  993. .UnicodeString = LSTR(PRODUCT)
  994. };
  995. #if defined(SERIAL_NUMBER)
  996. const USB_Descriptor_String_t PROGMEM SerialNumberString = {
  997. .Header = {
  998. .Size = USB_STRING_LEN(sizeof(SERIAL_NUMBER) - 1), // Subtract 1 for null terminator
  999. .Type = DTYPE_String
  1000. },
  1001. .UnicodeString = USBSTR(SERIAL_NUMBER)
  1002. };
  1003. #endif
  1004. // clang-format on
  1005. /**
  1006. * This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
  1007. * documentation) by the application code so that the address and size of a requested descriptor can be given
  1008. * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
  1009. * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
  1010. * USB host.
  1011. */
  1012. uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const void** const DescriptorAddress) {
  1013. const uint8_t DescriptorType = (wValue >> 8);
  1014. const uint8_t DescriptorIndex = (wValue & 0xFF);
  1015. const void* Address = NULL;
  1016. uint16_t Size = NO_DESCRIPTOR;
  1017. switch (DescriptorType) {
  1018. case DTYPE_Device:
  1019. Address = &DeviceDescriptor;
  1020. Size = sizeof(USB_Descriptor_Device_t);
  1021. break;
  1022. case DTYPE_Configuration:
  1023. Address = &ConfigurationDescriptor;
  1024. Size = sizeof(USB_Descriptor_Configuration_t);
  1025. break;
  1026. case DTYPE_String:
  1027. switch (DescriptorIndex) {
  1028. case 0x00:
  1029. Address = &LanguageString;
  1030. Size = pgm_read_byte(&LanguageString.Header.Size);
  1031. break;
  1032. case 0x01:
  1033. Address = &ManufacturerString;
  1034. Size = pgm_read_byte(&ManufacturerString.Header.Size);
  1035. break;
  1036. case 0x02:
  1037. Address = &ProductString;
  1038. Size = pgm_read_byte(&ProductString.Header.Size);
  1039. break;
  1040. #if defined(SERIAL_NUMBER)
  1041. case 0x03:
  1042. Address = &SerialNumberString;
  1043. Size = pgm_read_byte(&SerialNumberString.Header.Size);
  1044. break;
  1045. #endif
  1046. }
  1047. break;
  1048. case HID_DTYPE_HID:
  1049. switch (wIndex) {
  1050. #ifndef KEYBOARD_SHARED_EP
  1051. case KEYBOARD_INTERFACE:
  1052. Address = &ConfigurationDescriptor.Keyboard_HID;
  1053. Size = sizeof(USB_HID_Descriptor_HID_t);
  1054. break;
  1055. #endif
  1056. #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP)
  1057. case MOUSE_INTERFACE:
  1058. Address = &ConfigurationDescriptor.Mouse_HID;
  1059. Size = sizeof(USB_HID_Descriptor_HID_t);
  1060. break;
  1061. #endif
  1062. #ifdef SHARED_EP_ENABLE
  1063. case SHARED_INTERFACE:
  1064. Address = &ConfigurationDescriptor.Shared_HID;
  1065. Size = sizeof(USB_HID_Descriptor_HID_t);
  1066. break;
  1067. #endif
  1068. #ifdef RAW_ENABLE
  1069. case RAW_INTERFACE:
  1070. Address = &ConfigurationDescriptor.Raw_HID;
  1071. Size = sizeof(USB_HID_Descriptor_HID_t);
  1072. break;
  1073. #endif
  1074. #ifdef CONSOLE_ENABLE
  1075. case CONSOLE_INTERFACE:
  1076. Address = &ConfigurationDescriptor.Console_HID;
  1077. Size = sizeof(USB_HID_Descriptor_HID_t);
  1078. break;
  1079. #endif
  1080. #ifdef JOYSTICK_ENABLE
  1081. case JOYSTICK_INTERFACE:
  1082. Address = &ConfigurationDescriptor.Joystick_HID;
  1083. Size = sizeof(USB_HID_Descriptor_HID_t);
  1084. break;
  1085. #endif
  1086. #if defined(DIGITIZER_ENABLE) && !defined(DIGITIZER_SHARED_EP)
  1087. case DIGITIZER_INTERFACE:
  1088. Address = &ConfigurationDescriptor.Digitizer_HID;
  1089. Size = sizeof(USB_HID_Descriptor_HID_t);
  1090. break;
  1091. #endif
  1092. }
  1093. break;
  1094. case HID_DTYPE_Report:
  1095. switch (wIndex) {
  1096. #ifndef KEYBOARD_SHARED_EP
  1097. case KEYBOARD_INTERFACE:
  1098. Address = &KeyboardReport;
  1099. Size = sizeof(KeyboardReport);
  1100. break;
  1101. #endif
  1102. #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP)
  1103. case MOUSE_INTERFACE:
  1104. Address = &MouseReport;
  1105. Size = sizeof(MouseReport);
  1106. break;
  1107. #endif
  1108. #ifdef SHARED_EP_ENABLE
  1109. case SHARED_INTERFACE:
  1110. Address = &SharedReport;
  1111. Size = sizeof(SharedReport);
  1112. break;
  1113. #endif
  1114. #ifdef RAW_ENABLE
  1115. case RAW_INTERFACE:
  1116. Address = &RawReport;
  1117. Size = sizeof(RawReport);
  1118. break;
  1119. #endif
  1120. #ifdef CONSOLE_ENABLE
  1121. case CONSOLE_INTERFACE:
  1122. Address = &ConsoleReport;
  1123. Size = sizeof(ConsoleReport);
  1124. break;
  1125. #endif
  1126. #ifdef JOYSTICK_ENABLE
  1127. case JOYSTICK_INTERFACE:
  1128. Address = &JoystickReport;
  1129. Size = sizeof(JoystickReport);
  1130. break;
  1131. #endif
  1132. #if defined(DIGITIZER_ENABLE) && !defined(DIGITIZER_SHARED_EP)
  1133. case DIGITIZER_INTERFACE:
  1134. Address = &DigitizerReport;
  1135. Size = sizeof(DigitizerReport);
  1136. break;
  1137. #endif
  1138. }
  1139. break;
  1140. }
  1141. *DescriptorAddress = Address;
  1142. return Size;
  1143. }