Fixed binding the D-PAD on the 8BitDo M30 controller
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c
index d010c7e..75cf5fb 100644
--- a/src/joystick/SDL_joystick.c
+++ b/src/joystick/SDL_joystick.c
@@ -1015,17 +1015,16 @@ SDL_PrivateJoystickAxis(SDL_Joystick * joystick, Uint8 axis, Sint16 value)
info = &joystick->axes[axis];
if (!info->has_initial_value ||
- (!info->has_second_value && (info->initial_value == -32768 || info->initial_value == 32767) && SDL_abs(value) < (SDL_JOYSTICK_AXIS_MAX / 4))) {
+ (!info->has_second_value && (info->initial_value <= -32767 || info->initial_value == 32767) && SDL_abs(value) < (SDL_JOYSTICK_AXIS_MAX / 4))) {
info->initial_value = value;
info->value = value;
info->zero = value;
info->has_initial_value = SDL_TRUE;
+ } else if (value == info->value) {
+ return 0;
} else {
info->has_second_value = SDL_TRUE;
}
- if (value == info->value) {
- return 0;
- }
if (!info->sent_initial_value) {
/* Make sure we don't send motion until there's real activity on this axis */
const int MAX_ALLOWED_JITTER = SDL_JOYSTICK_AXIS_MAX / 80; /* ShanWan PS3 controller needed 96 */
@@ -1033,7 +1032,7 @@ SDL_PrivateJoystickAxis(SDL_Joystick * joystick, Uint8 axis, Sint16 value)
return 0;
}
info->sent_initial_value = SDL_TRUE;
- info->value = value; /* Just so we pass the check above */
+ info->value = ~value; /* Just so we pass the check above */
SDL_PrivateJoystickAxis(joystick, axis, info->initial_value);
}
@@ -1773,29 +1772,29 @@ SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_JoystickGUID guid)
https://raw.githubusercontent.com/denilsonsa/udev-joystick-blacklist/master/generate_rules.py
*/
static Uint32 joystick_blacklist[] = {
- /* Microsoft Microsoft Wireless Optical Desktop® 2.10 */
+ /* Microsoft Microsoft Wireless Optical Desktop?? 2.10 */
/* Microsoft Wireless Desktop - Comfort Edition */
MAKE_VIDPID(0x045e, 0x009d),
- /* Microsoft Microsoft® Digital Media Pro Keyboard */
+ /* Microsoft Microsoft?? Digital Media Pro Keyboard */
/* Microsoft Corp. Digital Media Pro Keyboard */
MAKE_VIDPID(0x045e, 0x00b0),
- /* Microsoft Microsoft® Digital Media Keyboard */
+ /* Microsoft Microsoft?? Digital Media Keyboard */
/* Microsoft Corp. Digital Media Keyboard 1.0A */
MAKE_VIDPID(0x045e, 0x00b4),
- /* Microsoft Microsoft® Digital Media Keyboard 3000 */
+ /* Microsoft Microsoft?? Digital Media Keyboard 3000 */
MAKE_VIDPID(0x045e, 0x0730),
- /* Microsoft Microsoft® 2.4GHz Transceiver v6.0 */
- /* Microsoft Microsoft® 2.4GHz Transceiver v8.0 */
+ /* Microsoft Microsoft?? 2.4GHz Transceiver v6.0 */
+ /* Microsoft Microsoft?? 2.4GHz Transceiver v8.0 */
/* Microsoft Corp. Nano Transceiver v1.0 for Bluetooth */
/* Microsoft Wireless Mobile Mouse 1000 */
/* Microsoft Wireless Desktop 3000 */
MAKE_VIDPID(0x045e, 0x0745),
- /* Microsoft® SideWinder(TM) 2.4GHz Transceiver */
+ /* Microsoft?? SideWinder(TM) 2.4GHz Transceiver */
MAKE_VIDPID(0x045e, 0x0748),
/* Microsoft Corp. Wired Keyboard 600 */
@@ -1807,16 +1806,16 @@ SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_JoystickGUID guid)
/* Microsoft Corp. Arc Touch Mouse Transceiver */
MAKE_VIDPID(0x045e, 0x0773),
- /* Microsoft® 2.4GHz Transceiver v9.0 */
- /* Microsoft® Nano Transceiver v2.1 */
+ /* Microsoft?? 2.4GHz Transceiver v9.0 */
+ /* Microsoft?? Nano Transceiver v2.1 */
/* Microsoft Sculpt Ergonomic Keyboard (5KV-00001) */
MAKE_VIDPID(0x045e, 0x07a5),
- /* Microsoft® Nano Transceiver v1.0 */
+ /* Microsoft?? Nano Transceiver v1.0 */
/* Microsoft Wireless Keyboard 800 */
MAKE_VIDPID(0x045e, 0x07b2),
- /* Microsoft® Nano Transceiver v2.0 */
+ /* Microsoft?? Nano Transceiver v2.0 */
MAKE_VIDPID(0x045e, 0x0800),
MAKE_VIDPID(0x046d, 0xc30a), /* Logitech, Inc. iTouch Composite keboard */
diff --git a/test/controllermap.c b/test/controllermap.c
index 6ef360a..ced9304 100644
--- a/test/controllermap.c
+++ b/test/controllermap.c
@@ -473,7 +473,7 @@ WatchJoystick(SDL_Joystick * joystick)
if (!pAxisState->m_bMoving) {
Sint16 nInitialValue;
pAxisState->m_bMoving = SDL_JoystickGetAxisInitialState(joystick, event.jaxis.axis, &nInitialValue);
- pAxisState->m_nLastValue = nInitialValue;
+ pAxisState->m_nLastValue = nValue;
pAxisState->m_nStartingValue = nInitialValue;
pAxisState->m_nFarthestValue = nInitialValue;
} else if (SDL_abs(nValue - pAxisState->m_nLastValue) <= MAX_ALLOWED_JITTER) {