com.jmex.awt.input
Class AWTKeyInput

java.lang.Object
  extended by com.jme.input.Input
      extended by com.jme.input.KeyInput
          extended by com.jmex.awt.input.AWTKeyInput
All Implemented Interfaces:
java.awt.event.KeyListener, java.util.EventListener

public class AWTKeyInput
extends KeyInput
implements java.awt.event.KeyListener

AWTKeyInput

Version:
$Revision: 4133 $
Author:
Joshua Slack

Field Summary
(package private)  java.util.LinkedList<java.awt.event.KeyEvent> events
           
(package private)  java.util.BitSet keyDown
           
 
Fields inherited from class com.jme.input.KeyInput
INPUT_AWT, INPUT_LWJGL, KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_A, KEY_ADD, KEY_APOSTROPHE, KEY_APPS, KEY_AT, KEY_AX, KEY_B, KEY_BACK, KEY_BACKSLASH, KEY_C, KEY_CAPITAL, KEY_CIRCUMFLEX, KEY_COLON, KEY_COMMA, KEY_CONVERT, KEY_D, KEY_DECIMAL, KEY_DELETE, KEY_DIVIDE, KEY_DOWN, KEY_E, KEY_END, KEY_EQUALS, KEY_ESCAPE, KEY_F, KEY_F1, KEY_F10, KEY_F11, KEY_F12, KEY_F13, KEY_F14, KEY_F15, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_G, KEY_GRAVE, KEY_H, KEY_HOME, KEY_I, KEY_INSERT, KEY_J, KEY_K, KEY_KANA, KEY_KANJI, KEY_L, KEY_LBRACKET, KEY_LCONTROL, KEY_LEFT, KEY_LMENU, KEY_LMETA, KEY_LSHIFT, KEY_LWIN, KEY_M, KEY_MINUS, KEY_MULTIPLY, KEY_N, KEY_NEXT, KEY_NOCONVERT, KEY_NUMLOCK, KEY_NUMPAD0, KEY_NUMPAD1, KEY_NUMPAD2, KEY_NUMPAD3, KEY_NUMPAD4, KEY_NUMPAD5, KEY_NUMPAD6, KEY_NUMPAD7, KEY_NUMPAD8, KEY_NUMPAD9, KEY_NUMPADCOMMA, KEY_NUMPADENTER, KEY_NUMPADEQUALS, KEY_O, KEY_P, KEY_PAUSE, KEY_PERIOD, KEY_PGDN, KEY_PGUP, KEY_POWER, KEY_PRIOR, KEY_Q, KEY_R, KEY_RBRACKET, KEY_RCONTROL, KEY_RETURN, KEY_RIGHT, KEY_RMENU, KEY_RMETA, KEY_RSHIFT, KEY_RWIN, KEY_S, KEY_SCROLL, KEY_SEMICOLON, KEY_SLASH, KEY_SLEEP, KEY_SPACE, KEY_STOP, KEY_SUBTRACT, KEY_SYSRQ, KEY_T, KEY_TAB, KEY_U, KEY_UNDERLINE, KEY_UNLABELED, KEY_UP, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_YEN, KEY_Z, listeners
 
Constructor Summary
protected AWTKeyInput()
           
 
Method Summary
 void clear()
           
 void clearKey(int keycode)
           
protected  void destroy()
          destroy frees the keyboard for use by other applications.
 int getKeyIndex(java.lang.String name)
          The reverse of getKeyName, returns the value of the key given the name
 java.lang.String getKeyName(int key)
          getKeyName returns the string prepresentation of a key code.
static java.lang.String getKeyParam(int key)
          getKeyParam returns the KEY_XXXXX param related to the code given.
 boolean isEnabled()
           
 boolean isKeyDown(int key)
          isKeyDown returns true if the given key is pressed.
 void keyPressed(java.awt.event.KeyEvent arg0)
           
 void keyReleased(java.awt.event.KeyEvent arg0)
           
 void keyTyped(java.awt.event.KeyEvent arg0)
           
 void setEnabled(boolean enabled)
           
static int toAWTCode(int key)
          toAWTCode converts KeyInput key codes to AWT key codes.
static int toInputCode(int key)
          toInputCode converts AWT key codes to KeyInput key codes.
 void update()
          Updates the current state of the keyboard, holding information about what keys are pressed.
 
Methods inherited from class com.jme.input.KeyInput
addListener, containsListener, destroyIfInitalized, get, getListeners, getProvider, isControlDown, isInited, isShiftDown, removeListener, removeListeners, setProvider, setProvider
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

events

java.util.LinkedList<java.awt.event.KeyEvent> events

keyDown

java.util.BitSet keyDown
Constructor Detail

AWTKeyInput

protected AWTKeyInput()
Method Detail

isKeyDown

public boolean isKeyDown(int key)
Description copied from class: KeyInput
isKeyDown returns true if the given key is pressed. False otherwise.

Specified by:
isKeyDown in class KeyInput
Parameters:
key - the keycode to check for.
Returns:
true if the key is pressed, false otherwise.

getKeyName

public java.lang.String getKeyName(int key)
Description copied from class: KeyInput
getKeyName returns the string prepresentation of a key code.

Specified by:
getKeyName in class KeyInput
Parameters:
key - the key code to check.
Returns:
the string representation of a key code.

getKeyIndex

public int getKeyIndex(java.lang.String name)
Description copied from class: KeyInput
The reverse of getKeyName, returns the value of the key given the name

Specified by:
getKeyIndex in class KeyInput
Returns:
the value of the key

update

public void update()
Description copied from class: KeyInput
Updates the current state of the keyboard, holding information about what keys are pressed. Invokes event listeners synchronously.

Specified by:
update in class KeyInput

destroy

protected void destroy()
Description copied from class: KeyInput
destroy frees the keyboard for use by other applications. Destroy is protected now - please is KeyInput.destroyIfInitalized().

Specified by:
destroy in class KeyInput

isEnabled

public boolean isEnabled()
Returns:
Returns the enabled.

setEnabled

public void setEnabled(boolean enabled)
Parameters:
enabled - The enabled to set.

keyTyped

public void keyTyped(java.awt.event.KeyEvent arg0)
Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent arg0)
Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent arg0)
Specified by:
keyReleased in interface java.awt.event.KeyListener

toAWTCode

public static int toAWTCode(int key)
toAWTCode converts KeyInput key codes to AWT key codes.

Parameters:
key - jme KeyInput key code
Returns:
awt KeyEvent key code

getKeyParam

public static java.lang.String getKeyParam(int key)
getKeyParam returns the KEY_XXXXX param related to the code given.

Parameters:
key - jme KeyInput key code
Returns:
param name for given code.

toInputCode

public static int toInputCode(int key)
toInputCode converts AWT key codes to KeyInput key codes.

Parameters:
key - awt KeyEvent key code
Returns:
jme KeyInput key code

clear

public void clear()
Specified by:
clear in class KeyInput

clearKey

public void clearKey(int keycode)
Specified by:
clearKey in class KeyInput