Commit 8a31634a authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

Replaced ToAscii by ToUnicode in the User driver interface.

parent 1e19fe32
......@@ -15,7 +15,7 @@ import kernel32.dll
@ cdecl VkKeyScan(long) TTYDRV_VkKeyScan
@ cdecl MapVirtualKey(long long) TTYDRV_MapVirtualKey
@ 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 SetBeepActive(long) TTYDRV_SetBeepActive
@ cdecl Beep() TTYDRV_Beep
......
......@@ -70,10 +70,10 @@ INT16 TTYDRV_GetKeyNameText( LONG lParam, LPSTR lpBuffer, INT16 nSize )
}
/***********************************************************************
* TTYDRV_ToAscii
* TTYDRV_ToUnicode
*/
INT16 TTYDRV_ToAscii( UINT16 virtKey, UINT16 scanCode,
LPBYTE lpKeyState, LPVOID lpChar, UINT16 flags )
INT TTYDRV_ToUnicode( UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
LPWSTR pwszBuff, int cchBuff, UINT flags )
{
return 0;
}
......
......@@ -64,7 +64,7 @@ static BOOL load_driver(void)
GET_USER_FUNC(VkKeyScan);
GET_USER_FUNC(MapVirtualKey);
GET_USER_FUNC(GetKeyNameText);
GET_USER_FUNC(ToAscii);
GET_USER_FUNC(ToUnicode);
GET_USER_FUNC(GetBeepActive);
GET_USER_FUNC(SetBeepActive);
GET_USER_FUNC(Beep);
......
......@@ -15,7 +15,7 @@ import kernel32.dll
@ cdecl VkKeyScan(long) X11DRV_VkKeyScan
@ cdecl MapVirtualKey(long long) X11DRV_MapVirtualKey
@ 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 SetBeepActive(long) X11DRV_SetBeepActive
@ cdecl Beep() X11DRV_Beep
......
......@@ -51,7 +51,7 @@ typedef struct tagUSER_DRIVER {
WORD (*pVkKeyScan)(CHAR);
UINT16 (*pMapVirtualKey)(UINT16, UINT16);
INT16 (*pGetKeyNameText)(LONG, LPSTR, INT16);
INT16 (*pToAscii)(UINT16, UINT16, LPBYTE, LPVOID, UINT16);
INT (*pToUnicode)(UINT, UINT, LPBYTE, LPWSTR, int, UINT);
BOOL (*pGetBeepActive)(void);
void (*pSetBeepActive)(BOOL);
void (*pBeep)(void);
......
......@@ -368,7 +368,6 @@ extern void X11DRV_InitKeyboard(void);
extern WORD X11DRV_VkKeyScan(CHAR cChar);
extern UINT16 X11DRV_MapVirtualKey(UINT16 wCode, UINT16 wMapType);
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_GetDIData(BYTE *keystate, DWORD dodsize, struct DIDEVICEOBJECTDATA *dod, LPDWORD entries, DWORD flags);
extern void X11DRV_GetKeyboardConfig(struct tagKEYBOARD_CONFIG *cfg);
......
......@@ -971,12 +971,38 @@ INT WINAPI GetKeyNameTextW(LONG lParam, LPWSTR lpBuffer, INT nSize)
}
/****************************************************************************
* 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)
*/
INT WINAPI ToAscii( UINT virtKey,UINT scanCode,LPBYTE lpKeyState,
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,
LPWORD lpChar, UINT flags, HKL dwhkl )
{
/* FIXME: need true implementation */
return ToAscii16(virtKey,scanCode,lpKeyState,lpChar,flags);
/* FIXME: need true implementation */
return ToAscii(virtKey, scanCode, lpKeyState, lpChar, flags);
}
/**********************************************************************
......@@ -1039,22 +1065,6 @@ BOOL WINAPI UnregisterHotKey(HWND hwnd,INT id) {
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)
* Call ignored. WINE supports only system default keyboard layout.
......
......@@ -252,7 +252,7 @@ INT16 WINAPI GetKeyNameText16(LONG lParam, LPSTR lpBuffer, INT16 nSize)
INT16 WINAPI ToAscii16(UINT16 virtKey,UINT16 scanCode, LPBYTE lpKeyState,
LPVOID lpChar, UINT16 flags)
{
return USER_Driver.pToAscii( virtKey, scanCode, lpKeyState, lpChar, flags );
return ToAscii( virtKey, scanCode, lpKeyState, lpChar, flags );
}
/***********************************************************************
......
......@@ -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.
*
* 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)
*
*/
INT16 X11DRV_ToAscii(
UINT16 virtKey,UINT16 scanCode, LPBYTE lpKeyState,
LPVOID lpChar, UINT16 flags)
INT X11DRV_ToUnicode(UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
LPWSTR bufW, int bufW_size, UINT flags)
{
XKeyEvent e;
KeySym keysym;
INT ret;
int keyc;
BYTE lpChar[2];
if (scanCode==0) {
/* 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);
if (ret == 0)
{
BYTE dead_char = 0;
BYTE dead_char;
((char*)lpChar)[1] = '\0';
dead_char = KEYBOARD_MapDeadKeysym(keysym);
if (dead_char)
{
*(char*)lpChar = dead_char;
MultiByteToWideChar(main_key_tab[kbd_layout].layout_cp, 0, &dead_char, 1, bufW, bufW_size);
ret = -1;
}
else
......@@ -1478,9 +1477,7 @@ INT16 X11DRV_ToAscii(
}
}
}
else { /* ret = 1 */
UINT ansi_cp = GetACP();
else { /* ret != 0 */
/* 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. */
if (!(lpKeyState[VK_NUMLOCK] & 0x01) /* NumLock is off */
......@@ -1499,27 +1496,24 @@ INT16 X11DRV_ToAscii(
ret = 0;
}
/* perform translation to the current ansi code page */
if(ret && ansi_cp != main_key_tab[kbd_layout].layout_cp)
/* perform translation to unicode */
if(ret)
{
WCHAR uni_char;
TRACE_(key)("Translating char 0x%02x from cp %d to cp %d\n",
*(BYTE *)lpChar, main_key_tab[kbd_layout].layout_cp, ansi_cp);
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)("Translating char 0x%02x from code page %d to unicode\n",
*(BYTE *)lpChar, main_key_tab[kbd_layout].layout_cp);
ret = MultiByteToWideChar(main_key_tab[kbd_layout].layout_cp, 0, (LPCSTR)lpChar, ret, bufW, bufW_size);
}
}
TRACE_(key)("ToAscii about to return %d with char %x\n",
ret, *(BYTE *)lpChar);
TRACE_(key)("ToUnicode about to return %d with char %x %s\n",
ret, bufW ? bufW[1] : 0, bufW ? "" : "(no buffer)");
return ret;
}
/***********************************************************************
* X11DRV_GetBeepActive
*/
BOOL X11DRV_GetBeepActive()
BOOL X11DRV_GetBeepActive(void)
{
XKeyboardState keyboard_state;
......@@ -1546,7 +1540,7 @@ void X11DRV_SetBeepActive(BOOL bActivate)
/***********************************************************************
* X11DRV_Beep
*/
void X11DRV_Beep()
void X11DRV_Beep(void)
{
TSXBell(display, 0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment