Community
cancel
Showing results for 
Search instead for 
Did you mean: 
JVerb1
Beginner
1,747 Views

Simulate Key Press event in Python [Edison]

I am trying to get an existing Python script which starts playing a song via mplayer to be able to interact with its keyboard input functionality (e.g. space to play/pause, arrow keys to ffw/rwd).

I have tried using http://tjjr.fi/sw/python-uinput/ python-uinput but running the example keyboard script does nothing (no errors). I executed modprobe input before running too.

I also tried https://github.com/gvalkov/python-evdev python-evdev (after installing some other necessary dependancies), ran its example code and again there was no output, and also no errors.

I'm wondering if there is something that's causing both of these to not work the way they would on a full Linux build? Just a thought; really not sure what's going on. Any help is much appreciated, thanks!

I'm also open to other suggestions on how to control mplayer from a python script, besides simulating keyboard events.

3 Replies
Diego_V_Intel
Employee
99 Views

Hi js3ph,

Let me check if I'm able to get Key Press events in a Python script. I'll update the thread as soon as possible.

Regards,

Diego

JVerb1
Beginner
99 Views

Thank you for looking into this Diego. I have not been able to find a solution yet on my side, so I'm eagerly awaiting a response from you!

Diego_V_Intel
Employee
99 Views

Hi js3ph,

The libraries for Python may not be compatible with the Python version installed on Edison. I recommend you to try to read the /dev/input/event* as it's described in the following site: http://stackoverflow.com/questions/5060710/format-of-dev-input-event http://stackoverflow.com/questions/5060710/format-of-dev-input-event. You will find a simple and raw reader example that might be useful for your application.

Regards,

Diego

Reply