Weird Controller Problems (yes, again)
-
@hansolo77 said in Weird Controller Problems (yes, again):
Looks like a couple of guys hijacked my thread though
I'm sorry I took the money!
-
LOL I was just kidding. No worries. We're all in this thing together. I'm spending my time soldering a blue LED to my NES, and learning about resistors because I want to have it wired on the GPIO rather than the Mausberry Circuit because the circuit cuts the LED before the system is fully off. Lots of good learning stuff. Have it working now. So my time is being well spent. :)
I just wish I knew more about Linux and programming so I could figure this stuff out on my own without having to ask for somebody to just do it for me.
-
@hansolo77 yeah a 220ohm resistor is good. If your blue led is a clear plastic and not blue if you use some wet 2000 grit sandpaper you can dissapate the led so it doesnt blind you when you look at it. But a colored led will always look better.
-
@meleu and Anybody Else...
Did you come up with anything I can try? This is still an unanswered issue. I'm game for anything (lol pun unintended). I tried to do some figuring out on my own.. these are some things I tried that didn't work:
- Change from " (double quotes) to ' (single quote) in the export command (I saw some scripts other people had written on other sites for other projects that said they had to be single quotes)
- Change the location of the export command to a totally different file (ie; crontrab by using @reboot, or a different autostart.sh file)
Something I've not tried to do is just manually edit those files you have listed that are calling on __joy2key_dev and just replace the input it's looking for from js0 and make it js2. That would probably be a harsh way to make it work but it probably would. The problem with that is if I ever get some kind of other controller issue, I might need to change them again. Changing 1 file is ideally easier than 3.
Is __joy2key_dev being implemented as a variable, or does this create a file somewhere that those other scripts are looking for? It looks like it's just creating a declaration for a variable. If that's the case, how do the other scripts find it? In my limited experience and examination of other scripts, variables are exclusive to the script it's running in. Is that what the export command does - make it a system-wide variable? I'm just trying to wrap my head around what's actually happening, in the hopes I'll be able to fix it on my own, or at least understand how the eventual fix actually works. :)
-
@hansolo77 said in Weird Controller Problems (yes, again):
variables are exclusive to the script it's running in. Is that what the export command does - make it a system-wide variable?
Not exactly system-wide. The
export
makes every child shell of the current shell "inherit" the variable.I made more tests and realized that problem is that when you
sudo
a script, it doesn't inherit that variable.Setting the device in a file was what I tried with this non-merged PR but it would work
runcommand.sh
only (what I now agree that isn't the best approach).I can use different controllers setting this variable when the scripts are not launched with sudo, but it doesn't solve your issue...
Unfortunately your issue remains unsolved... I'll keep trying.
-
At least it's a step in the right direction, and identified a possible cause as to why your original proposed fix didn't work. :) I'll keep my fingers crossed you'll figure something out.
-
I had a thought.. is there a way to maybe incorporate the Joystick-Selection addon into this? Since it goes in and configures default controllers on a per-emulator basis, could you simply add another "emulator" option called "EmulationStation", that would essentially set a default controller for everything outside RetroArch? Or is this something more deep-rooted into the OS, that a simple script to alter configs wouldn't work?
Still hoping a solution is found.
-
@hansolo77 I've found a way to make the sudo environment inherit
__joy2key_dev
. You have to add the following line to your/etc/sudoers
Defaults env_keep += "__joy2key_dev"
After the
Defaults
string there is a <TAB>. Note that using thesudo visudo
command is the recommended way to update/etc/sudoers
content, since it protects against many failure modes.My
/etc/sudoers
looks like this:# This file MUST be edited with the 'visudo' command as root. # # Please consider adding local content in /etc/sudoers.d/ instead of # directly modifying this file. # # See the man page for details on how to write a sudoers file. # Defaults env_reset Defaults mail_badpass Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" # added to export __joy2key_dev to sudo environments Defaults env_keep += "__joy2key_dev" # Host alias specification # User alias specification # Cmnd alias specification # User privilege specification root ALL=(ALL:ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL # See sudoers(5) for more information on "#include" directives: #includedir /etc/sudoers.d
@hansolo77 said in Weird Controller Problems (yes, again):
is there a way to maybe incorporate the Joystick-Selection addon into this?
Well, I was thinking on implement such functionality, but the main dev said that will do some more work on this subject, then I prefer to leave it to him.
-
Awesome work. I will give this a try later today (after Thanksgiving lunch is over and company has started leaving). I'm excited to find out if this is the fix I needed. So just to make sure, I still need to make sure I have the
export __joy2key_dev="/dev/input/js2"
inside the autostart.sh file correct? -
Ok new problem.
First of all, it didn't fix it. I tried to load up a game and pressed as many buttons as I could on the run-command window with my xbox controller, and nothing happened. I rebooted and checked to make sure, and YES, I have the export command in the autostart script, and the
/etc/sudoers
file looks like yours. I even added the # comments, and made sure it was a <TAB> betweenDefaults
andenv_keep
.The new problem is that now the NES controller doesn't trigger anything in the run-command now either. I further tested this with just the NES controller connected and the Xbox dongle disconnected, and it still doesn't work. Both controllers will work fine on their own as far as navigating inside ES, and playing games, but none of the joy2key functionality works.
-
So I played around with this some. I think the problem I'm having is related to the fact that the
__joy2key_dev
variable isn't created until right before ES starts. So when ES's autostart script finally creates the variable, the system environment still doesn't know that that should be stored in the/etc/sudoers
path. I managed to get everything back to normal (launching the run-command setup menus with a keypress on the Xbox controller and no NES connected) by # commenting out the entireexport __joy2key_dev="/dev/input/js2"
line from the autostart.sh file and removing the added line to the/etc/sudoers
file.I was just about to test re-adding the line to the
/etc/sudoers
file and leaving the autostart.sh unmodified (with the # comment still in), but now my system is fucked up. Don't know what happened, but I got a lot of text errors on my HDMI output. I unplugged the power, reconnected, and now all I have is the rainbow splash screen. So I might have just borked my whole system by trying to fix this. I've been doing nothing but SSH'ing into the Pi, and rebooting usingsudo reboot
, so I don't know what happened. :(I hate my life.
-
@hansolo77 WTF?! Calm down bro! I think that your current problem is unrelated with the
__joy2key_dev
we are messing...Sorry for giving incomplete instructions. I achieved what you are wanting to do here, using the following method:
- add
__joy2key_dev="/dev/input/jsX"
to the file/etc/environment
. Obviously you need to replacejsX
with the joystick you want to use. - add
Defaults env_keep += "__joy2key_dev"
to the file/etc/sudoers
(usingsudo visudo
is the best way to edit this file). - reboot.
Keep in mind the following:
- It is a "hardcoded" workaround, if you unplug or plug new controllers to the system, their respective
jsX
file may change. And it can bring confusion. - the scripts that use
joy2key.py
make it convert the0
button into an <enter> keystroke, and the1
button into a <tab> keystroke. But these buttons differs from joystick to joystick (model, manufacturer, etc.). - if the file you specified in your custom
__joy2key_dev
doesn't exist, the scripts won't get another one. (this can be improved with simple changes).
I hope you solve it and love your life again.
- add
-
Ok, there was apparently some major file corruptions. Not sure how it happened. When I took the SD card out and plugged it into my Windows Machine (so I could write a backed up image to the card) it prompted for Windows to attempt to repair. I let it, and it came back with THOUSANDS of files it tried to fix but just truncated. Needless to say, Windows failed to fix it. So I ended up just rewriting the backup image to the card, and I'm back to where I was. The only thing I had that I now don't was the scraped metadata I had stored on the SD card, so that's no biggie.
I tried what I was doing before the issue with the corruption happened. I still can't get it to work. Commenting out the export command in the autostart didn't fix anything with the sudoer's file. I still think the problem stems from not having the variable declared until right before ES starts, which in turn means the setting of the Default variable in sudoers won't do anything.
-
@meleu Aha, so I was on the right track! I needed to specify the variable
__joy2key_dev
somewhere. Just not in that autostart.sh file. I knew I was on to something. Like I said, I don't know enough about how Linux works to even know there was a/etc/evironment
file lol.
is the
/etc/environment
file supposed to be empty before I add my extra line? It looks like it is, I just want to make sure I'm editing the correct file. -
@hansolo77 said in Weird Controller Problems (yes, again):
is the
/etc/environment
file supposed to be empty before I add my extra line? It looks like it is, I just want to make sure I'm editing the correct file.Yeah! My
/etc/environment
here were empty before this change. -
@hansolo77 please, wait a little before going on this trick. I noticed that it doesn't work after some changes that runcommand got recently. I've already reported here.
-
It's still not working. I don't know what's going on. Here's everything I did:
Connect the NES controller adapter to USB, Connect Xbox dongle to USB
sudo visudo
Added a 4thDefaults
line (with a tab in beween): Defaults env_keep += "__joy2key_dev"
CTRL+X -> Y -> ENTER (saves file as /etc/sudoers.tmp)
sudo nano /etc/environment
Added a new line: __joy2key_dev="/dev/input/js2"
CTRL+X -> Y -> ENTER (saves file as **/etc/environment)
sudo reboot
(wait for system to load up ES)
Select Atari 2600 (first system on line)
Select 3D TicTacToe (first game)
Run-Command displays, I press ALL BUTTONS on the Xbox controller, nothing happens
Game StartsAlso doing all this, with js0 and having the NES adapter does nothing.
The only way I can get it to detect key presses on Run-Command is to have everything # commented out on those 2 files, and have the NES adapter unplugged. Without having them # commented out, while having the NES adapter unplugged does nothing. So clearly it's doing SOMETHING. Maybe Run-Command isn't right?
- Both controller adapters connected to USB = Only NES Works
- NES adapter connected, Xbox not = NES Works
- Xbox adapter connected, NES not = Xbox Works
- Modified variable entries, both controllers connected = Nothing Works
- Modified variable entries, NES connected, Xbox Not = Nothing Works
- Modified variable entries, Xbox connected, NES Not = Nothing Works
So the key presses just plain don't work when adding the new variable lines. Without them, they work fine by themselves, or only the NES one works when both connected.
-
@meleu said in Weird Controller Problems (yes, again):
@hansolo77 please, wait a little before going on this trick. I noticed that it doesn't work after some changes that runcommand got recently. I already reported here.
Ah OK. I didn't refresh my page before typing up my latest reply. Since everything works ok using just the Xbox controller and no modified files, I'll just keep it like this until something else comes up to try. I'll probably post back tomorrow/etc to see if there's anything new.
Looking at the changes, all we need to do is change the variable to ALL CAPS and remove the preceeding
__
right? But if it was just changed in the file, the changes need made on those other files as well. Maybe I'll still just wait. -
@meleu said in Weird Controller Problems (yes, again):
@hansolo77
The__joy2key_dev
is used only by the scripts which calljoy2key.py
. If you are curious, here are links to the exact line in each file:- runcommand.sh
- helpers.sh (used by
retropie_setup.sh
) - jsfuncs.sh (used by RetroPie-joystick-selection tool)
I'm away from my raspi now, but I'll try to find a solution when I get home. And the first thing I'll try is to put that
export
line at the end of/etc/profile
. :-)Should I try going through my system and replace all __joy2key_dev entries in the above listed files to just JOY2KEY_DEV and then also change the calls in the /etc/environment and sudoers files? Do you think that might work? I'm trying to rescrape my library right now (taking forever for some strange reason) but I'll make an SD card backup before I try it.
-
@hansolo77 I think it'll work, but my suggestion is to wait for the "official" solution. The decision made for
runcommand.sh
andhelpers.sh
I'll put on thejsfuncs.sh
.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.