更改 USB 键盘的击键

发布于 2024-09-18 21:03:42 字数 360 浏览 17 评论 0原文

每次在常规键盘上按下一个键时,都会将数字“键代码”发送到计算机,例如。 32或51代表特定的按键。

与我用来输入这篇文章的默认键盘无关,我希望能够通过 USB 插入键盘,并将其键码全部向上移动一些常量 C。

因此,当按此键盘上的“a”键时侧键盘时,计算机不会接收“a”的键码,而是接收计算机没有计划响应的更高数字。

这些超出常规范围的击键将控制我的程序,该程序知道它们是什么并且会监听它们。

硬件或软件解决方案适合我。也许有为此目的出售的特殊键盘,或者也许一些与软件相关的修改可以让任何常规键盘实现这一点——我不知道。至关重要的是,键码转换仅适用于我的侧面键盘,而不适用于我用于常规操作的默认键盘。

我在 Windows 上。

Every time a key is pressed on a regular keyboard, a numeric 'key code' is sent to the computer, eg. 32 or 51 which represent specific keys.

Unrelated to my default keyboard which I am using to type this post, I want to be able to plug in a keyboard via USB and have its key codes all shifted up by some constant C.

Thus, when pressing the 'a' key on this side keyboard, the computer would not receive the keycode for 'a', but rather some higher number which the computer does not have a planned response to.

These out-of-conventional-range keystrokes will control a program of mine which knows what they are and will be listening for them.

Hardware or software solution would work for me. Perhaps there are special keyboards sold for this end, or maybe some software-related modification could let this be accomplished for any regular keyboard-- I have no idea. What is crucial is that the keycode shift applies only for my side keyboard and not my default keyboard which I use for regular stuff.

I'm on Windows.

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

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

发布评论

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

评论(2

北凤男飞 2024-09-25 21:03:42

我认为你对自己的限制远远超过了必要的程度。

对于初学者来说,您对 USB 键盘的描述已经简化了很多。情况比这要复杂一些。例如,您实际上获得了按键/按键序列。 (也称为“通断”)。

接下来的事情是您对操作系统对键盘的处理进行假设。如果第二个键盘声称它是 USB 键盘,则它将由 USB 键盘的操作系统驱动程序处理。这不会期望改变值。例如,在 Microsoft Windows 上,记录了以下行为:

避免 Set 1 扫描 0x79 以上的代码,
因为释放(按键)代码会
为 0xFA 或更大,并且键盘
众所周知,驱动程序会解释这样的
来自 8042 的响应值
芯片,而不是按键(扫码)。

接下来,操作系统将假设额外的键盘将提供额外的按键,并直接处理它。例如,有适用于笔记本电脑的数字 USB 键盘,Windows 只是将它们视为额外的 0-9+-/*= 键。它并不关心它们位于单独的硬件上。基本上,我认为第二个键盘想法不会成功。

现在 USB 通常将键盘视为更通用类的特例,这更加灵活: HID = 人类输入设备。 。例如,USB 操纵杆也是人类输入设备,典型的操作系统不会尝试解释操纵杆按钮。游戏应该直接处理它们,您的应用程序也可以。

I think you are restricting yourself far more than necessary.

For starters, your description of USB keyboards is simplified a lot. The situation is a bit more complex than that. For instance, you actually get key-down/key-up sequences. (Also known as make and break).

The next thing is that you're making assumptions about the handling of the keyboard by the OS. If the second keyboard claims it's an USB keyboard, it will be handled by the OS driver for USB keyboards. That will not expect shifted values. For instance, on Microsoft Windows, the following behavior is documented:

Avoid Set 1 scan codes above 0x79,
since the release (key up) code would
be 0xFA or greater, and the keyboard
driver is known to interpret such
values as responses from the 8042
chip, not as keystrokes (scan codes).

Next, an OS will assume that an extra keybaord will provide extra keys, and handle it directly. For instance, there are numeric USB keyboards available for laptops, and Windows just treats them as extra 0-9+-/*= keys. It doesn't care that they're on separate hardware. Basically, I don't think this second keayboard idea will fly.

Now USB usually treats keyboard as a special case of a more generic class, which is more flexible: HID = Human Input Devices. . For instance, USB joysticks are also Human Input Devices, and a typical OS doesn't try to interpret joystick buttons. Games are expected to handle them directly, and so could your app.

老旧海报 2024-09-25 21:03:42

嗯,听起来您需要更多的硬件解决方案而不是编程解决方案。试试这个 http://www.instructables.com/id/Hacking-a -USB-键盘/

Well it sounds like you'll need more of a hardware solution than a programming solution. Try this http://www.instructables.com/id/Hacking-a-USB-Keyboard/

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