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

Fixes for older TVs and updated the Readme #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 33 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,25 @@ START <-> FAST FORWARD or BLUE
SELECT <-> REWIND OR YELLOW

# Dependencies

**Note: You must setup a keyboard through the Emulationstation GUI prior to doing any of the below!**

It depends on the `cec-utils` package and also the `python-uinput` package which contains the library and the udev rules at
`/etc/udev/rules.d/40-uinput.rules`.

Both `cec-utils` and `python-uinput` are in the repositories.
and can be installed with:
```
sudo pip install python-uinput
sudo apt-get install cec-utils
```

if python-uinput gives you a `bist-wheel` error, then do the following:
```
sudo pip uninstall python-uinput
sudo pip install wheel
sudo pip install python-uinput
```

The `40-uinput.rules` file should look like the following

Expand All @@ -42,8 +57,13 @@ ACTION=="add|change", KERNEL=="event[0-9]*", ENV{ID_VENDOR_ID}=="012a", ENV{ID_M
ENV{ID_INPUT_KEYBOARD}="1", ENV{ID_INPUT_TABLET}="1"SUBSYSTEM=="input", ATTRS{name}=="python-uinput",
ENV{ID_INPUT_KEYBOARD}="1"KERNEL=="uinput", MODE:="0666"
```
If not modify/create it with:
```
sudo nano /etc/udev/rules.d/40-uinput.rules
```
and add the code from above.

# Run the code as a non root user
# To run the code as a non root user
You must first create the uinput group

`sudo addgroup uinput`
Expand All @@ -55,15 +75,17 @@ Then add the pi user to the uinput group

# Testing before autostart

**Note: It was developed and tested on a pi3 with Retropie 4.1 with kodi installed in
**Note: It was tested on a pi3 with Retropie 4.4.12 with kodi 18.2 installed in
the ports section of retropie**

To make sure it will work you should run the script
as a non root user.

First make the script executable (assuming your in the same directory as the file)

`chmod u+x es-cec-input.py`
First download the code and make the script executable (assuming you are in the same directory as the file)
```
wget https://raw.githubusercontent.com/MacGyverr/es-cec-input/master/es-cec-input.py
sudo chmod ugo+rwx es-cec-input.py
```

then run it with

Expand All @@ -73,18 +95,21 @@ If you see no output then you can try your TV remote with the buttons
in the Button section above. If it works then proceed to the next section

If you see output it will exit and tell you the key which is unsupported and
a list of the supported keys.
a list of the supported keys. (If you see a lot of unsupported keys filled with gibberish, then you likely didn't already have a keyboard configured in EmulationStation as mentioned twice above)

Ensure all your keys are supported and try again until you get no output.

# Autostart on boot
To start on boot, add to user's crontab.
To start on boot, add to user's crontab. (notice it's not using sudo)

`crontab -e`

Add the line,

`@reboot nohup /home/pi/PATH/TO/THE/SCRIPT/es-cec-input.py`
which if you didn't switch to a different folder before downloading the script will be /home/pi/, so use the following:

`@reboot nohup /home/pi/es-cec-input.py`


# Supported Keyboard Keys
Expand All @@ -99,5 +124,5 @@ Letters ("a" to "z"), left, right, up, down, enter, kp_enter, tab, insert, del,
(where "kp_"# is for keypad keys)

# FAQ
* The script is not working after exiting from kodi. This is due to a setting in kodi. [Solution](https://github.com/dillbyrne/es-cec-input/issues/2#issuecomment-281341050)
* If the script is not working after exiting from kodi. This is due to a setting in kodi. [Solution](https://github.com/dillbyrne/es-cec-input/issues/2#issuecomment-281341050) (tested fine without but who knows)
* Using remote is not controlling menu but signal is being received (goes out of screensaver). Happens when keyboard was not configured as a controller. [Solution](https://github.com/dillbyrne/es-cec-input/issues/1#issuecomment-272633575)
10 changes: 7 additions & 3 deletions es-cec-input.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

"""
Name: es-cec-input.py
Version: 1.5
Version: 1.5.1
Description: cec remote control for emulation station in retropie
Author: dillbyrne
Author: dillbyrne (small fixes by MacGyverr)
Homepage: https://github.com/dillbyrne/es-cec-input
Licence: GPL3

Expand All @@ -19,7 +19,7 @@
sudo adduser pi uinput

to start on boot, add to user crontab. crontab -e
@reboot hohup ./home/pi/RetroPie/scripts/es-cec-input.py
@reboot nohup ./home/pi/RetroPie/scripts/es-cec-input.py
"""

import subprocess
Expand Down Expand Up @@ -193,12 +193,16 @@ def main():
running_processes = subprocess.check_output(['ps', '-A'])

if running_processes.find('kodi_v7.bin') == -1 and\
running_processes.find('kodi.bin') == -1 and\
running_processes.find('kodi-rbpi_v7') == -1 and\
running_processes.find('retroarch') == -1 and\
running_processes.find('reicast') == -1 and\
running_processes.find('drastic') == -1:

if idle:

# start cec-client with "as" and exit to initialize some older TVs to send the remote presses
print subprocess.call("echo as | cec-client -s", shell=True)
# start cec-client to track pressed buttons on remote
p = subprocess.Popen(
'cec-client', stdout=subprocess.PIPE, bufsize=1)
Expand Down