Slick Forums

Discuss the Slick 2D Library
It is currently Mon Dec 10, 2018 12:25 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Aug 03, 2012 4:11 am 
Offline

Joined: Fri Aug 03, 2012 3:51 am
Posts: 1
Hello all,

I have two issues right now. The first is that isKeyDown() will return true if the game window loses focus while they key in question is down, even after returning to the game and no longer holding the key down. In my particular case, this makes it so that if the game is alt+tabbed out of and brought back up, pressing enter will switch between fullscreen and windowed mode (when it should be alt+enter). They alt key returns to normal functionality afterwards.

The second issue stems from trying to fix the first. I was attempting to check the container with hasFocus(), then destroy() and create() the Keyboard once it came back into focus. This only seemed to work in windowed mode. When investigating, I found that hasFocus() always returns true in fullscreen mode, whether alt+tabbed or not.

Here are the relevant areas of the update() function:

Code:
   public void update(GameContainer container, int delta) throws SlickException
   {   
      if(!container.hasFocus())
      {
         System.out.println("Container does not have focus"); //Does not print when alt+tabbed in fullscreen, does in windowed
      }
      Input input = container.getInput();   
      input.enableKeyRepeat();
      
         
      if(input.isKeyPressed(Input.KEY_ENTER))
      {
         if(input.isKeyDown(Input.KEY_LALT) || input.isKeyDown(Input.KEY_RALT))
         {
            Vars.fullscreen = !Vars.fullscreen;
            container.setFullscreen(Vars.fullscreen);
         }
      }
...


If anyone can help me with these issues, it'd be greatly appreciated. Either getting hasFocus() to work properly with fullscreen enabled or forcing a key release on LALT and RALT could help, but I haven't been able to figure out how to do these things.

Thanks for reading.


Top
 Profile  
 
PostPosted: Fri Aug 03, 2012 7:29 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1482
The first issue:
viewtopic.php?f=1&t=5260

The second issue sounds like another LWJGL bug, since hasFocus just calls Display.isActive.

So, in short... Neither of those are something we can fix on our end very easily.


Top
 Profile  
 
PostPosted: Tue Sep 18, 2012 1:46 pm 
Offline

Joined: Mon Sep 17, 2012 8:33 am
Posts: 1
I've found another issue that may be related to this. (Also, I think I already posted this here, but I can't find it anywhere. So forgive me, if I repost).

When I check input.isKeyDown on Shift or Ctrl keys, as soon as I press the key once, the isKeyDown method always returns true. This happens against the latest version of the dev branch. I verified the problem on a friends slick setup and he also could check, that the bug did not occur in the "stable" version published on the slick homepage.

This happens even if the window does not lose focus. I'm not sure which keys are all affected by this, I only found LCTRL, RCTRL, LSHIFT and RSHIFT are not working up until now.

Here is the test class I used to verify the problem outside of my project: http://pastebin.com/NUBZjAWK


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group