[linux-audio-dev] Re: C++ Keyboard Event Handling

David Olofson david at olofson.net
Fri Jan 20 13:51:50 UTC 2006


On Friday 20 January 2006 14:35, Carlo Capocasa wrote:
> Hi!
> 
> Yes, vkeybd is what I am using now. I set out to create a console
> alternative that is also more stable when pressing many keys at
> once.

You're talking about ghosting issues? (For example, if you hold A, S 
and Z, the keyboard will either generate a ghost X, or the X key is 
filtered out and won't respond, depending on how smart the keyboard 
MCU is.)

I'm afraid there's no way to fix that, as it's the result of keyboard 
hardware limitations. As if that isn't bad enough, the behavior 
varies across models and makes of keyboards. You can "sort of" make 
it work well enough for games buy picking keys that don't conflict in 
normal use, but polyphonic musical applications? No, I think that's 
pretty much futile, unless you modify the keyboard. (With a very 
simple MCU that doesn't do any smart filtering, you might get away 
with adding diodes at the key switches.)

You need to get a proper MIDI master keyboard. Or, if you *really* 
want to use a PC keyboard, replace the keyboard MCU with one of these 
boards they use for interfacing arcade joysticks and buttons with the 
keyboard port or USB.

Or maybe something like this:
	
http://www.creative.com/products/product.asp?category=8&subcategory=234&product=14118

(I don't know if that one's Linux compatible, though.)


> I also have a little bit of distrust for TCL scripted keyboard event
> handling when operating quasi-realtime.

Well, I don't know about TCL, but your average (garbage collected) 
scripting language won't exactly make things more deterministic.

Then again, the keyboard input subsystem isn't designed for rock solid 
real time operation either. If timing is critical, you should 
probably stick with MIDI and use ALSA directly from C code running in 
your audio thread, or maybe even a high priority real time thread 
that timestamps events as they arrive.


//David Olofson - Programmer, Composer, Open Source Advocate

.-------  http://olofson.net - Games, SDL examples  -------.
|        http://zeespace.net - 2.5D rendering engine       |
|       http://audiality.org - Music/audio engine          |
|     http://eel.olofson.net - Real time scripting         |
'--  http://www.reologica.se - Rheology instrumentation  --'



More information about the Linux-audio-dev mailing list