Viewing 28 posts - 1 through 28 (of 28 total)
  • Author
    Posts
  • bradj074
    Participant
    Post count: 8

    I have a Retropie GPIO added into my pi (rev 2) that i put in a SNES. I wired the button on the GPIO to my reset button on the SNES but it isn’t functioning quite like i would prefer. I simply would like for the switch to press the escape key after one press (not 3) and nothing more (no 1 press for “r” or shutdown on 5).

    I cannot find where\which file of SNESDev-Pi needs to be modified to accomplish this. Which file should i change and how should i change it to adjust to this result?

    petrockblog
    Keymaster
    Post count: 1827

    Currently, you would have to modify the lines around https://github.com/petrockblog/SNESDev-RPi/blob/master/src/SNESDev.c#L287 and recompile/reinstall SNESDev.

    I plan to make this configurable when I find some time.

    bradj074
    Participant
    Post count: 8

    Awesome, thanks for the help. I’ve got it edited the way i need to.

    Now for my dumb question, how do i recompile and reinstall SNESDEV?

    supersirlink
    Participant
    Post count: 42

    Would like to know how to do this as well… :)

    petrockblog
    Keymaster
    Post count: 1827

    With the recent version of SNESDev, you need to run ./build from within the directory /home/pi/RetroPie/supplementary/SNESDev-Rpi/. After the compilation has finished, you need to copy the new executable to /usr/local/bin via

    sudo cp "/home/pi/RetroPie/supplementary/SNESDev-Rpi/SNESDev" /usr/local/bin/

    and restart SNESDev via

    sudo service SNESDev restart

    I know that this should be easier – in the best case the button behavior could also be configured via the config file. But I did not find the time to implement that feature yet.

    supersirlink
    Participant
    Post count: 42

    That’s not bad at all! I changed the single press from R to H to reset the ROM and kept 3 and 5 press as is for now… I got the GPIO board the other day and plan to wire it up this weekend! I also got a shutdown switch from Mausberry Circuits that I will be wiring up to power/shutdown… Thanks!

    bradj074
    Participant
    Post count: 8

    i modified the SNESDev.c lines in the coding in several different ways and am not having any luck getting it to register correctly. I have confirmed the button itself functions with the original code so it is in my editing.

    I have pasted the modified code i tried that is the same method supersirlink said he had written in the interest of helping out both of us (i used the escape key instead of h). I left the shutdown command in and that will function if it gets those 5 key presses but for some reason it will not register any of the esc keys.

    Can you have a look at the coding and tell me how it should be properly coded?

    case BTN_STATE_PRESSED:
    if (button.pressedCtr == 1 && button.duration >= 1) {
    uinput_kbd_write(&uinp_kbd, KEY_ESC, 1, EV_KEY);
    }
    break;
    case BTN_STATE_RELEASED:
    if (button.pressedCtr == 1 && button.duration >= 1) {
    uinput_kbd_write(&uinp_kbd, KEY_ESC, 0, EV_KEY);
    } else if (button.pressedCtr == 3 && button.duration >= 1) {
    // Sending ESC
    uinput_kbd_write(&uinp_kbd, KEY_ESC, 1, EV_KEY);
    usleep(50000);
    uinput_kbd_write(&uinp_kbd, KEY_ESC, 0, EV_KEY);
    } else if (button.pressedCtr == 5 && button.duration >= 1) {
    uinput_kbd_write(&uinp_kbd, KEY_ESC, 1, EV_KEY);
    usleep(50000);
    uinput_kbd_write(&uinp_kbd, KEY_ESC, 0, EV_KEY);
    // shutting down
    system(“shutdown -t 3 -h now”);

    supersirlink
    Participant
    Post count: 42

    Do you have this line defined in one of your retroarch.cfg files:
    input_enable_hotkey_btn = 6

    I found when I set that, I have to use the hotkey to send ANY commands, even from the keyboard. My momentary switch works when I hold down the hotkey button then press the switch…

    supersirlink
    Participant
    Post count: 42

    If all you want is ESC, try this:

    if (confres.button_enabled) {
                            btn_read(&button);
    
                            switch (button.state) {
                            case BTN_STATE_IDLE:
                                    break;
                            case BTN_STATE_PRESSED:
                                    if (button.pressedCtr == 1 && button.duration >= 1) {
                                            uinput_kbd_write(&uinp_kbd, KEY_ESC, 1, EV_KEY);
                                    }
                                    break;
                            case BTN_STATE_RELEASED:
                                            if (button.pressedCtr == 1 && button.duration >= 1) {
                                                    uinput_kbd_write(&uinp_kbd, KEY_ESC, 0, EV_KEY);
                                            }
                                    break;
                            }
                    }
    
                    /* wait for some time to keep the CPU load low */
    
    supersirlink
    Participant
    Post count: 42

    Florian, can we put a key combination in the code, like say KEY_ALT+ESC, or KEY_ALT+H?

    brooksyx
    Participant
    Post count: 81

    [quote=3492]If all you want is ESC, try this:

    [/quote]

    Thanks for this. I went ahead and forked the main repo. Will try to rebuild from my own tonight.

    Also I trying to wire this up to the reset button on the snes. Does anyone know which pins I need to short out? I would imagine it would be the 2 larger ones on the bottom.

    supersirlink
    Participant
    Post count: 42

    Chances are 2 pins are for the circuit and the other(s) are support. Test for continuity across all the points, with the switch depressed and open.

    If you do this on the switch provided with the GPIO board, you will see the outer 2 are isolated from the inner 2. And the corresponding holes on the board are also isolated. (Sometimes can be ground, but I didn’t see that. )

    So for mine, I used a NES reset switch, I picked up the middle two points.

    I actually soldered a connector there for easy removal.

    brooksyx
    Participant
    Post count: 81

    [quote=3512]Chances are 2 pins are for the circuit and the other(s) are support. Test for continuity across all the points, with the switch depressed and open.

    If you do this on the switch provided with the GPIO board, you will see the outer 2 are isolated from the inner 2. And the corresponding holes on the board are also isolated. (Sometimes can be ground, but I didn’t see that. )

    So for mine, I used a NES reset switch, I picked up the middle two points.

    I actually soldered a connector there for easy removal.
    [/quote]

    Thanks, makes sense. However I am not sure I know what you mean when you say the middle 2, as there are only 4, one on each corner. I assume you mean the two larger holes on the bottom. I did check to see if the resistance changed when the button was pressed with a multiometer and did not notice a change.

    edit:

    Do I need short the red points or the blue points?

    1

    supersirlink
    Participant
    Post count: 42

    It’s the red ones… You don’t want to check for resistance, but continuity… Should make a sound and show a value when the probes are touched…

    supersirlink
    Participant
    Post count: 42

    I haven’t managed to find if you can send a key sequence with the script… Anyone know if that is possible?

    brooksyx
    Participant
    Post count: 81

    Thanks much! Gonna wire it up later tonight.

    brooksyx
    Participant
    Post count: 81

    [quote=3411]With the recent version of SNESDev, you need to run ./build from within the directory /home/pi/RetroPie/supplementary/SNESDev-Rpi/. After the compilation has finished, you need to copy the new executable to /usr/local/bin via

    sudo cp "/home/pi/RetroPie/supplementary/SNESDev-Rpi/SNESDev" /usr/local/bin/

    and restart SNESDev via

    sudo service SNESDev restart

    I know that this should be easier – in the best case the button behavior could also be configured via the config file. But I did not find the time to implement that feature yet.
    [/quote]

    I can’t build from /home/pi/RetroPie/supplementary/SNESDev-Rpi as there is no build.sh there. I tried building from /home/pi/SNESDev-RPi/ and copying that to /usr/local/bin/ but I get a /etc/snesdev.cfg not found when I do that.

    Any tips on how to fix this or way to completely remove SNESDev and re-install it?

    Thanks!

    petrockblog
    Keymaster
    Post count: 1827

    If you start with the RetroPie SD-card image, first you need to install SNESDev from sources (e.g., via the RetroPie-Setup Script, source-baseed installation, select only SNESDev). The file build.sh is available afterwards.

    petrockblog
    Keymaster
    Post count: 1827

    [quote=3493]Florian, can we put a key combination in the code, like say KEY_ALT+ESC, or KEY_ALT+H?[/quote]
    I have not tried this myself, but I would guess that something like

                            case BTN_STATE_PRESSED:
                                    if (button.pressedCtr == 1 && button.duration >= 1) {
                                            uinput_kbd_write(&uinp_kbd, KEY_LEFTALT,  1, EV_KEY);
                                            uinput_kbd_write(&uinp_kbd, KEY_H, 1, EV_KEY);
                                    }
                                    break;
                            case BTN_STATE_RELEASED:
                                            if (button.pressedCtr == 1 && button.duration >= 1) {
                                                    uinput_kbd_write(&uinp_kbd, KEY_LEFTALT, 0, EV_KEY);
                                                    uinput_kbd_write(&uinp_kbd, KEY_H, 0, EV_KEY);
                                            }
                                    break;

    could work.

    See, e.g., http://www.cs.fsu.edu/~baker/devices/lxr/http/source/linux/include/linux/input.h?v=2.6.11.8#L164 for a complete list of key codes.

    brooksyx
    Participant
    Post count: 81

    [quote=3524]If you start with the RetroPie SD-card image, first you need to install SNESDev from sources (e.g., via the RetroPie-Setup Script, source-baseed installation, select only SNESDev). The file build.sh is available afterwards.[/quote]

    I did use the sd card image but I installed SNESDev via github and not via retropie_setup.sh. If thats what you are saying. I have SNESDev at /home/pi/SNESDev-RPi/ , can I install it from this location or do I need to run the retropie_setup.sh to add the additional files to /home/pi/RetroPie/supplements/SNESDev-Rpi/ ?

    bradj074
    Participant
    Post count: 8

    I tried Petrockblog’s most recent idea of entering two commands for key pressed to be able to use hotkeys and confirmed it does not work. I can get the GPIO button to function while holding down my function key on the gamepad but mapping two button commands to one command did not provide any results. Let me know if anyone else has any ideas so we can get this all figured out!

    brooksyx
    Participant
    Post count: 81

    Now I am really confused. I just did a fresh install and added SNESDev from my own forked repo which is set to exit back to emulation station after one press. However it is still 3 presses. What did I do wrong? I am positive I added my own correct repo. git clone git://github.com/brooksyx/SNESDev-RPi.git

    petrockblog
    Keymaster
    Post count: 1827

    [quote=3529]Now I am really confused. I just did a fresh install and added SNESDev from my own forked repo which is set to exit back to emulation station after one press. However it is still 3 presses. What did I do wrong? I am positive I added my own correct repo. git clone git://github.com/brooksyx/SNESDev-RPi.git[/quote]
    If you are running SNESDev as a service, you need to copy the new binary to /usr/local/bin/, see https://github.com/retropie/RetroPie-Setup/blob/master/scriptmodules/supplementary.shinc#L210.

    brooksyx
    Participant
    Post count: 81

    Okay, I gotcha. Looks like it copied over a precompiled version from the retropie setup. Thanks again!

    supersirlink
    Participant
    Post count: 42

    [quote=3528]I tried Petrockblog’s most recent idea of entering two commands for key pressed to be able to use hotkeys and confirmed it does not work. I can get the GPIO button to function while holding down my function key on the gamepad but mapping two button commands to one command did not provide any results. Let me know if anyone else has any ideas so we can get this all figured out![/quote]

    There was an extra space after the comma after leftalt, be sure you only have one space… Also you will need to put the correct key in for the hot key assignment you made… Thats where I put two hot keys in my retroarch.cfg

    I have one hot key defined for my controller and one for the keyboard. That way I can input commands from the controller OR keyboard without having to grab both…

    input_enable_hotkey = alt
    input_enable_hotkey_btn = 6
    case BTN_STATE_PRESSED:
                                    if (button.pressedCtr == 1 && button.duration >= 1) {
    										uinput_kbd_write(&uinp_kbd, KEY_LEFTALT, 1, EV_KEY);
                                            uinput_kbd_write(&uinp_kbd, KEY_R, 1, EV_KEY);
                                    }
                                    break;
                            case BTN_STATE_RELEASED:
                                            if (button.pressedCtr == 1 && button.duration >= 1) {
    												uinput_kbd_write(&uinp_kbd, KEY_LEFTALT, 0, EV_KEY);
                                                    uinput_kbd_write(&uinp_kbd, KEY_R, 0, EV_KEY);
    

    And just to confirm this worked for me… I push the momentary switch and with the assignments above, the rom resets (without having to touch the controller or keyboard)…

    Thanks Florian!

    brooksyx
    Participant
    Post count: 81

    [quote=3534]

    <div class=”d4p-bbt-quote-title”>brooksyx wrote:</div>
    Now I am really confused. I just did a fresh install and added SNESDev from my own forked repo which is set to exit back to emulation station after one press. However it is still 3 presses. What did I do wrong? I am positive I added my own correct repo. git clone git://github.com/brooksyx/SNESDev-RPi.git

    If you are running SNESDev as a service, you need to copy the new binary to /usr/local/bin/, see https://github.com/retropie/RetroPie-Setup/blob/master/scriptmodules/supplementary.shinc#L210.
    [/quote]

    I don’t seem to be having any luck compiling my own version of SNESDev and overwriting the prebuilt one. I backed up SNESDev in /usr/local/bin/ as SNESDev and overwrote with the one I compiled but it says its needs /etc/snesdev.cfg. So I copied the file in /home/pi/SNESDev-RPi/scipts/SNESDev over to etc as snesdev.cfg and it gives an error. Is that snesdev.cfg file from my build in a different location in SNESDev-RPi?

    petrockblog
    Keymaster
    Post count: 1827

    The cfg file is located in /home/pi/RetroPie/supplementary/SNESDev-Rpi/supplementary/.

    brooksyx
    Participant
    Post count: 81

    I don’t remember off of the top of my head but I don’t believe I saw it in there. Is it a hidden file? (Maybe that’s what you mean by “/.”?)

    edit: Well either way I just downloaded it from the repo. So even if I can’t find it I will just write this one. I would imagine it would work just fine.

    https://github.com/petrockblog/SNESDev-RPi/tree/master/supplementary

    edit: That fixed it. Working great with one button reboot now! Thanks x10

Viewing 28 posts - 1 through 28 (of 28 total)
  • The forum ‘Everything else related to the RetroPie Project’ is closed to new topics and replies.