I am currently having trouble correctly retrieving some of the keys on a standard keyboard (specifically F keys, arrow keys etc). I am cycling through all 256 ASCII characters using GetAsyncKeyState()
on each integer to see if it is pressed, and if so stores it as a char to use in a later SendMessage()
function.
this is so that I can allow a user to map a particular key to an Xbox 360 controller button/analog item by using XInput and then send the key to the topmost window when that button/analog item is triggered.
I am aware that the problem lies with hexadecimal/decimal conversion from the virtual key code identified by the GetAsyncKeyState()
function as, for example, when I press F4 (hex 73, dec 115) the char is assigned to "s" which in ASCII is the same hex/dec value.
Is Unicode the way forward for this? if so how would I implement this to retrieve the right values for the SendMessage()
function?
Below is the loop for GetAsyncKeyState()
while (mKey == NULL)
{
system("cls");
cout << "Press Key" << endl;
for (int i = 0; i < 256; i++)
{
if (GetAsyncKeyState((i) & SHRT_MAX))
{
mKey = i;
}
}
}
I am aware system("cls")
is bad practice but this console application is only a temporary solution.
Any help you can give will be greatly appreciated :)