[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: How to detect a keypress, and in which language?



Wayne Topa wrote:
Kent West(westk@acu.edu) is reported to have said:
Hugo Vanwoerkom wrote:
Kent West wrote:
All I want to do is to detect two keys, say the left- and right-shift keys, or the < and > keys. For one key, a short "dit" audio tone would be generated, and for the other key, a longer "dah" audio tone would be generated. I need to bypass the keyboard buffer, so that holding down the dit key for two seconds doesn't generate 30 dits; it should produce dits while the key is held down, but once the key is let up, the dits should immediately stop (after finishing the one it's on).

IFAIK you've hit upon the one problem in cross-platform programming, access to the speaker for variable duration (dit and dah).

I would use Qt and that makes keypresses easy to detect, but not sound of variable duration, unless you don't mind recording a dit.wav and a dah.wav and then the problem is easy again.

Ah, this is the info I needed. Basically what I'm hearing is that it can't be done, easily, cross-platform, suitably for giving my fellow hams a taste of programming.

Bummer.

This may not be what your looking for either Kent, but...

Install the beep package.  Then, using bash, write a program to output
to the case speaker like this.

A="/usr/bin/beep -l 80 -f 1000 ;sleep .1;/usr/bin/beep -d 100 -l 250  -f 1000"
B="/usr/bin/beep -d 100 -l 250 -f 1000 ; sleep .1;/usr/bin/beep -l 80 -r 3 -f 1000"
etc

I have 'UP' sent every 5 minutes if I'm connected to the net (dialup).

Sorry if this is waaay OT.


Turns out that keypress access *is* the hardest. You have that in Qt but you have to be running in X and within a widget. It's ridiculous to do all that to find out if a key is pressed.

I have no idea how to find out in low-level programming whether a key is depressed.

Any kernel savvy people out there?

Hugo


















Reply to: