diff options
Diffstat (limited to 'quantum/process_keycode/process_joystick.c')
-rw-r--r-- | quantum/process_keycode/process_joystick.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/quantum/process_keycode/process_joystick.c b/quantum/process_keycode/process_joystick.c index 5778a7434..3ffaf42bf 100644 --- a/quantum/process_keycode/process_joystick.c +++ b/quantum/process_keycode/process_joystick.c | |||
@@ -129,17 +129,17 @@ bool process_joystick_analogread_quantum() { | |||
129 | // test the converted value against the lower range | 129 | // test the converted value against the lower range |
130 | int32_t ref = joystick_axes[axis_index].mid_digit; | 130 | int32_t ref = joystick_axes[axis_index].mid_digit; |
131 | int32_t range = joystick_axes[axis_index].min_digit; | 131 | int32_t range = joystick_axes[axis_index].min_digit; |
132 | int32_t ranged_val = ((axis_val - ref) * -127) / (range - ref); | 132 | int32_t ranged_val = ((axis_val - ref) * -JOYSTICK_RESOLUTION) / (range - ref); |
133 | 133 | ||
134 | if (ranged_val > 0) { | 134 | if (ranged_val > 0) { |
135 | // the value is in the higher range | 135 | // the value is in the higher range |
136 | range = joystick_axes[axis_index].max_digit; | 136 | range = joystick_axes[axis_index].max_digit; |
137 | ranged_val = ((axis_val - ref) * 127) / (range - ref); | 137 | ranged_val = ((axis_val - ref) * JOYSTICK_RESOLUTION) / (range - ref); |
138 | } | 138 | } |
139 | 139 | ||
140 | // clamp the result in the valid range | 140 | // clamp the result in the valid range |
141 | ranged_val = ranged_val < -127 ? -127 : ranged_val; | 141 | ranged_val = ranged_val < -JOYSTICK_RESOLUTION ? -JOYSTICK_RESOLUTION : ranged_val; |
142 | ranged_val = ranged_val > 127 ? 127 : ranged_val; | 142 | ranged_val = ranged_val > JOYSTICK_RESOLUTION ? JOYSTICK_RESOLUTION : ranged_val; |
143 | 143 | ||
144 | if (ranged_val != joystick_status.axes[axis_index]) { | 144 | if (ranged_val != joystick_status.axes[axis_index]) { |
145 | joystick_status.axes[axis_index] = ranged_val; | 145 | joystick_status.axes[axis_index] = ranged_val; |