The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
[PATCH] Add a Dualshock 4 mapping to the game controller db
Frank Praznik
Guest

This patch adds a mapping to the game controller database header for the
Sony Dualshock 4 controller in Linux.

---
diff -r fce84c934f9e src/joystick/SDL_gamecontrollerdb.h
--- a/src/joystick/SDL_gamecontrollerdb.h Sat Jan 25 16:08:39 2014 -0500
+++ b/src/joystick/SDL_gamecontrollerdb.h Tue Feb 04 17:26:11 2014 -0500
@@ -57,6 +57,7 @@
"030000006d04000019c2000011010000,Logitech F710 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */
"030000006d0400001fc2000005030000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,",
+ "030000004c050000c405000011010000,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,",
"03000000de280000ff11000001000000,Valve Streaming Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
[PATCH] Add a Dualshock 4 mapping to the game controller db
gabomdq


Joined: 28 Jul 2011
Posts: 495
Location: Argentina
2014-02-04 19:37 GMT-03:00 Frank Praznik:
Quote:
This patch adds a mapping to the game controller database header for the
Sony Dualshock 4 controller in Linux.

---
diff -r fce84c934f9e src/joystick/SDL_gamecontrollerdb.h
--- a/src/joystick/SDL_gamecontrollerdb.h       Sat Jan 25 16:08:39 2014 -0500
+++ b/src/joystick/SDL_gamecontrollerdb.h       Tue Feb 04 17:26:11 2014 -0500
@@ -57,6 +57,7 @@
     "030000006d04000019c2000011010000,Logitech F710 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */
     "030000006d0400001fc2000005030000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
     "030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,",
+    "030000004c050000c405000011010000,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,",
     "03000000de280000ff11000001000000,Valve Streaming Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
     "030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
     "030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",



Thanks, I added it here: https://github.com/gabomdq/SDL_GameControllerDB


--
Gabriel.
[PATCH] Add a Dualshock 4 mapping to the game controller db
Ryan C. Gordon
Guest

On 2/4/14, 5:37 PM, Frank Praznik wrote:
Quote:
This patch adds a mapping to the game controller database header for the
Sony Dualshock 4 controller in Linux.

Went a step further and added Windows and Mac OS X support, too.

https://hg.libsdl.org/SDL/rev/a3b4d7e5eb8e

Tested with USB cable (couldn't coerce Bluetooth to work at all,
unrelated to SDL).

--ryan.


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Re: [PATCH] Add a Dualshock 4 mapping to the game controller
goldbuick


Joined: 08 Feb 2014
Posts: 3
Ryan C. Gordon wrote:
On 2/4/14, 5:37 PM, Frank Praznik wrote:
Quote:
This patch adds a mapping to the game controller database header for the
Sony Dualshock 4 controller in Linux.

Went a step further and added Windows and Mac OS X support, too.

https://hg.libsdl.org/SDL/rev/a3b4d7e5eb8e

Tested with USB cable (couldn't coerce Bluetooth to work at all,
unrelated to SDL).

--ryan.

On Mac I was able to get bluetooth to work. but I had to supplement how the joystick meta-data is retrieved.
I have no idea how to submit a patch. But I would love to contribute!
BTW, PS4 controller via bluetooth is so so nice on Mac

-- david
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
[PATCH] Add a Dualshock 4 mapping to the game controller db
Ryan C. Gordon
Guest

Quote:
On Mac I was able to get bluetooth to work. but I had to supplement how
the joystick meta-data is retrieved.

You can send the patch to me (or the mailing list). What did you have to
do to make this work? I literally get an error in the kernel logs on Mac
OS X when I pair the device, and a dictionary that IOKit is supposed to
give me comes in as a string with the same error message as the kernel log.

--ryan.


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
goldbuick


Joined: 08 Feb 2014
Posts: 3
I discovered that this example application could see all the controller meta-data

https://developer.apple.com/library/mac/samplecode/HID_Dumper/Introduction/Intro.html#//apple_ref/doc/uid/DTS40008869-Intro-DontLinkElementID_2

it uses a different HID api than what SDL uses.
IOHIDManagerCreate etc..

but they're really really similar. So I did something hacky, I match up serial numbers and use
IOHIDManagerCreate to grab the meta-data, turn it into a dictionary and call HIDAddElement(element, pDevice); on it.
Because the API that SDL still works. It just has a problem getting the meta-data of the device. But once you have it, you're good to go.

I changed two files darwin/SDL_sysjoystick.c & darwin/SDL_sysjoystick_c.h

I can just send the files to you?

Really the best long term solution is to re-write the wrapper code to use IOHIDManager API. It seems like that is the newer one of the two?

--david

P.S. I am excited to help! developing with the PS4 controller on mac is so so much fun Smile
goldbuick


Joined: 08 Feb 2014
Posts: 3
dropbox link with the two files

-- david
[PATCH] Add a Dualshock 4 mapping to the game controller db
Ryan C. Gordon
Guest

Quote:
it uses a different HID api than what SDL uses.
IOHIDManagerCreate etc..

Ah, yes, this API was introduced in Mac OS X 10.5. Updating SDL to use
it is on the TODO list. I'm just surprised the controller works through
that API and not the older one (I always assumed HIDManager was built on
top of the old HID Utilities API, to offer a nicer API to
programmers...perhaps I was wrong about that).

--ryan.


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
[PATCH] Add a Dualshock 4 mapping to the game controller db
Frank Praznik
Guest

Quote:
Went a step further and added Windows and Mac OS X support, too.

https://hg.libsdl.org/SDL/rev/a3b4d7e5eb8e

Tested with USB cable (couldn't coerce Bluetooth to work at all,
unrelated to SDL).

--ryan.
Bluetooth support requires BlueZ 5.14 or later as there were some issues
preventing the controller from connecting. Unfortunately, Debian based
distros are still on BlueZ version 4.x and won't work unless someone
backports the necessary fixes or they move to version 5.

Currently kernel 3.14 will have full support (rumble, LEDs and
accelerometers) for the DS4 on USB. Full featured support on Bluetooth
required some architectural changes in the Linux HID driver and full
support won't be in until 3.15.
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org