Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (howardR), 1,065 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
A small contribution Read scancode of keys #440482
04/26/14 13:28
04/26/14 13:28
Joined: May 2008
Posts: 257
D
djfeeler Offline OP
Member
djfeeler  Offline OP
Member
D

Joined: May 2008
Posts: 257
Hello,

I have program a small program, read the scancode of keys. It is very useful ^^

to read the scancode you must type the key you want. At the end tape y to press an another letter or n to exit the progam.

Djfeeler

Scancode V2

Last edited by djfeeler; 04/27/14 10:23. Reason: bug fixes and add scan code for the mouse
Re: A small contribution Read scancode of keys [Re: djfeeler] #440527
04/27/14 14:14
04/27/14 14:14
Joined: Nov 2013
Posts: 47
S
SkullBoy99 Offline
Newbie
SkullBoy99  Offline
Newbie
S

Joined: Nov 2013
Posts: 47
Ok...so..what we can do with it?
I just want to know laugh

Re: A small contribution Read scancode of keys [Re: SkullBoy99] #440533
04/27/14 16:49
04/27/14 16:49
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Cool. This could be much simpler than the manual -

This program inputs the typed letter for example 'p' then outputs the scan code, which is scan_code 25.

If(key_lastpressed(25)){beep();}//if the last key pressed scan code is 25 then beep.


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: A small contribution Read scancode of keys [Re: DLively] #440539
04/27/14 17:44
04/27/14 17:44
Joined: Nov 2013
Posts: 47
S
SkullBoy99 Offline
Newbie
SkullBoy99  Offline
Newbie
S

Joined: Nov 2013
Posts: 47
Or
Code:
if(key_yourkey)
{
beep();
}


Very simple laugh.
Ok..I don't say this program isn't useful.

Re: A small contribution Read scancode of keys [Re: SkullBoy99] #440549
04/27/14 20:45
04/27/14 20:45
Joined: May 2008
Posts: 257
D
djfeeler Offline OP
Member
djfeeler  Offline OP
Member
D

Joined: May 2008
Posts: 257
For keyboards qwerty and azerty ?

This program is very useful.

Last edited by djfeeler; 04/27/14 20:53.
Re: A small contribution Read scancode of keys [Re: djfeeler] #440550
04/27/14 20:51
04/27/14 20:51
Joined: May 2008
Posts: 257
D
djfeeler Offline OP
Member
djfeeler  Offline OP
Member
D

Joined: May 2008
Posts: 257
Here's the code to help those who want to do:

Code:
// read scancode created by djfeeler

#include <acknex.h>
#include <default.c>

STRING* VG_str_letter = "";

TEXT* Txt_tape =
{
	pos_x = 10;
	pos_y = 10;
	layer = 1;
	font = "Arial#14";
}

TEXT* Txt_youHaveTape =
{
	pos_x = 10;
	pos_y = 30;
	layer = 1;
	font = "Arial#14";
}

TEXT* Txt_hisScanCode =
{
	pos_x = 10;
	pos_y = 50;
	layer = 1;
	font = "Arial#14";
}

TEXT* Txt_restart =
{
	pos_x = 10;
	pos_y = 70;
	layer = 1;
	font = "Arial#14";
}

void main()
{
	STRING* VL_str = "Press a letter : ";
	STRING* VL_str_key = "";
	STRING* VL_str_youHaveTape = "";
	STRING* VL_str_hisScanCodeis = "";
	STRING* VL_str_scanCode = "";
	STRING* VL_str_restart = "Restart ? y / n";
	
	video_window(NULL,NULL,0,"Scancode");
	
	while(1)
	{
		// Display Press a letter
		(Txt_tape.pstring)[0] = VL_str;
		set(Txt_tape,SHOW);
		while (!key_any) { wait(1); } // we expect the key to be pressed
		while (key_any){ wait(1); }
		
		if(key_lastpressed == 280 || key_lastpressed == 281 || key_lastpressed == 282)
		{
			str_cpy(VL_str_key,"");
			
			switch(key_lastpressed)
			{
				case 280 :
					str_cat(VL_str_key,"left mouse button");
				break;
				
				case 281 :
					str_cat(VL_str_key,"right mouse button");
				break;
				
				case 282 :
					str_cat(VL_str_key,"middle mouse button");
				break;
			}
		}
		else
			str_for_key(VL_str_key,key_lastpressed); // recovering key
		
		// Display You pressed the letter :
		str_cpy(VL_str_youHaveTape,"You pressed the letter : ");
		str_cat(VL_str_youHaveTape,VL_str_key);
		(Txt_youHaveTape.pstring)[0] = VL_str_youHaveTape;
		set(Txt_youHaveTape,SHOW);
		
		// Display His ScanCode is
		str_cpy(VL_str_hisScanCodeis,"His ScanCode is  : ");
		str_for_num(VL_str_scanCode,key_lastpressed);
		str_cat(VL_str_hisScanCodeis,VL_str_scanCode);
		(Txt_hisScanCode.pstring)[0] = VL_str_hisScanCodeis;
		set(Txt_hisScanCode,SHOW);
		
		// restart
		(Txt_restart.pstring)[0] = VL_str_restart;
		set(Txt_restart,SHOW);
		while (!key_any) { wait(1); } // on attends que la touche soit pressée
		while (key_any){ wait(1); }
		
	switch(key_lastpressed)
		{
			case 49 : // for key n
				sys_exit(NULL);
			break;
			
			case 21 : // for key y
				reset(Txt_restart,SHOW);
				reset(Txt_hisScanCode,SHOW);
				reset(Txt_youHaveTape,SHOW);
			break;
			
			default :
				sys_exit(NULL);
			break;
		}
		wait(1);
	}
}



Djfeeler

Last edited by djfeeler; 04/27/14 20:52.
Re: A small contribution Read scancode of keys [Re: djfeeler] #440551
04/27/14 21:57
04/27/14 21:57
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
you should look into structs... this could be done with a struct much simpler with less code wink


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1