1

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

aktungmak
  • 409
  • 1
  • 5
  • 13

1 Answers1

0

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.

Community
  • 1
  • 1
Pavan Manjunath
  • 27,404
  • 12
  • 99
  • 125
  • ncurses does not detect key press/key release events. You would need a lower level library to do that. – Craig Feb 17 '12 at 22:31
  • that helped out, I have realised that it would be easier to use a switching style mechanism for the call controls. You're right, ncurses isn't so bad I have managed to get a prototype going already! – aktungmak Feb 19 '12 at 18:34