Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SDL2 Button Mapping incorrect
#1
Hi,
trying to run an SDL2 app on my RS2 and it seems the Buttons A & B as well as X & Y are swapped in the provided mapping.

Actual:
Quote:INFO: Following Mapping is used: 00000000526574726f53746f6e653200,RetroStone2 Controle,platform:Linux,a:b1,b:b0,x:b3,y:b2,back:b8,start:b9,leftshoulder:b4,rightshoulder:b5,dpup:b10,dpdown:b11,dpleft:b12,dpright:b13,leftx:a0,lefty:a1,lefttrigger:b6,righttrigger:b7,
Expectation
Quote:INFO: Following Mapping is used: 00000000526574726f53746f6e653200,RetroStone2 Console,a:b0,b:b1,x:b2,y:b3,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,back:b8,leftx:a0,lefty:a1,platform:Linux

Can anyone point me to the place where this can be changed?
Reply
#2
it has to be changed in SDL2 code, please open an issue in our github https://github.com/retr0rangepi/RetrOrangePi

if you want to do it by yourself, must change src/joystick/SDL_gamecontrollerdb.h
recompile it with KMS backend
Reply
#3
I'm trying to construct an SDL2 gamepad mapping to feed into PICO-8. I tried using this, as provided by maximilianvoss:

Quote:
00000000526574726f53746f6e653200,RetroStone2 Console,a:b0,b:b1,x:b2,y:b3,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,back:b8,leftx:a0,lefty:a1,platform:Linux


But none of the integrated gamepad buttons worked at all. 

So, I tried (hard) to research how to validate this with my own hardware to see what might be wrong. Near as I can tell, the device ID doesn't match my hardware, but I can't find any KBs anywhere that explains how to translate this into the above SDL2 format:

$ cat /proc/bus/input/devices
Code:
...
 I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="RetroStone2 Controle"
P: Phys=
S: Sysfs=/devices/virtual/input/input1
U: Uniq=
H: Handlers=js0 event1
B: PROP=0
B: EV=b
B: KEY=f 0 0 0 0 0 0 0 fdb0000 0 0 0 0 0 0 0 0 0
B: ABS=3
...

Can someone help?
Reply
#4
Hi megashub,
in my SDL code i have following function which shows the device's mapping.
CONTROLLER_MAPPING is my defined mapping which you see in the post above.

Code:
void inputhandler_init() {
    if (SDL_GameControllerAddMapping(CONTROLLER_MAPPING)) {
        SDL_Log("Failed to add mapping: %s", SDL_GetError());
    }

    gameControllerCount = SDL_NumJoysticks();
    SDL_Log("There are %d gamepads attached\n", gameControllerCount);

    if (gameControllerCount > 0) {
        gameControllers = (SDL_GameController **) calloc(gameControllerCount, sizeof(SDL_GameController *));

        for (int i = 0; i < gameControllerCount; ++i) {
            gameControllers[i] = SDL_GameControllerOpen(i);
            if (gameControllers[i] == NULL) {
                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GameControllerOpen(%d) failed: %s\n", i,
                            SDL_GetError());
            }
            char *mapping = SDL_GameControllerMapping(gameControllers[i]);
            SDL_Log("Following Mapping is used: %s\n", mapping);
            SDL_free(mapping);
        }
    }
}
Reply
#5
AFAIK, Pico-8 is not SDL2 based, so i'm afraid it wont work , or maybe i'm lacking knowledge
Reply
#6
(06-17-2020, 06:36 PM)alexkidd Wrote: AFAIK, Pico-8 is not SDL2 based, so i'm afraid it wont work , or maybe i'm lacking knowledge

Hmm. I'm only just getting familiar with it myself, but this is what I've been working off of: 
https://pico-8.fandom.com/wiki/Controllers


(06-17-2020, 06:19 PM)maximilianvoss Wrote: Hi megashub,
in my SDL code i have following function which shows the device's mapping.
CONTROLLER_MAPPING is my defined mapping which you see in the post above.

Code:
void inputhandler_init() {
    if (SDL_GameControllerAddMapping(CONTROLLER_MAPPING)) {
        SDL_Log("Failed to add mapping: %s", SDL_GetError());
    }

    gameControllerCount = SDL_NumJoysticks();
    SDL_Log("There are %d gamepads attached\n", gameControllerCount);

    if (gameControllerCount > 0) {
        gameControllers = (SDL_GameController **) calloc(gameControllerCount, sizeof(SDL_GameController *));

        for (int i = 0; i < gameControllerCount; ++i) {
            gameControllers[i] = SDL_GameControllerOpen(i);
            if (gameControllers[i] == NULL) {
                SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GameControllerOpen(%d) failed: %s\n", i,
                            SDL_GetError());
            }
            char *mapping = SDL_GameControllerMapping(gameControllers[i]);
            SDL_Log("Following Mapping is used: %s\n", mapping);
            SDL_free(mapping);
        }
    }
}

Thank you so much for sharing this. As this is my first foray into SDL, I'm afraid I'm going to have to beg for forgiveness and ask for an ELI5 on how to employ this in ROpi. I'm no stranger to the concepts involved, just not yet familiar with SDL. I'm happy to work through it myself, if there's a decent KB you can recommend?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  A button for launch options not effective rolle 1 537 07-29-2020, 06:54 AM
Last Post: CISKO
  (RetroStone2) Power button customization isn't working cisco1987 4 1,899 06-26-2020, 10:03 AM
Last Post: modo_lv
  NDS Mapping ShamSham 2 709 06-11-2020, 04:18 PM
Last Post: CISKO
  mid-game [power-button] confirm: press A to shut-down pushka 1 980 02-25-2020, 11:11 AM
Last Post: hando
  Unit button mappings Stargx 1 817 02-07-2020, 05:37 PM
Last Post: alexkidd
  Button mappings Stargx 4 1,824 02-03-2020, 09:34 AM
Last Post: Stargx
  A - red button Xavier31 1 804 01-28-2020, 09:20 PM
Last Post: alexkidd
  The Select Button Hates Me. Valden 1 833 01-25-2020, 12:11 AM
Last Post: alexkidd

Forum Jump:


Users browsing this thread: 1 Guest(s)