www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: raft on February 13, 2008, 12:42:03 am

Title: keyboard modifiers
Post by: raft on February 13, 2008, 12:42:03 am
i'm trying to map KeyState to awt.KeyEvent with the following code piece:

Code: [Select]
                int modifiers = 0;
                if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) ||  Keyboard.isKeyDown(Keyboard.KEY_RCONTROL))
                    modifiers |= KeyEvent.CTRL_DOWN_MASK;
                if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ||  Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))
                    modifiers |= KeyEvent.SHIFT_DOWN_MASK;

                final KeyEvent keyEvent;
                if (state.getState()) // pressed
                    keyEvent = new KeyEvent(EVENT_SOURCE, KeyEvent.KEY_PRESSED, 0, modifiers, state.getKeyCode(), KeyEvent.CHAR_UNDEFINED);
                else keyEvent = new KeyEvent(EVENT_SOURCE, KeyEvent.KEY_RELEASED, 0, modifiers, state.getKeyCode(), KeyEvent.CHAR_UNDEFINED);

but unfortunately Keyboard.isKeyDown(left-right control) never returns true. pressing/releasing control key never generates an event either. any ideas why this may happen ?

this is a fedora 4 linux laptop, with only left control key. awt itself properly generates control key events

btw, it may be handy to include modifiers in KeyState class.

r a f t
Title: Re: keyboard modifiers
Post by: EgonOlsen on February 13, 2008, 04:05:53 pm
But SHIFT does work?
Title: Re: keyboard modifiers
Post by: raft on February 13, 2008, 04:07:43 pm
yes shift does work  ???
Title: Re: keyboard modifiers
Post by: EgonOlsen on February 13, 2008, 04:12:11 pm
Obviously an LWJGL and/or Linux problem. I have no idea... ???
Title: Re: keyboard modifiers
Post by: raft on February 13, 2008, 04:13:23 pm
i guess i'd better post it to lwjgl forums  ::)
Title: Re: keyboard modifiers
Post by: EgonOlsen on February 13, 2008, 04:19:38 pm
Yes, there's already a thread from 2 days ago dealing with LWJGL/Linux/jPCT: http://lwjgl.org/forum/index.php/topic,2555.0.html (http://lwjgl.org/forum/index.php/topic,2555.0.html)