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 */