03-05-2018, 09:23 AM
(This post was last modified: 03-05-2018, 09:57 AM by Brian Beuken.)
The standard keyboard system I provide, is 99% effective, but I have discovered one or 2 wireless keyboards don't work. unrelated to the file lock some linux systems have, where a sudo chmod a+r /dev/input/* will make your event files accessible.
Usually the fix is to look at the AreYouMyKeyboard scanning method, whose job is to parse though the input systems to find the current active keyboard. Most Wired and WiFi keyboards will work perfectly with no issues, but sometimes wireless keyboards don't play nice. Usually though that can be fixed by changing the pattern to search for from event-kdb to event-mouse.
However.....Some BT keyboards won't even work with that fix, and I don't know the exact reasons why, Raspbian do state that not all BT keyboards are compatible, but its frustrating to see your BT keyboard working on your terminal and not in your project. However there is a "fix" but its very hacky will make your code work only on your system with your keyboard.
So if you are one of those poor people with a keyboard that refuses to register, you can hack the ProcessKeyboardThread to hard wire the event that controls your keyboard, like this:
//fp = fopen(((Input *)arg)->kbd.c_str(), "r"); // normal scanned keyboard
fp = fopen("/dev/input/event1", "r"); // hacked forced event0 or event1 or... (up to max events)
I'll work on a better solution, but for now this will fix most issues.
Usually the fix is to look at the AreYouMyKeyboard scanning method, whose job is to parse though the input systems to find the current active keyboard. Most Wired and WiFi keyboards will work perfectly with no issues, but sometimes wireless keyboards don't play nice. Usually though that can be fixed by changing the pattern to search for from event-kdb to event-mouse.
However.....Some BT keyboards won't even work with that fix, and I don't know the exact reasons why, Raspbian do state that not all BT keyboards are compatible, but its frustrating to see your BT keyboard working on your terminal and not in your project. However there is a "fix" but its very hacky will make your code work only on your system with your keyboard.
So if you are one of those poor people with a keyboard that refuses to register, you can hack the ProcessKeyboardThread to hard wire the event that controls your keyboard, like this:
//fp = fopen(((Input *)arg)->kbd.c_str(), "r"); // normal scanned keyboard
fp = fopen("/dev/input/event1", "r"); // hacked forced event0 or event1 or... (up to max events)
I'll work on a better solution, but for now this will fix most issues.
Brian Beuken
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's
Lecturer in Game Programming at Breda University of Applied Sciences.
Author of The Fundamentals of C/C++ Game Programming: Using Target-based Development on SBC's