Raspberry Pi Keyboard and Mouse Not Working (as expected)

3,304 views
Skip to first unread message

David Zahn

unread,
Nov 25, 2013, 5:44:45 PM11/25/13
to kivy-...@googlegroups.com
Hi,

I'm attempting to use Kivy on multiple environments (PC, Android, Raspberry Pi, etc).  So far the Raspberry Pi is the only one I've having real trouble with, as the Kivy app doesn't appear to take full control of the keyboard and mouse.  When I run the python script there's no cursor, but it appears as though I can click on widgets.  When I attempt to type into a text box nothing happens, but then once I close the app I see all the characters I typed in the terminal window I used to start up the script.

Are there known issues with keyboard and mouse control on the Raspberry Pi?  Are there a workarounds?  At this point I'm not sure how to interact with the Kivy app on the raspberry pi.

Thanks,

Dave\Esotic


Pawel Szubert

unread,
Nov 26, 2013, 6:39:55 AM11/26/13
to kivy-...@googlegroups.com


W dniu poniedziałek, 25 listopada 2013 23:44:45 UTC+1 użytkownik David Zahn napisał:
Hi,

I'm attempting to use Kivy on multiple environments (PC, Android, Raspberry Pi, etc).  So far the Raspberry Pi is the only one I've having real trouble with, as the Kivy app doesn't appear to take full control of the keyboard and mouse.  When I run the python script there's no cursor, but it appears as though I can click on widgets.  When I attempt to type into a text box nothing happens, but then once I close the app I see all the characters I typed in the terminal window I used to start up the script.

Exactly the same behaviour in my experiments. Examining the log file (I haven't my Pi at hand now, so cannot attach it) shows that keyboard and mouse are recognized correctly upon startup, but there is no reaction for mouse/keyboard events.
No reaction to pressing any Fnx key, after closing the app in the terminal window used for starting the app I can see "A" for every F1 keystroke, "B" for F2 etc.
(the same is on my Linux box after switching to 1-st vt (Alt+F1) and pressing Fnx key after logging in.
Could it be something concerned to keyboard mapping?
Gimbus

David Zahn

unread,
Nov 26, 2013, 9:49:41 AM11/26/13
to kivy-...@googlegroups.com

My main Pi has a lot of customization on it (vino for remote access, upnp media server, dlna media sharing, etc) and I'm wondering if any of those services may be causing a conflict with the keyboard and mouse, so I'm currently working on setting up a fresh Raspbian install to see if that behaves any better.

Paweł Szubert

unread,
Nov 26, 2013, 10:45:44 AM11/26/13
to kivy-...@googlegroups.com
I don't think so, in my case it was a fresh install.
Investigating....


David Zahn

unread,
Nov 26, 2013, 12:20:49 PM11/26/13
to kivy-...@googlegroups.com
Is kivy using pygame to get the mouse and keyboard inputs? If so,testing a simple pygame app may provide some information.

Mathieu Virbel

unread,
Nov 27, 2013, 4:52:52 AM11/27/13
to kivy-...@googlegroups.com
Kivy on Pi is using directly EGL, and need accelerated window. Pygame is
not something you can use for that on the Pi. This is why a specific
provider has been done.

As for the keyboard/mouse, i never tested under X env, but it should
work in a console. If not, contribution are welcome :)

Le 26/11/2013 18:20, David Zahn a �crit :

David Zahn

unread,
Nov 27, 2013, 8:35:19 AM11/27/13
to kivy-...@googlegroups.com
Searching for egl in the kivy code should point me in the right direction for understanding some of the RPi specific graphics handling.  Are you suggesting that Kivy needs custom providers for the mouse and keyboard on the RPi?

It also appears like kivy on the RPi is ignoring the settings in the kivy config.ini.  Would it be safe to assume this is also due to the RPi's egl specific implementation?

On a side note, I tried out some of the pygame example apps on the RPi and had no issues using the keyboard and mouse.

Cheers,

Dave\Esotic

Mathieu Virbel

unread,
Nov 27, 2013, 8:42:29 AM11/27/13
to kivy-...@googlegroups.com
I don't know which settings you are referring too.
But yes, Kivy on the RPi has also been improved to support mouse (i
don't remember keyboard really, maybe i forgot about it), by reading
kernel event directly (check hidinput provider).

Pygame example are EGL based? It's not because pygame has mouse/keyboard
support that we can use it, it's unrelated, even incompatible.

Maybe our SDL2 support will improve everything on that side too.

Mathieu


Le 27/11/2013 14:35, David Zahn a �crit :
> --
> You received this message because you are subscribed to the Google
> Groups "Kivy users support" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to kivy-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Chris Bradfield

unread,
Nov 29, 2013, 12:04:24 PM11/29/13
to kivy-...@googlegroups.com
I can confirm this behavior - no mouse cursor in kivy app under X.  Same app works fine in other environments.

Running from console doesn't work either.  

What are the prospects for getting this working as expected?  I would think the majority of RPi users are working 
with keyboard/mouse input.  I use the RPi to teach programming, and I'd love to be able to use Kivy
as a way to build GUI apps with kids.

Chris


On Wednesday, November 27, 2013 1:52:52 AM UTC-8, Mathieu Virbel wrote:
As for the keyboard/mouse, i never tested under X env, but it should
work in a console. If not, contribution are welcome :)

Le 26/11/2013 18:20, David Zahn a �crit :

David Zahn

unread,
Dec 10, 2013, 2:37:21 PM12/10/13
to kivy-...@googlegroups.com

After some googling I found a RPi forum post that talks about using SDL to capture the Mouse/Keyboard inputs and OpenGLES for creating the graphics:


Just an FYI...

David Zahn

unread,
Dec 12, 2013, 7:58:39 PM12/12/13
to kivy-...@googlegroups.com
I found something called pykeylogger that hooks the global mouse and keyboard handler and records it all to file:


I was able to get all the necessary python libs installed and verified that the code works on the RPi.  I'm assuming that this could be repurposed to trap keystrokes for Kivy scripts on the RPi.  If I get this working reasonably well I post up a sample project to github.

Cheers,

Dave/Esotic
 

Gabriel Pettier

unread,
Dec 27, 2013, 9:00:03 AM12/27/13
to kivy-...@googlegroups.com
mouse cursor is not visible in X11 or in console because on X11, kivy
draws its windows above everything, including the X11-drawn mouse
cursor, and in console, nothing draws the mouse cursor. The solution is
to have kivy draw the cursor, i did a quick patch for this some time
ago, a better solution would be to implement it in the toucthring module
as an option instead of as something specific to rpi. (and have all
input providers dispatch non-touch events to it).

For the keyboard, i didn't investigate at all, but i guess a provider
have to be done for it too.

David Zahn

unread,
Mar 4, 2014, 2:45:32 PM3/4/14
to kivy-...@googlegroups.com
 
As an FYI, I purchased an Adafruit LCD Panel with buttons and have been able to poll their state using a timer/clock:
 
This has worked well for allowing some basic control/interaction with my Python/Kivy scripts on a Raspberry Pi.
 
Cheers,
 
Dave\Esotic 
Reply all
Reply to author
Forward
0 new messages