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.

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