SDL icon indicating copy to clipboard operation
SDL copied to clipboard

FF-GP1 not recognized as Game Controller

Open drfiemost opened this issue 2 years ago • 2 comments

Trying to make the Final Fantasy XIV game controller work with SDL2 (2.24.0) on Linux but SDL_IsGameController() returns false so we cannot get the button mappings.

We tried to add the configuration to the GameControllerDB and then load it with SDL_GameControllerAddMappingsFromFile (see https://github.com/gabomdq/SDL_GameControllerDB/issues/678) but it's still being recognized as "FUJIWORK CO., FF-GP1". The function returns 273 as the number of mappings added.

This is the mapping produced with SDL2 Gamepad Mapper and included in the gamecontrollerdb.txt file: 03005036852100000201000010010000,Final Fantasy XIV,a:b1,b:b2,x:b0,y:b3,back:b8,start:b9,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:-a0,+leftx:+a0,-lefty:-a1,+lefty:+a1,-rightx:-a2,+rightx:+a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Linux

The ID is slightly different from the one in the SDL2 internal DB: "03000000852100000201000000000000,FF-GP1,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,",

drfiemost avatar May 12 '23 07:05 drfiemost

Try this patch?

diff --git a/src/joystick/SDL_gamepad_db.h b/src/joystick/SDL_gamepad_db.h
index 0847a8c38..feca2cadc 100644
--- a/src/joystick/SDL_gamepad_db.h
+++ b/src/joystick/SDL_gamepad_db.h
@@ -611,6 +611,7 @@ static const char *s_GamepadMappings[] = {
     "050000004c050000f20d000000010000,DualSense Edge Wireless 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,",
     "030000006f0e00003001000001010000,EA Sports PS3 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:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
     "03000000790000001100000010010000,Elecom Gamepad,crc:e86c,a:b2,b:b3,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b0,y:b1,",
+    "03000000852100000201000010010000,Final Fantasy XIV,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,",
     "03000000b40400001124000011010000,Flydigi Vader 2,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b12,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b14,paddle1:b2,paddle2:b5,paddle3:b16,paddle4:b17,rightshoulder:b7,rightstick:b13,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,", /* Dongle */
     "03000000b40400001224000011010000,Flydigi Vader 2,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b12,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b2,paddle1:b16,paddle2:b17,paddle3:b14,paddle4:b15,rightshoulder:b7,rightstick:b13,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,", /* Wired */
     "05000000151900004000000001000000,Flydigi Vader 2,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b21,leftshoulder:b6,leftstick:b12,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b14,paddle1:b2,paddle2:b5,paddle3:b16,paddle4:b17,rightshoulder:b7,rightstick:b13,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,", /* Bluetooth */

slouken avatar May 12 '23 15:05 slouken

I cannot test personally as I don't own the controller, but will report back as soon as I have some news. Thanks!

drfiemost avatar May 13 '23 18:05 drfiemost

Did this work?

slouken avatar Nov 08 '23 04:11 slouken

Haven't got any feedback yet. @Silicomancer any chance you could check?

drfiemost avatar Nov 08 '23 15:11 drfiemost

I tested the patch via Hurrican game. See this issue: https://github.com/HurricanGame/Hurrican/issues/35 It didn't work. I don't know if it is a game issue or a SDL issue. Can't say much more since I am not involved in developing the game.

I guess the issue can only be cleared by having Hurrican and SDL developers look at the code together.

If there is a new game version to test, just tell me.

Silicomancer avatar Nov 08 '23 20:11 Silicomancer

Can you grab the SDL source code and build and run test/testcontroller?

You can get the code from: https://github.com/libsdl-org/SDL

You can build and test like this: cd SDL; mkdir -p build; cd build; cmake .. -DSDL_TESTS=ON; make; test/testcontroller

slouken avatar Nov 08 '23 20:11 slouken

Ok, build worked, GUI is running. It found the controller and pressing buttons makes number boxes on the right side green.

What else can I do?

Silicomancer avatar Nov 09 '23 14:11 Silicomancer

Press "Setup Mapping" and go through the mapping process, click "Copy" and paste it here.

slouken avatar Nov 09 '23 17:11 slouken

Ok, this is the result:

03005036852100000201000010010000,FUJIWORK CO. FF-GP1,crc:3650,platform:Linux,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,

Do the numbers on the right-hand side have any meaning? I have noticed that the numbers in the tool do not match the numbers printed on my gamepad. Also the letters of the buttons (X,Y,A,B) do not match those on my gamepad (it only has numbers). When mapping, I just made sure that the buttons on the picture have more or less the same position as on my gamepad. Did I do it right?

Silicomancer avatar Nov 09 '23 18:11 Silicomancer

You did it perfectly.

So if you open a terminal window and run: export SDL_GAMECONTROLLERCONFIG="03005036852100000201000010010000,FUJIWORK CO. FF-GP1,crc:3650,platform:Linux,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," and then launch a game from that terminal window, it should have the correct mapping for your controller.

slouken avatar Nov 09 '23 18:11 slouken

is it ok if we put it into the gamecontrollerdb and load it with SDL_GameControllerAddMappingsFromFile?

We've tried with the following line with no luck:

03000000852100000201000010010000,Final Fantasy XIV,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,

I see the Id is slightly different but don't understand the meaning.

drfiemost avatar Nov 09 '23 18:11 drfiemost

That should have worked as well, I'm not sure why that didn't work.

slouken avatar Nov 09 '23 19:11 slouken

You did it perfectly.

So if you open a terminal window and run: export SDL_GAMECONTROLLERCONFIG="03005036852100000201000010010000,FUJIWORK CO. FF-GP1,crc:3650,platform:Linux,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," and then launch a game from that terminal window, it should have the correct mapping for your controller.

Will this also work when running a flatpak wrapped game?

Silicomancer avatar Nov 12 '23 17:11 Silicomancer

I don't know, try it?

slouken avatar Nov 12 '23 18:11 slouken