From 3c3b758b4f5e560dbceb7e9c06b63e57c2e2a84a Mon Sep 17 00:00:00 2001 From: MacGyverr Date: Mon, 27 May 2019 11:41:51 -0700 Subject: [PATCH 1/2] Fixes for older TVs and Readme Added the command to initialize the CEC source and updated the running check to include more kodi binary instances. Updated the Readme to include more instructions. --- README.md | 39 ++++++++++++++++++++++++++++++++------- es-cec-input.py | 10 +++++++--- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 20440de..cb83843 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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` @@ -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 developed and 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 your 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 @@ -78,13 +100,16 @@ a list of the supported keys. 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 @@ -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) +* 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) diff --git a/es-cec-input.py b/es-cec-input.py index e48acbe..bb9b511 100755 --- a/es-cec-input.py +++ b/es-cec-input.py @@ -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 @@ -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 @@ -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) From 156c46dc51712ca1ea50dfa3a1fc4af7d15fd9bf Mon Sep 17 00:00:00 2001 From: MacGyverr Date: Thu, 30 May 2019 05:31:29 -0700 Subject: [PATCH 2/2] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cb83843..bf47792 100644 --- a/README.md +++ b/README.md @@ -75,13 +75,13 @@ Then add the pi user to the uinput group # Testing before autostart -**Note: It was developed and tested on a pi3 with Retropie 4.4.12 with kodi 18.2 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 download the code and make the script executable (assuming your in the same directory as the file) +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 @@ -95,7 +95,7 @@ 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. @@ -124,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) (tested fine without but who knows) +* 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)