org.jtgl.input
Class KeyInputControl

java.lang.Object
  extended by org.jtgl.input.InputControl
      extended by org.jtgl.input.KeyInputControl

public abstract class KeyInputControl
extends InputControl

Keyboard InputControl

Author:
Manuel Polo (manuel_polo at yahoo dot es)

Field Summary
static char CHAR_NONE
           
static java.lang.String CONTROL_CLASSNAME
           
static int KEY_DOWN
           
static int KEY_ENTER
           
static int KEY_LEFT
           
static int KEY_MASK_DOWN
           
static int KEY_MASK_ENTER
           
static int KEY_MASK_LEFT
           
static int KEY_MASK_RIGHT
           
static int KEY_MASK_UP
           
static int KEY_NONE
           
static int KEY_NUM0
           
static int KEY_NUM1
           
static int KEY_NUM2
           
static int KEY_NUM3
           
static int KEY_NUM4
           
static int KEY_NUM5
           
static int KEY_NUM6
           
static int KEY_NUM7
           
static int KEY_NUM8
           
static int KEY_NUM9
           
static int KEY_RIGHT
           
static int KEY_UP
           
protected  int keyPressed
           
protected  int keyReleased
           
protected  int keysPressed
           
protected  char typedChar
           
 
Constructor Summary
KeyInputControl()
          Creates a new instance of KeyInputControl
 
Method Summary
 int getKey()
          Gets last single key pressed translated to KeyInputControl.KEY_XXX codes This method is an alias of getKeyPressed() method.
 int getKeyPressed()
           
 int getKeyReleased()
           
 int getKeys()
          Gets multiple keys pressed if supported by implementation as single bits.
 int getKeyStates()
          Gets pressed keys bitmask status.
 char getTypedChar()
           
 boolean supportsSimultaneusKeys()
           
protected  int translateKey(int nativeKey)
          Translates from native keycode to KeyInputControl.KEY_XXX codes
 void updateKeyPressed(int nativeKey)
           
 void updateKeyReleased(int nativeKey)
           
 void updateKeyRepeated(int nativeKey)
           
 void updateKeyTyped(char key)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTROL_CLASSNAME

public static final java.lang.String CONTROL_CLASSNAME
See Also:
Constant Field Values

KEY_NONE

public static final int KEY_NONE
See Also:
Constant Field Values

KEY_UP

public static final int KEY_UP
See Also:
Constant Field Values

KEY_DOWN

public static final int KEY_DOWN
See Also:
Constant Field Values

KEY_LEFT

public static final int KEY_LEFT
See Also:
Constant Field Values

KEY_RIGHT

public static final int KEY_RIGHT
See Also:
Constant Field Values

KEY_ENTER

public static final int KEY_ENTER
See Also:
Constant Field Values

KEY_MASK_UP

public static final int KEY_MASK_UP
See Also:
Constant Field Values

KEY_MASK_DOWN

public static final int KEY_MASK_DOWN
See Also:
Constant Field Values

KEY_MASK_LEFT

public static final int KEY_MASK_LEFT
See Also:
Constant Field Values

KEY_MASK_RIGHT

public static final int KEY_MASK_RIGHT
See Also:
Constant Field Values

KEY_MASK_ENTER

public static final int KEY_MASK_ENTER
See Also:
Constant Field Values

KEY_NUM0

public static final int KEY_NUM0
See Also:
Constant Field Values

KEY_NUM1

public static final int KEY_NUM1
See Also:
Constant Field Values

KEY_NUM2

public static final int KEY_NUM2
See Also:
Constant Field Values

KEY_NUM3

public static final int KEY_NUM3
See Also:
Constant Field Values

KEY_NUM4

public static final int KEY_NUM4
See Also:
Constant Field Values

KEY_NUM5

public static final int KEY_NUM5
See Also:
Constant Field Values

KEY_NUM6

public static final int KEY_NUM6
See Also:
Constant Field Values

KEY_NUM7

public static final int KEY_NUM7
See Also:
Constant Field Values

KEY_NUM8

public static final int KEY_NUM8
See Also:
Constant Field Values

KEY_NUM9

public static final int KEY_NUM9
See Also:
Constant Field Values

CHAR_NONE

public static final char CHAR_NONE
See Also:
Constant Field Values

keyPressed

protected int keyPressed

keyReleased

protected int keyReleased

keysPressed

protected int keysPressed

typedChar

protected char typedChar
Constructor Detail

KeyInputControl

public KeyInputControl()
Creates a new instance of KeyInputControl

Method Detail

supportsSimultaneusKeys

public boolean supportsSimultaneusKeys()
Returns:

getKeyPressed

public int getKeyPressed()
Returns:

getKeyReleased

public int getKeyReleased()
Returns:

getTypedChar

public char getTypedChar()

getKey

public int getKey()
Gets last single key pressed translated to KeyInputControl.KEY_XXX codes This method is an alias of getKeyPressed() method.

Returns:
KeyInputControl.KEY_XXX code
See Also:
getKeyPressed()

getKeys

public int getKeys()
Gets multiple keys pressed if supported by implementation as single bits. Value returned may content any combination of KeyInputControl.KEY_MASK_XXX codes.

Returns:

getKeyStates

public int getKeyStates()
Gets pressed keys bitmask status. If implementation support multiple keys pressed then return value will contain all detected keys pressed as a enabled bit, otherwise only one bit may be checked.

Returns:
Any combination of KeyInputControl.KEY_MASK_XXX

updateKeyPressed

public void updateKeyPressed(int nativeKey)
Parameters:
nativeKey -

updateKeyReleased

public void updateKeyReleased(int nativeKey)
Parameters:
nativeKey -

updateKeyRepeated

public void updateKeyRepeated(int nativeKey)
Parameters:
nativeKey -

updateKeyTyped

public void updateKeyTyped(char key)

translateKey

protected int translateKey(int nativeKey)
Translates from native keycode to KeyInputControl.KEY_XXX codes

Parameters:
nativeKey -
Returns:
KeyInputControl.KEY_XXX code