English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 13 August 2014, 21:09   #1
AGS
XoXo/Tasko Developer
 
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
Question ESC Key

Hi

I would like to know that the ESC Key is pressed. I have read that it has the RAWKEY code $45. This works, but only when I keep the ESC key pressed until the key-repeat starts (I guess). How to detect ESC key press immediately?

greets
A
AGS is offline  
Old 13 August 2014, 22:43   #2
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
Can you post your main loop. Did you using signals and Wait from exec.library ? Perhaps something ( function or it part ) takes too much time.

Here you are the example main loop from wb game (yep game is made by me ). And everything works like charm.

Code:
static void loop(void)
{
	g_bExitFromGame = FALSE;

	while (!g_bExitFromGame)
	{
		const ULONG signals = Wait(g_nWindowSignal | g_nMainTimerSig| g_nDemoTimerSig | g_nGamePortSignal | SIGBREAKF_CTRL_C);

		if (signals & SIGBREAKF_CTRL_C)
		{
			g_bExitFromGame = TRUE;
		}

		if (signals & g_nWindowSignal)
		{
			if (signalsWindow())
			{
				g_bExitFromGame = TRUE;
			}
		}

		if (signals & g_nGamePortSignal)
		{
			if (SignalsInput())
			{
				g_bExitFromGame = TRUE;
			}
		}

		if (g_bDemoMode)
		{
			if (signals & g_nDemoTimerSig)
			{
				DemoRun();
			}
		}

		if (signals & g_nMainTimerSig)
		{
			signalsMainTimer();
			g_nCnt++;
			(*g_pFnc)();
		}
	}
}
Asman is offline  
Old 13 August 2014, 22:55   #3
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
You can subscribe to IDCMP_RAWKEY events for your window, and you will receive an IECLASS_RAWKEY event with an ie_Code value of 69 immediately when ESC is pressed.
Leffmann is offline  
Old 14 August 2014, 04:08   #4
AGS
XoXo/Tasko Developer
 
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
My mainloop is probably correct as any other keys and klicks are processed immediately. I receive IDCMP_RAWKEY events.
AGS is offline  
Old 14 August 2014, 08:02   #5
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,003
Esc is a key like any other. If you get cursor up and cursor down, for example, then you get Esc, too. Immediately. If it seems for you that Esc does not arrive immediately, then your check is wrong. Or you have some strange software patch installed which removes Esc key presses from your system.
thomas is offline  
Old 14 August 2014, 11:33   #6
AGS
XoXo/Tasko Developer
 
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
I tried: When I replace the $45 of the ESC rawkey-code by for example $42 for shift-tab, the key is immediately reported. But with the value $45 it does not work. Happens in E-UAE, FS-UAE and OS4.1 environments.
AGS is offline  
Old 14 August 2014, 15:32   #7
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,003
I can assure you that the Esc key is not special. All of my programs quit when they receive an Esc key code. Immediately.

Have you set IDCMP_VANILLAKEY on your window, too? In this case you get VANILLAKEY events for all keys which have a single ASCII code. Only the remaining keys receive RAWKEY events.

The ASCII code for the Esc key is $1b.

You get a RAWKEY event for the Esc key when the repeat delay is expired.

For Tab you never get RAWKEY events when VANILLAKEY is set.

And you don't get key-up events when VANILLAKEY is set.
thomas is offline  
Old 14 August 2014, 15:37   #8
AGS
XoXo/Tasko Developer
 
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
THIS was the solution. I /have/ VANILLAKEY set also. Thus the raw code $45 for Escape was only sent when the repeat delay was expired. This was the reason why I needed to hold they key pressed to get the $45. Thanks.

ps: I still get RAWKEY events for SHIFT+TAB. I don't know if there is a VANILLAKEY code for SHIFT+TAB?
AGS is offline  
Old 14 August 2014, 16:05   #9
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,003
Shift is a qualifier, not a key. You get a VANILLAKEY event for Tab because there is an ASCII code for tab (9). You don't get a VANILLAKEY event for Shift-Tab because there is no ASCII code for back-tab.

$42 is the raw key code for Tab, not for Shift-Tab. There is no difference in raw key codes for Tab or Shift-Tab. Like I said, Shift is a qualifier and Tab is the key.
thomas is offline  
Old 14 August 2014, 16:10   #10
AGS
XoXo/Tasko Developer
 
AGS's Avatar
 
Join Date: Dec 2013
Location: Munich
Age: 48
Posts: 450
So then do I need to add a SHIFT qualifier check to my compares that check for SHIFT+TAB? I never had a problem with this, just asking ...
AGS is offline  
Old 14 August 2014, 17:15   #11
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,003
Strictly yes. If you one day decice to remove IDCMP_VANILLAKEY then you'll get $42 for Tab, Shift-Tab, Alt-Tab, Ctrl-Tab, Amiga-Tab, whatever is pressed in combination with Tab.
thomas is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
FS-UAE 2.5.6dev Amiga Key (Windows key) pops up the start menu Marskilla support.FS-UAE 3 23 September 2014 23:18
ESC key seems to crash Leslie Viljoen support.FS-UAE 1 17 December 2012 17:25
Disable LALT-ESC Ed Cruse request.UAE Wishlist 6 02 March 2011 19:56
LAlt-Esc key combo problem Ed Cruse support.WinUAE 0 20 January 2011 05:40
Amiga 'HELP' key - tribute thread to the abandoned key... Paul_s Amiga scene 22 23 July 2009 12:15

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:31.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.08193 seconds with 13 queries