Class GUIKeyStroke
java.lang.Object
com.blackrook.gui.input.GUIKeyStroke
- All Implemented Interfaces:
GUIInputConstants, GUIKeyTables
A keystroke defined by this GUI for listening for broadcast events.
The key masks are defined by the MASK_* constants in this class.
- Author:
- Matthew Tropiano
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intInput type, Gamepad.static final intInput type, Gamepad Axis.static final intInput type, Generic.static final intInput type, Keyboard.static final intMask for ALT key.static final intMask for ALT GRAPH key.static final intMask for CTRL key.static final intMask for META key.static final intMask for SHIFT key.static final intMask for WINDOW key.Fields inherited from interface GUIInputConstants
AXIS_POV, AXIS_POV_DOWN, AXIS_POV_DOWN_LEFT, AXIS_POV_DOWN_RIGHT, AXIS_POV_LEFT, AXIS_POV_RIGHT, AXIS_POV_UP, AXIS_POV_UP_LEFT, AXIS_POV_UP_RIGHT, AXIS_RX, AXIS_RY, AXIS_RZ, AXIS_SLIDER, AXIS_TAP_NEGATIVE, AXIS_TAP_POSITIVE, AXIS_UNDEFINED, AXIS_X, AXIS_XBOX_LEFT_X, AXIS_XBOX_LEFT_Y, AXIS_XBOX_PAD, AXIS_XBOX_RIGHT_X, AXIS_XBOX_RIGHT_Y, AXIS_XBOX_TRIGGER, AXIS_Y, AXIS_Z, GAMEPAD_1, GAMEPAD_10, GAMEPAD_11, GAMEPAD_12, GAMEPAD_2, GAMEPAD_3, GAMEPAD_4, GAMEPAD_5, GAMEPAD_6, GAMEPAD_7, GAMEPAD_8, GAMEPAD_9, GAMEPAD_UNDEFINED, GAMEPAD_XBOX_A, GAMEPAD_XBOX_B, GAMEPAD_XBOX_BACK, GAMEPAD_XBOX_LB, GAMEPAD_XBOX_LSTICK, GAMEPAD_XBOX_RB, GAMEPAD_XBOX_RSTICK, GAMEPAD_XBOX_START, GAMEPAD_XBOX_X, GAMEPAD_XBOX_Y, KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_A, KEY_ACCEPT, KEY_ADD, KEY_AGAIN, KEY_ALL_CANDIDATES, KEY_ALPHANUMERIC, KEY_ALT, KEY_ALT_GRAPH, KEY_AMPERSAND, KEY_ASTERISK, KEY_AT, KEY_B, KEY_BACK_QUOTE, KEY_BACK_SLASH, KEY_BACK_SPACE, KEY_BEGIN, KEY_BRACELEFT, KEY_BRACERIGHT, KEY_C, KEY_CANCEL, KEY_CAPS_LOCK, KEY_CIRCUMFLEX, KEY_CLEAR, KEY_CLOSE_BRACKET, KEY_CODE_INPUT, KEY_COLON, KEY_COMMA, KEY_COMPOSE, KEY_CONTEXT_MENU, KEY_CONTROL, KEY_CONVERT, KEY_COPY, KEY_CUT, KEY_D, KEY_DEAD_ABOVEDOT, KEY_DEAD_ABOVERING, KEY_DEAD_ACUTE, KEY_DEAD_BREVE, KEY_DEAD_CARON, KEY_DEAD_CEDILLA, KEY_DEAD_CIRCUMFLEX, KEY_DEAD_DIAERESIS, KEY_DEAD_DOUBLEACUTE, KEY_DEAD_GRAVE, KEY_DEAD_IOTA, KEY_DEAD_MACRON, KEY_DEAD_OGONEK, KEY_DEAD_SEMIVOICED_SOUND, KEY_DEAD_TILDE, KEY_DEAD_VOICED_SOUND, KEY_DECIMAL, KEY_DELETE, KEY_DIVIDE, KEY_DOLLAR, KEY_DOWN, KEY_E, KEY_END, KEY_ENTER, KEY_EQUALS, KEY_ESCAPE, KEY_EURO_SIGN, KEY_EXCLAMATION_MARK, KEY_F, KEY_F1, KEY_F10, KEY_F11, KEY_F12, KEY_F13, KEY_F14, KEY_F15, KEY_F16, KEY_F17, KEY_F18, KEY_F19, KEY_F2, KEY_F20, KEY_F21, KEY_F22, KEY_F23, KEY_F24, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_FINAL, KEY_FIND, KEY_FULL_WIDTH, KEY_G, KEY_GREATER, KEY_H, KEY_HALF_WIDTH, KEY_HELP, KEY_HIRAGANA, KEY_HOME, KEY_I, KEY_INPUT_METHOD_ON_OFF, KEY_INSERT, KEY_INVERTED_EXCLAMATION_MARK, KEY_J, KEY_JAPANESE_HIRAGANA, KEY_JAPANESE_KATAKANA, KEY_JAPANESE_ROMAN, KEY_K, KEY_KANA, KEY_KANA_LOCK, KEY_KANJI, KEY_KATAKANA, KEY_KP_DOWN, KEY_KP_LEFT, KEY_KP_RIGHT, KEY_KP_UP, KEY_L, KEY_LEFT, KEY_LEFT_PARENTHESIS, KEY_LESS, KEY_M, KEY_META, KEY_MINUS, KEY_MODECHANGE, KEY_MULTIPLY, KEY_N, KEY_NONCONVERT, KEY_NUM_LOCK, KEY_NUMBER_SIGN, KEY_NUMPAD0, KEY_NUMPAD1, KEY_NUMPAD2, KEY_NUMPAD3, KEY_NUMPAD4, KEY_NUMPAD5, KEY_NUMPAD6, KEY_NUMPAD7, KEY_NUMPAD8, KEY_NUMPAD9, KEY_O, KEY_OPEN_BRACKET, KEY_P, KEY_PAGE_DOWN, KEY_PAGE_UP, KEY_PASTE, KEY_PAUSE, KEY_PERIOD, KEY_PLUS, KEY_PREVIOUS_CANDIDATE, KEY_PRINTSCREEN, KEY_PROPS, KEY_Q, KEY_QUOTE, KEY_QUOTEDBL, KEY_R, KEY_RIGHT, KEY_RIGHT_PARENTHESIS, KEY_ROMAN_CHARACTERS, KEY_S, KEY_SCROLL_LOCK, KEY_SEMICOLON, KEY_SEPARATER, KEY_SEPARATOR, KEY_SHIFT, KEY_SLASH, KEY_SPACE, KEY_STOP, KEY_SUBTRACT, KEY_T, KEY_TAB, KEY_U, KEY_UNDEFINED, KEY_UNDERSCORE, KEY_UNDO, KEY_UP, KEY_V, KEY_W, KEY_WINDOWS, KEY_X, KEY_Y, KEY_Z, MOUSE_BACK, MOUSE_BUTTON1, MOUSE_BUTTON10, MOUSE_BUTTON11, MOUSE_BUTTON12, MOUSE_BUTTON2, MOUSE_BUTTON3, MOUSE_BUTTON4, MOUSE_BUTTON5, MOUSE_BUTTON6, MOUSE_BUTTON7, MOUSE_BUTTON8, MOUSE_BUTTON9, MOUSE_CENTER, MOUSE_FORWARD, MOUSE_LEFT, MOUSE_RIGHT, MOUSE_UNDEFINEDFields inherited from interface GUIKeyTables
GAMEPAD_AXIS_TAP_FLAG_MAP, GAMEPAD_AXIS_TAP_MAP, GAMEPAD_BUTTON_MAP, GAMEPAD_PREFIX, GENERIC_PREFIX, KEY_RELEASE, KEYBOARD_KEY_MAP, KEYBOARD_MASK_MAP -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedGUIKeyStroke(int inputType, int keyMask, int keyPress, boolean flag) Creates a keystroke. -
Method Summary
Modifier and TypeMethodDescriptionstatic GUIKeyStrokeCreates a keystroke by parsing a string that represents the keystroke.static GUIKeyStrokecreateGamepad(int button) Creates a new gamepad button press keystroke with no mask.static GUIKeyStrokecreateGamepad(int button, boolean flag) Creates a new gamepad button keystroke with no mask.static GUIKeyStrokecreateGamepad(int keyMask, int button, boolean flag) Creates a new gamepad button keystroke.static GUIKeyStrokecreateGamepadTap(int axis, boolean positive) Creates a new gamepad axis tap with no mask.static GUIKeyStrokecreateGeneric(int code) Creates a new generic input keystroke.static GUIKeyStrokecreateKey(int keyPress) Creates a new keyboard press keystroke with no mask.static GUIKeyStrokecreateKey(int keyPress, boolean flag) Creates a new keyboard keystroke with no mask.static GUIKeyStrokecreateKey(int keyMask, int keyPress, boolean flag) Creates a new keyboard keystroke.booleanequals(GUIKeyStroke ks) Tests if this keystroke equals another.booleaninthashCode()
-
Field Details
-
INPUT_KEY
public static final int INPUT_KEYInput type, Keyboard.- See Also:
-
INPUT_GAMEPAD
public static final int INPUT_GAMEPADInput type, Gamepad.- See Also:
-
INPUT_GAMEPAD_AXIS
public static final int INPUT_GAMEPAD_AXISInput type, Gamepad Axis.- See Also:
-
INPUT_GENERIC
public static final int INPUT_GENERICInput type, Generic.- See Also:
-
MASK_CTRL
public static final int MASK_CTRLMask for CTRL key.- See Also:
-
MASK_ALT
public static final int MASK_ALTMask for ALT key.- See Also:
-
MASK_ALT_GRAPH
public static final int MASK_ALT_GRAPHMask for ALT GRAPH key.- See Also:
-
MASK_SHIFT
public static final int MASK_SHIFTMask for SHIFT key.- See Also:
-
MASK_META
public static final int MASK_METAMask for META key.- See Also:
-
MASK_WIN
public static final int MASK_WINMask for WINDOW key.- See Also:
-
-
Constructor Details
-
GUIKeyStroke
protected GUIKeyStroke(int inputType, int keyMask, int keyPress, boolean flag) Creates a keystroke.- Parameters:
inputType- the input type.keyMask- the key mask.keyPress- the key press.flag- the modifier flag.
-
-
Method Details
-
create
Creates a keystroke by parsing a string that represents the keystroke.The key is defined by how a keystroke is defined in menus: modifiers plus the key. Gamepad taps are "PAD" plus an axis plus "+" or "-" to signify the axis direction. If no direction, assumes button. The keys and axes are not case-sensitive.
For example:
"X"->GUIKeyStroke.create(INPUT_KEY, 0, OGLInputConstants.KEY_X, false)"CTRL+X"->GUIKeyStroke.create(INPUT_KEY, MASK_CTRL, OGLInputConstants.KEY_X, false)"CTRL+ALT+X"->GUIKeyStroke.create(INPUT_KEY, MASK_CTRL | MASK_ALT, OGLInputConstants.KEY_X, false)"X release"->GUIKeyStroke.create(INPUT_KEY, 0, OGLInputConstants.KEY_X, true)"PAD 2"->GUIKeyStroke.create(INPUT_GAMEPAD, 0, OGLInputConstants.GAMEPAD_2)"PAD X+"->GUIKeyStroke.create(INPUT_GAMEPAD_AXIS, 0, OGLInputConstants.AXIS_X, true)"PAD Y-"->GUIKeyStroke.create(INPUT_GAMEPAD_AXIS, 0, OGLInputConstants.AXIS_Y, false)"generic 2"->GUIKeyStroke.create(INPUT_GENERIC, 0, 2, false)
- Parameters:
keystroke- the keystroke name.- Returns:
- the corresponding key stroke.
- Throws:
IllegalArgumentException- if the keystroke can't be parsed.
-
createGeneric
Creates a new generic input keystroke.- Parameters:
code- the input code.- Returns:
- the corresponding key stroke.
-
createGamepad
Creates a new gamepad button press keystroke with no mask.- Parameters:
button- the button press (OGLInputContants.*).- Returns:
- the corresponding key stroke.
-
createGamepad
Creates a new gamepad button keystroke with no mask.- Parameters:
button- the button press (OGLInputContants.*).flag- if true, this is a release.- Returns:
- the corresponding key stroke.
-
createGamepad
Creates a new gamepad button keystroke.- Parameters:
keyMask- the key mask (GUIKeyStroke.MASK_*).button- the button press (OGLInputContants.*).flag- if true, this is a release.- Returns:
- the corresponding key stroke.
-
createGamepadTap
Creates a new gamepad axis tap with no mask.- Parameters:
axis- the axis (OGLInputContants.*).positive- if true, positive axis, if false, negative.- Returns:
- the corresponding key stroke.
-
createKey
Creates a new keyboard press keystroke with no mask.- Parameters:
keyPress- the key press (OGLInputContants.*).- Returns:
- the corresponding key stroke.
-
createKey
Creates a new keyboard keystroke with no mask.- Parameters:
keyPress- the key press (OGLInputContants.*).flag- if keyboard key, this is a release. If a gamepad axis tap: if true, positive axis, if false, negative.- Returns:
- the corresponding key stroke.
-
createKey
Creates a new keyboard keystroke.- Parameters:
keyMask- the key mask (GUIKeyStroke.MASK_*).keyPress- the key press (OGLInputContants.*).flag- if keyboard key, this is a release. If a gamepad axis tap: if true, positive axis, if false, negative.- Returns:
- the corresponding key stroke.
-
hashCode
-
equals
-
equals
Tests if this keystroke equals another.- Parameters:
ks- the key stroke.- Returns:
- true if so, false if not.
-