Keyboard not detected on Raspberry Pi after update

Hi!

I made a simple presentation programme in openFrameworks that runs on a Raspberry Pi 2. I updated Raspbian today with “apt-get upgrade” and compiled my programme with the latest stable openFrameworks.

Unfortunately my Keyboard isn’t detected anymore. It is a Logitech K400r keyboard with touch pad that worked fine before.
I tested the old version of my programme and it has the same behaviour, so I don’t think it is an openFrameworks issue.

This is the openFrameworks output:
[notice ] ofAppEGLWindow: setupRPiNativeWindow(): screenRect: 1920x1200
[notice ] ofAppEGLWindow: setupRPiNativeWindow(): windowRect: 1024x768
[notice ] ofAppEGLWindow: createSurface(): setting up EGL Display
[notice ] ofAppEGLWindow: createSurface(): EGL Display correctly set 0x1
[notice ] ofAppEGLWindow: createSurface(): no current renderer selected
[notice ] ofAppEGLWindow: createSurface(): default renderer detected
[notice ] ofAppEGLWindow: createSurface(): surface created correctly
[notice ] ofAppEGLWindow: createSurface(): API bound correctly
[notice ] ofAppEGLWindow: createSurface(): -----EGL-----
[notice ] ofAppEGLWindow: createSurface(): EGL_VERSION_MAJOR = 1
[notice ] ofAppEGLWindow: createSurface(): EGL_VERSION_MINOR = 4
[notice ] ofAppEGLWindow: createSurface(): EGL_CLIENT_APIS = OpenGL_ES OpenVG
[notice ] ofAppEGLWindow: createSurface(): EGL_VENDOR = Broadcom
[notice ] ofAppEGLWindow: createSurface(): EGL_VERSION = 1.4
[notice ] ofAppEGLWindow: createSurface(): EGL_EXTENSIONS = EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_vg_parent_image EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_lock_surface
[notice ] ofAppEGLWindow: createSurface(): GL_RENDERER = VideoCore IV HW
[notice ] ofAppEGLWindow: createSurface(): GL_VERSION = OpenGL ES-CM 1.1
[notice ] ofAppEGLWindow: createSurface(): GL_VENDOR = Broadcom
[notice ] ofAppEGLWindow: createSurface(): -------------
[notice ] ofAppEGLWindow: setupPeripherals(): peripheral setup complete
[notice ] ofAppEGLWindow: setupNativeUDev(): created udev object
[notice ] ofAppEGLWindow: setupMouse(): mouse_fd= 5 devicePath=/dev/input/by-path/platform-3f980000.usb-usb-0:1.2:1.2-event-mouse
[notice ] ofAppEGLWindow: setupMouse(): mouse device name = Logitech K400
[warning] ofAppEGLWindow: setupKeyboard(): unabled to find keyboard
[notice ] ofAppEGLWindow: setupPeripherals(): native event setup complete
[notice ] ofAppEGLWindow: setWindowTitle(): not implemented
[notice ] ofAppEGLWindow: readMouseEvents(): EV_KEY : unknown ev.code = 108
[notice ] ofAppEGLWindow: readMouseEvents(): EV_KEY : unknown ev.code = 108
[notice ] ofAppEGLWindow: readMouseEvents(): EV_KEY : unknown ev.code = 29
[notice ] ofAppEGLWindow: readMouseEvents(): EV_KEY : unknown ev.code = 29
[notice ] ofAppEGLWindow: destroyNativeKeyboard()
[notice ] ofAppEGLWindow: destroyNativeKeyboard(): unable to reset terminal
[notice ] ofAppEGLWindow: destroySurface(): destroying EGL surface
[notice ] ofAppEGLWindow: display(): eglSwapBuffers failed: invalid display specified

The keyboard isn’t detected, the touch pad on the keyboard works fine, but when entering keys it generates unknown mouse events.

dmesg

[ 216.626489] logitech-hidpp-device 0003:046D:4024.0007: HID++ 2.0 device connected.
[ 241.823889] logitech-djreceiver 0003:046D:C52B.0003: hiddev0,hidraw3: USB HID v1.11 Device [Logitech USB Receiver] on usb-3f980000.usb-1.2/input2
[ 242.581943] input: Logitech K400 as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.2/0003:046D:C52B.0003/0003:046D:4024.0008/input/input4
[ 242.584750] logitech-hidpp-device 0003:046D:4024.0008: input,hidraw4: USB HID v1.11 Keyboard [Logitech K400] on usb-3f980000.usb-1.2:1
[ 242.598599] logitech-hidpp-device 0003:046D:4024.0008: HID++ 2.0 device connected.

Looks like both keyboard and mouse are detected.

/dev/input

event3
mice
mouse1

/dev/input/by-path

platform-3f980000.usb-usb-0:1.2:1.2-event-mouse
platform-3f980000.usb-usb-0:1.2:1.2-mouse

No keyboard here.

Any ideas? I hope someone can point me in the right direction to solve this issue.

Thanks!

Kees-Jan

Hi Kees-Jan,
I am having the same problem too. I’m not sure how to solve it, though. If you’ve made any progress, I’d be interested to hear.
Cheers,
Ian

Hi Ian,

The problem seems to be that the ‘newer’ versions of Raspbian come with a new version of the Logitech module. Instead of creating separate entries in /dev/input/by-path for the mouse and the keyboard, it only creates an entry for the mouse. This all works fine in the terminal, but OF expects separate entries for the keyboard and mouse.

So in my case the following symlinks are created in /dev/input/by-path:

platform-3f980000.usb-usb-0:1.2:1.2-event-mouse
platform-3f980000.usb-usb-0:1.2:1.2-mouse

And OF recognises this as the Mouse, though it also generates keyboard input, which OF logs as input errors.

My workaround is to create symlinks for a keyboard too:

ln -s /dev/input/event0 /dev/input/by-path/platform-3f980000.usb-usb-0:1.2:1.3-event-kbd
ln -s /dev/input/mouse0 /dev/input/by-path/platform-3f980000.usb-usb-0:1.2:1.3-kbd

I made up the path by substituting a 3 instead of the 2, not sure if that is right.
But when these symlinks exist OF works fine again and it recognises both Keyboard and Mouse.

The only thing is that these symlinks need to be recreated after reboot, I already had a bash script that runs my OF app so I added these to lines in there too, you could probably do it in /etc/rc.local

Hope this helps!

Kees-Jan

1 Like

Wow, thanks for such a comprehensive answer Kees-Jan. That’s really helpful! Can’t wait to get it fixed again. :smiley:

Hi all,

It seems this problem does not occur in actual raspbian versions but anyway: I have some Cards I do not want to upgrade, so I wrote a small shell script doing the symlinks based on Kees-Jans solution, including if there is already a keyboard and checking which USB port is used.

maybe it’s still useful…

if ls /dev/input/by-path/*event-kbd* 1> /dev/null 2>&1; then
    echo "keyboard event exists"
	elif ls /dev/input/by-path/platform-3f980000.usb-usb-0:1.1:1.2* 1> /dev/null 2>&1; then
	echo "keyboard event does not exist. /dev/input/by-path/ lists:"
	ls /dev/input/by-path/
	echo "seems to be a logitech keyboard which registers as mouse on USB 1. creating event-kbd symlink..."
	cd /dev/input/by-path/
	sudo ln -s ../event0 platform-3f980000.usb-usb-0:1.1:1.1-event-kbd
	cd
	elif ls /dev/input/by-path/platform-3f980000.usb-usb-0:1.2:1.2* 1> /dev/null 2>&1; then
	echo "keyboard event does not exist. /dev/input/by-path/ lists:"
	ls /dev/input/by-path/
	echo "seems to be a logitech keyboard which registers as mouse on USB 2. creating event-kbd symlink..."
	cd /dev/input/by-path/
	sudo ln -s ../event0 platform-3f980000.usb-usb-0:1.2:1.1-event-kbd
	cd
	elif ls /dev/input/by-path/platform-3f980000.usb-usb-0:1.3:1.2* 1> /dev/null 2>&1; then
	echo "keyboard event does not exist. /dev/input/by-path/ lists:"
	ls /dev/input/by-path/
	echo "seems to be a logitech keyboard which registers as mouse on USB 3. creating event-kbd symlink..."
	cd /dev/input/by-path/
	sudo ln -s ../event0 platform-3f980000.usb-usb-0:1.3:1.1-event-kbd
	cd
	elif ls /dev/input/by-path/platform-3f980000.usb-usb-0:1.4:1.2* 1> /dev/null 2>&1; then
	echo "keyboard event does not exist. /dev/input/by-path/ lists:"
	ls /dev/input/by-path/
	echo "seems to be a logitech keyboard which registers as mous4 on USB 1. creating event-kbd symlink..."
	cd /dev/input/by-path/
	sudo ln -s ../event0 platform-3f980000.usb-usb-0:1.4:1.1-event-kbd
	cd
    else
    echo "keyboard event does not exist. Does not seem to be a logitech keyboard."
fi

have a good day!
oe