Log In  

I have a controller connected to my laptop. To configure pico-8 for it, I did : launch Gamepad Tool > Copy Mapping String > append string to sdl_controllers.txt > relaunch pico-8. This works well.

Now, I would like to use the controller's shoulder buttons as replacements for the d-pad's dpleft (btn 0) and dpright (btn 1), respectively. Can this be done at all? Note that this is not for exported (to html) games but rather to those launched from the pico-8 console.

EDIT:
To be clear, I'd like to control a pico-8 game using a gamepad's shoulder buttons.

EDIT2:
GamepadTool mapping string, as entered in sdl_controllers.txt is this:
03000000bd12000015d0000000010000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,

P#71408 2019-12-26 02:50 ( Edited 2019-12-26 03:43)

:: alexr

I'll answer my own question, in case someone else has the same.

Per pico8_manual.txt, I followed this thread, customized my mapping string entry in sdl_controllers.txt, from:
03000000bd12000015d0000000010000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,

to:
03000000bd12000015d0000000010000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:b4,dpright:b5,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,

and it worked. Right/left shoulder buttons are now recognized as btn 0 and 1, respectively.

Of course, being able to do this on a per-game basis, since this overrides a gamepad's d-pad functionality that everyone expects, would be important. And you can't. There seems to be no way to associate custom mappings to a specific game via a local (same dir as game.p8 file) override of sdl_controllers.txt. Bummer.

Happy holidays.

P#71411 2019-12-26 03:40 ( Edited 2019-12-26 04:15)
:: zlg

As you note, this is less of a PICO-8 problem and more of an SDL problem. SDL's controller interface is based on explicit hardware matches. The 03000000bd12... thing is the kernel's ID for the controller, so it won't match for every system, or in some systems might not even match with a different port.

In short, there isn't really a way to do this reliably. How do we know which buttons are the shoulder buttons? One typically uses diagnostic programs to identify button and axis numbers. These aren't universal, either. Hardware revisions are a thing. Submodels are a thing. Regions are a thing. All of these can make configuring manually a pain.

To add to this, PICO-8 as a system does not have a controller with shoulder buttons. We get four directions, a pause button, and two action buttions. Anything more requires activating dev features like keyboard and mouse support.

Sadly, I think this sort of thing is limited. I would instead look into multiple mappings for the same command. If SDL can map an action to more than one button, then you can simply map the shoulder buttons to left and right, alongside the d-pad.

If SDL can't do multi-mapping, you'll still be stuck with the problem of reversing this when you're done playing that one game, but given that you're on OSX, you can automate this and create a launcher for that one game that sets the SDL controller stuff, runs PICO-8 with that game, and sets the SDL stuff back after PICO-8 exits. Boom. :)

EDIT: Found a helpful link: https://wiki.libsdl.org/CategoryGameController

I haven't found a good resource on explaining the text file's format. Such a page would include ways to map multiple hardware buttons to an SDL event in its description of the syntax.

P#72947 2020-02-09 22:06 ( Edited 2020-02-09 22:36)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-02-17 18:15 | 0.009s | 4194k | Q:13