public class SquidInput extends com.badlogic.gdx.InputAdapter
Modifier and Type | Class and Description |
---|---|
static interface |
SquidInput.KeyHandler
A single-method interface used to process "typed" characters, special characters produced by unusual keys, and
modifiers that can affect them.
|
Modifier and Type | Field and Description |
---|---|
static char |
BACKSPACE
Backspace key on most PC keyboards; Delete key on Mac keyboards.
|
static char |
CENTER_ARROW
Not typically a dedicated key, but if numpadDirections is enabled, this will be sent by Numpad 5.
|
static char |
DOWN_ARROW
Down arrow key.
|
static char |
DOWN_LEFT_ARROW
Not typically a dedicated key, but if numpadDirections is enabled, this will be sent by Numpad 1.
|
static char |
DOWN_RIGHT_ARROW
Not typically a dedicated key, but if numpadDirections is enabled, this will be sent by Numpad 3.
|
static char |
END
End key (commonly used for moving a cursor to end of line).
|
static char |
ENTER
Enter key, also called Return key.
|
static char |
ESCAPE
Esc or Escape key
|
static char |
F1
Function key F1
|
static char |
F10
Function key F10
|
static char |
F11
Function key F11
|
static char |
F12
Function key F12
|
static char |
F2
Function key F2
|
static char |
F3
Function key F3
|
static char |
F4
Function key F4
|
static char |
F5
Function key F5
|
static char |
F6
Function key F6
|
static char |
F7
Function key F7
|
static char |
F8
Function key F8
|
static char |
F9
Function key F9
|
static char |
FORWARD_DELETE
Delete key on most PC keyboards; no equivalent on some (all?) Mac keyboards.
|
static char |
GAMEPAD_A
Gamepad A button.
|
static char |
GAMEPAD_B
Gamepad B button.
|
static char |
GAMEPAD_C
Gamepad C button.
|
static char |
GAMEPAD_L1
Gamepad L1 button.
|
static char |
GAMEPAD_L2
Gamepad L2 button.
|
static char |
GAMEPAD_LEFT_THUMB
Gamepad Left Thumb button.
|
static char |
GAMEPAD_R1
Gamepad R1 button.
|
static char |
GAMEPAD_R2
Gamepad R2 button.
|
static char |
GAMEPAD_RIGHT_THUMB
Gamepad Right Thumb button.
|
static char |
GAMEPAD_SELECT
Gamepad Select button.
|
static char |
GAMEPAD_START
Gamepad Start button.
|
static char |
GAMEPAD_X
Gamepad X button.
|
static char |
GAMEPAD_Y
Gamepad Y button.
|
static char |
GAMEPAD_Z
Gamepad Z button.
|
static char |
HOME
Home key (commonly used for moving a cursor to start of line).
|
protected boolean |
ignoreInput |
static char |
INSERT
Insert key.
|
protected SquidInput.KeyHandler |
keyAction |
static char |
LEFT_ARROW
Left arrow key.
|
protected SquidMouse |
mouse |
protected boolean |
numpadDirections |
static char |
PAGE_DOWN
Page Down key.
|
static char |
PAGE_UP
Page Up key.
|
protected com.badlogic.gdx.utils.CharArray |
processingQueue |
protected com.badlogic.gdx.utils.CharArray |
queue |
static char |
RIGHT_ARROW
Down arrow key.
|
static char |
TAB
Tab key.
|
static char |
UP_ARROW
Up arrow key.
|
static char |
UP_LEFT_ARROW
Not typically a dedicated key, but if numpadDirections is enabled, this will be sent by Numpad 7.
|
static char |
UP_RIGHT_ARROW
Not typically a dedicated key, but if numpadDirections is enabled, this will be sent by Numpad 9.
|
static char |
VERTICAL_ARROW
Not typically a dedicated key, but if numpadDirections is enabled, this will be sent by Numpad 0.
|
Constructor and Description |
---|
SquidInput()
Constructs a new SquidInput that does not respond to keyboard or mouse input.
|
SquidInput(SquidInput.KeyHandler keyHandler)
Constructs a new SquidInput that does not respond to mouse input, but does take keyboard input and sends keyboard
events through some processing before calling keyHandler.handle() on keypresses that can sensibly be processed.
|
SquidInput(SquidInput.KeyHandler keyHandler,
boolean ignoreInput)
Constructs a new SquidInput that does not respond to mouse input, but does take keyboard input and sends keyboard
events through some processing before calling keyHandler.handle() on keypresses that can sensibly be processed.
|
SquidInput(SquidInput.KeyHandler keyHandler,
SquidMouse mouse)
Constructs a new SquidInput that responds to mouse and keyboard input when given a SquidMouse and a
SquidInput.KeyHandler implementation.
|
SquidInput(SquidInput.KeyHandler keyHandler,
SquidMouse mouse,
boolean ignoreInput)
Constructs a new SquidInput that responds to mouse and keyboard input when given a SquidMouse and a
SquidInput.KeyHandler implementation, and can be put in an initial state where it ignores input until told
otherwise via setIgnoreInput(boolean).
|
SquidInput(SquidMouse mouse)
Constructs a new SquidInput that does not respond to keyboard input, but does take mouse input and passes mouse
events along to the given SquidMouse.
|
Modifier and Type | Method and Description |
---|---|
void |
drain()
Processes all events queued up, passing them through this object's key processing and then to keyHandler.
|
void |
flush()
Empties the backing queue of data.
|
char |
fromCode(int keycode,
boolean shift)
Maps keycodes to unicode chars, sometimes depending on whether the Shift key is held.
|
boolean |
getIgnoreInput()
Get the status for whether this should ignore input right now or not.
|
SquidInput.KeyHandler |
getKeyHandler() |
SquidMouse |
getMouse() |
boolean |
hasNext()
Returns true if at least one event is queued.
|
boolean |
isUsingNumpadDirections() |
boolean |
keyDown(int keycode) |
boolean |
keyTyped(char character) |
boolean |
keyUp(int keycode) |
boolean |
mouseMoved(int screenX,
int screenY) |
void |
next()
Processes the first key event queued up, passing it to this object's InputProcessor.
|
boolean |
scrolled(int amount) |
void |
setIgnoreInput(boolean ignoreInput)
Set the status for whether this should ignore input right now or not.
|
void |
setKeyHandler(SquidInput.KeyHandler keyHandler) |
void |
setMouse(SquidMouse mouse) |
void |
setUsingNumpadDirections(boolean using) |
boolean |
touchDown(int screenX,
int screenY,
int pointer,
int button) |
boolean |
touchDragged(int screenX,
int screenY,
int pointer) |
boolean |
touchUp(int screenX,
int screenY,
int pointer,
int button) |
protected SquidInput.KeyHandler keyAction
protected boolean numpadDirections
protected boolean ignoreInput
protected SquidMouse mouse
protected final com.badlogic.gdx.utils.CharArray queue
protected final com.badlogic.gdx.utils.CharArray processingQueue
public static final char LEFT_ARROW
public static final char UP_ARROW
public static final char RIGHT_ARROW
public static final char DOWN_ARROW
public static final char DOWN_LEFT_ARROW
public static final char DOWN_RIGHT_ARROW
public static final char UP_RIGHT_ARROW
public static final char UP_LEFT_ARROW
public static final char CENTER_ARROW
public static final char VERTICAL_ARROW
public static final char ENTER
public static final char TAB
public static final char BACKSPACE
public static final char FORWARD_DELETE
public static final char INSERT
public static final char PAGE_DOWN
public static final char PAGE_UP
public static final char HOME
public static final char END
public static final char ESCAPE
public static final char F1
public static final char F2
public static final char F3
public static final char F4
public static final char F5
public static final char F6
public static final char F7
public static final char F8
public static final char F9
public static final char F10
public static final char F11
public static final char F12
public static final char GAMEPAD_A
public static final char GAMEPAD_B
public static final char GAMEPAD_C
public static final char GAMEPAD_X
public static final char GAMEPAD_Y
public static final char GAMEPAD_Z
public static final char GAMEPAD_L1
public static final char GAMEPAD_L2
public static final char GAMEPAD_R1
public static final char GAMEPAD_R2
public static final char GAMEPAD_LEFT_THUMB
public static final char GAMEPAD_RIGHT_THUMB
public static final char GAMEPAD_START
public static final char GAMEPAD_SELECT
public SquidInput()
public SquidInput(SquidMouse mouse)
mouse
- a SquidMouse instance that will be used for handling mouse input. Must not be null.public SquidInput(SquidInput.KeyHandler keyHandler)
keyHandler
- must implement the SquidInput.KeyHandler interface so it can handle() key input.public SquidInput(SquidInput.KeyHandler keyHandler, boolean ignoreInput)
keyHandler
- must implement the SquidInput.KeyHandler interface so it can handle() key input.ignoreInput
- true if this should ignore input initially, false if it should process input normally.public SquidInput(SquidInput.KeyHandler keyHandler, SquidMouse mouse)
keyHandler
- must implement the SquidInput.KeyHandler interface so it can handle() key input.mouse
- a SquidMouse instance that will be used for handling mouse input. Must not be null.public SquidInput(SquidInput.KeyHandler keyHandler, SquidMouse mouse, boolean ignoreInput)
keyHandler
- must implement the SquidInput.KeyHandler interface so it can handle() key input.mouse
- a SquidMouse instance that will be used for handling mouse input. Must not be null.ignoreInput
- true if this should ignore input initially, false if it should process input normally.public void setKeyHandler(SquidInput.KeyHandler keyHandler)
public void setMouse(SquidMouse mouse)
public boolean isUsingNumpadDirections()
public void setUsingNumpadDirections(boolean using)
public SquidInput.KeyHandler getKeyHandler()
public SquidMouse getMouse()
public boolean getIgnoreInput()
public void setIgnoreInput(boolean ignoreInput)
ignoreInput
- true if this should object should ignore and not queue input, false otherwise.public void drain()
public boolean hasNext()
public void next()
public void flush()
public boolean keyDown(int keycode)
keyDown
in interface com.badlogic.gdx.InputProcessor
keyDown
in class com.badlogic.gdx.InputAdapter
public boolean keyUp(int keycode)
keyUp
in interface com.badlogic.gdx.InputProcessor
keyUp
in class com.badlogic.gdx.InputAdapter
public boolean keyTyped(char character)
keyTyped
in interface com.badlogic.gdx.InputProcessor
keyTyped
in class com.badlogic.gdx.InputAdapter
public boolean touchDown(int screenX, int screenY, int pointer, int button)
touchDown
in interface com.badlogic.gdx.InputProcessor
touchDown
in class com.badlogic.gdx.InputAdapter
public boolean touchUp(int screenX, int screenY, int pointer, int button)
touchUp
in interface com.badlogic.gdx.InputProcessor
touchUp
in class com.badlogic.gdx.InputAdapter
public boolean touchDragged(int screenX, int screenY, int pointer)
touchDragged
in interface com.badlogic.gdx.InputProcessor
touchDragged
in class com.badlogic.gdx.InputAdapter
public boolean mouseMoved(int screenX, int screenY)
mouseMoved
in interface com.badlogic.gdx.InputProcessor
mouseMoved
in class com.badlogic.gdx.InputAdapter
public boolean scrolled(int amount)
scrolled
in interface com.badlogic.gdx.InputProcessor
scrolled
in class com.badlogic.gdx.InputAdapter
public char fromCode(int keycode, boolean shift)
keycode
- a keycode as passed by LibGDXshift
- true if Shift key is being held.Copyright © 2012–2016. All rights reserved.