Fixed binding the D-PAD on the 8BitDo M30 controller
authorSam Lantinga <slouken@libsdl.org>
Fri, 13 Mar 2020 13:05:40 -0700
changeset 13616aa4407193fa2
parent 13615 04a241d30c91
child 13617 08acb1ee220a
Fixed binding the D-PAD on the 8BitDo M30 controller
src/joystick/SDL_joystick.c
test/controllermap.c
     1.1 --- a/src/joystick/SDL_joystick.c	Fri Mar 13 13:05:38 2020 -0700
     1.2 +++ b/src/joystick/SDL_joystick.c	Fri Mar 13 13:05:40 2020 -0700
     1.3 @@ -1015,17 +1015,16 @@
     1.4  
     1.5      info = &joystick->axes[axis];
     1.6      if (!info->has_initial_value ||
     1.7 -        (!info->has_second_value && (info->initial_value == -32768 || info->initial_value == 32767) && SDL_abs(value) < (SDL_JOYSTICK_AXIS_MAX / 4))) {
     1.8 +        (!info->has_second_value && (info->initial_value <= -32767 || info->initial_value == 32767) && SDL_abs(value) < (SDL_JOYSTICK_AXIS_MAX / 4))) {
     1.9          info->initial_value = value;
    1.10          info->value = value;
    1.11          info->zero = value;
    1.12          info->has_initial_value = SDL_TRUE;
    1.13 +    } else if (value == info->value) {
    1.14 +        return 0;
    1.15      } else {
    1.16          info->has_second_value = SDL_TRUE;
    1.17      }
    1.18 -    if (value == info->value) {
    1.19 -        return 0;
    1.20 -    }
    1.21      if (!info->sent_initial_value) {
    1.22          /* Make sure we don't send motion until there's real activity on this axis */
    1.23          const int MAX_ALLOWED_JITTER = SDL_JOYSTICK_AXIS_MAX / 80;  /* ShanWan PS3 controller needed 96 */
    1.24 @@ -1033,7 +1032,7 @@
    1.25              return 0;
    1.26          }
    1.27          info->sent_initial_value = SDL_TRUE;
    1.28 -        info->value = value; /* Just so we pass the check above */
    1.29 +        info->value = ~value; /* Just so we pass the check above */
    1.30          SDL_PrivateJoystickAxis(joystick, axis, info->initial_value);
    1.31      }
    1.32  
    1.33 @@ -1773,29 +1772,29 @@
    1.34         https://raw.githubusercontent.com/denilsonsa/udev-joystick-blacklist/master/generate_rules.py
    1.35       */
    1.36      static Uint32 joystick_blacklist[] = {
    1.37 -        /* Microsoft Microsoft Wireless Optical Desktop® 2.10 */
    1.38 +        /* Microsoft Microsoft Wireless Optical Desktop?? 2.10 */
    1.39          /* Microsoft Wireless Desktop - Comfort Edition */
    1.40          MAKE_VIDPID(0x045e, 0x009d),
    1.41  
    1.42 -        /* Microsoft Microsoft® Digital Media Pro Keyboard */
    1.43 +        /* Microsoft Microsoft?? Digital Media Pro Keyboard */
    1.44          /* Microsoft Corp. Digital Media Pro Keyboard */
    1.45          MAKE_VIDPID(0x045e, 0x00b0),
    1.46  
    1.47 -        /* Microsoft Microsoft® Digital Media Keyboard */
    1.48 +        /* Microsoft Microsoft?? Digital Media Keyboard */
    1.49          /* Microsoft Corp. Digital Media Keyboard 1.0A */
    1.50          MAKE_VIDPID(0x045e, 0x00b4),
    1.51  
    1.52 -        /* Microsoft Microsoft® Digital Media Keyboard 3000 */
    1.53 +        /* Microsoft Microsoft?? Digital Media Keyboard 3000 */
    1.54          MAKE_VIDPID(0x045e, 0x0730),
    1.55  
    1.56 -        /* Microsoft Microsoft® 2.4GHz Transceiver v6.0 */
    1.57 -        /* Microsoft Microsoft® 2.4GHz Transceiver v8.0 */
    1.58 +        /* Microsoft Microsoft?? 2.4GHz Transceiver v6.0 */
    1.59 +        /* Microsoft Microsoft?? 2.4GHz Transceiver v8.0 */
    1.60          /* Microsoft Corp. Nano Transceiver v1.0 for Bluetooth */
    1.61          /* Microsoft Wireless Mobile Mouse 1000 */
    1.62          /* Microsoft Wireless Desktop 3000 */
    1.63          MAKE_VIDPID(0x045e, 0x0745),
    1.64  
    1.65 -        /* Microsoft® SideWinder(TM) 2.4GHz Transceiver */
    1.66 +        /* Microsoft?? SideWinder(TM) 2.4GHz Transceiver */
    1.67          MAKE_VIDPID(0x045e, 0x0748),
    1.68  
    1.69          /* Microsoft Corp. Wired Keyboard 600 */
    1.70 @@ -1807,16 +1806,16 @@
    1.71          /* Microsoft Corp. Arc Touch Mouse Transceiver */
    1.72          MAKE_VIDPID(0x045e, 0x0773),
    1.73  
    1.74 -        /* Microsoft® 2.4GHz Transceiver v9.0 */
    1.75 -        /* Microsoft® Nano Transceiver v2.1 */
    1.76 +        /* Microsoft?? 2.4GHz Transceiver v9.0 */
    1.77 +        /* Microsoft?? Nano Transceiver v2.1 */
    1.78          /* Microsoft Sculpt Ergonomic Keyboard (5KV-00001) */
    1.79          MAKE_VIDPID(0x045e, 0x07a5),
    1.80  
    1.81 -        /* Microsoft® Nano Transceiver v1.0 */
    1.82 +        /* Microsoft?? Nano Transceiver v1.0 */
    1.83          /* Microsoft Wireless Keyboard 800 */
    1.84          MAKE_VIDPID(0x045e, 0x07b2),
    1.85  
    1.86 -        /* Microsoft® Nano Transceiver v2.0 */
    1.87 +        /* Microsoft?? Nano Transceiver v2.0 */
    1.88          MAKE_VIDPID(0x045e, 0x0800),
    1.89  
    1.90          MAKE_VIDPID(0x046d, 0xc30a),  /* Logitech, Inc. iTouch Composite keboard */
     2.1 --- a/test/controllermap.c	Fri Mar 13 13:05:38 2020 -0700
     2.2 +++ b/test/controllermap.c	Fri Mar 13 13:05:40 2020 -0700
     2.3 @@ -473,7 +473,7 @@
     2.4                      if (!pAxisState->m_bMoving) {
     2.5                          Sint16 nInitialValue;
     2.6                          pAxisState->m_bMoving = SDL_JoystickGetAxisInitialState(joystick, event.jaxis.axis, &nInitialValue);
     2.7 -                        pAxisState->m_nLastValue = nInitialValue;
     2.8 +                        pAxisState->m_nLastValue = nValue;
     2.9                          pAxisState->m_nStartingValue = nInitialValue;
    2.10                          pAxisState->m_nFarthestValue = nInitialValue;
    2.11                      } else if (SDL_abs(nValue - pAxisState->m_nLastValue) <= MAX_ALLOWED_JITTER) {