aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common_features.mk11
-rw-r--r--docs/feature_joystick.md16
-rw-r--r--keyboards/handwired/onekey/keymaps/joystick/rules.mk2
3 files changed, 20 insertions, 9 deletions
diff --git a/common_features.mk b/common_features.mk
index 088db89ca..1f110d081 100644
--- a/common_features.mk
+++ b/common_features.mk
@@ -536,9 +536,18 @@ ifeq ($(strip $(AUTO_SHIFT_ENABLE)), yes)
536 endif 536 endif
537endif 537endif
538 538
539ifeq ($(strip $(JOYSTICK_ENABLE)), yes) 539JOYSTICK_ENABLE ?= no
540ifneq ($(strip $(JOYSTICK_ENABLE)), no)
540 OPT_DEFS += -DJOYSTICK_ENABLE 541 OPT_DEFS += -DJOYSTICK_ENABLE
541 SRC += $(QUANTUM_DIR)/process_keycode/process_joystick.c 542 SRC += $(QUANTUM_DIR)/process_keycode/process_joystick.c
542 SRC += $(QUANTUM_DIR)/joystick.c 543 SRC += $(QUANTUM_DIR)/joystick.c
544endif
545
546ifeq ($(strip $(JOYSTICK_ENABLE)), analog)
547 OPT_DEFS += -DANALOG_JOYSTICK_ENABLE
543 SRC += analog.c 548 SRC += analog.c
544endif 549endif
550
551ifeq ($(strip $(JOYSTICK_ENABLE)), digital)
552 OPT_DEFS += -DDIGITAL_JOYSTICK_ENABLE
553endif
diff --git a/docs/feature_joystick.md b/docs/feature_joystick.md
index 58dfc7b8d..be3c781f6 100644
--- a/docs/feature_joystick.md
+++ b/docs/feature_joystick.md
@@ -2,11 +2,7 @@
2 2
3The keyboard can be made to be recognized as a joystick HID device by the operating system. 3The keyboard can be made to be recognized as a joystick HID device by the operating system.
4 4
5This is enabled by adding the following to `rules.mk`: 5This is enabled by adding `JOYSTICK_ENABLE` to `rules.mk`. You can set this value to `analog`, `digital`, or `no`.
6
7```makefile
8JOYSTICK_ENABLE = yes
9```
10 6
11!> Joystick support is not currently available on V-USB devices. 7!> Joystick support is not currently available on V-USB devices.
12 8
@@ -19,6 +15,12 @@ or send gamepad reports based on values computed by the keyboard.
19 15
20### Analog Input 16### Analog Input
21 17
18To use analog input you must first enable it in `rules.mk`:
19
20```makefile
21JOYSTICK_ENABLE = analog
22```
23
22An analog device such as a potentiometer found on a gamepad's analog axes is based on a [voltage divider](https://en.wikipedia.org/wiki/Voltage_divider). 24An analog device such as a potentiometer found on a gamepad's analog axes is based on a [voltage divider](https://en.wikipedia.org/wiki/Voltage_divider).
23It is composed of three connectors linked to the ground, the power input and power output (usually the middle one). The power output holds the voltage that varies based on the position of the cursor, 25It is composed of three connectors linked to the ground, the power input and power output (usually the middle one). The power output holds the voltage that varies based on the position of the cursor,
24which value will be read using your MCU's [ADC](https://en.wikipedia.org/wiki/Analog-to-digital_converter). 26which value will be read using your MCU's [ADC](https://en.wikipedia.org/wiki/Analog-to-digital_converter).
@@ -75,7 +77,7 @@ You assign a value by writing to `joystick_status.axes[axis_index]` a signed 8-b
75The following example writes two axes based on keypad presses, with `KC_P5` as a precision modifier: 77The following example writes two axes based on keypad presses, with `KC_P5` as a precision modifier:
76 78
77```c 79```c
78#ifdef JOYSTICK_ENABLE 80#ifdef ANALOG_JOYSTICK_ENABLE
79static uint8_t precision_val = 70; 81static uint8_t precision_val = 70;
80static uint8_t axesFlags = 0; 82static uint8_t axesFlags = 0;
81enum axes { 83enum axes {
@@ -89,7 +91,7 @@ enum axes {
89 91
90bool process_record_user(uint16_t keycode, keyrecord_t *record) { 92bool process_record_user(uint16_t keycode, keyrecord_t *record) {
91 switch(keycode) { 93 switch(keycode) {
92#ifdef JOYSTICK_ENABLE 94#ifdef ANALOG_JOYSTICK_ENABLE
93 // virtual joystick 95 // virtual joystick
94# if JOYSTICK_AXES_COUNT > 1 96# if JOYSTICK_AXES_COUNT > 1
95 case KC_P8: 97 case KC_P8:
diff --git a/keyboards/handwired/onekey/keymaps/joystick/rules.mk b/keyboards/handwired/onekey/keymaps/joystick/rules.mk
index fbddbc6de..cf0348173 100644
--- a/keyboards/handwired/onekey/keymaps/joystick/rules.mk
+++ b/keyboards/handwired/onekey/keymaps/joystick/rules.mk
@@ -1 +1 @@
JOYSTICK_ENABLE = yes JOYSTICK_ENABLE = analog