Original Post
I am trying to use Photon''s routine for converting scan codes gathered using DirectInput into ASCII character codes. My program is using the full screen in exclusive mode. Unfortunately whenever I press a key the routine seems to be crashing my program and sending me back to plain old Windows.
The function is called as follows:
for(int iCount = 0; iCount < (INT)dwItems; iCount++)
{
//Convert the scan code to its ASCII equivalent.
scan2ascii(dodKey[iCount].dwOfs, lpdwAsciiResult);
pszText[iNextChar] = (char)lpdwAsciiResult;
NextChar++;
}
And the actual code is:
int scan2ascii(DWORD scancode, LPWORD result)
{
//Establish the keyboard layout for this thread.
static HKL layout=GetKeyboardLayout(0);
//Get the state of each virtual key and put it into the buffer
static BYTE State[256];
if (GetKeyboardState(State)==FALSE)
return 0;
//Convert the scancode into a virtual keycode.
UINT vk=MapVirtualKeyEx(scancode,1,layout);
//Convert the virtual key to ASCII based on the state of
//the keyboard. God knows why the scancode has to be supplied
//again.
return ToAsciiEx(vk,scancode,State,result,0,layout);
}
My guess is that the scan2ascii functionis somehow interfering with DirectDraw''s exclusive mode.
