I am trying to create a program which will move the mouse cursor on the screen automatically using buttons connected up to the GPO pins of the Raspberry pi. However I am having trouble using uinput. Having downloaded it, when I run the code it says Uinput is not installed. Does anyone know what the issue is? Thank you in advance.

I am trying to learn how uinput works but can find very little online showing how to use it. If anybody knows of somewhere to learn about it or can say how to use it then please help.
Thanks in advance

Mouse events are sent using emit(), keyboard & joystick events are sent using emit_click() (single key presses) and emit_combo() (multiple key presses at the same time).

By default you generally need to be running as root to create a connection to uinput.

Thank you very much, Please could you give an example of this all in 1 piece of code, where when it receives an input through one of the GPIO pins, it moves the mouse to the left, and if held down will continue to do so. I am going to do this for 4 buttons, so the mouse can move in 4 directions. Please could you also say how to trigger a mouse click, both left and right, so that when it receives an input on one of the GPIO pins it will trigger a mouse click.

louiepi wrote:Thank you very much, Please could you give an example of this all in 1 piece of code, where when it receives an input through one of the GPIO pins, it moves the mouse to the left, and if held down will continue to do so. I am going to do this for 4 buttons, so the mouse can move in 4 directions. Please could you also say how to trigger a mouse click, both left and right, so that when it receives an input on one of the GPIO pins it will trigger a mouse click.

The main mouse buttons are uinput.BTN_LEFT, uinput.BTN_MIDDLE and uinput.BTN_RIGHT, there are other mouse buttons too, they are all listed in the source code to python-uinput.

As to full code, what have you tried? There are plenty of examples around that show how to read the GPIOs.

louiepi wrote:Thank you very much, Please could you give an example of this all in 1 piece of code, where when it receives an input through one of the GPIO pins, it moves the mouse to the left, and if held down will continue to do so. I am going to do this for 4 buttons, so the mouse can move in 4 directions. Please could you also say how to trigger a mouse click, both left and right, so that when it receives an input on one of the GPIO pins it will trigger a mouse click.

The main mouse buttons are uinput.BTN_LEFT, uinput.BTN_MIDDLE and uinput.BTN_RIGHT, there are other mouse buttons too, they are all listed in the source code to python-uinput.

As to full code, what have you tried? There are plenty of examples around that show how to read the GPIOs.

Thank you for the help. I unspderstand how to get input from the GPIO pins but I'm not sure how to use them to trigger an event using uinput

Hi, I tried using the uinput as a "send enter key" kind of command, but I'm getting back a syntax error for some reason despite what I'm pretty sure is following the rules properly, what I've got as the code is as follows;

What I'm trying to do is get the enter button to be pressed when I press the button on GPIO 26
what I get instead is a syntax error saying that "device" is invalid syntax though? (but it doesn't matter if I change it to anything else either, so I don't know what's wrong despite following the uinput example... I'm really confused!

What I'm trying to do is get the enter button to be pressed when I press the button on GPIO 26
what I get instead is a syntax error saying that "device" is invalid syntax though? (but it doesn't matter if I change it to anything else either, so I don't know what's wrong despite following the uinput example... I'm really confused!

Your if line has a superfluous open bracket and no colon at the end. And the line(s) under it isn't indented.