qmk_firmware/quantum
a-chol d4be07dad3 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>
2020-08-29 14:30:02 -07:00
..
api clang-format changes 2019-08-30 15:01:52 -07:00
audio Allow for user song list (#9281) 2020-07-16 16:45:50 +10:00
backlight Refactor ARM backlight (#7959) 2020-07-10 09:12:40 +01:00
debounce quantum/debounce: Added sym_pk debounce algorithm (#8587) 2020-04-11 21:29:48 +10:00
keymap_extras Fixed CA_DOTA key code (#9722) 2020-07-16 15:50:51 +10:00
process_keycode Hid joystick interface (#4226) 2020-08-29 14:30:02 -07:00
rgb_matrix_animations 2020 May 30 Breaking Changes Update (#9215) 2020-05-30 13:14:59 -07:00
rgb_matrix_runners 2020 May 30 Breaking Changes Update (#9215) 2020-05-30 13:14:59 -07:00
serial_link 2020 February 29 Breaking Changes Update (#8064) 2020-02-29 11:59:30 -08:00
split_common add SPLIT_HAND_MATRIX_GRID support (#8685) 2020-07-04 15:04:47 +01:00
template Remove DESCRIPTION (#9732) 2020-07-16 15:49:18 +10:00
tools Backlight abstraction and other changes (#439) 2016-06-23 22:18:20 -04:00
visualizer 2020 February 29 Breaking Changes Update (#8064) 2020-02-29 11:59:30 -08:00
api.c clang-format changes 2019-08-30 15:01:52 -07:00
api.h clang-format changes 2019-08-30 15:01:52 -07:00
color.c Run clang-format manually to fix recently changed files (#7934) 2020-01-19 16:30:34 +00:00
color.h Use White channel on RGBW LEDs (#7678) 2019-12-31 16:33:49 +00:00
config_common.h adds support for the atmega328 (#9043) 2020-06-10 22:23:11 +01:00
debounce.h Removed #include "matrix.h" from debounce.h 2019-01-26 22:44:33 +11:00
dip_switch.c format code according to conventions [skip ci] 2020-07-04 15:01:25 +00:00
dip_switch.h Add Dip Switch as a core feature (#6140) 2019-09-03 08:34:31 -07:00
dynamic_keymap.c format code according to conventions [skip ci] 2020-03-14 14:08:48 +00:00
dynamic_keymap.h clang-format changes 2019-08-30 15:01:52 -07:00
dynamic_macro.h [Core] Convert Dynamic Macro to a Core Feature (#5948) 2019-11-04 22:59:13 -08:00
encoder.c 2020 February 29 Breaking Changes Update (#8064) 2020-02-29 11:59:30 -08:00
encoder.h Added encoder support to split common code (#5477) 2019-04-03 16:01:17 -07:00
fauxclicky.c clang-format changes 2019-08-30 15:01:52 -07:00
fauxclicky.h clang-format changes 2019-08-30 15:01:52 -07:00
joystick.c Hid joystick interface (#4226) 2020-08-29 14:30:02 -07:00
joystick.h Hid joystick interface (#4226) 2020-08-29 14:30:02 -07:00
keycode_config.c clang-format changes 2019-08-30 15:01:52 -07:00
keycode_config.h clang-format changes 2019-08-30 15:01:52 -07:00
keymap_common.c Strip out features to allow minimum firmware sizes (#8645) 2020-04-01 21:06:22 +01:00
keymap.h clang-format changes 2019-08-30 15:01:52 -07:00
led_matrix_drivers.c clang-format changes 2019-08-30 15:01:52 -07:00
led_matrix.c clang-format changes 2019-08-30 15:01:52 -07:00
led_tables.c Remove unused LED_BREATHING_TABLE 2020-03-06 22:29:01 -08:00
led_tables.h Remove unused LED_BREATHING_TABLE 2020-03-06 22:29:01 -08:00
ledmatrix.h clang-format changes 2019-08-30 15:01:52 -07:00
matrix_common.c format code according to conventions [skip ci] 2020-07-04 15:01:25 +00:00
matrix.c format code according to conventions [skip ci] 2020-05-21 17:39:29 +00:00
mcu_selection.mk Additional cleanups for V-USB code (#9310) 2020-08-29 14:30:02 -07:00
pointing_device.c clang-format changes 2019-08-30 15:01:52 -07:00
pointing_device.h clang-format changes 2019-08-30 15:01:52 -07:00
quantum_keycodes.h Hid joystick interface (#4226) 2020-08-29 14:30:02 -07:00
quantum.c Hid joystick interface (#4226) 2020-08-29 14:30:02 -07:00
quantum.h Hid joystick interface (#4226) 2020-08-29 14:30:02 -07:00
rgb_matrix_drivers.c Compiler warning when using WS2812 (#9955) 2020-08-25 19:05:39 +10:00
rgb_matrix_types.h Add Indicator flag for RGB Matrix (#9933) 2020-08-05 13:29:04 -07:00
rgb_matrix.c Fix RGB_DISABLE_TIMEOUT overflow warning (#9866) (#9874) 2020-08-04 21:03:29 -07:00
rgb_matrix.h Support IS31FL3741 and IS31FL3741A. (#9201) 2020-06-20 14:49:15 +10:00
rgb.h clang-format changes 2019-08-30 15:01:52 -07:00
rgblight_breathe_table.h clang-format changes 2019-08-30 15:01:52 -07:00
rgblight_list.h clang-format changes 2019-08-30 15:01:52 -07:00
rgblight_modes.h New RGB Lighting effect: Twinkle (#8887) 2020-05-09 01:56:16 -07:00
rgblight_post_config.h clang-format changes 2019-08-30 15:01:52 -07:00
rgblight.c Add noeeprom speed function for RGBLIGHT (#9706) 2020-08-25 19:08:09 +10:00
rgblight.h Add noeeprom speed function for RGBLIGHT (#9706) 2020-08-25 19:08:09 +10:00
send_string_keycodes.h Add *OPT aliases for *ALT keycodes and macros (#8714) 2020-04-12 11:37:55 -07:00
variable_trace.c clang-format changes 2019-08-30 15:01:52 -07:00
variable_trace.h clang-format changes 2019-08-30 15:01:52 -07:00
velocikey.c clang-format changes 2019-08-30 15:01:52 -07:00
velocikey.h clang-format changes 2019-08-30 15:01:52 -07:00
via.c Configurable VIA layout options default value (#8707) 2020-04-06 20:27:44 +01:00
via.h Configurable VIA layout options default value (#8707) 2020-04-06 20:27:44 +01:00
wpm.c Run clang-format manually to fix recently changed files (#8552) 2020-03-25 14:39:53 +11:00
wpm.h Run clang-format manually to fix recently changed files (#8552) 2020-03-25 14:39:53 +11:00