“推动制作”键盘按键的风格使用

发布于 2025-01-07 09:38:56 字数 322 浏览 2 评论 0原文

我正在 Fedora Linux 中使用 C 来构建语音流应用程序。我在两个客户端之间运行音频,但下一阶段是实现用户界面。

我的目标是以“一键通话”方式使用不同的键盘按键,即按住“Q”键允许用户与一个用户交谈,“W”键允许用户与另一个用户交谈,依此类推。

我的问题是,我将如何实施这个?传输线程只是一个 while 循环,它从声卡读取 180 个字节并将其作为 UDP 数据包发送。最明显的问题是按键的回声,用 q 和 w 填充屏幕,以及如何在 C 中检测按键按下/按键按下。我正在查看 ncurses,但这是一个很大的主题!

任何想法或进一步阅读将不胜感激。

J

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲娇萝莉攻 2025-01-14 09:38:56

您的问题的第一部分,关于如何在不使用 ncurses 的情况下检测按键是 使用 termios 很好地回答了,作者:@jim mcnamara

并且 ncurses 似乎并不那么可怕声音:-)。 这里是一个ncurses实现,它完全(几乎)满足你的要求。但根据 这篇文章,您需要添加 notimeout( ) 调用,以便 getch()(ncurses one) 不会等待下一次按键。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文