de.jreality.toolsystem.raw
Class DeviceKeyboard
java.lang.Object
de.jreality.toolsystem.raw.DeviceKeyboard
- All Implemented Interfaces:
- PollingDevice, RawDevice, java.awt.event.AWTEventListener, java.awt.event.KeyListener, java.util.EventListener
public class DeviceKeyboard
- extends java.lang.Object
- implements RawDevice, java.awt.event.KeyListener, java.awt.event.AWTEventListener, PollingDevice
This driver mainly consists of a workaround for the keyboard auto-repeat:
Windows:
The auto-repeat on windows triggers repeating key-pressed events, and also
key-typed events which we ignore. So the only thing to do is to check the
last state of the key and only handle a key-pressed if the key was not
pressed before. This happens in poll().
Linux:
The auto-repeat on linux triggers repeating key-released/key-pressed events,
so we enqueue the occuring events and merge them if possible: When a
key-released event occurs, we check if there is a matching key-pressed event
in the queue - if yes ignore both events. Happens in handleEvent(..).
MacOS:
Seems to work!
Solaris etc.:
TODO!
Now this class also listens to mouse events and always checks if the status of
shift/ctrl/alt/algt_graph/meta has changed without a corresponding event.
- Author:
- Steffen Weissmann
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
DeviceKeyboard
public DeviceKeyboard()
initialize
public void initialize(Viewer viewer,
java.util.Map<java.lang.String,java.lang.Object> config)
- Specified by:
initialize
in interface RawDevice
keyPressed
public void keyPressed(java.awt.event.KeyEvent e)
- Specified by:
keyPressed
in interface java.awt.event.KeyListener
keyReleased
public void keyReleased(java.awt.event.KeyEvent e)
- Specified by:
keyReleased
in interface java.awt.event.KeyListener
keyTyped
public void keyTyped(java.awt.event.KeyEvent e)
- Specified by:
keyTyped
in interface java.awt.event.KeyListener
mapRawDevice
public ToolEvent mapRawDevice(java.lang.String rawDeviceName,
InputSlot inputDevice)
- Specified by:
mapRawDevice
in interface RawDevice
- Returns:
- a ToolEvent representing a reasonable initial
value for the mapping - that means the source
must be the given input slot!
setEventQueue
public void setEventQueue(ToolEventQueue queue)
- Specified by:
setEventQueue
in interface RawDevice
dispose
public void dispose()
- Specified by:
dispose
in interface RawDevice
getName
public java.lang.String getName()
- Specified by:
getName
in interface RawDevice
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
poll
public void poll(long when)
- Description copied from interface:
PollingDevice
- Perform polling for the device in this method.
- Specified by:
poll
in interface PollingDevice
eventDispatched
public void eventDispatched(java.awt.AWTEvent event)
- Specified by:
eventDispatched
in interface java.awt.event.AWTEventListener