Hello Guest

[RFE] Buffered ' and " when polling for keyboard events

  • 16 Replies
  • 12580 Views

Re: Buffered ' and " when polling for keyboard events
« Reply #1 on: September 24, 2011, 21:30:10 »
After looking into it (thanks Riven!) it appears on several keyboard layouts. if you for example choose the layout for United States-International, the keys ~, ^, ' and " is only displayed after after one extra keystroke, in which case you'll either get two letters appearing, or the special ones ó, î õ, ÿ and so on. I don't know if lwjgl can read two characters when only one keystroke appears (I guess not?) which is why it doesn't work.

If anyone has any ideas I'm all ears.

http://support.microsoft.com/kb/306560/en-us a bit down is an explanation.

Mike
« Last Edit: September 24, 2011, 21:32:54 by Mickelukas »

Re: Buffered ' and " when polling for keyboard events
« Reply #2 on: September 25, 2011, 18:24:01 »
Looks like we need to somehow use WM_DEADCHAR on Windows?

http://msdn.microsoft.com/en-us/library/windows/desktop/ms646277(v=VS.85).aspx
cool story, bro

Re: Buffered ' and " when polling for keyboard events
« Reply #3 on: September 25, 2011, 21:52:08 »
That looks precisely like it! Is it difficult to pick up those messages?

Mike

Re: Buffered ' and " when polling for keyboard events
« Reply #4 on: September 26, 2011, 02:38:41 »
I'm not sure how you would incorporate it with WM_CHAR to ignore it though unfortunately, unless WM_DEADCHAR always gets called first.  There must be a way...but have no idea right now.
cool story, bro

Re: Buffered ' and " when polling for keyboard events
« Reply #5 on: September 26, 2011, 06:17:33 »
Is there anything I can do to help? I'm not very good in c++ (very rusty even) so I don't think I can mess around in the native code, but if there is something that can be tested in the java part...?

Mike

Re: Buffered ' and " when polling for keyboard events
« Reply #6 on: September 27, 2011, 15:39:12 »
It sounds like an RFE/Bug, can someone move the thread?

Mike

*

Offline kappa

  • *****
  • 1313
Re: [RFE] Buffered ' and " when polling for keyboard events
« Reply #7 on: September 28, 2011, 10:14:08 »
At a glance I assume that the above is related to the recent RFE for a Text API ?.
« Last Edit: September 28, 2011, 10:41:29 by kappa »

Re: [RFE] Buffered ' and " when polling for keyboard events
« Reply #8 on: September 28, 2011, 17:16:14 »
That looks more like support for chinese/japanese. This is for making the lwjgl keyboard work with the US international keyboard layout (which it does not at the moment). It might be that IME support would solve that as well, but supporting the us international keyboard layout is probably a lot easier than supporting IME.

Mike

*

Offline princec

  • *****
  • 1929
    • Puppygames
Re: [RFE] Buffered ' and " when polling for keyboard events
« Reply #9 on: September 28, 2011, 18:44:41 »
Hm how much of this is honestly just reinventing the wheel?

Cas :)

Re: [RFE] Buffered ' and " when polling for keyboard events
« Reply #10 on: September 28, 2011, 21:54:19 »
Reinventing the wheel? Does lwjgl already work correctly with us international in some other way?

Re: [RFE] Buffered ' and " when polling for keyboard events
« Reply #11 on: September 29, 2011, 05:07:38 »
This is what appears LWJGL needs to do....

If I remember correctly, LWJGL uses WM_CHAR, so based this off of that.  I didn't test any of this...
Code: [Select]
WM_CHAR:{
// also may need to stick bit 30 on the end of scanCode to indicate up/down
int scanCode = (lParam>>16)&0xFF;
int virtualKey = MapVirtualKey(scanCode,MAPVK_VSC_TO_VK_EX);
BYTE states[256];    
GetKeyboardState(states);

WCHAR buffer[10];
int result = ToUnicode(virtualKey,scanCode,states,buffer,10,0);

if(result < 0) {
  // Ignore this key; it's a dead char
}
else {
  // Process this key!
}
}break;

This may work; would have to test.  Based on research it should.  It may be easier to just process WM_KEYDOWN's and translate those with ToUnicode (you don't lose any of the functionality of WM_CHAR I believe).

I hope the equivalent keyboard Linux code works fine for this.  I'm probably never going to install another Keyboard layout, so I won't look into suggesting fixed code for that unless it crops up as a bug on the forums.

LWJGL really needs a QA person for each OS haha.  And then also a different forum for tracking bugs and posting fixes for each OS.

NOTE:  this code is missing necessary checks like if scanCode is 0, etc., that would be necessary for production.
« Last Edit: September 29, 2011, 05:19:26 by jediTofu »
cool story, bro

Re: [RFE] Buffered ' and " when polling for keyboard events
« Reply #12 on: October 03, 2011, 18:52:31 »
How can I test this? Try to compile lwjgl myself with the change? Is it enough with compiling the jar part?

*

Offline kappa

  • *****
  • 1313
Re: [RFE] Buffered ' and " when polling for keyboard events
« Reply #13 on: October 03, 2011, 19:01:33 »
How can I test this? Try to compile lwjgl myself with the change? Is it enough with compiling the jar part?
yes, its pretty easy to compile lwjgl once you've got the compiler installed, just run build.xml. The jar part isn't going to be enough here as native code is involved. Once the ant script is done running, the new lwjgl.jar is found in the lib folder with the new natives in the lib/windows folder.

Re: [RFE] Buffered ' and " when polling for keyboard events
« Reply #14 on: October 03, 2011, 21:02:43 »
Oh, as far as I could see the natives were tricky with visual studio and so on... I'll see if I can figure out how to do it and otherwise look into maybe jinput if they handle the international keyboard correctly (if you can handle keyboard there, never looked at jinput before).

Mike