[paid] Programmer wanted // different keyboard layouts

Posted By: preacherX

[paid] Programmer wanted // different keyboard layouts - 06/19/17 13:36

In my game the players have to use their keyboards but not only normal letters but also these special characters: " {} [] () , ; . - +

Now I need a function which can detect if theses keys are pressed. At the moment I'm using if(key_8 ==1 && (key_shiftr==1||key_shiftl==1)) for detecting if the ( is pressed. But this works only for german keyboard layouts, in other parts of the world ( is not on key 8.

Now I'm looking for a function which can detect these keys no matter which layout is used.

I found something at Microsoft which could be useful:

https://msdn.microsoft.com/en-us/library/system.windows.input.key(v=vs.110).aspx

But I don't know how to use it in lite-c...
Posted By: txesmi

Re: [paid] Programmer wanted // different keyboard layouts - 06/19/17 14:25

Hi,
the return of 'inchar' might help.
Posted By: preacherX

Re: [paid] Programmer wanted // different keyboard layouts - 06/19/17 15:22

WOW, I'm working so many years now with GameStudio and learn still new things! Thank you very much!!!
Posted By: Ch40zzC0d3r

Re: [paid] Programmer wanted // different keyboard layouts - 06/19/17 16:13

Code:
#include <acknex.h>
#include <windows.h>

LRESULT CALLBACK origWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK hkWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	if(message == WM_CHAR)
	{
		printf("Keypress: %c", wParam);	
	}
	
	return origWndProc(hwnd, message, wParam, lParam);
}

void main()
{
	origWndProc = on_message;
	on_message = hkWndProc;
}



Works fine too have fun with it
© 2024 lite-C Forums