I am using C in Fedora Linux to build a voice streaming application. I have audio running between two clients, but the next stage is to implement the user interface.
I am aiming to use different keyboard keys in a "push to talk" style, ie holding the "Q" key allows the user to talk to one user, "W" another and so on.
My question is, how would I go about implementing this? The transmit thread is just a while loop that reads 180 bytes from the sound card and sends it as a UDP packet. THe mist obvious issue is echoing of the key pressed, filling the screen with q's and w's, and how I can detect key down/key up in C. I am looking at ncurses
but it is a big topic!
Any ideas or further reading would be greatly appreciated.
J
The first part of your question, as to how to detect keypress without using ncurses
is answered excellently, using termios
, by @jim mcnamara
And ncurses
doesn't seem to be as scary as it sounds :-). Here is an ncurses
implementation which exactly ( almost ) satisfies your requirement. But according to this post, you need to add a notimeout()
call so that getch()
(ncurses one) doesn't wait for next keypress.