NUM 1, to NUM 9, and curser keys just the same ???

Posted By: sebbi91

NUM 1, to NUM 9, and curser keys just the same ??? - 10/17/10 15:28

Hi 3dgs Members

I am just wondering why it's even not possible to handle the NUM keys from NUM 1 to NUM 9 the curser keys ,Pg up and PG dn, the home key and Pos key discreted.

I tried it so long but I can't handle it!

If I press the NUM8 key its the same if I press the CUU key?

WHY?

That's worse because I need the Num keys and the curser keys discreted because of a small splitscreen-game.

I noticed that I can't use NUM5.


I tried to handle it with
Code:
if(key_cuu)



and
Code:
if(key_pressed(72))



but the result is the same. frown


My question is simple:

Is there a way to hande the NUM keys ,the curser and special keys(home,pgdn,pgup,pos) discreted?



I hope anyone could help me.

best regards

Sebastian
Posted By: Michael_Schwarz

Re: NUM 1, to NUM 9, and curser keys just the same ??? - 10/17/10 17:59

press the num-lock button?
Posted By: sebbi91

Re: NUM 1, to NUM 9, and curser keys just the same ??? - 10/17/10 18:07

Thats the problem if I press the NUM lock key its the same!
if i press key_cuu player1 is moving and if I press NUM8 Player1 is moving.
But I want that Player1 can controll his player with the arrow keys and Player2 can controll his Player with the NUM keys.

And I have no Idea to use NUM5.

Any Ideas?
Posted By: flits

Re: NUM 1, to NUM 9, and curser keys just the same ??? - 10/18/10 10:23

using win api

i did some lookup it isnt that hard

GetKeyState(0x61); // 0x61 is the virtual key if not presses == 1 else isnt 1

make sure you include #include <windows.h>

here here is the page of al virtual keys

http://msdn.microsoft.com/en-us/library/dd375731(v=VS.85).aspx
Posted By: sebbi91

Re: NUM 1, to NUM 9, and curser keys just the same ??? - 10/19/10 14:30

o.O
Thanks for the tipp.
But, ehhh ... I can't get it working.
can you give me a Testscript plaease.

I used the Search funtion and the manual but I can't find an example.

thanks in advance.

best regards
Posted By: flits

Re: NUM 1, to NUM 9, and curser keys just the same ??? - 10/20/10 10:48

here you go there are even some caps and left right shift axamples


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


void main()
{
	wait(2);
	
	while(1)
	{
		if(GetKeyState(0x60) <  0)
		{
			draw_text("num0 is pressed",5,5,vector(255,255,255));
		}
		
		if(GetKeyState(0x65) <  0){draw_text("num5 is pressed",5,25,vector(255,255,255));}
		
		if(GetKeyState(0x90) == 1)
		{
			draw_text("numlock is on",5,50,vector(255,255,255));
		}
		else
		{
			draw_text("numlock is off",5,50,vector(255,255,255));
		}
		
		if(GetKeyState(0x14) == 1)
		{
			draw_text("numlock is on",5,75,vector(255,255,255));
		}
		else
		{
			draw_text("caps is off",5,75,vector(255,255,255));
		}
		
		
		if(GetKeyState(0xA0) < 0)
		{
			draw_text("left shift is pressed",5,100,vector(255,255,255));
		}
		if(GetKeyState(0xA1) < 0)
		{
			draw_text("right shift is pressed",200,100,vector(255,255,255));
		}
		
		wait(1);
	}
	
	
	wait(1);
}


Posted By: sebbi91

Re: NUM 1, to NUM 9, and curser keys just the same ??? - 10/20/10 16:45

ahhhh....

Thank you very much ^^
My mistake I tried it in a wrong way.

regards
Sebastian
© 2024 lite-C Forums