Problem with key presses, mac-exult & SDL 1.1.3

Hi,

I’m currently doing the mac port of exult. Now, i have a strange
problem: key presses are only recognized the first time. I.e. if I
press ‘i’ to show the inventory, works fine. If I press ‘i’ again, it
isn’t detected! I checked via Debugger, the event doesn’t even reach
exult code…

Anyone got an idea or has experienced similiar problems?

If not, don’t bother to dive into it, I just ask in case someone has
a quick solution for this. Otherwise, I will try to dig this out
myself later on.

Bye,

Max–

Max “The Black Fingolfin” Horn
mailto:Max_Horn
http://www.quendi.de - please use my guestbook!

I have seen this in other games I have tried to port. I haven’t really
investigated it though. I have gotten events to work in a different project
by using this code, called on every game iteration:

int handleEvents () {

SDL_Event event;

while (SDL_PollEvent (&event))
switch (event.type) {

case SDL_KEYDOWN:
  switch ( event.key.keysym.sym ) {
          
    case SDLK_SPACE:
      return 0;
  
  }
  break;
 
case SDL_QUIT:
  return 0; 
}

return 1;
}

The main game loop looks like this:

while (handleEvents()) {

// do stuff

}

Maybe exult is polling for events in some other fashion? That might indicate
what part of the event code is broken.

HTH,
Darrell> From: Max Horn

Reply-To: sdl at lokigames.com
Date: Thu, 29 Jun 2000 17:40:04 +0200
To: sdl at lokigames.com
Subject: [SDL] Problem with key presses, mac-exult & SDL 1.1.3

Hi,

I’m currently doing the mac port of exult. Now, i have a strange
problem: key presses are only recognized the first time. I.e. if I
press ‘i’ to show the inventory, works fine. If I press ‘i’ again, it
isn’t detected! I checked via Debugger, the event doesn’t even reach
exult code…

Anyone got an idea or has experienced similiar problems?

If not, don’t bother to dive into it, I just ask in case someone has
a quick solution for this. Otherwise, I will try to dig this out
myself later on.

Bye,

Max


Max “The Black Fingolfin” Horn
<mailto:max at quendi.de>
http://www.quendi.de - please use my guestbook!

I think I found the problem: SDL receives no keyUp events from the
OS! I dunno how to fix this right now, though :frowning:

Bye,

Max–

Max “The Black Fingolfin” Horn
mailto:Max_Horn
http://www.quendi.de - please use my guestbook!

I think I found it. You were probably running from the debugger, right? Try
running without the debugger, it should catch the keyUp event. CodeWarrior
must be modifying the OS event mask. So I put this line of code in:

static int Mac_HandleActivate(int activate)
{
if ( activate ) {
if ( !(SDL_cursorstate & CURSOR_VISIBLE) ) {
HideCursor();
}
SDL_SetCursor(NULL);

  /* put our mask back in case it changed during context switch */
  SetEventMask(everyEvent - autoKeyMask);
          
} else {

At 14:23 Uhr -0600 29.06.2000, Darrell Walisser wrote:

I think I found it. You were probably running from the debugger, right? Try
running without the debugger, it should catch the keyUp event. CodeWarrior
must be modifying the OS event mask. So I put this line of code in:

Yes! That solved it! Thank you! Now, maybe this code could be put
into main SDL, with #if DEBUG … #endif so it only gets into debug
builds?!?

Bye,

Max–

Max “The Black Fingolfin” Horn
mailto:Max_Horn
http://www.quendi.de - please use my guestbook!