Implement scaled radial deadzone in S922X kernel.
This commit is contained in:
parent
1018f10be7
commit
13bf681da2
1 changed files with 13 additions and 4 deletions
|
@ -2652,7 +2652,7 @@ diff -rupN linux.orig/drivers/input/joystick/amlogic-saradc.h linux/drivers/inpu
|
|||
diff -rupN linux.orig/drivers/input/joystick/odroid-gou-joypad.c linux/drivers/input/joystick/odroid-gou-joypad.c
|
||||
--- linux.orig/drivers/input/joystick/odroid-gou-joypad.c 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ linux/drivers/input/joystick/odroid-gou-joypad.c 2023-09-12 12:03:27.490291628 +0000
|
||||
@@ -0,0 +1,950 @@
|
||||
@@ -0,0 +1,959 @@
|
||||
+/*----------------------------------------------------------------------------*/
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/module.h>
|
||||
|
@ -3042,6 +3042,7 @@ diff -rupN linux.orig/drivers/input/joystick/odroid-gou-joypad.c linux/drivers/i
|
|||
+{
|
||||
+ struct joypad *joypad = poll_dev->private;
|
||||
+ int nbtn;
|
||||
+ int mag;
|
||||
+
|
||||
+ /* Assumes an even number of axes and that joystick axis pairs are sequential */
|
||||
+ /* e.g. left stick Y immediately follows left stick X */
|
||||
|
@ -3067,12 +3068,19 @@ diff -rupN linux.orig/drivers/input/joystick/odroid-gou-joypad.c linux/drivers/i
|
|||
+ }
|
||||
+ adcy->value = adcy->value - adcy->cal;
|
||||
+
|
||||
+ /* Joystick Deadzone check */
|
||||
+ /* Scaled Radial Deadzone */
|
||||
+ /* https://web.archive.org/web/20190129113357/http://www.third-helix.com/2013/04/12/doing-thumbstick-dead-zones-right.html */
|
||||
+ mag = int_sqrt((adcx->value * adcx->value) + (adcy->value * adcy->value));
|
||||
+ if (joypad->bt_adc_deadzone) {
|
||||
+ if (abs(adcx->value) < joypad->bt_adc_deadzone)
|
||||
+ if (mag <= joypad->bt_adc_deadzone) {
|
||||
+ adcx->value = 0;
|
||||
+ if (abs(adcy->value) < joypad->bt_adc_deadzone)
|
||||
+ adcy->value = 0;
|
||||
+ }
|
||||
+ else {
|
||||
+ /* Assumes adcx->max == -adcx->min == adcy->max == -adcy->min */
|
||||
+ adcx->value = (adcx->max * adcx->value * (mag - joypad->bt_adc_deadzone)) / (mag * (adcx->max - joypad->bt_adc_deadzone));
|
||||
+ adcy->value = (adcy->max * adcy->value * (mag - joypad->bt_adc_deadzone)) / (mag * (adcy->max - joypad->bt_adc_deadzone));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* adc data tuning */
|
||||
|
@ -3085,6 +3093,7 @@ diff -rupN linux.orig/drivers/input/joystick/odroid-gou-joypad.c linux/drivers/i
|
|||
+ if (adcy->tuning_p && adcy->value > 0)
|
||||
+ adcy->value = ADC_DATA_TUNING(adcy->value, adcy->tuning_p);
|
||||
+
|
||||
+ /* Clamp to [min, max] */
|
||||
+ adcx->value = adcx->value > adcx->max ? adcx->max : adcx->value;
|
||||
+ adcx->value = adcx->value < adcx->min ? adcx->min : adcx->value;
|
||||
+ adcy->value = adcy->value > adcy->max ? adcy->max : adcy->value;
|
||||
|
|
Loading…
Reference in a new issue