Hi! I'm new to Wine, but not a total newbie at C. I have a very specific interest: I would like Wine to support more keys.
Background: Windows has support for no fewer than 24 function keys; in fact, possibly, as many as 32. However, right now, Wine only supports 16 of them. It is insanely trivial to patch Wine to support 24 function keys by plugging new values into nonchar_key_vkey and nonchar_key_scan. It is not much harder to support 32 at least partially; some sites claim that vkey values 0x88-0x8F are intended to be used as F25-F32, but there are no corresponding codes. Well, okay; it's not unheard of for a key to have a vkey value but no corresponding scan code.
I have diffs for this. It works.
There's just one TINY little problem. Many Windows games have no support for these keys! NOOOOO!
I have implemented and tested a patch which is almost certainly unsuitable for production, but which is very convenient to me; it is this patch I enclose. This patch replaces F13-F24 with "control-alt-F1" through "control-alt-F12", and F25-F32 control-alt-shift-F1 through F8.
Now, this is great for me, but it is obviously unsuitable as the only behavior; it deprives people of functioning keys. (My implementation my also be utter crap, but "it works in Warcraft", and that's my real interest.)
I have no clue how to do Wine configuration settings. I think that this behavior is likely to be useful to a lot of people; X systems are easy to configure to generate extra keysyms, and many people have interesting keyboards which generate a broad range of additional values. Binding them to function keys is useful, and this patch would allow people to use such things in Windows games.
Insofar as I have any possible copyright claim on this patch, I hereby release it into the public domain. Also, not in patch form, the winuser.h change:
#define VK_F25 0x88 #define VK_F26 0x89 #define VK_F27 0x8A #define VK_F28 0x8B #define VK_F29 0x8C #define VK_F30 0x8D #define VK_F31 0x8E #define VK_F32 0x8F
--- *** keyboard.c.orig Mon Jan 22 11:10:15 2007 --- keyboard.c Mon Jan 22 13:59:38 2007 *************** *** 1020,1027 **** /* function keys */ VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6, VK_F7, VK_F8, VK_F9, VK_F10, /* FFC0 */ ! VK_F11, VK_F12, VK_F13, VK_F14, VK_F15, VK_F16, 0, 0, /* FFC8 */ ! 0, 0, 0, 0, 0, 0, 0, 0, /* FFD0 */ 0, 0, 0, 0, 0, 0, 0, 0, /* FFD8 */ /* modifier keys */ 0, VK_SHIFT, VK_SHIFT, VK_CONTROL, /* FFE0 */ --- 1020,1027 ---- /* function keys */ VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6, VK_F7, VK_F8, VK_F9, VK_F10, /* FFC0 */ ! VK_F11, VK_F12, VK_F13, VK_F14, VK_F15, VK_F16, VK_F17, VK_F18, /* FFC8 */ ! VK_F19, VK_F20, VK_F21, VK_F22, VK_F23, VK_F24, 0, 0, /* FFD0 */ 0, 0, 0, 0, 0, 0, 0, 0, /* FFD8 */ /* modifier keys */ 0, VK_SHIFT, VK_SHIFT, VK_CONTROL, /* FFE0 */ *************** *** 1066,1073 **** /* function keys */ 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, /* FFC0 */ ! 0x57, 0x58, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FFC8 */ ! 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FFD0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FFD8 */ /* modifier keys */ 0x00, 0x2A, 0x36, 0x1D, 0x11D, 0x3A, 0x00, 0x38, /* FFE0 */ --- 1066,1073 ---- /* function keys */ 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, /* FFC0 */ ! 0x57, 0x58, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, /* FFC8 */ ! 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x76, 0x00, 0x00, /* FFD0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* FFD8 */ /* modifier keys */ 0x00, 0x2A, 0x36, 0x1D, 0x11D, 0x3A, 0x00, 0x38, /* FFE0 */ *************** *** 1465,1471 **** if ( event->type == KeyRelease ) dwFlags |= KEYEVENTF_KEYUP; if ( vkey & 0x100 ) dwFlags |= KEYEVENTF_EXTENDEDKEY;
! X11DRV_send_keyboard_input( vkey & 0xff, bScan, dwFlags, event_time, 0, 0 ); } } } --- 1465,1499 ---- if ( event->type == KeyRelease ) dwFlags |= KEYEVENTF_KEYUP; if ( vkey & 0x100 ) dwFlags |= KEYEVENTF_EXTENDEDKEY;
! if ((vkey & 0xFF) >= VK_F13 && (vkey & 0xFF) <= VK_F24) { ! /* translate to control-alt-F(N-12) */ ! vkey = vkey - 12; ! if (event->type != KeyRelease) { ! X11DRV_send_keyboard_input(VK_MENU, 0, 0, event_time, 0, 0 ); ! X11DRV_send_keyboard_input(VK_CONTROL, 0, 0, event_time, 0, 0 ); ! } ! X11DRV_send_keyboard_input( vkey & 0xff, bScan, dwFlags, event_time, 0, 0 ); ! if (event->type != KeyRelease) { ! X11DRV_send_keyboard_input(VK_CONTROL, 0, KEYEVENTF_KEYUP, event_time, 0, 0 ); ! X11DRV_send_keyboard_input(VK_MENU, 0, KEYEVENTF_KEYUP, event_time, 0, 0 ); ! } ! } else if ((vkey & 0xFF) >= VK_F25 && (vkey & 0xFF) <= VK_F32) { ! /* translate to control-alt-F(N-12) */ ! vkey = vkey - 24; ! if (event->type != KeyRelease) { ! X11DRV_send_keyboard_input(VK_MENU, 0, 0, event_time, 0, 0 ); ! X11DRV_send_keyboard_input(VK_CONTROL, 0, 0, event_time, 0, 0 ); ! X11DRV_send_keyboard_input(VK_SHIFT, 0, 0, event_time, 0, 0 ); ! } ! X11DRV_send_keyboard_input( vkey & 0xff, bScan, dwFlags, event_time, 0, 0 ); ! if (event->type != KeyRelease) { ! X11DRV_send_keyboard_input(VK_SHIFT, 0, KEYEVENTF_KEYUP, event_time, 0, 0 ); ! X11DRV_send_keyboard_input(VK_CONTROL, 0, KEYEVENTF_KEYUP, event_time, 0, 0 ); ! X11DRV_send_keyboard_input(VK_MENU, 0, KEYEVENTF_KEYUP, event_time, 0, 0 ); ! } ! } else { ! X11DRV_send_keyboard_input( vkey & 0xff, bScan, dwFlags, event_time, 0, 0 ); ! } } } } *************** *** 2253,2260 **** function keys. Soooo.. We will leave the table alone and fudge the lookup here till the other part is found and fixed!!! */
! if ( ((scanCode >= 0x13b) && (scanCode <= 0x144)) || ! (scanCode == 0x157) || (scanCode == 0x158)) scanCode &= 0xff; /* remove "extended-key" flag for Fx keys */
/* let's do scancode -> keycode -> keysym -> String */ --- 2281,2290 ---- function keys. Soooo.. We will leave the table alone and fudge the lookup here till the other part is found and fixed!!! */
! if (((scanCode >= 0x13b) && (scanCode <= 0x144)) || ! ((scanCode >= 0x164) && (scanCode <= 0x16e)) || ! (scanCode == 0x157) || (scanCode == 0x158) || ! (scanCode == 0x176)) scanCode &= 0xff; /* remove "extended-key" flag for Fx keys */
/* let's do scancode -> keycode -> keysym -> String */
In message 20070122200734.BA13641A5C@guild.seebs.net, Peter Seebach writes:
I have implemented and tested a patch which is almost certainly unsuitable for production, but which is very convenient to me; it is this patch I enclose. This patch replaces F13-F24 with "control-alt-F1" through "control-alt-F12", and F25-F32 control-alt-shift-F1 through F8.
Except obviously this is the slightly older patch that only does 13-24. Oops! Well, it's a proof of concept anyway.
-s
"Peter Seebach" seebs@plethora.net wrote:
Hi! I'm new to Wine, but not a total newbie at C. I have a very specific interest: I would like Wine to support more keys.
Background: Windows has support for no fewer than 24 function keys; in fact, possibly, as many as 32. However, right now, Wine only supports 16 of them. It is insanely trivial to patch Wine to support 24 function keys by plugging new values into nonchar_key_vkey and nonchar_key_scan. It is not much harder to support 32 at least partially; some sites claim that vkey values 0x88-0x8F are intended to be used as F25-F32, but there are no corresponding codes. Well, okay; it's not unheard of for a key to have a vkey value but no corresponding scan code.
I have diffs for this. It works.
Please send this part of your work to wine-patches, it looks good and completely acceptable.
There's just one TINY little problem. Many Windows games have no support for these keys! NOOOOO!
We can do nothing about that. Under Windows that games won't start magically recognize unsupported keys and work either.
I have implemented and tested a patch which is almost certainly unsuitable for production, but which is very convenient to me; it is this patch I enclose. This patch replaces F13-F24 with "control-alt-F1" through "control-alt-F12", and F25-F32 control-alt-shift-F1 through F8.
If this is not how Windows handles those keys then that's obviously a not acceptable solution for Wine.
In message 009901c73ea9$578ecd00$0100a8c0@DMITRY, "Dmitry Timoshkov" writes:
I have implemented and tested a patch which is almost certainly unsuitable for production, but which is very convenient to me; it is this patch I enclose. This patch replaces F13-F24 with "control-alt-F1" through "control-alt-F12", and F25-F32 control-alt-shift-F1 through F8.
If this is not how Windows handles those keys then that's obviously a not acceptable solution for Wine.
How windows handles them is "you run a second app that hooks keys". Can I run one app under Wine that intercepts and modifies key codes for another?
I guess, I'm not sure what's "obvious" about this. I'd agree that it's obvious that we don't want the user to have no option at all but to have this very different behavior... However, it might make a wonderful *option* to have it, given that the usual windows behavior for keyboards like this is "make the user run a special application to hook key events".
-s
"Peter Seebach" seebs@plethora.net wrote:
If this is not how Windows handles those keys then that's obviously a not acceptable solution for Wine.
How windows handles them is "you run a second app that hooks keys". Can I run one app under Wine that intercepts and modifies key codes for another?
Usually xmodmap is used to redefine keys behaviour in X11, no need for 3rd party apps.
In message 015e01c73eb4$e93860d0$0100a8c0@DMITRY, "Dmitry Timoshkov" writes:
Usually xmodmap is used to redefine keys behaviour in X11, no need for 3rd party apps.
If xmodmap could do this, I'd agree.
Xmodmap can't map "F13" to "Control-F1", though, and many Windows apps can't hack F13. Xmodmap can only map keys to single keys; it can't change their modifiers.
If you have a keyboard with extra keys, on Windows, you'd run a special app (that probably came with the keyboard) to intercept those keys and turn them into something else; say, mapping the F13 key to Control-F1.
If we can't run an app like that in between X and Wine, then the closest we can come to the Windows Way is to offer people an opportunity to remap some X keys to other keys.
-s
Peter Seebach wrote:
In message 015e01c73eb4$e93860d0$0100a8c0@DMITRY, "Dmitry Timoshkov" writes:
Usually xmodmap is used to redefine keys behaviour in X11, no need for 3rd party apps.
If xmodmap could do this, I'd agree.
Xmodmap can't map "F13" to "Control-F1", though, and many Windows apps can't hack F13. Xmodmap can only map keys to single keys; it can't change their modifiers.
I'm sure I could hack you a small app that takes input events from /dev/input/eventX and uses XTest to fake X key events. That way you could 'map' F13 to Control-F1. I've written a few 'drivers' for input devices (MS Strategic Commander etc) that way.. and it works great.
tom (aka wereHamster :P )
On Tue, Jan 23, 2007 at 08:58:24AM +0100, Tomas Carnecky wrote:
I'm sure I could hack you a small app that takes input events from /dev/input/eventX and uses XTest to fake X key events. That way you could 'map' F13 to Control-F1. I've written a few 'drivers' for input devices (MS Strategic Commander etc) that way.. and it works great.
this app allready exists: http://hansmi.ch/software/inputd
On Mon, Jan 22, 2007 at 02:07:34PM -0600, Peter Seebach wrote:
I have implemented and tested a patch which is almost certainly unsuitable for production, but which is very convenient to me; it is this patch I enclose. This patch replaces F13-F24 with "control-alt-F1" through "control-alt-F12", and F25-F32 control-alt-shift-F1 through F8.
CTRL+ALT+Fn is used to switch to the text-consoles and back to X11 (at least on linux and openbsd). hardwire this in wine might not be a good idea.
In message 20070123100854.GH20585@byleth.sc-networks.de, Christoph Frick writes:
On Mon, Jan 22, 2007 at 02:07:34PM -0600, Peter Seebach wrote:
I have implemented and tested a patch which is almost certainly unsuitable for production, but which is very convenient to me; it is this patch I enclose. This patch replaces F13-F24 with "control-alt-F1" through "control-alt-F12", and F25-F32 control-alt-shift-F1 through F8.
CTRL+ALT+Fn is used to switch to the text-consoles and back to X11 (at least on linux and openbsd). hardwire this in wine might not be a good idea.
That's the thing that's neat about having Wine translate keycodes X has but Windows doesn't into keycodes you can't send in X (because something else would grab them) that Windows can use. :)
-s