LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Nop on September 11, 2006, 11:22:07

Title: Keyboard not responding since update to 1.0 beta3
Post by: Nop on September 11, 2006, 11:22:07
Hello!

I have upgraded a game client to the libs V1.0beta 3. The game has been running smoothly on V0.98 for about a year. Now a problem has occurred for about 3 out of maybe 100 users that the application no longer responds to the keyboard. To be exact, typed text is no longer accepted.

Question: Was there a major chane in the way keyboard input is processed?
Title: Keyboard not responding since update to 1.0 beta3
Post by: Matzon on September 11, 2006, 11:46:54
since 0.98 there has been some input changes.
How are you using the keyboard ?
Title: Keyboard not responding since update to 1.0 beta3
Post by: Nop on September 11, 2006, 15:00:30
The keyboard is polled about 20 times per second by the following code:

     
       Keyboard.next();

       int key = Keyboard.getEventKey();
       // react only to pressed keys
       if( Keyboard.getEventKeyState() )
       {
           // still holding the same old key
           if( lastKeyDown == key
               && System.currentTimeMillis() < lastKeyTime )
           {
               return;
           }
           lastKeyDown = key;
           lastKeyTime = Long.MAX_VALUE;
        switch( key )
           {
               case Keyboard.KEY_F12:
                   Game.getPeople().toggleNameMode();
                   break;
...


For those people experiencing the problem, the switch() is never called. For most people it works fine.

Before this code, there is a call to
Keyboard.isKeyDown( Keyyboard.KEY_ESCAPE ) ) for quitting the application. That always seems to work.
Title: Keyboard not responding since update to 1.0 beta3
Post by: Nop on September 26, 2006, 16:42:44
* BUMP *

Has anybody any idea what the problem might be?

Anything wrong with the way I am calling those methods?

We still have the problem, that keyboard works for most users, but for some their input is ingored.
Title: Keyboard not responding since update to 1.0 beta3
Post by: kappa on September 27, 2006, 00:18:22
Keyboard seems to work fine for me, heres some code on how it do it might help.

if (Keyboard.next()) {
           switch (Keyboard.getEventKey()) {
                                 
               case Keyboard.KEY_E:
                   if (Keyboard.getEventKeyState()) {
                       
                       emboss = !emboss;
                   }
                   break;
                   
               case Keyboard.KEY_M:
                   if (Keyboard.getEventKeyState()) {
                       
                       useMultitexture = ((!useMultitexture) && multitextureSupported);
                   }
                   break;
                   
               case Keyboard.KEY_B:
                   if (Keyboard.getEventKeyState()) {
                       
                       bumps = !bumps;
                   }
                   break;
                   
               case Keyboard.KEY_F:
                   if (Keyboard.getEventKeyState()) {
                       
                       filter++;
                       filter%=3;
                   }
                   break;
           }
       }
Title: Keyboard not responding since update to 1.0 beta3
Post by: Nop on October 07, 2006, 12:20:00
It appears that all users with the problem are using Windows 98.

Has anybody observed any problems with that version and LWJGL?
Title: Keyboard not responding since update to 1.0 beta3
Post by: Matzon on October 07, 2006, 12:38:31
I haven't. Unfortunately I dont have access to a win9x box, so a bit hard to find the cause
Title: Keyboard not responding since update to 1.0 beta3
Post by: Nop on October 08, 2006, 01:18:17
Clarification. I have learned that we have 7 users with this problem and all of them seem to have Windows 98 SE. The regular Win98 seems to work.

Also, the problem seems to be with regular keys. F-Keys and Enter do work, just all regularly typed keys are not coming through. This looks like it was not a problem with my code but with LWJGL under Win98.

Anybody out there who can confirm or disprove this theory?
Title: Keyboard not responding since update to 1.0 beta3
Post by: Nop on October 11, 2006, 18:44:06
I reworked my code a little according to the code sample posted and removed the time-dependent code. But no change, typed letters seem not to work on Windows 98 SE.
Title: Keyboard not responding since update to 1.0 beta3
Post by: Matzon on October 11, 2006, 19:36:53
have you tried with debug turned on(http://lwjgl.org/wiki/doku.php/lwjgl/tutorials/usingdebug)?
what version of directx is installed?
Title: Keyboard not responding since update to 1.0 beta3
Post by: elias on October 11, 2006, 20:37:21
I comitted a possible fix, please test these pre-built libraries (as I have no access to any win9x machines):

http://download.oddlabs.com/elias/lwjgl.jar
http://download.oddlabs.com/elias/lwjgl.dll

- elias
Title: Keyboard not responding since update to 1.0 beta3
Post by: Nop on October 13, 2006, 19:59:38
Nope, I haven't. I don't have a Win98 SE system either, otherwise I'd provide much better information. :-)

The problem has occurred at 7 of our players machines. It is reproducible there, but due to the nature of an online game I can't get there for debugging.

What was the nature of the changes in keyboard input between 0.98 and 1.0?
Title: Keyboard not responding since update to 1.0 beta3
Post by: elias on October 13, 2006, 20:06:29
Several changes, but mostly moving stuff from native to java which should be without any side effects, but you never know of course. The fix I comitted was a reversal of the removal of the usage of ToAscii for win9x machines. It seems that the alternative, ToUnicode, was only available for NT based OSes.

- elias
Title: Keyboard not responding since update to 1.0 beta3
Post by: Nop on October 14, 2006, 08:51:43
Quote from: "elias"Several changes, but mostly moving stuff from native to java which should be without any side effects, but you never know of course. The fix I comitted was a reversal of the removal of the usage of ToAscii for win9x machines. It seems that the alternative, ToUnicode, was only available for NT based OSes.

Ist it possible that this change is related to the problem? I think there are two circumstances that may be hinting at this:
- only Windows 98 SE machines are concerned
- only letters (which would go through this conversion) are disappearing, enter, function and cursor keys are working
Title: Keyboard not responding since update to 1.0 beta3
Post by: elias on October 14, 2006, 14:38:53
Hmm, by closer inspection it might not be the problem after all - I see you're not using the translated characters, but raw keys. Then I'm not sure what could cause this - the only bigger change I can recall is the dinput3->dinput8 conversion (with fallback to dinput3 if dinput8 is unavailable). What version of directx are your users running?

- elias
Title: Keyboard not responding since update to 1.0 beta3
Post by: elias on October 14, 2006, 14:40:41
Another thing - are you using JInput or similar, accessing directinput outside of LWJGL?

- elias
Title: Keyboard not responding since update to 1.0 beta3
Post by: Nop on October 15, 2006, 08:21:34
So far, I have precise information from two users having the problem:

Win 98 4.10 build 2222
DirectX 9.0c 4.09.0000.0904

Win 98 4.10 build 2222 A
4.09.0000.0904 (DirectX 9.0c)

All users did not change their system configuration except for updating my client software. My client did not contain any changes in the keyboard code, just the upgrade of the lwjgl libs.
Title: Keyboard not responding since update to 1.0 beta3
Post by: elias on October 15, 2006, 08:43:39
Ok, they should work fine with the directinput8 input methods of LWJGL, so I'm out of ideas, really :/ (I assume you've already tried -Dorg.lwjgl.util.Debug=true and checking any debug output to see if there's anything suspicious there) If you want to move forward on this issue, I see two possibilities:

1. Do a binary search on the LWJGL version, that is, try the LWJGL version "1.0beta", and if that works, "1.0beta2", until we know which version that broke input for you.
2. Go with my hunch and disable the directinput8 path:

Change:


   private static WindowsDirectInput createDirectInput() throws LWJGLException {
       try {
           return new WindowsDirectInput8(getDllInstance());
       } catch (LWJGLException e) {
           LWJGLUtil.log("Failed to create DirectInput 8 interface, falling back to DirectInput 3");
           return new WindowsDirectInput3(getDllInstance());
       }
   }


in WindowsDisplay.java to:


   private static WindowsDirectInput createDirectInput() throws LWJGLException {
           return new WindowsDirectInput3(getDllInstance());
   }

Title: Keyboard not responding since update to 1.0 beta3
Post by: Nop on October 21, 2006, 01:05:19
I have gotten some players to run a client with the debug flag enabled. Here is the result:

Illarion Client V0.98astarted Sat Oct 21 00:04:28 BST 2006
Initial mode: 1152 x 864 x 32 @0Hz
Found 30 displaymodes
Removed 0 duplicate displaymodes
Found mouse object: X-axis
Found mouse object: Y-axis
Found mouse object: Wheel
Found mouse object: Button 0
Found mouse object: Button 1
Found mouse object: Button 2
Mouse buffer overflowed


That is all, nothing else. And it is the same for every player.

Can it be the mousebuffer message? But the mouse is working for all of them.

Is there anything I can do about the mouse buffer?
Title: Keyboard not responding since update to 1.0 beta3
Post by: elias on October 21, 2006, 08:53:03
The mouse buffer message is normal, and can be ignored. I did a memory corruption fix (in SVN), which could theoretically cause all sorts of trouble. But it's very hard to trigger, so I'm not sure you are affected by this. Other than trying the current SVN version, I need you to do the binary search of the offending version and/or the dinput8->dinput3 fallback.

- elias
Title: Keyboard not responding since update to 1.0 beta3
Post by: Nop on October 30, 2006, 07:20:02
Ok, we have started the binary search. For a start I have reverted back to LWJGL 0.98. I have the first positive feedback that keyboard input works again with that version of the lib and the latest version of my code. I'm waiting for the feedback of some more people, then I am going to step up through the versions. Any bets which one it is going to be? :-)
Title: Keyboard not responding since update to 1.0 beta3
Post by: elias on October 30, 2006, 10:50:29
I'm guessing the version that introduced dinput8 support. Not sure if that was introduced in beta 3 or beta2.

- elias
Title: Keyboard not responding since update to 1.0 beta3
Post by: Nop on November 02, 2006, 17:42:40
I have moved to LWJGL 0.99 now. While the I/O works, for one player an unrelated problem has popped up. This is the log:

Initial mode: 1024 x 768 x 32 @0Hz
Exception occurred while querying registry: org.lwjgl.LWJGLException: Failed to open registry key
java.lang.NullPointerException
at org.lwjgl.opengl.Win32Display.nGetVersion(Native Method)
at org.lwjgl.opengl.Win32Display.getVersion(Win32Display.java:83)
at org.lwjgl.opengl.Display.getVersion(Display.java:826)


Any hint what's the problem here?
Title: Keyboard not responding since update to 1.0 beta3
Post by: elias on November 02, 2006, 22:23:17
It's a known bug with Display.getVersion()/getAdapter(), which is fixed (possibly only in SVN). You can work around it by catching the NPE and treating the value as null. Sorry for the inconvenience.

- elias
Title: Keyboard not responding since update to 1.0 beta3
Post by: Nop on November 03, 2006, 00:59:40
Can you tell me what causes this problem? Two players are having this problem, but when I start the same version, updated in the same manner, it runs fine.
Title: Keyboard not responding since update to 1.0 beta3
Post by: elias on November 03, 2006, 07:33:19
It's caused by a failure to read the registry key with the display adapter information. When it succeeds (on your machine) the bug is not triggered. The fix was a simple null check.

- elias
Title: Keyboard not responding since update to 1.0 beta3
Post by: Nop on November 10, 2006, 11:46:37
We have nailed down the problem. Everything is working fine up to V1.0 beta 1.

After update to V1.0 beta2 the keyboard is no longer working properly for Win 98 SE. F-keys, cursor keys and Alt-Shift-Ctrl do work, but letters do not.

I think your guess was correct. Now what can we do to solve the problem?
Title: Keyboard not responding since update to 1.0 beta3
Post by: elias on November 10, 2006, 12:02:30
Excellent. A quick check reveals that beta2 was the release that introduced dinput8 support (for jinput compatibility). The release also moved the input stuff from native to java. If my guess is correct, we'll need to disable dinput8 and test without it. Can you svn checkout the beta3 version (we fumbled the beta2 tag in SVN):


https://svn.sourceforge.net/svnroot/java-game-lib/tags/lwjgl1.0beta3


or the latest HEAD:


https://svn.sourceforge.net/svnroot/java-game-lib/trunk/LWJGL


and change src/jav/org/lwjgl/WindowsDisplay.java:

from:


   static WindowsDirectInput createDirectInput() throws LWJGLException {
       try {
           return new WindowsDirectInput8(getDllInstance());
       } catch (LWJGLException e) {
           LWJGLUtil.log("Failed to create DirectInput 8 interface, falling back to DirectInput 3");
           return new WindowsDirectInput3(getDllInstance());
       }
   }


to


   static WindowsDirectInput createDirectInput() throws LWJGLException {
           LWJGLUtil.log("Falling back to DirectInput 3");
           return new WindowsDirectInput3(getDllInstance());
   }


thus only using dinput3 everywhere. It should be equivalent to dinput8, except that jinput will not work with LWJGL. Rebuild lwjgl.jar and re-use the lwjgl.dll from beta3 (or one built freshly off HEAD).

If that fix works, I'll make sure dinput3 is always used on win9x machines.

Please reply if you have any doubts, or reach me on msn at: elias_naurAThotmail.com

- elias
Title: Keyboard not responding since update to 1.0 beta3
Post by: Nop on November 15, 2006, 19:56:33
I have done this, but it did not work. I changed the source to DirectX3 only and used that lwjgl.jar with the beta3 binaries. The no typing problem persists with this version.

Any more ideas?
Title: Keyboard not responding since update to 1.0 beta3
Post by: elias on November 16, 2006, 13:29:06
I finally got hold of a Win98 SE machine, to try and reproduce the bug. However, I can't reproduce what I think you specify as the bug, but I can reproduce the bug I fixed in HEAD that makes Keyboard.getEventCharacter() fail on (some?) win9x platforms. Your original code snippet does not contain getEventCharacter(), but the way you explain that the Function keys and the arrow keys work, makes me suspect that maybe it's not really getEventKey() that fails, but getEventCharacter instead.

So, I'd like to know exactly which method you use for "typing" that fails on Win98 SE - is it Keyboard.getEventKey() or Keyboard.getEventCharacter()? Note that I mean character input, not arrow keys, function keys and the escape key (which can only be queryed through getEventKey()). In fact, my question could be posed as: Do you use Keyboard.getEventCharacter() at all in your project?

- elias
Title: Keyboard not responding since update to 1.0 beta3
Post by: Nop on November 16, 2006, 21:28:49
I think you are right on the mark. I use getEventCharacter() to get the typed key after having handled the F- and cursor keys. The following is the code that takes the typed key and adds it to the editor (which does not work with the bug).

Quotedefault:
                   char c = Keyboard.getEventCharacter();
                   if( c >= 32 )
                   {
                       Gui.getEditor().addChar( c );
                   }
Title: Keyboard not responding since update to 1.0 beta3
Post by: elias on November 17, 2006, 06:50:55
Great! Then there's a good chance you'll find beta4 working on win98 SE. You can either wait for the release (should be very soon, probably this weekend), or if you like to test it, compile either directly from SVN or use these prebuilt binaries:

http://download.oddlabs.com/elias/lwjgl-17112006.zip

- elias
Title: Keyboard not responding since update to 1.0 beta3
Post by: Nop on November 17, 2006, 18:14:07
I have tried the pre-build files. Unfortunately this always gives me the following exception:

java.lang.IllegalStateException: Destroy the Keyboard first.
at org.lwjgl.input.Keyboard.create(Keyboard.java:293)
at org.lwjgl.input.Keyboard.create(Keyboard.java:312)


(I used the old lwgjl_util.jar, as there wasn't a pre-built one.)
Title: Keyboard not responding since update to 1.0 beta3
Post by: elias on November 17, 2006, 18:24:27
Try this newer lwjgl.jar with that bug fixed (you can keep the natives):

http://download.oddlabs.com/elias/lwjgl.jar

- elias
Title: Keyboard not responding since update to 1.0 beta3
Post by: Nop on November 18, 2006, 00:17:38
This appears to work. Thank you.