Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting controller to work with firejail #678

Closed
tetoNidan opened this issue Dec 1, 2022 · 10 comments
Closed

getting controller to work with firejail #678

tetoNidan opened this issue Dec 1, 2022 · 10 comments
Labels
enhancement New feature or request

Comments

@tetoNidan
Copy link

having some issues getting controllers to connect when using STL. I had this issue with and without using firejail. I really like to use firejail to sandbox steam. It has so many benefits especially using mods. I would like to trust the mod authors and for the most part I do. There is still potential to do shady things and the few that will capitalize on it. Limited access to your $USER files can never be a bad thing in the days of information exploit people and companies.

firejail is also great for testing out games. especially ones that give you issues you might have that could take the entire trial period steam gives you to return it. Firejail seems to stop steam from getting an accurate count of time played. I havent told anyone this out of fear it could be abused and patched by steam. But lets face it buying a game you want to play on steam is always a gamble and it might be something you really want to play and sometimes you can get it to work if you had more time to play around with it. Firejail gives you that time. And if you cant get it to work you can always return it without feeling that you've been ripped off for spending your trial time just trying to get the game to work.

STL works great under firejail as long as you whitelist it in your firejails steam.profile like so

User defined rules

allow external drive folder for steam

noblacklist /mnt/Linux2/SteamGames
whitelist /mnt/Linux2/SteamGames

allow steamtinkerlaunch

noblacklist /usr/bin/steamtinkerlaunch
#whitelist /usr/bin/steamtinkerlaunch

noblacklist /usr/share/steamtinkerlaunch
#whitelist /usr/share/steamtinkerlaunch

noblacklist ${HOME}/.config/steamtinkerlaunch
whitelist ${HOME}/.config/steamtinkerlaunch

I have tried to whitelist uinput, js and hidraw thinking that might help but to no avail.

noblacklist /dev/hidraw*
#whitelist /dev/hidraw*

noblacklist /dev/uinput
#whitelist /dev/uinput*

noblacklist /dev/js*
#whitelist /dev/js*

Everything works except the controller. Also having problems getting controllers to work without firejail using STL. Still troubleshooting.

Any way thanks for all you all do making STL a great tool for every steam gamer.

@tetoNidan tetoNidan added the enhancement New feature or request label Dec 1, 2022
@sonic2kk
Copy link
Owner

sonic2kk commented Dec 1, 2022

Hi there!

An interesting find! I can't say I know very much about firejail, but I really appreciate the background that you have given! Glad to hear STL itself works with firejail.

The steps you've taken with allowing uinput, js and hidraw make sense. What about evdev though? I believe that is used for some input, though maybe this is only on Wayland. That could be complete nonsense though, so please excuse my ignorance :-)

Everything works except the controller. Also having problems getting controllers to work without firejail using STL. Still troubleshooting.

Maybe I am completely misunderstanding, but by the sounds of this part, this issue may be unrelated to firejail? If you can't get controllers to work with and without firejail when using STL, the common factor here seems to be STL? I would be interested to hear back if you manage to figure this out.

Just to confirm, controllers work for you without STL or firejail, right?

I use controllers with games using SteamTinkerLaunch without any issue, on my PC and Steam Deck, so this is certainly a strange issue. The only common factor in this case is that I haven't used firejail really. But in your case, you have mentioned that even without firejail, controllers do not work when a game is launched with STL.

This is a non-standard issue to file so I understand why there were no logs or why the template was not followed in this instance, but could you add your distro, SteamTinkerLaunch version and SteamTinkerLaunch installation method to the OP? Just for completeness :-)

As of this moment I am not sure how to proceed with debugging, but thank you for bringing it up and for the kind words about STL! Hopefully we can get this sorted.

@tetoNidan
Copy link
Author

tetoNidan commented Dec 9, 2022

Sorry about the lack of information.

OS: Manjaro
STL Version: steamtinkerlaunch-v11.12.20221020-3
STL install method: build from AUR-git version.

Just to confirm, controllers work for you without STL or firejail, right?

Yes controller input works well without launching STL. Side note this might be a firmware issue. I have a 1st gen PS5 controller that has never had a firmware update? Dont own a ps5.

So I have finally had some luck getting controllers to work with and without firejail. Same solution works for both.

Controller has to be connected before you launch Steam!

  1. in steam overlay go to Manage Game.
  2. Controller Options.
  3. Set controller Steam Input Per-Game Settings to "Off".
  4. Game might not except settings the first time or two but should start with gamepad control mostly working.
  5. In game bring up Steam Overlay and change the Steam Input Per-Game Settings to "ON" or Global Setting(PS/Generic/Switch) and you should have access to your controller settings again.

Steam states that changing these settings will require game restart but does not.

Should state that I reverted from Steam Beta before troubleshooting, might work in Beta version as well, haven't tried yet.

I did get it working albeit with some extra steps in firejail and without. This probably can be closed unless there is something that doesn't feel right about the extra steps. I have to travel to the big city soon and will probably buy a new PS5 controller to see if the outdated controller firmware is the issue.

Thanks STL team!

@sonic2kk
Copy link
Owner

sonic2kk commented Dec 9, 2022

Thanks for the background!

This is almost certainly unrelated but I just wanted to mention that the listed version of SteamTinkerLaunch is a little old. The latest is v11.12.20221209-5. Just in case you want to update, but I am almost entirely sure it won't make a difference here.

Side note this might be a firmware issue. [...] Set controller Steam Input Per-Game Settings to "Off".

I am not at all an expert here but I am pretty sure this is a firmware issue or a driver issue. I think I have seen similar complaints. There could also be conflict with the PS5 kernel driver and the Steam Input controller driver - There is an issue like this for the Switch Pro Controller as well, where you have to install a third party driver and start the controller by pressing the + / - buttons together, which registers the controller differently. Though you can hotplug with the Switch Pro Controller.

For the PS5 controller issue, see Steam for Linux issue 7791 (not linking it here to avoid spam on the upstream issue) - I haven't used any PlayStation controller with my PC so I can't say for sure, but it sounds a bit similar to your issue. That user said the PS5 controller doesn't work with Steam Input.

And just from the Steam Beta changelog notes I've read over the months, the Steam Beta could have improvements to fix the controller support in the long-term, so it might be a good idea to switch back to it in future :-) This is just an unrelated tip though, from someone who doesn't own a PS5 controller, so please take it with a grain of salt heh. On this note, absolutely feel free to get another PS5 controller but in my humble opinion it may not make much difference, so you may be able to save yourself some money if the linked issue sounds like your problem.

Good luck! If the mentioned Steam issue sounds like your problem, feel free to close this issue :-)

@tetoNidan
Copy link
Author

Thanks much sonic2kk, I will have a look at the Steam for Linux issue and see what they have going on there. It looks like this is not a STL issue. I will close this issue.

Thanks again STL team!

@sonic2kk
Copy link
Owner

sonic2kk commented Dec 9, 2022

No problem :-) Feel free to re-open this issue in future if you find reason to suspect SteamTinkerLaunch is at fault here and we can try fix it.

Thanks!

@tetoNidan
Copy link
Author

tetoNidan commented Oct 24, 2023

sonic2kk, you can ignore this as this is not an issue with STL and directly relates to how firejail works. If future firejail users have any inquiry's they can find the solution below. As always, thanks sonic2kk!

So I have been working with firejail again and believe I have it all sorted out. I thought I'd post some instructions on how to get STL working in firejail along with controller input in case someone else wants it working too. Tested using firejail version 0.9.72.

First we need to make a custom firejail steam.profile

  1. Create a firejail directory in your users .config

mkdir ~/.config/firejail

  1. Copy your steam's firejail profile there. For general purpose I will copy all steam's profiles there. Might only need the steam.profile or the steam-native.profile. I have both installed. Read #4 for an explanation.

sudo cp /etc/firejail/steam* ~/.config/firejail/

  1. Take ownership of those files we moved from root so you can edit them.

sudo chown -R $USER:$USER ~/.config/firejail/

  1. If you have both steam and steam-native installed like I do you will only have to edit the steam.profile. The steam-native.profile only really holds links to steam.profile. To be honest I don't know how firejail handles it if you only have setam-native installed. I'm assuming that the steam-native.profile will have the full firejail config in that case. To verify see if you have both profiles in your ~/.config/firejail folder. The profile we want to edit is the larger one with many rules. Open the larger profile in any text editor and we will noblacklist all the STL locations and whitelist STL's ~/.config. To do so add these lines at the bottom of the file:
## Allow SteamTinkerLaunch
noblacklist /usr/bin/steamtinkerlaunch
noblacklist /usr/share/steamtinkerlaunch
noblacklist /dev/shm/steamtinkerlaunch
noblacklist ${HOME}/.config/steamtinkerlaunch
  1. (Optional) Now we have to allow access to the controller input. To do so we need to tell firejail to allow access to /dev. Not too far from the bottom where we added the STL lines find the line that says private-dev. Change that line to read ignore private-dev. Make sure there is no # in front of that line. Save the profile and start steam.

STL should have access to all your previously setup games with access to your controller. I will likely verify that this is the best way to go about this with the firejail team and amend this if there is a better way but for now this should get you gaming.

@sonic2kk
Copy link
Owner

Excellent stuff! If there's a page on the wiki that think we could/should document this on, or after your discussion if there's anything STL can do here to help, please let me know :-)

@tetoNidan
Copy link
Author

Awesome, give me a few days to see if I did everything right from the firejail team and I will get back to you!

@tetoNidan
Copy link
Author

So I have not asked firejail if there is a better way but I did do some digging and testing. It looks like for now the best way to get controller support is to use the ignore private-dev. The most recent issue that I found was here in 2022 and a previous here in 2021 suggesting to ignore private-dev or simply commenting it out. I will remove the whitelist from my instructions.

I removed the whitelist ${HOME}/.config/steamtinkerlaunch without issue so it looks like one only needs the noblocklists.

I was thinking that since firejail is a work in progress and things are defiantly subject to change, maybe add my instructions and link here or just link here in the wiki for firejail workaround/compatability? My reasoning here is I don't know how actively you want to maintain the wiki for firejail compatibility? I was thinking that if the wiki links here I would be notified able be to help troubleshoot as I actively use firejail? I don't want to overburden you with issues related to this as it has no relation to your fine work and is a luxury playing in a sandbox. Let me know what you think? Also let me test all my games and maybe my switch controller to make sure everything plays nice.

I was doing some further testing and ran into a strange issue related to a previous issue I had unrelated to this, so I'll pop over there and ask for some help.

@tetoNidan
Copy link
Author

tetoNidan commented Oct 24, 2023

I have now tested all 12 games I have installed with STL and they all work. I have tested with my PS5 controller and my Switch Pro controller. Everything works as expected! I cannot test on xBox controller as I don't own one but I don't think there will be any issue. I also tested removing /etc/shm/steamtinkerlaunch just to make sure firejail wouldn't have an issue with directory removal and there was none.

The strange issue that I thought was an issue was a nonissue, accidentally set one game to timeout at 0 in the STL game menu. I found the timeout setting in the steaminkerlaunch/gamecfgs/title/Fallout 4.conf and re-adjusted it back to 3 seconds. Operator error!

Whatever you decide on the Wiki I'll be there for testing and troubleshooting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants