Author Topic: keyboard modifiers  (Read 4411 times)

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
keyboard modifiers
« 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: keyboard modifiers
« Reply #1 on: February 13, 2008, 04:05:53 pm »
But SHIFT does work?

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: keyboard modifiers
« Reply #2 on: February 13, 2008, 04:07:43 pm »
yes shift does work  ???

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: keyboard modifiers
« Reply #3 on: February 13, 2008, 04:12:11 pm »
Obviously an LWJGL and/or Linux problem. I have no idea... ???

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: keyboard modifiers
« Reply #4 on: February 13, 2008, 04:13:23 pm »
i guess i'd better post it to lwjgl forums  ::)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: keyboard modifiers
« Reply #5 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