|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.newdawn.slick.Input
public class Input
A wrapped for all keyboard, mouse and controller input
Field Summary | |
---|---|
protected java.util.HashSet |
allListeners
A list of listeners to be notified of input events |
static int |
ANY_CONTROLLER
The controller index to pass to check all controllers |
protected boolean |
consumed
True if the event has been consumed |
protected java.util.ArrayList |
controllerListeners
The listener to nofiy of controller events |
static int |
KEY_0
|
static int |
KEY_1
|
static int |
KEY_2
|
static int |
KEY_3
|
static int |
KEY_4
|
static int |
KEY_5
|
static int |
KEY_6
|
static int |
KEY_7
|
static int |
KEY_8
|
static int |
KEY_9
|
static int |
KEY_A
|
static int |
KEY_ADD
|
static int |
KEY_APOSTROPHE
|
static int |
KEY_APPS
|
static int |
KEY_AT
|
static int |
KEY_AX
|
static int |
KEY_B
|
static int |
KEY_BACK
|
static int |
KEY_BACKSLASH
|
static int |
KEY_C
|
static int |
KEY_CAPITAL
|
static int |
KEY_CIRCUMFLEX
|
static int |
KEY_COLON
|
static int |
KEY_COMMA
|
static int |
KEY_CONVERT
|
static int |
KEY_D
|
static int |
KEY_DECIMAL
|
static int |
KEY_DELETE
|
static int |
KEY_DIVIDE
|
static int |
KEY_DOWN
|
static int |
KEY_E
|
static int |
KEY_END
|
static int |
KEY_ENTER
|
static int |
KEY_EQUALS
|
static int |
KEY_ESCAPE
|
static int |
KEY_F
|
static int |
KEY_F1
|
static int |
KEY_F10
|
static int |
KEY_F11
|
static int |
KEY_F12
|
static int |
KEY_F13
|
static int |
KEY_F14
|
static int |
KEY_F15
|
static int |
KEY_F2
|
static int |
KEY_F3
|
static int |
KEY_F4
|
static int |
KEY_F5
|
static int |
KEY_F6
|
static int |
KEY_F7
|
static int |
KEY_F8
|
static int |
KEY_F9
|
static int |
KEY_G
|
static int |
KEY_GRAVE
|
static int |
KEY_H
|
static int |
KEY_HOME
|
static int |
KEY_I
|
static int |
KEY_INSERT
|
static int |
KEY_J
|
static int |
KEY_K
|
static int |
KEY_KANA
|
static int |
KEY_KANJI
|
static int |
KEY_L
|
static int |
KEY_LALT
A helper for left ALT |
static int |
KEY_LBRACKET
|
static int |
KEY_LCONTROL
|
static int |
KEY_LEFT
|
static int |
KEY_LMENU
|
static int |
KEY_LSHIFT
|
static int |
KEY_LWIN
|
static int |
KEY_M
|
static int |
KEY_MINUS
|
static int |
KEY_MULTIPLY
|
static int |
KEY_N
|
static int |
KEY_NEXT
|
static int |
KEY_NOCONVERT
|
static int |
KEY_NUMLOCK
|
static int |
KEY_NUMPAD0
|
static int |
KEY_NUMPAD1
|
static int |
KEY_NUMPAD2
|
static int |
KEY_NUMPAD3
|
static int |
KEY_NUMPAD4
|
static int |
KEY_NUMPAD5
|
static int |
KEY_NUMPAD6
|
static int |
KEY_NUMPAD7
|
static int |
KEY_NUMPAD8
|
static int |
KEY_NUMPAD9
|
static int |
KEY_NUMPADCOMMA
|
static int |
KEY_NUMPADENTER
|
static int |
KEY_NUMPADEQUALS
|
static int |
KEY_O
|
static int |
KEY_P
|
static int |
KEY_PAUSE
|
static int |
KEY_PERIOD
|
static int |
KEY_POWER
|
static int |
KEY_PRIOR
|
static int |
KEY_Q
|
static int |
KEY_R
|
static int |
KEY_RALT
A helper for right ALT |
static int |
KEY_RBRACKET
|
static int |
KEY_RCONTROL
|
static int |
KEY_RETURN
|
static int |
KEY_RIGHT
|
static int |
KEY_RMENU
|
static int |
KEY_RSHIFT
|
static int |
KEY_RWIN
|
static int |
KEY_S
|
static int |
KEY_SCROLL
|
static int |
KEY_SEMICOLON
|
static int |
KEY_SLASH
|
static int |
KEY_SLEEP
|
static int |
KEY_SPACE
|
static int |
KEY_STOP
|
static int |
KEY_SUBTRACT
|
static int |
KEY_SYSRQ
|
static int |
KEY_T
|
static int |
KEY_TAB
|
static int |
KEY_U
|
static int |
KEY_UNDERLINE
|
static int |
KEY_UNLABELED
|
static int |
KEY_UP
|
static int |
KEY_V
|
static int |
KEY_W
|
static int |
KEY_X
|
static int |
KEY_Y
|
static int |
KEY_YEN
|
static int |
KEY_Z
|
protected java.util.ArrayList |
keyListeners
The listeners to notify of key events |
protected java.util.ArrayList |
keyListenersToAdd
The listener to add |
protected char[] |
keys
The character values representing the pressed keys |
static int |
MOUSE_LEFT_BUTTON
The left mouse button indicator |
static int |
MOUSE_MIDDLE_BUTTON
The middle mouse button indicator |
static int |
MOUSE_RIGHT_BUTTON
The right mouse button indicator |
protected java.util.ArrayList |
mouseListeners
The listeners to notify of mouse events |
protected java.util.ArrayList |
mouseListenersToAdd
The listener to add |
protected boolean[] |
mousePressed
THe state of the mouse buttons |
protected long[] |
nextRepeat
The time since the next key repeat to be fired for the key |
protected boolean[] |
pressed
True if the key has been pressed since last queries |
Constructor Summary | |
---|---|
Input(int height)
Create a new input with the height of the screen |
Method Summary | |
---|---|
void |
addControllerListener(ControllerListener listener)
Add a controller listener to be notified of controller input events |
void |
addKeyListener(KeyListener listener)
Add a key listener to be notified of key input events |
void |
addListener(InputListener listener)
Add a listener to be notified of input events |
void |
addMouseListener(MouseListener listener)
Add a mouse listener to be notified of mouse input events |
void |
addPrimaryListener(InputListener listener)
Add a listener to be notified of input events. |
void |
clearControlPressedRecord()
Clear the state for isControlPressed method. |
void |
clearKeyPressedRecord()
Clear the state for the isKeyPressed method. |
void |
clearMousePressedRecord()
Clear the state for the isMousePressed method. |
void |
considerDoubleClick(int button,
int x,
int y)
Notification that the mouse has been pressed and hence we should consider what we're doing with double clicking |
void |
consumeEvent()
Notification from an event handle that an event has been consumed |
static void |
disableControllers()
Disables support for controllers. |
void |
disableKeyRepeat()
Disable key repeat for this input context |
void |
enableKeyRepeat()
Enable key repeat for this input context. |
void |
enableKeyRepeat(int initial,
int interval)
Deprecated. |
int |
getAbsoluteMouseX()
Get the absolute x position of the mouse cursor within the container |
int |
getAbsoluteMouseY()
Get the absolute y position of the mouse cursor within the container |
int |
getAxisCount(int controller)
Get the number of axis that are avaiable on a given controller |
java.lang.String |
getAxisName(int controller,
int axis)
Get the name of the axis with the given index |
float |
getAxisValue(int controller,
int axis)
Get the value of the axis with the given index |
int |
getControllerCount()
Get a count of the number of controlles available |
static java.lang.String |
getKeyName(int code)
Get the character representation of the key identified by the specified code |
int |
getMouseX()
Get the x position of the mouse cursor |
int |
getMouseY()
Get the y position of the mouse cursor |
void |
initControllers()
Initialise the controllers system |
boolean |
isButton1Pressed(int controller)
Check if button 1 is pressed |
boolean |
isButton2Pressed(int controller)
Check if button 2 is pressed |
boolean |
isButton3Pressed(int controller)
Check if button 3 is pressed |
boolean |
isButtonPressed(int index,
int controller)
Check if controller button is pressed |
boolean |
isControllerDown(int controller)
Check if the controller has the down direction pressed |
boolean |
isControllerLeft(int controller)
Check if the controller has the left direction pressed |
boolean |
isControllerRight(int controller)
Check if the controller has the right direction pressed |
boolean |
isControllerUp(int controller)
Check if the controller has the up direction pressed |
boolean |
isControlPressed(int button)
Check if a controller button has been pressed since last time |
boolean |
isControlPressed(int button,
int controller)
Check if a controller button has been pressed since last time |
boolean |
isKeyDown(int code)
Check if a particular key is down |
boolean |
isKeyPressed(int code)
Check if a particular key has been pressed since this method was last called for the specified key |
boolean |
isKeyRepeatEnabled()
Check if key repeat is enabled |
boolean |
isMouseButtonDown(int button)
Check if a given mouse button is down |
boolean |
isMousePressed(int button)
Check if a mouse button has been pressed since last call |
void |
pause()
Pauses the polling and sending of input events. |
void |
poll(int width,
int height)
Poll the state of the input |
void |
removeAllControllerListeners()
Remove all the controller listeners from this input |
void |
removeAllKeyListeners()
Remove all the key listeners from this input |
void |
removeAllListeners()
Remove all the listeners from this input |
void |
removeAllMouseListeners()
Remove all the mouse listeners from this input |
void |
removeControllerListener(ControllerListener listener)
Remove a controller listener that will no longer be notified |
void |
removeKeyListener(KeyListener listener)
Remove a key listener that will no longer be notified |
void |
removeListener(InputListener listener)
Remove a listener that will no longer be notified |
void |
removeMouseListener(MouseListener listener)
Remove a mouse listener that will no longer be notified |
void |
resetInputTransform()
Reset the transformation being applied to the input to the default |
void |
resume()
Resumes the polling and sending of input events. |
void |
setDoubleClickInterval(int delay)
Set the double click interval, the time between the first and second clicks that should be interpreted as a double click. |
void |
setMouseClickTolerance(int mouseClickTolerance)
Set the pixel distance the mouse can move to accept a mouse click. |
void |
setOffset(float xoffset,
float yoffset)
Set the offset to apply to the screen coodinates |
void |
setScale(float scaleX,
float scaleY)
Set the scaling to apply to screen coordinates |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int ANY_CONTROLLER
public static final int KEY_ESCAPE
public static final int KEY_1
public static final int KEY_2
public static final int KEY_3
public static final int KEY_4
public static final int KEY_5
public static final int KEY_6
public static final int KEY_7
public static final int KEY_8
public static final int KEY_9
public static final int KEY_0
public static final int KEY_MINUS
public static final int KEY_EQUALS
public static final int KEY_BACK
public static final int KEY_TAB
public static final int KEY_Q
public static final int KEY_W
public static final int KEY_E
public static final int KEY_R
public static final int KEY_T
public static final int KEY_Y
public static final int KEY_U
public static final int KEY_I
public static final int KEY_O
public static final int KEY_P
public static final int KEY_LBRACKET
public static final int KEY_RBRACKET
public static final int KEY_RETURN
public static final int KEY_ENTER
public static final int KEY_LCONTROL
public static final int KEY_A
public static final int KEY_S
public static final int KEY_D
public static final int KEY_F
public static final int KEY_G
public static final int KEY_H
public static final int KEY_J
public static final int KEY_K
public static final int KEY_L
public static final int KEY_SEMICOLON
public static final int KEY_APOSTROPHE
public static final int KEY_GRAVE
public static final int KEY_LSHIFT
public static final int KEY_BACKSLASH
public static final int KEY_Z
public static final int KEY_X
public static final int KEY_C
public static final int KEY_V
public static final int KEY_B
public static final int KEY_N
public static final int KEY_M
public static final int KEY_COMMA
public static final int KEY_PERIOD
public static final int KEY_SLASH
public static final int KEY_RSHIFT
public static final int KEY_MULTIPLY
public static final int KEY_LMENU
public static final int KEY_SPACE
public static final int KEY_CAPITAL
public static final int KEY_F1
public static final int KEY_F2
public static final int KEY_F3
public static final int KEY_F4
public static final int KEY_F5
public static final int KEY_F6
public static final int KEY_F7
public static final int KEY_F8
public static final int KEY_F9
public static final int KEY_F10
public static final int KEY_NUMLOCK
public static final int KEY_SCROLL
public static final int KEY_NUMPAD7
public static final int KEY_NUMPAD8
public static final int KEY_NUMPAD9
public static final int KEY_SUBTRACT
public static final int KEY_NUMPAD4
public static final int KEY_NUMPAD5
public static final int KEY_NUMPAD6
public static final int KEY_ADD
public static final int KEY_NUMPAD1
public static final int KEY_NUMPAD2
public static final int KEY_NUMPAD3
public static final int KEY_NUMPAD0
public static final int KEY_DECIMAL
public static final int KEY_F11
public static final int KEY_F12
public static final int KEY_F13
public static final int KEY_F14
public static final int KEY_F15
public static final int KEY_KANA
public static final int KEY_CONVERT
public static final int KEY_NOCONVERT
public static final int KEY_YEN
public static final int KEY_NUMPADEQUALS
public static final int KEY_CIRCUMFLEX
public static final int KEY_AT
public static final int KEY_COLON
public static final int KEY_UNDERLINE
public static final int KEY_KANJI
public static final int KEY_STOP
public static final int KEY_AX
public static final int KEY_UNLABELED
public static final int KEY_NUMPADENTER
public static final int KEY_RCONTROL
public static final int KEY_NUMPADCOMMA
public static final int KEY_DIVIDE
public static final int KEY_SYSRQ
public static final int KEY_RMENU
public static final int KEY_PAUSE
public static final int KEY_HOME
public static final int KEY_UP
public static final int KEY_PRIOR
public static final int KEY_LEFT
public static final int KEY_RIGHT
public static final int KEY_END
public static final int KEY_DOWN
public static final int KEY_NEXT
public static final int KEY_INSERT
public static final int KEY_DELETE
public static final int KEY_LWIN
public static final int KEY_RWIN
public static final int KEY_APPS
public static final int KEY_POWER
public static final int KEY_SLEEP
public static final int KEY_LALT
public static final int KEY_RALT
public static final int MOUSE_LEFT_BUTTON
public static final int MOUSE_RIGHT_BUTTON
public static final int MOUSE_MIDDLE_BUTTON
protected boolean[] mousePressed
protected char[] keys
protected boolean[] pressed
protected long[] nextRepeat
protected boolean consumed
protected java.util.HashSet allListeners
protected java.util.ArrayList keyListeners
protected java.util.ArrayList keyListenersToAdd
protected java.util.ArrayList mouseListeners
protected java.util.ArrayList mouseListenersToAdd
protected java.util.ArrayList controllerListeners
Constructor Detail |
---|
public Input(int height)
height
- The height of the screenMethod Detail |
---|
public static void disableControllers()
public void setDoubleClickInterval(int delay)
delay
- The delay between clickspublic void setMouseClickTolerance(int mouseClickTolerance)
mouseClickTolerance
- The number of pixels.public void setScale(float scaleX, float scaleY)
scaleX
- The scaling to apply to the horizontal axisscaleY
- The scaling to apply to the vertical axispublic void setOffset(float xoffset, float yoffset)
xoffset
- The offset on the x-axisyoffset
- The offset on the y-axispublic void resetInputTransform()
public void addListener(InputListener listener)
listener
- The listener to be notifiedpublic void addKeyListener(KeyListener listener)
listener
- The listener to be notifiedpublic void addMouseListener(MouseListener listener)
listener
- The listener to be notifiedpublic void addControllerListener(ControllerListener listener)
listener
- The listener to be notifiedpublic void removeAllListeners()
public void removeAllKeyListeners()
public void removeAllMouseListeners()
public void removeAllControllerListeners()
public void addPrimaryListener(InputListener listener)
listener
- The listener to be notifiedpublic void removeListener(InputListener listener)
listener
- The listen to be removedpublic void removeKeyListener(KeyListener listener)
listener
- The listen to be removedpublic void removeControllerListener(ControllerListener listener)
listener
- The listen to be removedpublic void removeMouseListener(MouseListener listener)
listener
- The listen to be removedpublic static java.lang.String getKeyName(int code)
code
- The key code of the key to retrieve the name of
public boolean isKeyPressed(int code)
code
- The key code of the key to check
public boolean isMousePressed(int button)
button
- The button to check
public boolean isControlPressed(int button)
button
- The button to check for (note that this includes directional controls first)
public boolean isControlPressed(int button, int controller)
controller
- The index of the controller to checkbutton
- The button to check for (note that this includes directional controls first)
public void clearControlPressedRecord()
public void clearKeyPressedRecord()
isKeyPressed
method. This will
resort in all keys returning that they haven't been pressed, until
they are pressed again
public void clearMousePressedRecord()
isMousePressed
method. This will
resort in all mouse buttons returning that they haven't been pressed, until
they are pressed again
public boolean isKeyDown(int code)
code
- The key code of the key to check
public int getAbsoluteMouseX()
public int getAbsoluteMouseY()
public int getMouseX()
public int getMouseY()
public boolean isMouseButtonDown(int button)
button
- The index of the button to check (starting at 0)
public int getControllerCount()
public int getAxisCount(int controller)
controller
- The index of the controller to check
public float getAxisValue(int controller, int axis)
controller
- The index of the controller to checkaxis
- The index of the axis to read
public java.lang.String getAxisName(int controller, int axis)
controller
- The index of the controller to checkaxis
- The index of the axis to read
public boolean isControllerLeft(int controller)
controller
- The index of the controller to check
public boolean isControllerRight(int controller)
controller
- The index of the controller to check
public boolean isControllerUp(int controller)
controller
- The index of the controller to check
public boolean isControllerDown(int controller)
controller
- The index of the controller to check
public boolean isButtonPressed(int index, int controller)
controller
- The index of the controller to checkindex
- The index of the button to check
public boolean isButton1Pressed(int controller)
controller
- The index of the controller to check
public boolean isButton2Pressed(int controller)
controller
- The index of the controller to check
public boolean isButton3Pressed(int controller)
controller
- The index of the controller to check
public void initControllers() throws SlickException
SlickException
- Indicates a failure to use the hardwarepublic void consumeEvent()
public void considerDoubleClick(int button, int x, int y)
button
- The button pressed/releasedx
- The location of the mousey
- The location of the mousepublic void poll(int width, int height)
width
- The width of the game viewheight
- The height of the game viewpublic void enableKeyRepeat(int initial, int interval)
initial
- The interval before key repreating starts after a key pressinterval
- The interval between key repeats in mspublic void enableKeyRepeat()
public void disableKeyRepeat()
public boolean isKeyRepeatEnabled()
public void pause()
public void resume()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |