Numpad translated characters

Started by james.kirk, July 03, 2007, 18:38:58

Previous topic - Next topic

james.kirk

I'm having trouble getting a character associated with most of the input from the numpad. Particularly, the numbers, '/', and '.'.
It seems that calling org.lwjgl.input.Keyboard.getEventCharacter() always returns 0 for those characters.  If anyone knows if this is a bug or if they have a solution, it'd be much appreciated.

Edit: The project is using lwjgl 1.0 and num lock is on ;)

james.kirk

It appears that org.lwjgl.input.Keyboard.getEventCharacter() uses private static int eventCharacter, which is set in org.lwjgl.input.Keyboard.next(), so for a windows keyboard, org.lwgl.opengl.WindowsKeyboard.translateData(IntBuffer, ByteBuffer) processes the buffered keys.  In my case, I'm using unicode and so, the num_chars = ToUnicode(...) runs within this method.  This ALWAYS returns 0 when pressing the above mentioned keys.

ToUnicode is a native function in src\native\windows\org_lwjgl_opengl_WindowsKeyboard.c

It appears, that its preparing the buffer to be passed onto a windows dll's (user32.dll) function with the same name 'ToUnicode'.

http://msdn2.microsoft.com/en-us/library/ms646320.aspx  (<-- this one to be specific)

I can't seem to find any references on the net about the windows ToUnicode having trouble with numpad conversions, so that's why i'm posting here about the issue.  I did find a comment on JME's forum which stated the person was having the same problem. It was suggested to him that he post here about it, but I can't find any follow ups on the subject.

If this issue was fixed in lwjgl 1.1, that would be helpful to know also. I could more easily convince the team to update the library if so.

Matzon

I just ran KeyboardTest, and this is the output:

Quote
Checking key:DIVIDE
Pressed:true
Key character code: 0x2f
Key character: /
Repeat event: false

Checking key:MULTIPLY
Pressed:true
Key character code: 0x2a
Key character: *
Repeat event: false

Checking key:SUBTRACT
Pressed:true
Key character code: 0x2d
Key character: -
Repeat event: false

Checking key:ADD
Pressed:true
Key character code: 0x2b
Key character: +
Repeat event: false

Checking key:RETURN
Pressed:true
Key character code: 0xd
Key character:
Repeat event: false

Checking key:DELETE
Pressed:true
Key character code: 0x0
Key character:
Repeat event: false

Checking key:NUMLOCK
Pressed:true
Key character code: 0x0
Key character:
Repeat event: false

Checking key:DECIMAL
Pressed:true
Key character code: 0x2c
Key character: ,
Repeat event: false

james.kirk

Hey Matzon,
Thanks for taking a peek at this for me. I was unaware of the KeyboardTest and so also ran it.

Using lwjgl 1.0 on windows I am getting this:

Quote
Checking key:DIVIDE
Pressed:true
Key character:

Checking key:MULTIPLY
Pressed:true
Key character: *

Checking key:SUBTRACT
Pressed:true
Key character: -

Checking key:ADD
Pressed:true
Key character: +

Checking key:RETURN
Pressed:true
Key character:


Checking key:DELETE
Pressed:true
Key character:

Checking key:NUMLOCK
Pressed:true
Key character:

Checking key:DECIMAL
Pressed:true
Key character:


And so i tried with the 1.1 jars and dlls and it appears to output the correct results. (which you had gotten)

This answers my question. It looks like i'll need to do an update. Thanks!