Extending the Windows Keyboard
I'm interested in extending the keys on the Windows keyboard (specifically - but not necessarily limited to - Windows 7). Currently I can use the keys available here in my C# application:
http://msdn.microsoft.开发者_高级运维com/en-us/library/system.windows.forms.keys(v=vs.71).aspx
What I'm interested in doing is extending the available keycodes so I can tailor them to my particular (programmable keyboard) hardware, and then be able to register these in my C#/DirectX applications. I know it is possible to create hotkey combinations, but I'd like to explore this option first. My questions are:
A) is this approach completely crazy?
B) if A == false: has anyone had any practical experience with this. Can you recommend any good keywords/tutorials that I should be looking at?
It is my understanding that Windows only accepts mouse/keyboard input based on the Keys enumeration (Virtual-keys in the unmanged world: http://msdn.microsoft.com/en-us/library/dd375731(v=vs.85).aspx). This makes your option A impossible to do on Windows.
As a concrete example Windows only has codes for five mouse buttons (LButton
, RButton
, MButton
, XButton1
, XButton2
) but you can purchase a mouse that comes with more than five buttons. New virtual-key codes for the extended buttons cannot be created on the fly. To get around this limitation mice like this come with software that allows you to program what a press of each button does. Generally you'll find options to bind the extended buttons to a single press of some other virtual-key code or even write more complex macros that combine multiple key presses.
In your application the best you will be able to do is ensure that you properly handle the full range of values (and modifier combinations) from the Keys enumeration. Then program your keyboard appropriately. This may mean taking advantage of some of the extended virtual-keys like BrowserForward
to make a larger set of virtual-key codes immediately available or generating more complex macros to enter a quick succession of virtual-key codes.
精彩评论