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

Don't work on RetroPie 4.6 #26

Open
hollysheep opened this issue Aug 2, 2020 · 4 comments
Open

Don't work on RetroPie 4.6 #26

hollysheep opened this issue Aug 2, 2020 · 4 comments

Comments

@hollysheep
Copy link

Should the script work with retropie 4.6? There is an error when i start the script

Traceback (most recent call last):
  File "./es-cec-input.py", line 224, in <module>
    main()
  File "./es-cec-input.py", line 183, in main
    device = register_device(keylist)
  File "./es-cec-input.py", line 129, in register_device
    return uinput.Device(keylist)
  File "/usr/lib/python2.7/dist-packages/uinput/__init__.py", line 178, in __init__
    self.__uinput_fd = fd or fdopen()
  File "/usr/lib/python2.7/dist-packages/uinput/__init__.py", line 84, in fdopen
    return _libsuinput.suinput_open()
  File "/usr/lib/python2.7/dist-packages/uinput/__init__.py", line 70, in _open_error_handler
    raise OSError(code, msg)
OSError: [Errno 13] Failed to open the uinput device: Permission denied

It works when i start it with sudo but cec doesn't work.

@allenbina
Copy link

I think the permissions issue can be fixed by adding your user to uinput group. I copied this from the readme. This assumes you are using the pi username.

Run the code as a non root user

You must first create the uinput group

sudo addgroup uinput

Then add the pi user to the uinput group

sudo adduser pi uinput

@evbernardes
Copy link

Having the same problem, Raspi 3B+ with the latest retropie. Created the group and added pi to it, still have the same problem

@Markisen
Copy link

I found the solution here: tuomasjjrasanen/python-uinput#6 (comment)
I also needed to do the following:

Change group ownership and permissions on /dev/uinput:

sudo chmod g+rw /dev/uinput
sudo chgrp uinput /dev/uinput

@Kenarude
Copy link

Hello,
I'm not an expert on linux but by using what was said in this thread and made some search, I would like to share my 2 cents knowledge.
I think there was some changes in the way the access right are assigned to /dev/uinput. I figured out how to make it working as it was previously.
First, as I fell into the trap I give a clue :), the udev rules are in 3 lines and not on one line only (the magic of copy/paste)
So I added GROUP to the uinput device otherwise it is assigned to the root.

ACTION=="add|change", KERNEL=="event[0-9]*", ENV{ID_VENDOR_ID}=="012a", ENV{ID_MODEL_ID}=="034b", ENV{ID_INPUT_KEYBOARD}="1", ENV{ID_INPUT_TABLET}="1"
SUBSYSTEM=="input", ATTRS{name}=="python-uinput", ENV{ID_INPUT_KEYBOARD}="1"
KERNEL=="uinput", GROUP="uinput", MODE:="0660"

What can be done also is instead of using a crontab rule to start the script we can use a user systemd service.
Create the folder ~/.config/systemd/user if it doesn't exist.
Create a file named for example cec.service into that folder.
add the following information (take care to set correctly the path to your script)

[Unit]
Description=CEC to keyboard input converter

[Service]
ExecStart=python /path/to/the/script/es-cec-input.py

[Install]
WantedBy=default.target

When done, enable the service

systemctl --user enable cec.service

Now you can reboot and test if it works.

I think this could also be done with a systemd system service so as not to change the uinput group but I haven't tried it yet.

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

No branches or pull requests

5 participants