将 USB 键盘的行为更改或覆盖为更通用的控制器

发布于 2024-11-09 05:03:59 字数 400 浏览 6 评论 0原文

我的问题

与上面的一个...(没有明确的答案)

我有一个漂亮的 USB 键盘,我想用它来控制我正在编写的音频/视频程序。我不能让 USB 键盘输入干扰常规操作系统接口 -

因此我需要让操作系统将其识别为某种通用 HID 设备、MIDI 设备或其他设备发送 OSC 消息。

我正在 OSX 上编写程序,但想找出一个跨平台解决方案,不涉及我破解键盘的硬件 - 希望我可以使用某种程序或脚本。这样做的原因是我想分发这个程序以供其他人轻松使用。

关于从哪里开始有什么想法吗?我想我可能需要编写一个单独的程序,供用户选择 USB 设备并将其重新路由到我的程序中...

任何语言都可以 - 我用 Python、有时用 C 和 Java/Processing 编写代码。

Changing the keystrokes of a USB keyboard

My question is very similar to the one above... (to which there was no clear answer)

I have a nice USB keyboard that I would like to use to control an audio/visual program I am writing. I can't have the USB keyboard input interfere with the regular operating system interface -

Therefore I need to have the OS recognize it as a generic HID device of some kind, or a MIDI device, or something that sends OSC messages.

I am writing the program on OSX but would like to figure out a cross platform solution that doesn't involve me hacking the hardware of the keyboard - hopefully some sort of program or script that I can use. The reason for this is I'd like to distribute this program for others to use easily.

Any ideas on where to start? I'm thinking I'll probably need to write a separate program for users to select a USB device and reroute that into my program...

Any language is fine - I write code in Python, sometimes C, and Java / Processing.

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

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

发布评论

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

评论(2

天生の放荡 2024-11-16 05:03:59

不幸的是,您会发现这极其困难:大多数现代操作系统都会自动检测 HID 配置文件并为其加载驱动程序,一般来说,很难覆盖该默认行为。

如果不破解硬件,您是否需要以某种方式覆盖操作系统针对特定 USB VID(供应商 ID)和 PID(产品 ID)的默认行为,并指示操作系统加载您自己的自定义内核扩展?我建议从 http 处的 AppleUSBKeyboard 驱动程序源开始: //www.opensource.apple.com/source/IOUSBFamily/IOUSBFamily-206.4.1/AppleUSBKeyboard/ 然后弄清楚如何安装您的自定义构建为您特定键盘的 VID 和 PID 的首选 USB 驱动程序。之后,这应该是一个混乱的问题,只将密钥发送到您的应用程序,而不发送到其他任何东西。

Unfortunately you're going to find this EXTREMELY difficult to do: most modern operating systems will automatically detect the HID profile and load the drivers for it, and generally speaking make it very difficult to override that default behavior.

Without hacking the hardware you would need to somehow override the OS's default behavior for that specific USB VID (vendor ID) and PID (product ID) and instruct the OS to load your own custom kernel extension? I'd suggest starting with source of the AppleUSBKeyboard drivers at http://www.opensource.apple.com/source/IOUSBFamily/IOUSBFamily-206.4.1/AppleUSBKeyboard/ and then figuring out how to install your custom build as the preferred USB driver for your specific keyboard's VID and PID. After that it should be the messy messy messy issue of only sending the keys to your app and not to anything else.

信愁 2024-11-16 05:03:59

能不能写一个
禁用常规功能
操作系统键盘输入
除 ESC 之类的所有键 if
我的程序是焦点吗? ——杰弗里·梅
24 日 21:59

是的,这应该是很有可能的,我不了解 Mac,但在 Win32 上你需要一个全局键盘钩子(查找 SetWindowsHookEx)

Would it be possible to write a
function that disables regular
operating system keyboard input for
all keys except something like ESC if
my program is in focus? – jeffrey May
24 at 21:59

Yes this should be quite possible, I dont know about Mac but on Win32 you want a global keyboard hook (look up SetWindowsHookEx)

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