On 01/17/2012 09:32 AM, Aric Stewart wrote:
The problem is that there is no XK keycode for just Shift, Control or Menu so X11DRV_MapVirtualKeyEx maps them to Shift_L, etc. As a result the string XKeysymToString returns is a string with a _L or _R at the end, even if the "don't care" bit is set.
char *new_name;
INT rc = 0;
new_name = HeapAlloc(GetProcessHeap(),0,(idx-name)+1);
lstrcpynA(new_name,name,(idx-name)+1);
new_name[idx-name] = 0;
TRACE("found scan=%04x keyc=%u keysym=%04x new_string=%s\n",
scanCode, keyc, (int)keys, new_name);
if (lpBuffer && nSize)
rc = MultiByteToWideChar(CP_UNIXCP, 0, new_name, -1, lpBuffer, nSize);
HeapFree(GetProcessHeap(),0,new_name);
return rc;
I don't think you need an extra buffer. Just do something like: if (lpBuffer && nSize) { rc = MultiByteToWideChar(CP_UNIXCP, 0, new_name, idx - name, lpBuffer, nSize); if (nSize > idx - name) lpBuffer[idx - name] = 0; }
Of course need to account for rc.
Vitaliy
On 1/17/12 10:18 PM, Vitaliy Margolen wrote:
On 01/17/2012 09:32 AM, Aric Stewart wrote:
The problem is that there is no XK keycode for just Shift, Control or Menu so X11DRV_MapVirtualKeyEx maps them to Shift_L, etc. As a result the string XKeysymToString returns is a string with a _L or _R at the end, even if the "don't care" bit is set.
char *new_name;
INT rc = 0;
new_name = HeapAlloc(GetProcessHeap(),0,(idx-name)+1);
lstrcpynA(new_name,name,(idx-name)+1);
new_name[idx-name] = 0;
TRACE("found scan=%04x keyc=%u keysym=%04x new_string=%s\n",
scanCode, keyc, (int)keys, new_name);
if (lpBuffer&& nSize)
rc = MultiByteToWideChar(CP_UNIXCP, 0, new_name, -1, lpBuffer, nSize);
HeapFree(GetProcessHeap(),0,new_name);
return rc;
I don't think you need an extra buffer. Just do something like: if (lpBuffer&& nSize) { rc = MultiByteToWideChar(CP_UNIXCP, 0, new_name, idx - name, lpBuffer, nSize); if (nSize> idx - name) lpBuffer[idx - name] = 0; }
Of course need to account for rc.
Vitaliy
Can't really use idx after the MultiByteToWideChar but I could possibly use rc.
I will investigate quick. -aric