Replaced ToAscii by ToUnicode in the User driver interface.

This commit is contained in:
Dmitry Timoshkov 2000-10-25 21:34:31 +00:00 committed by Alexandre Julliard
parent 1e19fe323f
commit 8a31634a00
9 changed files with 54 additions and 51 deletions

View file

@ -15,7 +15,7 @@ import kernel32.dll
@ cdecl VkKeyScan(long) TTYDRV_VkKeyScan @ cdecl VkKeyScan(long) TTYDRV_VkKeyScan
@ cdecl MapVirtualKey(long long) TTYDRV_MapVirtualKey @ cdecl MapVirtualKey(long long) TTYDRV_MapVirtualKey
@ cdecl GetKeyNameText(long str long) TTYDRV_GetKeyNameText @ cdecl GetKeyNameText(long str long) TTYDRV_GetKeyNameText
@ cdecl ToAscii(long long ptr ptr long) TTYDRV_ToAscii @ cdecl ToUnicode(long long ptr ptr long long) TTYDRV_ToUnicode
@ cdecl GetBeepActive() TTYDRV_GetBeepActive @ cdecl GetBeepActive() TTYDRV_GetBeepActive
@ cdecl SetBeepActive(long) TTYDRV_SetBeepActive @ cdecl SetBeepActive(long) TTYDRV_SetBeepActive
@ cdecl Beep() TTYDRV_Beep @ cdecl Beep() TTYDRV_Beep

View file

@ -70,10 +70,10 @@ INT16 TTYDRV_GetKeyNameText( LONG lParam, LPSTR lpBuffer, INT16 nSize )
} }
/*********************************************************************** /***********************************************************************
* TTYDRV_ToAscii * TTYDRV_ToUnicode
*/ */
INT16 TTYDRV_ToAscii( UINT16 virtKey, UINT16 scanCode, INT TTYDRV_ToUnicode( UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
LPBYTE lpKeyState, LPVOID lpChar, UINT16 flags ) LPWSTR pwszBuff, int cchBuff, UINT flags )
{ {
return 0; return 0;
} }

View file

@ -64,7 +64,7 @@ static BOOL load_driver(void)
GET_USER_FUNC(VkKeyScan); GET_USER_FUNC(VkKeyScan);
GET_USER_FUNC(MapVirtualKey); GET_USER_FUNC(MapVirtualKey);
GET_USER_FUNC(GetKeyNameText); GET_USER_FUNC(GetKeyNameText);
GET_USER_FUNC(ToAscii); GET_USER_FUNC(ToUnicode);
GET_USER_FUNC(GetBeepActive); GET_USER_FUNC(GetBeepActive);
GET_USER_FUNC(SetBeepActive); GET_USER_FUNC(SetBeepActive);
GET_USER_FUNC(Beep); GET_USER_FUNC(Beep);

View file

@ -15,7 +15,7 @@ import kernel32.dll
@ cdecl VkKeyScan(long) X11DRV_VkKeyScan @ cdecl VkKeyScan(long) X11DRV_VkKeyScan
@ cdecl MapVirtualKey(long long) X11DRV_MapVirtualKey @ cdecl MapVirtualKey(long long) X11DRV_MapVirtualKey
@ cdecl GetKeyNameText(long str long) X11DRV_GetKeyNameText @ cdecl GetKeyNameText(long str long) X11DRV_GetKeyNameText
@ cdecl ToAscii(long long ptr ptr long) X11DRV_ToAscii @ cdecl ToUnicode(long long ptr ptr long long) X11DRV_ToUnicode
@ cdecl GetBeepActive() X11DRV_GetBeepActive @ cdecl GetBeepActive() X11DRV_GetBeepActive
@ cdecl SetBeepActive(long) X11DRV_SetBeepActive @ cdecl SetBeepActive(long) X11DRV_SetBeepActive
@ cdecl Beep() X11DRV_Beep @ cdecl Beep() X11DRV_Beep

View file

@ -51,7 +51,7 @@ typedef struct tagUSER_DRIVER {
WORD (*pVkKeyScan)(CHAR); WORD (*pVkKeyScan)(CHAR);
UINT16 (*pMapVirtualKey)(UINT16, UINT16); UINT16 (*pMapVirtualKey)(UINT16, UINT16);
INT16 (*pGetKeyNameText)(LONG, LPSTR, INT16); INT16 (*pGetKeyNameText)(LONG, LPSTR, INT16);
INT16 (*pToAscii)(UINT16, UINT16, LPBYTE, LPVOID, UINT16); INT (*pToUnicode)(UINT, UINT, LPBYTE, LPWSTR, int, UINT);
BOOL (*pGetBeepActive)(void); BOOL (*pGetBeepActive)(void);
void (*pSetBeepActive)(BOOL); void (*pSetBeepActive)(BOOL);
void (*pBeep)(void); void (*pBeep)(void);

View file

@ -368,7 +368,6 @@ extern void X11DRV_InitKeyboard(void);
extern WORD X11DRV_VkKeyScan(CHAR cChar); extern WORD X11DRV_VkKeyScan(CHAR cChar);
extern UINT16 X11DRV_MapVirtualKey(UINT16 wCode, UINT16 wMapType); extern UINT16 X11DRV_MapVirtualKey(UINT16 wCode, UINT16 wMapType);
extern INT16 X11DRV_GetKeyNameText(LONG lParam, LPSTR lpBuffer, INT16 nSize); extern INT16 X11DRV_GetKeyNameText(LONG lParam, LPSTR lpBuffer, INT16 nSize);
extern INT16 X11DRV_ToAscii(UINT16 virtKey, UINT16 scanCode, LPBYTE lpKeyState, LPVOID lpChar, UINT16 flags);
extern BOOL X11DRV_GetDIState(DWORD len, LPVOID ptr); extern BOOL X11DRV_GetDIState(DWORD len, LPVOID ptr);
extern BOOL X11DRV_GetDIData(BYTE *keystate, DWORD dodsize, struct DIDEVICEOBJECTDATA *dod, LPDWORD entries, DWORD flags); extern BOOL X11DRV_GetDIData(BYTE *keystate, DWORD dodsize, struct DIDEVICEOBJECTDATA *dod, LPDWORD entries, DWORD flags);
extern void X11DRV_GetKeyboardConfig(struct tagKEYBOARD_CONFIG *cfg); extern void X11DRV_GetKeyboardConfig(struct tagKEYBOARD_CONFIG *cfg);

View file

@ -970,13 +970,39 @@ INT WINAPI GetKeyNameTextW(LONG lParam, LPWSTR lpBuffer, INT nSize)
return res; return res;
} }
/****************************************************************************
* ToUnicode (USER32.@)
*/
INT WINAPI ToUnicode(UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
LPWSTR lpwStr, int size, UINT flags)
{
return USER_Driver.pToUnicode(virtKey, scanCode, lpKeyState, lpwStr, size, flags);
}
/****************************************************************************
* ToUnicodeEx (USER32.@)
*/
INT WINAPI ToUnicodeEx(UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
LPWSTR lpwStr, int size, UINT flags, HKL hkl)
{
/* FIXME: need true implementation */
return ToUnicode(virtKey, scanCode, lpKeyState, lpwStr, size, flags);
}
/**************************************************************************** /****************************************************************************
* ToAscii (USER32.546) * ToAscii (USER32.546)
*/ */
INT WINAPI ToAscii( UINT virtKey,UINT scanCode,LPBYTE lpKeyState, INT WINAPI ToAscii( UINT virtKey,UINT scanCode,LPBYTE lpKeyState,
LPWORD lpChar,UINT flags ) LPWORD lpChar,UINT flags )
{ {
return ToAscii16(virtKey,scanCode,lpKeyState,lpChar,flags); WCHAR uni_chars[2];
INT ret, n_ret;
ret = ToUnicode(virtKey, scanCode, lpKeyState, uni_chars, 2, flags);
if(ret < 0) n_ret = 1; /* FIXME: make ToUnicode return 2 for dead chars */
else n_ret = ret;
WideCharToMultiByte(CP_ACP, 0, uni_chars, n_ret, (LPSTR)lpChar, 2, NULL, NULL);
return ret;
} }
/**************************************************************************** /****************************************************************************
@ -985,8 +1011,8 @@ INT WINAPI ToAscii( UINT virtKey,UINT scanCode,LPBYTE lpKeyState,
INT WINAPI ToAsciiEx( UINT virtKey, UINT scanCode, LPBYTE lpKeyState, INT WINAPI ToAsciiEx( UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
LPWORD lpChar, UINT flags, HKL dwhkl ) LPWORD lpChar, UINT flags, HKL dwhkl )
{ {
/* FIXME: need true implementation */ /* FIXME: need true implementation */
return ToAscii16(virtKey,scanCode,lpKeyState,lpChar,flags); return ToAscii(virtKey, scanCode, lpKeyState, lpChar, flags);
} }
/********************************************************************** /**********************************************************************
@ -1039,22 +1065,6 @@ BOOL WINAPI UnregisterHotKey(HWND hwnd,INT id) {
return TRUE; return TRUE;
} }
/***********************************************************************
* ToUnicode (USER32.548)
*/
INT WINAPI ToUnicode(
UINT wVirtKey,
UINT wScanCode,
PBYTE lpKeyState,
LPWSTR pwszBuff,
INT cchBuff,
UINT wFlags) {
FIXME_(keyboard)(": stub\n");
return 0;
}
/*********************************************************************** /***********************************************************************
* LoadKeyboardLayoutA (USER32.367) * LoadKeyboardLayoutA (USER32.367)
* Call ignored. WINE supports only system default keyboard layout. * Call ignored. WINE supports only system default keyboard layout.

View file

@ -252,7 +252,7 @@ INT16 WINAPI GetKeyNameText16(LONG lParam, LPSTR lpBuffer, INT16 nSize)
INT16 WINAPI ToAscii16(UINT16 virtKey,UINT16 scanCode, LPBYTE lpKeyState, INT16 WINAPI ToAscii16(UINT16 virtKey,UINT16 scanCode, LPBYTE lpKeyState,
LPVOID lpChar, UINT16 flags) LPVOID lpChar, UINT16 flags)
{ {
return USER_Driver.pToAscii( virtKey, scanCode, lpKeyState, lpChar, flags ); return ToAscii( virtKey, scanCode, lpKeyState, lpChar, flags );
} }
/*********************************************************************** /***********************************************************************

View file

@ -1369,9 +1369,9 @@ static char KEYBOARD_MapDeadKeysym(KeySym keysym)
} }
/*********************************************************************** /***********************************************************************
* X11DRV_ToAscii * X11DRV_ToUnicode
* *
* The ToAscii function translates the specified virtual-key code and keyboard * The ToUnicode function translates the specified virtual-key code and keyboard
* state to the corresponding Windows character or characters. * state to the corresponding Windows character or characters.
* *
* If the specified key is a dead key, the return value is negative. Otherwise, * If the specified key is a dead key, the return value is negative. Otherwise,
@ -1386,14 +1386,14 @@ static char KEYBOARD_MapDeadKeysym(KeySym keysym)
* FIXME : should do the above (return 2 for non matching deadchar+char combinations) * FIXME : should do the above (return 2 for non matching deadchar+char combinations)
* *
*/ */
INT16 X11DRV_ToAscii( INT X11DRV_ToUnicode(UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
UINT16 virtKey,UINT16 scanCode, LPBYTE lpKeyState, LPWSTR bufW, int bufW_size, UINT flags)
LPVOID lpChar, UINT16 flags)
{ {
XKeyEvent e; XKeyEvent e;
KeySym keysym; KeySym keysym;
INT ret; INT ret;
int keyc; int keyc;
BYTE lpChar[2];
if (scanCode==0) { if (scanCode==0) {
/* This happens when doing Alt+letter : a fake 'down arrow' key press /* This happens when doing Alt+letter : a fake 'down arrow' key press
@ -1453,13 +1453,12 @@ INT16 X11DRV_ToAscii(
ret = TSXLookupString(&e, (LPVOID)lpChar, 2, &keysym, NULL); ret = TSXLookupString(&e, (LPVOID)lpChar, 2, &keysym, NULL);
if (ret == 0) if (ret == 0)
{ {
BYTE dead_char = 0; BYTE dead_char;
((char*)lpChar)[1] = '\0';
dead_char = KEYBOARD_MapDeadKeysym(keysym); dead_char = KEYBOARD_MapDeadKeysym(keysym);
if (dead_char) if (dead_char)
{ {
*(char*)lpChar = dead_char; MultiByteToWideChar(main_key_tab[kbd_layout].layout_cp, 0, &dead_char, 1, bufW, bufW_size);
ret = -1; ret = -1;
} }
else else
@ -1478,9 +1477,7 @@ INT16 X11DRV_ToAscii(
} }
} }
} }
else { /* ret = 1 */ else { /* ret != 0 */
UINT ansi_cp = GetACP();
/* We have a special case to handle : Shift + arrow, shift + home, ... /* We have a special case to handle : Shift + arrow, shift + home, ...
X returns a char for it, but Windows doesn't. Let's eat it. */ X returns a char for it, but Windows doesn't. Let's eat it. */
if (!(lpKeyState[VK_NUMLOCK] & 0x01) /* NumLock is off */ if (!(lpKeyState[VK_NUMLOCK] & 0x01) /* NumLock is off */
@ -1499,27 +1496,24 @@ INT16 X11DRV_ToAscii(
ret = 0; ret = 0;
} }
/* perform translation to the current ansi code page */ /* perform translation to unicode */
if(ret && ansi_cp != main_key_tab[kbd_layout].layout_cp) if(ret)
{ {
WCHAR uni_char; TRACE_(key)("Translating char 0x%02x from code page %d to unicode\n",
TRACE_(key)("Translating char 0x%02x from cp %d to cp %d\n", *(BYTE *)lpChar, main_key_tab[kbd_layout].layout_cp);
*(BYTE *)lpChar, main_key_tab[kbd_layout].layout_cp, ansi_cp); ret = MultiByteToWideChar(main_key_tab[kbd_layout].layout_cp, 0, (LPCSTR)lpChar, ret, bufW, bufW_size);
MultiByteToWideChar(main_key_tab[kbd_layout].layout_cp, 0, lpChar, 1, &uni_char, 1);
ret = WideCharToMultiByte(ansi_cp, 0, &uni_char, 1, lpChar, 2, NULL, NULL);
TRACE_(key)("Translation result: 0x%04x, 0x%02x (%d)\n", uni_char, *(BYTE *)lpChar, ret);
} }
} }
TRACE_(key)("ToAscii about to return %d with char %x\n", TRACE_(key)("ToUnicode about to return %d with char %x %s\n",
ret, *(BYTE *)lpChar); ret, bufW ? bufW[1] : 0, bufW ? "" : "(no buffer)");
return ret; return ret;
} }
/*********************************************************************** /***********************************************************************
* X11DRV_GetBeepActive * X11DRV_GetBeepActive
*/ */
BOOL X11DRV_GetBeepActive() BOOL X11DRV_GetBeepActive(void)
{ {
XKeyboardState keyboard_state; XKeyboardState keyboard_state;
@ -1546,7 +1540,7 @@ void X11DRV_SetBeepActive(BOOL bActivate)
/*********************************************************************** /***********************************************************************
* X11DRV_Beep * X11DRV_Beep
*/ */
void X11DRV_Beep() void X11DRV_Beep(void)
{ {
TSXBell(display, 0); TSXBell(display, 0);
} }