From 57cbec1095182a07472d2302bd3ae66e76535636 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 28 Aug 2022 23:18:40 -0700 Subject: [PATCH] Added controller mappings for Xbox 360, PS4, and PS5 controllers on OpenBSD Removed the axis flipping hack for Xbox controllers which would actually apply to any controller with a full 16-bit range. Fixes https://github.com/libsdl-org/SDL/issues/6143 --- src/joystick/SDL_gamecontrollerdb.h | 5 +++++ src/joystick/bsd/SDL_bsdjoystick.c | 12 ------------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/joystick/SDL_gamecontrollerdb.h b/src/joystick/SDL_gamecontrollerdb.h index 181e688a3..0094a7ddb 100644 --- a/src/joystick/SDL_gamecontrollerdb.h +++ b/src/joystick/SDL_gamecontrollerdb.h @@ -846,6 +846,11 @@ static const char *s_ControllerMappings [] = "03000000b50700001503000010010000,impact,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,", "030000009b2800000300000001010000,raphnet.net 4nes4snes v1.5,a:b0,b:b4,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b1,y:b5,", #endif +#if defined(__OpenBSD__) + "030000004c050000c405000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", + "030000004c050000e60c000000010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", + "030000005e0400008e02000010010000,Xbox 360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1~,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4~,start:b7,x:b2,y:b3,", +#endif #if defined(__ANDROID__) "05000000c82d000006500000ffff3f00,8BitDo M30 Gamepad,a:b0,b:b1,back:b4,guide:b17,leftshoulder:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,righttrigger:a4,start:b6,x:b2,y:b3,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "05000000c82d000006500000ffff3f00,8BitDo M30 Gamepad,a:b1,b:b0,back:b4,guide:b17,leftshoulder:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,righttrigger:a4,start:b6,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", diff --git a/src/joystick/bsd/SDL_bsdjoystick.c b/src/joystick/bsd/SDL_bsdjoystick.c index 59780d2da..94b20788b 100644 --- a/src/joystick/bsd/SDL_bsdjoystick.c +++ b/src/joystick/bsd/SDL_bsdjoystick.c @@ -731,18 +731,6 @@ BSD_JoystickUpdate(SDL_Joystick *joy) naxe = joy->hwdata->axis_map[joyaxe]; /* scaleaxe */ v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); -#ifdef __OpenBSD__ - /* XInput controllermapping relies on inverted Y axes. - * These devices have a 16bit signed space, as opposed - * to older DInput devices (8bit unsigned), so - * hitem.logical_maximum can be used to differentiate them. - */ - if ((joyaxe == JOYAXE_Y || joyaxe == JOYAXE_RY) - && hitem.logical_maximum > 255) { - if (v != 0) - v = ~v; - } -#endif v -= (hitem.logical_maximum + hitem.logical_minimum + 1) / 2; v *= 32768 /