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.

1247 lines
46 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
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
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. #ifdef OS_DETECTION_ENABLE
  41. # include "os_detection.h"
  42. #endif
  43. // clang-format off
  44. /*
  45. * HID report descriptors
  46. */
  47. #ifdef KEYBOARD_SHARED_EP
  48. const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
  49. # define SHARED_REPORT_STARTED
  50. #else
  51. const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = {
  52. #endif
  53. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  54. HID_RI_USAGE(8, 0x06), // Keyboard
  55. HID_RI_COLLECTION(8, 0x01), // Application
  56. #ifdef KEYBOARD_SHARED_EP
  57. HID_RI_REPORT_ID(8, REPORT_ID_KEYBOARD),
  58. #endif
  59. // Modifiers (8 bits)
  60. HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad
  61. HID_RI_USAGE_MINIMUM(8, 0xE0), // Keyboard Left Control
  62. HID_RI_USAGE_MAXIMUM(8, 0xE7), // Keyboard Right GUI
  63. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  64. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  65. HID_RI_REPORT_COUNT(8, 0x08),
  66. HID_RI_REPORT_SIZE(8, 0x01),
  67. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  68. // Reserved (1 byte)
  69. HID_RI_REPORT_COUNT(8, 0x01),
  70. HID_RI_REPORT_SIZE(8, 0x08),
  71. HID_RI_INPUT(8, HID_IOF_CONSTANT),
  72. // Keycodes (6 bytes)
  73. HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad
  74. HID_RI_USAGE_MINIMUM(8, 0x00),
  75. HID_RI_USAGE_MAXIMUM(8, 0xFF),
  76. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  77. HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
  78. HID_RI_REPORT_COUNT(8, 0x06),
  79. HID_RI_REPORT_SIZE(8, 0x08),
  80. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
  81. // Status LEDs (5 bits)
  82. HID_RI_USAGE_PAGE(8, 0x08), // LED
  83. HID_RI_USAGE_MINIMUM(8, 0x01), // Num Lock
  84. HID_RI_USAGE_MAXIMUM(8, 0x05), // Kana
  85. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  86. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  87. HID_RI_REPORT_COUNT(8, 0x05),
  88. HID_RI_REPORT_SIZE(8, 0x01),
  89. HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
  90. // LED padding (3 bits)
  91. HID_RI_REPORT_COUNT(8, 0x01),
  92. HID_RI_REPORT_SIZE(8, 0x03),
  93. HID_RI_OUTPUT(8, HID_IOF_CONSTANT),
  94. HID_RI_END_COLLECTION(0),
  95. #ifndef KEYBOARD_SHARED_EP
  96. };
  97. #endif
  98. #ifdef MOUSE_ENABLE
  99. # ifndef MOUSE_SHARED_EP
  100. const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = {
  101. # elif !defined(SHARED_REPORT_STARTED)
  102. const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
  103. # define SHARED_REPORT_STARTED
  104. # endif
  105. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  106. HID_RI_USAGE(8, 0x02), // Mouse
  107. HID_RI_COLLECTION(8, 0x01), // Application
  108. # ifdef MOUSE_SHARED_EP
  109. HID_RI_REPORT_ID(8, REPORT_ID_MOUSE),
  110. # endif
  111. HID_RI_USAGE(8, 0x01), // Pointer
  112. HID_RI_COLLECTION(8, 0x00), // Physical
  113. // Buttons (8 bits)
  114. HID_RI_USAGE_PAGE(8, 0x09), // Button
  115. HID_RI_USAGE_MINIMUM(8, 0x01), // Button 1
  116. HID_RI_USAGE_MAXIMUM(8, 0x08), // Button 8
  117. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  118. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  119. HID_RI_REPORT_COUNT(8, 0x08),
  120. HID_RI_REPORT_SIZE(8, 0x01),
  121. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  122. # ifdef MOUSE_EXTENDED_REPORT
  123. // Boot protocol XY ignored in Report protocol
  124. HID_RI_REPORT_COUNT(8, 0x02),
  125. HID_RI_REPORT_SIZE(8, 0x08),
  126. HID_RI_INPUT(8, HID_IOF_CONSTANT),
  127. # endif
  128. // X/Y position (2 or 4 bytes)
  129. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  130. HID_RI_USAGE(8, 0x30), // X
  131. HID_RI_USAGE(8, 0x31), // Y
  132. # ifndef MOUSE_EXTENDED_REPORT
  133. HID_RI_LOGICAL_MINIMUM(8, -127),
  134. HID_RI_LOGICAL_MAXIMUM(8, 127),
  135. HID_RI_REPORT_COUNT(8, 0x02),
  136. HID_RI_REPORT_SIZE(8, 0x08),
  137. # else
  138. HID_RI_LOGICAL_MINIMUM(16, -32767),
  139. HID_RI_LOGICAL_MAXIMUM(16, 32767),
  140. HID_RI_REPORT_COUNT(8, 0x02),
  141. HID_RI_REPORT_SIZE(8, 0x10),
  142. # endif
  143. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
  144. // Vertical wheel (1 byte)
  145. HID_RI_USAGE(8, 0x38), // Wheel
  146. HID_RI_LOGICAL_MINIMUM(8, -127),
  147. HID_RI_LOGICAL_MAXIMUM(8, 127),
  148. HID_RI_REPORT_COUNT(8, 0x01),
  149. HID_RI_REPORT_SIZE(8, 0x08),
  150. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
  151. // Horizontal wheel (1 byte)
  152. HID_RI_USAGE_PAGE(8, 0x0C), // Consumer
  153. HID_RI_USAGE(16, 0x0238), // AC Pan
  154. HID_RI_LOGICAL_MINIMUM(8, -127),
  155. HID_RI_LOGICAL_MAXIMUM(8, 127),
  156. HID_RI_REPORT_COUNT(8, 0x01),
  157. HID_RI_REPORT_SIZE(8, 0x08),
  158. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
  159. HID_RI_END_COLLECTION(0),
  160. HID_RI_END_COLLECTION(0),
  161. # ifndef MOUSE_SHARED_EP
  162. };
  163. # endif
  164. #endif
  165. #ifdef JOYSTICK_ENABLE
  166. # ifndef JOYSTICK_SHARED_EP
  167. const USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] = {
  168. # elif !defined(SHARED_REPORT_STARTED)
  169. const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
  170. # define SHARED_REPORT_STARTED
  171. # endif
  172. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  173. HID_RI_USAGE(8, 0x04), // Joystick
  174. HID_RI_COLLECTION(8, 0x01), // Application
  175. # ifdef JOYSTICK_SHARED_EP
  176. HID_RI_REPORT_ID(8, REPORT_ID_JOYSTICK),
  177. # endif
  178. HID_RI_COLLECTION(8, 0x00), // Physical
  179. # if JOYSTICK_AXIS_COUNT > 0
  180. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  181. HID_RI_USAGE(8, 0x30), // X
  182. # if JOYSTICK_AXIS_COUNT > 1
  183. HID_RI_USAGE(8, 0x31), // Y
  184. # endif
  185. # if JOYSTICK_AXIS_COUNT > 2
  186. HID_RI_USAGE(8, 0x32), // Z
  187. # endif
  188. # if JOYSTICK_AXIS_COUNT > 3
  189. HID_RI_USAGE(8, 0x33), // Rx
  190. # endif
  191. # if JOYSTICK_AXIS_COUNT > 4
  192. HID_RI_USAGE(8, 0x34), // Ry
  193. # endif
  194. # if JOYSTICK_AXIS_COUNT > 5
  195. HID_RI_USAGE(8, 0x35), // Rz
  196. # endif
  197. # if JOYSTICK_AXIS_RESOLUTION == 8
  198. HID_RI_LOGICAL_MINIMUM(8, -JOYSTICK_MAX_VALUE),
  199. HID_RI_LOGICAL_MAXIMUM(8, JOYSTICK_MAX_VALUE),
  200. HID_RI_REPORT_COUNT(8, JOYSTICK_AXIS_COUNT),
  201. HID_RI_REPORT_SIZE(8, 0x08),
  202. # else
  203. HID_RI_LOGICAL_MINIMUM(16, -JOYSTICK_MAX_VALUE),
  204. HID_RI_LOGICAL_MAXIMUM(16, JOYSTICK_MAX_VALUE),
  205. HID_RI_REPORT_COUNT(8, JOYSTICK_AXIS_COUNT),
  206. HID_RI_REPORT_SIZE(8, 0x10),
  207. # endif
  208. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  209. # endif
  210. # if JOYSTICK_BUTTON_COUNT > 0
  211. HID_RI_USAGE_PAGE(8, 0x09), // Button
  212. HID_RI_USAGE_MINIMUM(8, 0x01),
  213. HID_RI_USAGE_MAXIMUM(8, JOYSTICK_BUTTON_COUNT),
  214. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  215. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  216. HID_RI_REPORT_COUNT(8, JOYSTICK_BUTTON_COUNT),
  217. HID_RI_REPORT_SIZE(8, 0x01),
  218. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  219. # if (JOYSTICK_BUTTON_COUNT % 8) != 0
  220. HID_RI_REPORT_COUNT(8, 8 - (JOYSTICK_BUTTON_COUNT % 8)),
  221. HID_RI_REPORT_SIZE(8, 0x01),
  222. HID_RI_INPUT(8, HID_IOF_CONSTANT),
  223. # endif
  224. # endif
  225. HID_RI_END_COLLECTION(0),
  226. HID_RI_END_COLLECTION(0),
  227. # ifndef JOYSTICK_SHARED_EP
  228. };
  229. # endif
  230. #endif
  231. #ifdef DIGITIZER_ENABLE
  232. # ifndef DIGITIZER_SHARED_EP
  233. const USB_Descriptor_HIDReport_Datatype_t PROGMEM DigitizerReport[] = {
  234. # elif !defined(SHARED_REPORT_STARTED)
  235. const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
  236. # define SHARED_REPORT_STARTED
  237. # endif
  238. HID_RI_USAGE_PAGE(8, 0x0D), // Digitizers
  239. HID_RI_USAGE(8, 0x01), // Digitizer
  240. HID_RI_COLLECTION(8, 0x01), // Application
  241. # ifdef DIGITIZER_SHARED_EP
  242. HID_RI_REPORT_ID(8, REPORT_ID_DIGITIZER),
  243. # endif
  244. HID_RI_USAGE(8, 0x20), // Stylus
  245. HID_RI_COLLECTION(8, 0x00), // Physical
  246. // In Range, Tip Switch & Barrel Switch (3 bits)
  247. HID_RI_USAGE(8, 0x32), // In Range
  248. HID_RI_USAGE(8, 0x42), // Tip Switch
  249. HID_RI_USAGE(8, 0x44), // Barrel Switch
  250. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  251. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  252. HID_RI_REPORT_COUNT(8, 0x03),
  253. HID_RI_REPORT_SIZE(8, 0x01),
  254. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  255. // Padding (5 bits)
  256. HID_RI_REPORT_COUNT(8, 0x05),
  257. HID_RI_INPUT(8, HID_IOF_CONSTANT),
  258. // X/Y Position (4 bytes)
  259. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  260. HID_RI_USAGE(8, 0x30), // X
  261. HID_RI_USAGE(8, 0x31), // Y
  262. HID_RI_LOGICAL_MAXIMUM(16, 0x7FFF),
  263. HID_RI_REPORT_COUNT(8, 0x02),
  264. HID_RI_REPORT_SIZE(8, 0x10),
  265. HID_RI_UNIT(8, 0x33), // Inch, English Linear
  266. HID_RI_UNIT_EXPONENT(8, 0x0E), // -2
  267. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  268. HID_RI_END_COLLECTION(0),
  269. HID_RI_END_COLLECTION(0),
  270. # ifndef DIGITIZER_SHARED_EP
  271. };
  272. # endif
  273. #endif
  274. #if defined(SHARED_EP_ENABLE) && !defined(SHARED_REPORT_STARTED)
  275. const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
  276. #endif
  277. #ifdef EXTRAKEY_ENABLE
  278. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  279. HID_RI_USAGE(8, 0x80), // System Control
  280. HID_RI_COLLECTION(8, 0x01), // Application
  281. HID_RI_REPORT_ID(8, REPORT_ID_SYSTEM),
  282. HID_RI_USAGE_MINIMUM(8, 0x01), // Pointer
  283. HID_RI_USAGE_MAXIMUM(16, 0x00B7), // System Display LCD Autoscale
  284. HID_RI_LOGICAL_MINIMUM(8, 0x01),
  285. HID_RI_LOGICAL_MAXIMUM(16, 0x00B7),
  286. HID_RI_REPORT_COUNT(8, 1),
  287. HID_RI_REPORT_SIZE(8, 16),
  288. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
  289. HID_RI_END_COLLECTION(0),
  290. HID_RI_USAGE_PAGE(8, 0x0C), // Consumer
  291. HID_RI_USAGE(8, 0x01), // Consumer Control
  292. HID_RI_COLLECTION(8, 0x01), // Application
  293. HID_RI_REPORT_ID(8, REPORT_ID_CONSUMER),
  294. HID_RI_USAGE_MINIMUM(8, 0x01), // Consumer Control
  295. HID_RI_USAGE_MAXIMUM(16, 0x02A0), // AC Desktop Show All Applications
  296. HID_RI_LOGICAL_MINIMUM(8, 0x01),
  297. HID_RI_LOGICAL_MAXIMUM(16, 0x02A0),
  298. HID_RI_REPORT_COUNT(8, 1),
  299. HID_RI_REPORT_SIZE(8, 16),
  300. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
  301. HID_RI_END_COLLECTION(0),
  302. #endif
  303. #ifdef PROGRAMMABLE_BUTTON_ENABLE
  304. HID_RI_USAGE_PAGE(8, 0x0C), // Consumer
  305. HID_RI_USAGE(8, 0x01), // Consumer Control
  306. HID_RI_COLLECTION(8, 0x01), // Application
  307. HID_RI_REPORT_ID(8, REPORT_ID_PROGRAMMABLE_BUTTON),
  308. HID_RI_USAGE(8, 0x03), // Programmable Buttons
  309. HID_RI_COLLECTION(8, 0x04), // Named Array
  310. HID_RI_USAGE_PAGE(8, 0x09), // Button
  311. HID_RI_USAGE_MINIMUM(8, 0x01), // Button 1
  312. HID_RI_USAGE_MAXIMUM(8, 0x20), // Button 32
  313. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  314. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  315. HID_RI_REPORT_COUNT(8, 32),
  316. HID_RI_REPORT_SIZE(8, 1),
  317. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  318. HID_RI_END_COLLECTION(0),
  319. HID_RI_END_COLLECTION(0),
  320. #endif
  321. #ifdef NKRO_ENABLE
  322. HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
  323. HID_RI_USAGE(8, 0x06), // Keyboard
  324. HID_RI_COLLECTION(8, 0x01), // Application
  325. HID_RI_REPORT_ID(8, REPORT_ID_NKRO),
  326. // Modifiers (8 bits)
  327. HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad
  328. HID_RI_USAGE_MINIMUM(8, 0xE0), // Keyboard Left Control
  329. HID_RI_USAGE_MAXIMUM(8, 0xE7), // Keyboard Right GUI
  330. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  331. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  332. HID_RI_REPORT_COUNT(8, 0x08),
  333. HID_RI_REPORT_SIZE(8, 0x01),
  334. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  335. // Keycodes
  336. HID_RI_USAGE_PAGE(8, 0x07), // Keyboard/Keypad
  337. HID_RI_USAGE_MINIMUM(8, 0x00),
  338. HID_RI_USAGE_MAXIMUM(8, NKRO_REPORT_BITS * 8 - 1),
  339. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  340. HID_RI_LOGICAL_MAXIMUM(8, 0x01),
  341. HID_RI_REPORT_COUNT(8, NKRO_REPORT_BITS * 8),
  342. HID_RI_REPORT_SIZE(8, 0x01),
  343. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  344. // Status LEDs (5 bits)
  345. HID_RI_USAGE_PAGE(8, 0x08), // LED
  346. HID_RI_USAGE_MINIMUM(8, 0x01), // Num Lock
  347. HID_RI_USAGE_MAXIMUM(8, 0x05), // Kana
  348. HID_RI_REPORT_COUNT(8, 0x05),
  349. HID_RI_REPORT_SIZE(8, 0x01),
  350. HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
  351. // LED padding (3 bits)
  352. HID_RI_REPORT_COUNT(8, 0x01),
  353. HID_RI_REPORT_SIZE(8, 0x03),
  354. HID_RI_OUTPUT(8, HID_IOF_CONSTANT),
  355. HID_RI_END_COLLECTION(0),
  356. #endif
  357. #ifdef SHARED_EP_ENABLE
  358. };
  359. #endif
  360. #ifdef RAW_ENABLE
  361. const USB_Descriptor_HIDReport_Datatype_t PROGMEM RawReport[] = {
  362. HID_RI_USAGE_PAGE(16, RAW_USAGE_PAGE), // Vendor Defined
  363. HID_RI_USAGE(8, RAW_USAGE_ID), // Vendor Defined
  364. HID_RI_COLLECTION(8, 0x01), // Application
  365. // Data to host
  366. HID_RI_USAGE(8, 0x62), // Vendor Defined
  367. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  368. HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
  369. HID_RI_REPORT_COUNT(8, RAW_EPSIZE),
  370. HID_RI_REPORT_SIZE(8, 0x08),
  371. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  372. // Data from host
  373. HID_RI_USAGE(8, 0x63), // Vendor Defined
  374. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  375. HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
  376. HID_RI_REPORT_COUNT(8, RAW_EPSIZE),
  377. HID_RI_REPORT_SIZE(8, 0x08),
  378. HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
  379. HID_RI_END_COLLECTION(0),
  380. };
  381. #endif
  382. #ifdef CONSOLE_ENABLE
  383. const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = {
  384. HID_RI_USAGE_PAGE(16, 0xFF31), // Vendor Defined (PJRC Teensy compatible)
  385. HID_RI_USAGE(8, 0x74), // Vendor Defined (PJRC Teensy compatible)
  386. HID_RI_COLLECTION(8, 0x01), // Application
  387. // Data to host
  388. HID_RI_USAGE(8, 0x75), // Vendor Defined
  389. HID_RI_LOGICAL_MINIMUM(8, 0x00),
  390. HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
  391. HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE),
  392. HID_RI_REPORT_SIZE(8, 0x08),
  393. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
  394. HID_RI_END_COLLECTION(0),
  395. };
  396. #endif
  397. /*
  398. * Device descriptor
  399. */
  400. const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = {
  401. .Header = {
  402. .Size = sizeof(USB_Descriptor_Device_t),
  403. .Type = DTYPE_Device
  404. },
  405. .USBSpecification = VERSION_BCD(2, 0, 0),
  406. #if VIRTSER_ENABLE
  407. .Class = USB_CSCP_IADDeviceClass,
  408. .SubClass = USB_CSCP_IADDeviceSubclass,
  409. .Protocol = USB_CSCP_IADDeviceProtocol,
  410. #else
  411. .Class = USB_CSCP_NoDeviceClass,
  412. .SubClass = USB_CSCP_NoDeviceSubclass,
  413. .Protocol = USB_CSCP_NoDeviceProtocol,
  414. #endif
  415. .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
  416. // Specified in config.h
  417. .VendorID = VENDOR_ID,
  418. .ProductID = PRODUCT_ID,
  419. .ReleaseNumber = DEVICE_VER,
  420. .ManufacturerStrIndex = 0x01,
  421. .ProductStrIndex = 0x02,
  422. #if defined(SERIAL_NUMBER)
  423. .SerialNumStrIndex = 0x03,
  424. #else
  425. .SerialNumStrIndex = 0x00,
  426. #endif
  427. .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
  428. };
  429. #ifndef USB_MAX_POWER_CONSUMPTION
  430. # define USB_MAX_POWER_CONSUMPTION 500
  431. #endif
  432. #ifndef USB_POLLING_INTERVAL_MS
  433. # define USB_POLLING_INTERVAL_MS 1
  434. #endif
  435. /*
  436. * Configuration descriptors
  437. */
  438. const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = {
  439. .Config = {
  440. .Header = {
  441. .Size = sizeof(USB_Descriptor_Configuration_Header_t),
  442. .Type = DTYPE_Configuration
  443. },
  444. .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
  445. .TotalInterfaces = TOTAL_INTERFACES,
  446. .ConfigurationNumber = 1,
  447. .ConfigurationStrIndex = NO_DESCRIPTOR,
  448. .ConfigAttributes = (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_REMOTEWAKEUP),
  449. .MaxPowerConsumption = USB_CONFIG_POWER_MA(USB_MAX_POWER_CONSUMPTION)
  450. },
  451. #ifndef KEYBOARD_SHARED_EP
  452. /*
  453. * Keyboard
  454. */
  455. .Keyboard_Interface = {
  456. .Header = {
  457. .Size = sizeof(USB_Descriptor_Interface_t),
  458. .Type = DTYPE_Interface
  459. },
  460. .InterfaceNumber = KEYBOARD_INTERFACE,
  461. .AlternateSetting = 0x00,
  462. .TotalEndpoints = 1,
  463. .Class = HID_CSCP_HIDClass,
  464. .SubClass = HID_CSCP_BootSubclass,
  465. .Protocol = HID_CSCP_KeyboardBootProtocol,
  466. .InterfaceStrIndex = NO_DESCRIPTOR
  467. },
  468. .Keyboard_HID = {
  469. .Header = {
  470. .Size = sizeof(USB_HID_Descriptor_HID_t),
  471. .Type = HID_DTYPE_HID
  472. },
  473. .HIDSpec = VERSION_BCD(1, 1, 1),
  474. .CountryCode = 0x00,
  475. .TotalReportDescriptors = 1,
  476. .HIDReportType = HID_DTYPE_Report,
  477. .HIDReportLength = sizeof(KeyboardReport)
  478. },
  479. .Keyboard_INEndpoint = {
  480. .Header = {
  481. .Size = sizeof(USB_Descriptor_Endpoint_t),
  482. .Type = DTYPE_Endpoint
  483. },
  484. .EndpointAddress = (ENDPOINT_DIR_IN | KEYBOARD_IN_EPNUM),
  485. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  486. .EndpointSize = KEYBOARD_EPSIZE,
  487. .PollingIntervalMS = USB_POLLING_INTERVAL_MS
  488. },
  489. #endif
  490. #ifdef RAW_ENABLE
  491. /*
  492. * Raw HID
  493. */
  494. .Raw_Interface = {
  495. .Header = {
  496. .Size = sizeof(USB_Descriptor_Interface_t),
  497. .Type = DTYPE_Interface
  498. },
  499. .InterfaceNumber = RAW_INTERFACE,
  500. .AlternateSetting = 0x00,
  501. .TotalEndpoints = 2,
  502. .Class = HID_CSCP_HIDClass,
  503. .SubClass = HID_CSCP_NonBootSubclass,
  504. .Protocol = HID_CSCP_NonBootProtocol,
  505. .InterfaceStrIndex = NO_DESCRIPTOR
  506. },
  507. .Raw_HID = {
  508. .Header = {
  509. .Size = sizeof(USB_HID_Descriptor_HID_t),
  510. .Type = HID_DTYPE_HID
  511. },
  512. .HIDSpec = VERSION_BCD(1, 1, 1),
  513. .CountryCode = 0x00,
  514. .TotalReportDescriptors = 1,
  515. .HIDReportType = HID_DTYPE_Report,
  516. .HIDReportLength = sizeof(RawReport)
  517. },
  518. .Raw_INEndpoint = {
  519. .Header = {
  520. .Size = sizeof(USB_Descriptor_Endpoint_t),
  521. .Type = DTYPE_Endpoint
  522. },
  523. .EndpointAddress = (ENDPOINT_DIR_IN | RAW_IN_EPNUM),
  524. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  525. .EndpointSize = RAW_EPSIZE,
  526. .PollingIntervalMS = 0x01
  527. },
  528. .Raw_OUTEndpoint = {
  529. .Header = {
  530. .Size = sizeof(USB_Descriptor_Endpoint_t),
  531. .Type = DTYPE_Endpoint
  532. },
  533. .EndpointAddress = (ENDPOINT_DIR_OUT | RAW_OUT_EPNUM),
  534. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  535. .EndpointSize = RAW_EPSIZE,
  536. .PollingIntervalMS = 0x01
  537. },
  538. #endif
  539. #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP)
  540. /*
  541. * Mouse
  542. */
  543. .Mouse_Interface = {
  544. .Header = {
  545. .Size = sizeof(USB_Descriptor_Interface_t),
  546. .Type = DTYPE_Interface
  547. },
  548. .InterfaceNumber = MOUSE_INTERFACE,
  549. .AlternateSetting = 0x00,
  550. .TotalEndpoints = 1,
  551. .Class = HID_CSCP_HIDClass,
  552. .SubClass = HID_CSCP_BootSubclass,
  553. .Protocol = HID_CSCP_MouseBootProtocol,
  554. .InterfaceStrIndex = NO_DESCRIPTOR
  555. },
  556. .Mouse_HID = {
  557. .Header = {
  558. .Size = sizeof(USB_HID_Descriptor_HID_t),
  559. .Type = HID_DTYPE_HID
  560. },
  561. .HIDSpec = VERSION_BCD(1, 1, 1),
  562. .CountryCode = 0x00,
  563. .TotalReportDescriptors = 1,
  564. .HIDReportType = HID_DTYPE_Report,
  565. .HIDReportLength = sizeof(MouseReport)
  566. },
  567. .Mouse_INEndpoint = {
  568. .Header = {
  569. .Size = sizeof(USB_Descriptor_Endpoint_t),
  570. .Type = DTYPE_Endpoint
  571. },
  572. .EndpointAddress = (ENDPOINT_DIR_IN | MOUSE_IN_EPNUM),
  573. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  574. .EndpointSize = MOUSE_EPSIZE,
  575. .PollingIntervalMS = USB_POLLING_INTERVAL_MS
  576. },
  577. #endif
  578. #ifdef SHARED_EP_ENABLE
  579. /*
  580. * Shared
  581. */
  582. .Shared_Interface = {
  583. .Header = {
  584. .Size = sizeof(USB_Descriptor_Interface_t),
  585. .Type = DTYPE_Interface
  586. },
  587. .InterfaceNumber = SHARED_INTERFACE,
  588. .AlternateSetting = 0x00,
  589. .TotalEndpoints = 1,
  590. .Class = HID_CSCP_HIDClass,
  591. # ifdef KEYBOARD_SHARED_EP
  592. .SubClass = HID_CSCP_BootSubclass,
  593. .Protocol = HID_CSCP_KeyboardBootProtocol,
  594. # else
  595. .SubClass = HID_CSCP_NonBootSubclass,
  596. .Protocol = HID_CSCP_NonBootProtocol,
  597. # endif
  598. .InterfaceStrIndex = NO_DESCRIPTOR
  599. },
  600. .Shared_HID = {
  601. .Header = {
  602. .Size = sizeof(USB_HID_Descriptor_HID_t),
  603. .Type = HID_DTYPE_HID
  604. },
  605. .HIDSpec = VERSION_BCD(1, 1, 1),
  606. .CountryCode = 0x00,
  607. .TotalReportDescriptors = 1,
  608. .HIDReportType = HID_DTYPE_Report,
  609. .HIDReportLength = sizeof(SharedReport)
  610. },
  611. .Shared_INEndpoint = {
  612. .Header = {
  613. .Size = sizeof(USB_Descriptor_Endpoint_t),
  614. .Type = DTYPE_Endpoint
  615. },
  616. .EndpointAddress = (ENDPOINT_DIR_IN | SHARED_IN_EPNUM),
  617. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  618. .EndpointSize = SHARED_EPSIZE,
  619. .PollingIntervalMS = USB_POLLING_INTERVAL_MS
  620. },
  621. #endif
  622. #ifdef CONSOLE_ENABLE
  623. /*
  624. * Console
  625. */
  626. .Console_Interface = {
  627. .Header = {
  628. .Size = sizeof(USB_Descriptor_Interface_t),
  629. .Type = DTYPE_Interface
  630. },
  631. .InterfaceNumber = CONSOLE_INTERFACE,
  632. .AlternateSetting = 0x00,
  633. .TotalEndpoints = 1,
  634. .Class = HID_CSCP_HIDClass,
  635. .SubClass = HID_CSCP_NonBootSubclass,
  636. .Protocol = HID_CSCP_NonBootProtocol,
  637. .InterfaceStrIndex = NO_DESCRIPTOR
  638. },
  639. .Console_HID = {
  640. .Header = {
  641. .Size = sizeof(USB_HID_Descriptor_HID_t),
  642. .Type = HID_DTYPE_HID
  643. },
  644. .HIDSpec = VERSION_BCD(1, 1, 1),
  645. .CountryCode = 0x00,
  646. .TotalReportDescriptors = 1,
  647. .HIDReportType = HID_DTYPE_Report,
  648. .HIDReportLength = sizeof(ConsoleReport)
  649. },
  650. .Console_INEndpoint = {
  651. .Header = {
  652. .Size = sizeof(USB_Descriptor_Endpoint_t),
  653. .Type = DTYPE_Endpoint
  654. },
  655. .EndpointAddress = (ENDPOINT_DIR_IN | CONSOLE_IN_EPNUM),
  656. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  657. .EndpointSize = CONSOLE_EPSIZE,
  658. .PollingIntervalMS = 0x01
  659. },
  660. #endif
  661. #ifdef MIDI_ENABLE
  662. /*
  663. * MIDI
  664. */
  665. .Audio_Interface_Association = {
  666. .Header = {
  667. .Size = sizeof(USB_Descriptor_Interface_Association_t),
  668. .Type = DTYPE_InterfaceAssociation
  669. },
  670. .FirstInterfaceIndex = AC_INTERFACE,
  671. .TotalInterfaces = 2,
  672. .Class = AUDIO_CSCP_AudioClass,
  673. .SubClass = AUDIO_CSCP_ControlSubclass,
  674. .Protocol = AUDIO_CSCP_ControlProtocol,
  675. .IADStrIndex = NO_DESCRIPTOR,
  676. },
  677. .Audio_ControlInterface = {
  678. .Header = {
  679. .Size = sizeof(USB_Descriptor_Interface_t),
  680. .Type = DTYPE_Interface
  681. },
  682. .InterfaceNumber = AC_INTERFACE,
  683. .AlternateSetting = 0,
  684. .TotalEndpoints = 0,
  685. .Class = AUDIO_CSCP_AudioClass,
  686. .SubClass = AUDIO_CSCP_ControlSubclass,
  687. .Protocol = AUDIO_CSCP_ControlProtocol,
  688. .InterfaceStrIndex = NO_DESCRIPTOR
  689. },
  690. .Audio_ControlInterface_SPC = {
  691. .Header = {
  692. .Size = sizeof(USB_Audio_Descriptor_Interface_AC_t),
  693. .Type = AUDIO_DTYPE_CSInterface
  694. },
  695. .Subtype = AUDIO_DSUBTYPE_CSInterface_Header,
  696. .ACSpecification = VERSION_BCD(1, 0, 0),
  697. .TotalLength = sizeof(USB_Audio_Descriptor_Interface_AC_t),
  698. .InCollection = 1,
  699. .InterfaceNumber = AS_INTERFACE,
  700. },
  701. .Audio_StreamInterface = {
  702. .Header = {
  703. .Size = sizeof(USB_Descriptor_Interface_t),
  704. .Type = DTYPE_Interface
  705. },
  706. .InterfaceNumber = AS_INTERFACE,
  707. .AlternateSetting = 0,
  708. .TotalEndpoints = 2,
  709. .Class = AUDIO_CSCP_AudioClass,
  710. .SubClass = AUDIO_CSCP_MIDIStreamingSubclass,
  711. .Protocol = AUDIO_CSCP_StreamingProtocol,
  712. .InterfaceStrIndex = NO_DESCRIPTOR
  713. },
  714. .Audio_StreamInterface_SPC = {
  715. .Header = {
  716. .Size = sizeof(USB_MIDI_Descriptor_AudioInterface_AS_t),
  717. .Type = AUDIO_DTYPE_CSInterface
  718. },
  719. .Subtype = AUDIO_DSUBTYPE_CSInterface_General,
  720. .AudioSpecification = VERSION_BCD(1, 0, 0),
  721. .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)
  722. },
  723. .MIDI_In_Jack_Emb = {
  724. .Header = {
  725. .Size = sizeof(USB_MIDI_Descriptor_InputJack_t),
  726. .Type = AUDIO_DTYPE_CSInterface
  727. },
  728. .Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
  729. .JackType = MIDI_JACKTYPE_Embedded,
  730. .JackID = 0x01,
  731. .JackStrIndex = NO_DESCRIPTOR
  732. },
  733. .MIDI_In_Jack_Ext = {
  734. .Header = {
  735. .Size = sizeof(USB_MIDI_Descriptor_InputJack_t),
  736. .Type = AUDIO_DTYPE_CSInterface
  737. },
  738. .Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
  739. .JackType = MIDI_JACKTYPE_External,
  740. .JackID = 0x02,
  741. .JackStrIndex = NO_DESCRIPTOR
  742. },
  743. .MIDI_Out_Jack_Emb = {
  744. .Header = {
  745. .Size = sizeof(USB_MIDI_Descriptor_OutputJack_t),
  746. .Type = AUDIO_DTYPE_CSInterface
  747. },
  748. .Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
  749. .JackType = MIDI_JACKTYPE_Embedded,
  750. .JackID = 0x03,
  751. .NumberOfPins = 1,
  752. .SourceJackID = {0x02},
  753. .SourcePinID = {0x01},
  754. .JackStrIndex = NO_DESCRIPTOR
  755. },
  756. .MIDI_Out_Jack_Ext = {
  757. .Header = {
  758. .Size = sizeof(USB_MIDI_Descriptor_OutputJack_t),
  759. .Type = AUDIO_DTYPE_CSInterface
  760. },
  761. .Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
  762. .JackType = MIDI_JACKTYPE_External,
  763. .JackID = 0x04,
  764. .NumberOfPins = 1,
  765. .SourceJackID = {0x01},
  766. .SourcePinID = {0x01},
  767. .JackStrIndex = NO_DESCRIPTOR
  768. },
  769. .MIDI_In_Jack_Endpoint = {
  770. .Endpoint = {
  771. .Header = {
  772. .Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t),
  773. .Type = DTYPE_Endpoint
  774. },
  775. .EndpointAddress = (ENDPOINT_DIR_OUT | MIDI_STREAM_OUT_EPNUM),
  776. .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  777. .EndpointSize = MIDI_STREAM_EPSIZE,
  778. .PollingIntervalMS = 0x05
  779. },
  780. .Refresh = 0,
  781. .SyncEndpointNumber = 0
  782. },
  783. .MIDI_In_Jack_Endpoint_SPC = {
  784. .Header = {
  785. .Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t),
  786. .Type = AUDIO_DTYPE_CSEndpoint
  787. },
  788. .Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
  789. .TotalEmbeddedJacks = 0x01,
  790. .AssociatedJackID = {0x01}
  791. },
  792. .MIDI_Out_Jack_Endpoint = {
  793. .Endpoint = {
  794. .Header = {
  795. .Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t),
  796. .Type = DTYPE_Endpoint
  797. },
  798. .EndpointAddress = (ENDPOINT_DIR_IN | MIDI_STREAM_IN_EPNUM),
  799. .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  800. .EndpointSize = MIDI_STREAM_EPSIZE,
  801. .PollingIntervalMS = 0x05
  802. },
  803. .Refresh = 0,
  804. .SyncEndpointNumber = 0
  805. },
  806. .MIDI_Out_Jack_Endpoint_SPC = {
  807. .Header = {
  808. .Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t),
  809. .Type = AUDIO_DTYPE_CSEndpoint
  810. },
  811. .Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
  812. .TotalEmbeddedJacks = 0x01,
  813. .AssociatedJackID = {0x03}
  814. },
  815. #endif
  816. #ifdef VIRTSER_ENABLE
  817. /*
  818. * Virtual Serial
  819. */
  820. .CDC_Interface_Association = {
  821. .Header = {
  822. .Size = sizeof(USB_Descriptor_Interface_Association_t),
  823. .Type = DTYPE_InterfaceAssociation
  824. },
  825. .FirstInterfaceIndex = CCI_INTERFACE,
  826. .TotalInterfaces = 2,
  827. .Class = CDC_CSCP_CDCClass,
  828. .SubClass = CDC_CSCP_ACMSubclass,
  829. .Protocol = CDC_CSCP_ATCommandProtocol,
  830. .IADStrIndex = NO_DESCRIPTOR,
  831. },
  832. .CDC_CCI_Interface = {
  833. .Header = {
  834. .Size = sizeof(USB_Descriptor_Interface_t),
  835. .Type = DTYPE_Interface
  836. },
  837. .InterfaceNumber = CCI_INTERFACE,
  838. .AlternateSetting = 0,
  839. .TotalEndpoints = 1,
  840. .Class = CDC_CSCP_CDCClass,
  841. .SubClass = CDC_CSCP_ACMSubclass,
  842. .Protocol = CDC_CSCP_ATCommandProtocol,
  843. .InterfaceStrIndex = NO_DESCRIPTOR
  844. },
  845. .CDC_Functional_Header = {
  846. .Header = {
  847. .Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t),
  848. .Type = CDC_DTYPE_CSInterface
  849. },
  850. .Subtype = 0x00,
  851. .CDCSpecification = VERSION_BCD(1, 1, 0),
  852. },
  853. .CDC_Functional_ACM = {
  854. .Header = {
  855. .Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t),
  856. .Type = CDC_DTYPE_CSInterface
  857. },
  858. .Subtype = 0x02,
  859. .Capabilities = 0x02,
  860. },
  861. .CDC_Functional_Union = {
  862. .Header = {
  863. .Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t),
  864. .Type = CDC_DTYPE_CSInterface
  865. },
  866. .Subtype = 0x06,
  867. .MasterInterfaceNumber = CCI_INTERFACE,
  868. .SlaveInterfaceNumber = CDI_INTERFACE,
  869. },
  870. .CDC_NotificationEndpoint = {
  871. .Header = {
  872. .Size = sizeof(USB_Descriptor_Endpoint_t),
  873. .Type = DTYPE_Endpoint
  874. },
  875. .EndpointAddress = (ENDPOINT_DIR_IN | CDC_NOTIFICATION_EPNUM),
  876. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  877. .EndpointSize = CDC_NOTIFICATION_EPSIZE,
  878. .PollingIntervalMS = 0xFF
  879. },
  880. .CDC_DCI_Interface = {
  881. .Header = {
  882. .Size = sizeof(USB_Descriptor_Interface_t),
  883. .Type = DTYPE_Interface
  884. },
  885. .InterfaceNumber = CDI_INTERFACE,
  886. .AlternateSetting = 0,
  887. .TotalEndpoints = 2,
  888. .Class = CDC_CSCP_CDCDataClass,
  889. .SubClass = CDC_CSCP_NoDataSubclass,
  890. .Protocol = CDC_CSCP_NoDataProtocol,
  891. .InterfaceStrIndex = NO_DESCRIPTOR
  892. },
  893. .CDC_DataOutEndpoint = {
  894. .Header = {
  895. .Size = sizeof(USB_Descriptor_Endpoint_t),
  896. .Type = DTYPE_Endpoint
  897. },
  898. .EndpointAddress = (ENDPOINT_DIR_OUT | CDC_OUT_EPNUM),
  899. .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  900. .EndpointSize = CDC_EPSIZE,
  901. .PollingIntervalMS = 0x05
  902. },
  903. .CDC_DataInEndpoint = {
  904. .Header = {
  905. .Size = sizeof(USB_Descriptor_Endpoint_t),
  906. .Type = DTYPE_Endpoint
  907. },
  908. .EndpointAddress = (ENDPOINT_DIR_IN | CDC_IN_EPNUM),
  909. .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  910. .EndpointSize = CDC_EPSIZE,
  911. .PollingIntervalMS = 0x05
  912. },
  913. #endif
  914. #if defined(JOYSTICK_ENABLE) && !defined(JOYSTICK_SHARED_EP)
  915. /*
  916. * Joystick
  917. */
  918. .Joystick_Interface = {
  919. .Header = {
  920. .Size = sizeof(USB_Descriptor_Interface_t),
  921. .Type = DTYPE_Interface
  922. },
  923. .InterfaceNumber = JOYSTICK_INTERFACE,
  924. .AlternateSetting = 0x00,
  925. .TotalEndpoints = 1,
  926. .Class = HID_CSCP_HIDClass,
  927. .SubClass = HID_CSCP_NonBootSubclass,
  928. .Protocol = HID_CSCP_NonBootProtocol,
  929. .InterfaceStrIndex = NO_DESCRIPTOR
  930. },
  931. .Joystick_HID = {
  932. .Header = {
  933. .Size = sizeof(USB_HID_Descriptor_HID_t),
  934. .Type = HID_DTYPE_HID
  935. },
  936. .HIDSpec = VERSION_BCD(1, 1, 1),
  937. .CountryCode = 0x00,
  938. .TotalReportDescriptors = 1,
  939. .HIDReportType = HID_DTYPE_Report,
  940. .HIDReportLength = sizeof(JoystickReport)
  941. },
  942. .Joystick_INEndpoint = {
  943. .Header = {
  944. .Size = sizeof(USB_Descriptor_Endpoint_t),
  945. .Type = DTYPE_Endpoint
  946. },
  947. .EndpointAddress = (ENDPOINT_DIR_IN | JOYSTICK_IN_EPNUM),
  948. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  949. .EndpointSize = JOYSTICK_EPSIZE,
  950. .PollingIntervalMS = USB_POLLING_INTERVAL_MS
  951. }
  952. #endif
  953. #if defined(DIGITIZER_ENABLE) && !defined(DIGITIZER_SHARED_EP)
  954. /*
  955. * Digitizer
  956. */
  957. .Digitizer_Interface = {
  958. .Header = {
  959. .Size = sizeof(USB_Descriptor_Interface_t),
  960. .Type = DTYPE_Interface
  961. },
  962. .InterfaceNumber = DIGITIZER_INTERFACE,
  963. .AlternateSetting = 0x00,
  964. .TotalEndpoints = 1,
  965. .Class = HID_CSCP_HIDClass,
  966. .SubClass = HID_CSCP_NonBootSubclass,
  967. .Protocol = HID_CSCP_NonBootProtocol,
  968. .InterfaceStrIndex = NO_DESCRIPTOR
  969. },
  970. .Digitizer_HID = {
  971. .Header = {
  972. .Size = sizeof(USB_HID_Descriptor_HID_t),
  973. .Type = HID_DTYPE_HID
  974. },
  975. .HIDSpec = VERSION_BCD(1, 1, 1),
  976. .CountryCode = 0x00,
  977. .TotalReportDescriptors = 1,
  978. .HIDReportType = HID_DTYPE_Report,
  979. .HIDReportLength = sizeof(DigitizerReport)
  980. },
  981. .Digitizer_INEndpoint = {
  982. .Header = {
  983. .Size = sizeof(USB_Descriptor_Endpoint_t),
  984. .Type = DTYPE_Endpoint
  985. },
  986. .EndpointAddress = (ENDPOINT_DIR_IN | DIGITIZER_IN_EPNUM),
  987. .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
  988. .EndpointSize = DIGITIZER_EPSIZE,
  989. .PollingIntervalMS = USB_POLLING_INTERVAL_MS
  990. },
  991. #endif
  992. };
  993. /*
  994. * String descriptors
  995. */
  996. const USB_Descriptor_String_t PROGMEM LanguageString = {
  997. .Header = {
  998. .Size = 4,
  999. .Type = DTYPE_String
  1000. },
  1001. .UnicodeString = {LANGUAGE_ID_ENG}
  1002. };
  1003. const USB_Descriptor_String_t PROGMEM ManufacturerString = {
  1004. .Header = {
  1005. .Size = sizeof(USBSTR(MANUFACTURER)),
  1006. .Type = DTYPE_String
  1007. },
  1008. .UnicodeString = USBSTR(MANUFACTURER)
  1009. };
  1010. const USB_Descriptor_String_t PROGMEM ProductString = {
  1011. .Header = {
  1012. .Size = sizeof(USBSTR(PRODUCT)),
  1013. .Type = DTYPE_String
  1014. },
  1015. .UnicodeString = USBSTR(PRODUCT)
  1016. };
  1017. #if defined(SERIAL_NUMBER)
  1018. const USB_Descriptor_String_t PROGMEM SerialNumberString = {
  1019. .Header = {
  1020. .Size = sizeof(USBSTR(SERIAL_NUMBER)),
  1021. .Type = DTYPE_String
  1022. },
  1023. .UnicodeString = USBSTR(SERIAL_NUMBER)
  1024. };
  1025. #endif
  1026. // clang-format on
  1027. /**
  1028. * This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
  1029. * documentation) by the application code so that the address and size of a requested descriptor can be given
  1030. * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
  1031. * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
  1032. * USB host.
  1033. */
  1034. uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const uint16_t wLength, const void** const DescriptorAddress) {
  1035. const uint8_t DescriptorType = (wValue >> 8);
  1036. const uint8_t DescriptorIndex = (wValue & 0xFF);
  1037. const void* Address = NULL;
  1038. uint16_t Size = NO_DESCRIPTOR;
  1039. switch (DescriptorType) {
  1040. case DTYPE_Device:
  1041. Address = &DeviceDescriptor;
  1042. Size = sizeof(USB_Descriptor_Device_t);
  1043. break;
  1044. case DTYPE_Configuration:
  1045. Address = &ConfigurationDescriptor;
  1046. Size = sizeof(USB_Descriptor_Configuration_t);
  1047. break;
  1048. case DTYPE_String:
  1049. switch (DescriptorIndex) {
  1050. case 0x00:
  1051. Address = &LanguageString;
  1052. Size = pgm_read_byte(&LanguageString.Header.Size);
  1053. break;
  1054. case 0x01:
  1055. Address = &ManufacturerString;
  1056. Size = pgm_read_byte(&ManufacturerString.Header.Size);
  1057. break;
  1058. case 0x02:
  1059. Address = &ProductString;
  1060. Size = pgm_read_byte(&ProductString.Header.Size);
  1061. break;
  1062. #if defined(SERIAL_NUMBER)
  1063. case 0x03:
  1064. Address = &SerialNumberString;
  1065. Size = pgm_read_byte(&SerialNumberString.Header.Size);
  1066. break;
  1067. #endif
  1068. }
  1069. #ifdef OS_DETECTION_ENABLE
  1070. process_wlength(wLength);
  1071. #endif
  1072. break;
  1073. case HID_DTYPE_HID:
  1074. switch (wIndex) {
  1075. #ifndef KEYBOARD_SHARED_EP
  1076. case KEYBOARD_INTERFACE:
  1077. Address = &ConfigurationDescriptor.Keyboard_HID;
  1078. Size = sizeof(USB_HID_Descriptor_HID_t);
  1079. break;
  1080. #endif
  1081. #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP)
  1082. case MOUSE_INTERFACE:
  1083. Address = &ConfigurationDescriptor.Mouse_HID;
  1084. Size = sizeof(USB_HID_Descriptor_HID_t);
  1085. break;
  1086. #endif
  1087. #ifdef SHARED_EP_ENABLE
  1088. case SHARED_INTERFACE:
  1089. Address = &ConfigurationDescriptor.Shared_HID;
  1090. Size = sizeof(USB_HID_Descriptor_HID_t);
  1091. break;
  1092. #endif
  1093. #ifdef RAW_ENABLE
  1094. case RAW_INTERFACE:
  1095. Address = &ConfigurationDescriptor.Raw_HID;
  1096. Size = sizeof(USB_HID_Descriptor_HID_t);
  1097. break;
  1098. #endif
  1099. #ifdef CONSOLE_ENABLE
  1100. case CONSOLE_INTERFACE:
  1101. Address = &ConfigurationDescriptor.Console_HID;
  1102. Size = sizeof(USB_HID_Descriptor_HID_t);
  1103. break;
  1104. #endif
  1105. #if defined(JOYSTICK_ENABLE) && !defined(JOYSTICK_SHARED_EP)
  1106. case JOYSTICK_INTERFACE:
  1107. Address = &ConfigurationDescriptor.Joystick_HID;
  1108. Size = sizeof(USB_HID_Descriptor_HID_t);
  1109. break;
  1110. #endif
  1111. #if defined(DIGITIZER_ENABLE) && !defined(DIGITIZER_SHARED_EP)
  1112. case DIGITIZER_INTERFACE:
  1113. Address = &ConfigurationDescriptor.Digitizer_HID;
  1114. Size = sizeof(USB_HID_Descriptor_HID_t);
  1115. break;
  1116. #endif
  1117. }
  1118. break;
  1119. case HID_DTYPE_Report:
  1120. switch (wIndex) {
  1121. #ifndef KEYBOARD_SHARED_EP
  1122. case KEYBOARD_INTERFACE:
  1123. Address = &KeyboardReport;
  1124. Size = sizeof(KeyboardReport);
  1125. break;
  1126. #endif
  1127. #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP)
  1128. case MOUSE_INTERFACE:
  1129. Address = &MouseReport;
  1130. Size = sizeof(MouseReport);
  1131. break;
  1132. #endif
  1133. #ifdef SHARED_EP_ENABLE
  1134. case SHARED_INTERFACE:
  1135. Address = &SharedReport;
  1136. Size = sizeof(SharedReport);
  1137. break;
  1138. #endif
  1139. #ifdef RAW_ENABLE
  1140. case RAW_INTERFACE:
  1141. Address = &RawReport;
  1142. Size = sizeof(RawReport);
  1143. break;
  1144. #endif
  1145. #ifdef CONSOLE_ENABLE
  1146. case CONSOLE_INTERFACE:
  1147. Address = &ConsoleReport;
  1148. Size = sizeof(ConsoleReport);
  1149. break;
  1150. #endif
  1151. #if defined(JOYSTICK_ENABLE) && !defined(JOYSTICK_SHARED_EP)
  1152. case JOYSTICK_INTERFACE:
  1153. Address = &JoystickReport;
  1154. Size = sizeof(JoystickReport);
  1155. break;
  1156. #endif
  1157. #if defined(DIGITIZER_ENABLE) && !defined(DIGITIZER_SHARED_EP)
  1158. case DIGITIZER_INTERFACE:
  1159. Address = &DigitizerReport;
  1160. Size = sizeof(DigitizerReport);
  1161. break;
  1162. #endif
  1163. }
  1164. break;
  1165. }
  1166. *DescriptorAddress = Address;
  1167. return Size;
  1168. }