org.newdawn.slick
Class Input

java.lang.Object
  extended by org.newdawn.slick.Input

public class Input
extends java.lang.Object

A wrapped for all keyboard, mouse and controller input

Author:
kevin

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

ANY_CONTROLLER

public static final int ANY_CONTROLLER
The controller index to pass to check all controllers

See Also:
Constant Field Values

KEY_ESCAPE

public static final int KEY_ESCAPE
See Also:
Constant Field Values

KEY_1

public static final int KEY_1
See Also:
Constant Field Values

KEY_2

public static final int KEY_2
See Also:
Constant Field Values

KEY_3

public static final int KEY_3
See Also:
Constant Field Values

KEY_4

public static final int KEY_4
See Also:
Constant Field Values

KEY_5

public static final int KEY_5
See Also:
Constant Field Values

KEY_6

public static final int KEY_6
See Also:
Constant Field Values

KEY_7

public static final int KEY_7
See Also:
Constant Field Values

KEY_8

public static final int KEY_8
See Also:
Constant Field Values

KEY_9

public static final int KEY_9
See Also:
Constant Field Values

KEY_0

public static final int KEY_0
See Also:
Constant Field Values

KEY_MINUS

public static final int KEY_MINUS
See Also:
Constant Field Values

KEY_EQUALS

public static final int KEY_EQUALS
See Also:
Constant Field Values

KEY_BACK

public static final int KEY_BACK
See Also:
Constant Field Values

KEY_TAB

public static final int KEY_TAB
See Also:
Constant Field Values

KEY_Q

public static final int KEY_Q
See Also:
Constant Field Values

KEY_W

public static final int KEY_W
See Also:
Constant Field Values

KEY_E

public static final int KEY_E
See Also:
Constant Field Values

KEY_R

public static final int KEY_R
See Also:
Constant Field Values

KEY_T

public static final int KEY_T
See Also:
Constant Field Values

KEY_Y

public static final int KEY_Y
See Also:
Constant Field Values

KEY_U

public static final int KEY_U
See Also:
Constant Field Values

KEY_I

public static final int KEY_I
See Also:
Constant Field Values

KEY_O

public static final int KEY_O
See Also:
Constant Field Values

KEY_P

public static final int KEY_P
See Also:
Constant Field Values

KEY_LBRACKET

public static final int KEY_LBRACKET
See Also:
Constant Field Values

KEY_RBRACKET

public static final int KEY_RBRACKET
See Also:
Constant Field Values

KEY_RETURN

public static final int KEY_RETURN
See Also:
Constant Field Values

KEY_ENTER

public static final int KEY_ENTER
See Also:
Constant Field Values

KEY_LCONTROL

public static final int KEY_LCONTROL
See Also:
Constant Field Values

KEY_A

public static final int KEY_A
See Also:
Constant Field Values

KEY_S

public static final int KEY_S
See Also:
Constant Field Values

KEY_D

public static final int KEY_D
See Also:
Constant Field Values

KEY_F

public static final int KEY_F
See Also:
Constant Field Values

KEY_G

public static final int KEY_G
See Also:
Constant Field Values

KEY_H

public static final int KEY_H
See Also:
Constant Field Values

KEY_J

public static final int KEY_J
See Also:
Constant Field Values

KEY_K

public static final int KEY_K
See Also:
Constant Field Values

KEY_L

public static final int KEY_L
See Also:
Constant Field Values

KEY_SEMICOLON

public static final int KEY_SEMICOLON
See Also:
Constant Field Values

KEY_APOSTROPHE

public static final int KEY_APOSTROPHE
See Also:
Constant Field Values

KEY_GRAVE

public static final int KEY_GRAVE
See Also:
Constant Field Values

KEY_LSHIFT

public static final int KEY_LSHIFT
See Also:
Constant Field Values

KEY_BACKSLASH

public static final int KEY_BACKSLASH
See Also:
Constant Field Values

KEY_Z

public static final int KEY_Z
See Also:
Constant Field Values

KEY_X

public static final int KEY_X
See Also:
Constant Field Values

KEY_C

public static final int KEY_C
See Also:
Constant Field Values

KEY_V

public static final int KEY_V
See Also:
Constant Field Values

KEY_B

public static final int KEY_B
See Also:
Constant Field Values

KEY_N

public static final int KEY_N
See Also:
Constant Field Values

KEY_M

public static final int KEY_M
See Also:
Constant Field Values

KEY_COMMA

public static final int KEY_COMMA
See Also:
Constant Field Values

KEY_PERIOD

public static final int KEY_PERIOD
See Also:
Constant Field Values

KEY_SLASH

public static final int KEY_SLASH
See Also:
Constant Field Values

KEY_RSHIFT

public static final int KEY_RSHIFT
See Also:
Constant Field Values

KEY_MULTIPLY

public static final int KEY_MULTIPLY
See Also:
Constant Field Values

KEY_LMENU

public static final int KEY_LMENU
See Also:
Constant Field Values

KEY_SPACE

public static final int KEY_SPACE
See Also:
Constant Field Values

KEY_CAPITAL

public static final int KEY_CAPITAL
See Also:
Constant Field Values

KEY_F1

public static final int KEY_F1
See Also:
Constant Field Values

KEY_F2

public static final int KEY_F2
See Also:
Constant Field Values

KEY_F3

public static final int KEY_F3
See Also:
Constant Field Values

KEY_F4

public static final int KEY_F4
See Also:
Constant Field Values

KEY_F5

public static final int KEY_F5
See Also:
Constant Field Values

KEY_F6

public static final int KEY_F6
See Also:
Constant Field Values

KEY_F7

public static final int KEY_F7
See Also:
Constant Field Values

KEY_F8

public static final int KEY_F8
See Also:
Constant Field Values

KEY_F9

public static final int KEY_F9
See Also:
Constant Field Values

KEY_F10

public static final int KEY_F10
See Also:
Constant Field Values

KEY_NUMLOCK

public static final int KEY_NUMLOCK
See Also:
Constant Field Values

KEY_SCROLL

public static final int KEY_SCROLL
See Also:
Constant Field Values

KEY_NUMPAD7

public static final int KEY_NUMPAD7
See Also:
Constant Field Values

KEY_NUMPAD8

public static final int KEY_NUMPAD8
See Also:
Constant Field Values

KEY_NUMPAD9

public static final int KEY_NUMPAD9
See Also:
Constant Field Values

KEY_SUBTRACT

public static final int KEY_SUBTRACT
See Also:
Constant Field Values

KEY_NUMPAD4

public static final int KEY_NUMPAD4
See Also:
Constant Field Values

KEY_NUMPAD5

public static final int KEY_NUMPAD5
See Also:
Constant Field Values

KEY_NUMPAD6

public static final int KEY_NUMPAD6
See Also:
Constant Field Values

KEY_ADD

public static final int KEY_ADD
See Also:
Constant Field Values

KEY_NUMPAD1

public static final int KEY_NUMPAD1
See Also:
Constant Field Values

KEY_NUMPAD2

public static final int KEY_NUMPAD2
See Also:
Constant Field Values

KEY_NUMPAD3

public static final int KEY_NUMPAD3
See Also:
Constant Field Values

KEY_NUMPAD0

public static final int KEY_NUMPAD0
See Also:
Constant Field Values

KEY_DECIMAL

public static final int KEY_DECIMAL
See Also:
Constant Field Values

KEY_F11

public static final int KEY_F11
See Also:
Constant Field Values

KEY_F12

public static final int KEY_F12
See Also:
Constant Field Values

KEY_F13

public static final int KEY_F13
See Also:
Constant Field Values

KEY_F14

public static final int KEY_F14
See Also:
Constant Field Values

KEY_F15

public static final int KEY_F15
See Also:
Constant Field Values

KEY_KANA

public static final int KEY_KANA
See Also:
Constant Field Values

KEY_CONVERT

public static final int KEY_CONVERT
See Also:
Constant Field Values

KEY_NOCONVERT

public static final int KEY_NOCONVERT
See Also:
Constant Field Values

KEY_YEN

public static final int KEY_YEN
See Also:
Constant Field Values

KEY_NUMPADEQUALS

public static final int KEY_NUMPADEQUALS
See Also:
Constant Field Values

KEY_CIRCUMFLEX

public static final int KEY_CIRCUMFLEX
See Also:
Constant Field Values

KEY_AT

public static final int KEY_AT
See Also:
Constant Field Values

KEY_COLON

public static final int KEY_COLON
See Also:
Constant Field Values

KEY_UNDERLINE

public static final int KEY_UNDERLINE
See Also:
Constant Field Values

KEY_KANJI

public static final int KEY_KANJI
See Also:
Constant Field Values

KEY_STOP

public static final int KEY_STOP
See Also:
Constant Field Values

KEY_AX

public static final int KEY_AX
See Also:
Constant Field Values

KEY_UNLABELED

public static final int KEY_UNLABELED
See Also:
Constant Field Values

KEY_NUMPADENTER

public static final int KEY_NUMPADENTER
See Also:
Constant Field Values

KEY_RCONTROL

public static final int KEY_RCONTROL
See Also:
Constant Field Values

KEY_NUMPADCOMMA

public static final int KEY_NUMPADCOMMA
See Also:
Constant Field Values

KEY_DIVIDE

public static final int KEY_DIVIDE
See Also:
Constant Field Values

KEY_SYSRQ

public static final int KEY_SYSRQ
See Also:
Constant Field Values

KEY_RMENU

public static final int KEY_RMENU
See Also:
Constant Field Values

KEY_PAUSE

public static final int KEY_PAUSE
See Also:
Constant Field Values

KEY_HOME

public static final int KEY_HOME
See Also:
Constant Field Values

KEY_UP

public static final int KEY_UP
See Also:
Constant Field Values

KEY_PRIOR

public static final int KEY_PRIOR
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_END

public static final int KEY_END
See Also:
Constant Field Values

KEY_DOWN

public static final int KEY_DOWN
See Also:
Constant Field Values

KEY_NEXT

public static final int KEY_NEXT
See Also:
Constant Field Values

KEY_INSERT

public static final int KEY_INSERT
See Also:
Constant Field Values

KEY_DELETE

public static final int KEY_DELETE
See Also:
Constant Field Values

KEY_LWIN

public static final int KEY_LWIN
See Also:
Constant Field Values

KEY_RWIN

public static final int KEY_RWIN
See Also:
Constant Field Values

KEY_APPS

public static final int KEY_APPS
See Also:
Constant Field Values

KEY_POWER

public static final int KEY_POWER
See Also:
Constant Field Values

KEY_SLEEP

public static final int KEY_SLEEP
See Also:
Constant Field Values

KEY_LALT

public static final int KEY_LALT
A helper for left ALT

See Also:
Constant Field Values

KEY_RALT

public static final int KEY_RALT
A helper for right ALT

See Also:
Constant Field Values

MOUSE_LEFT_BUTTON

public static final int MOUSE_LEFT_BUTTON
The left mouse button indicator

See Also:
Constant Field Values

MOUSE_RIGHT_BUTTON

public static final int MOUSE_RIGHT_BUTTON
The right mouse button indicator

See Also:
Constant Field Values

MOUSE_MIDDLE_BUTTON

public static final int MOUSE_MIDDLE_BUTTON
The middle mouse button indicator

See Also:
Constant Field Values

mousePressed

protected boolean[] mousePressed
THe state of the mouse buttons


keys

protected char[] keys
The character values representing the pressed keys


pressed

protected boolean[] pressed
True if the key has been pressed since last queries


nextRepeat

protected long[] nextRepeat
The time since the next key repeat to be fired for the key


consumed

protected boolean consumed
True if the event has been consumed


allListeners

protected java.util.HashSet allListeners
A list of listeners to be notified of input events


keyListeners

protected java.util.ArrayList keyListeners
The listeners to notify of key events


keyListenersToAdd

protected java.util.ArrayList keyListenersToAdd
The listener to add


mouseListeners

protected java.util.ArrayList mouseListeners
The listeners to notify of mouse events


mouseListenersToAdd

protected java.util.ArrayList mouseListenersToAdd
The listener to add


controllerListeners

protected java.util.ArrayList controllerListeners
The listener to nofiy of controller events

Constructor Detail

Input

public Input(int height)
Create a new input with the height of the screen

Parameters:
height - The height of the screen
Method Detail

disableControllers

public static void disableControllers()
Disables support for controllers. This means the jinput JAR and native libs are not required.


setDoubleClickInterval

public 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.

Parameters:
delay - The delay between clicks

setMouseClickTolerance

public void setMouseClickTolerance(int mouseClickTolerance)
Set the pixel distance the mouse can move to accept a mouse click. Default is 5.

Parameters:
mouseClickTolerance - The number of pixels.

setScale

public void setScale(float scaleX,
                     float scaleY)
Set the scaling to apply to screen coordinates

Parameters:
scaleX - The scaling to apply to the horizontal axis
scaleY - The scaling to apply to the vertical axis

setOffset

public void setOffset(float xoffset,
                      float yoffset)
Set the offset to apply to the screen coodinates

Parameters:
xoffset - The offset on the x-axis
yoffset - The offset on the y-axis

resetInputTransform

public void resetInputTransform()
Reset the transformation being applied to the input to the default


addListener

public void addListener(InputListener listener)
Add a listener to be notified of input events

Parameters:
listener - The listener to be notified

addKeyListener

public void addKeyListener(KeyListener listener)
Add a key listener to be notified of key input events

Parameters:
listener - The listener to be notified

addMouseListener

public void addMouseListener(MouseListener listener)
Add a mouse listener to be notified of mouse input events

Parameters:
listener - The listener to be notified

addControllerListener

public void addControllerListener(ControllerListener listener)
Add a controller listener to be notified of controller input events

Parameters:
listener - The listener to be notified

removeAllListeners

public void removeAllListeners()
Remove all the listeners from this input


removeAllKeyListeners

public void removeAllKeyListeners()
Remove all the key listeners from this input


removeAllMouseListeners

public void removeAllMouseListeners()
Remove all the mouse listeners from this input


removeAllControllerListeners

public void removeAllControllerListeners()
Remove all the controller listeners from this input


addPrimaryListener

public void addPrimaryListener(InputListener listener)
Add a listener to be notified of input events. This listener will get events before others that are currently registered

Parameters:
listener - The listener to be notified

removeListener

public void removeListener(InputListener listener)
Remove a listener that will no longer be notified

Parameters:
listener - The listen to be removed

removeKeyListener

public void removeKeyListener(KeyListener listener)
Remove a key listener that will no longer be notified

Parameters:
listener - The listen to be removed

removeControllerListener

public void removeControllerListener(ControllerListener listener)
Remove a controller listener that will no longer be notified

Parameters:
listener - The listen to be removed

removeMouseListener

public void removeMouseListener(MouseListener listener)
Remove a mouse listener that will no longer be notified

Parameters:
listener - The listen to be removed

getKeyName

public static java.lang.String getKeyName(int code)
Get the character representation of the key identified by the specified code

Parameters:
code - The key code of the key to retrieve the name of
Returns:
The name or character representation of the key requested

isKeyPressed

public boolean isKeyPressed(int code)
Check if a particular key has been pressed since this method was last called for the specified key

Parameters:
code - The key code of the key to check
Returns:
True if the key has been pressed

isMousePressed

public boolean isMousePressed(int button)
Check if a mouse button has been pressed since last call

Parameters:
button - The button to check
Returns:
True if the button has been pressed since last call

isControlPressed

public boolean isControlPressed(int button)
Check if a controller button has been pressed since last time

Parameters:
button - The button to check for (note that this includes directional controls first)
Returns:
True if the button has been pressed since last time

isControlPressed

public boolean isControlPressed(int button,
                                int controller)
Check if a controller button has been pressed since last time

Parameters:
controller - The index of the controller to check
button - The button to check for (note that this includes directional controls first)
Returns:
True if the button has been pressed since last time

clearControlPressedRecord

public void clearControlPressedRecord()
Clear the state for isControlPressed method. This will reset all controls to not pressed


clearKeyPressedRecord

public void clearKeyPressedRecord()
Clear the state for the isKeyPressed method. This will resort in all keys returning that they haven't been pressed, until they are pressed again


clearMousePressedRecord

public void clearMousePressedRecord()
Clear the state for the isMousePressed method. This will resort in all mouse buttons returning that they haven't been pressed, until they are pressed again


isKeyDown

public boolean isKeyDown(int code)
Check if a particular key is down

Parameters:
code - The key code of the key to check
Returns:
True if the key is down

getAbsoluteMouseX

public int getAbsoluteMouseX()
Get the absolute x position of the mouse cursor within the container

Returns:
The absolute x position of the mouse cursor

getAbsoluteMouseY

public int getAbsoluteMouseY()
Get the absolute y position of the mouse cursor within the container

Returns:
The absolute y position of the mouse cursor

getMouseX

public int getMouseX()
Get the x position of the mouse cursor

Returns:
The x position of the mouse cursor

getMouseY

public int getMouseY()
Get the y position of the mouse cursor

Returns:
The y position of the mouse cursor

isMouseButtonDown

public boolean isMouseButtonDown(int button)
Check if a given mouse button is down

Parameters:
button - The index of the button to check (starting at 0)
Returns:
True if the mouse button is down

getControllerCount

public int getControllerCount()
Get a count of the number of controlles available

Returns:
The number of controllers available

getAxisCount

public int getAxisCount(int controller)
Get the number of axis that are avaiable on a given controller

Parameters:
controller - The index of the controller to check
Returns:
The number of axis available on the controller

getAxisValue

public float getAxisValue(int controller,
                          int axis)
Get the value of the axis with the given index

Parameters:
controller - The index of the controller to check
axis - The index of the axis to read
Returns:
The axis value at time of reading

getAxisName

public java.lang.String getAxisName(int controller,
                                    int axis)
Get the name of the axis with the given index

Parameters:
controller - The index of the controller to check
axis - The index of the axis to read
Returns:
The name of the specified axis

isControllerLeft

public boolean isControllerLeft(int controller)
Check if the controller has the left direction pressed

Parameters:
controller - The index of the controller to check
Returns:
True if the controller is pressed to the left

isControllerRight

public boolean isControllerRight(int controller)
Check if the controller has the right direction pressed

Parameters:
controller - The index of the controller to check
Returns:
True if the controller is pressed to the right

isControllerUp

public boolean isControllerUp(int controller)
Check if the controller has the up direction pressed

Parameters:
controller - The index of the controller to check
Returns:
True if the controller is pressed to the up

isControllerDown

public boolean isControllerDown(int controller)
Check if the controller has the down direction pressed

Parameters:
controller - The index of the controller to check
Returns:
True if the controller is pressed to the down

isButtonPressed

public boolean isButtonPressed(int index,
                               int controller)
Check if controller button is pressed

Parameters:
controller - The index of the controller to check
index - The index of the button to check
Returns:
True if the button is pressed

isButton1Pressed

public boolean isButton1Pressed(int controller)
Check if button 1 is pressed

Parameters:
controller - The index of the controller to check
Returns:
True if the button is pressed

isButton2Pressed

public boolean isButton2Pressed(int controller)
Check if button 2 is pressed

Parameters:
controller - The index of the controller to check
Returns:
True if the button is pressed

isButton3Pressed

public boolean isButton3Pressed(int controller)
Check if button 3 is pressed

Parameters:
controller - The index of the controller to check
Returns:
True if the button is pressed

initControllers

public void initControllers()
                     throws SlickException
Initialise the controllers system

Throws:
SlickException - Indicates a failure to use the hardware

consumeEvent

public void consumeEvent()
Notification from an event handle that an event has been consumed


considerDoubleClick

public 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

Parameters:
button - The button pressed/released
x - The location of the mouse
y - The location of the mouse

poll

public void poll(int width,
                 int height)
Poll the state of the input

Parameters:
width - The width of the game view
height - The height of the game view

enableKeyRepeat

public void enableKeyRepeat(int initial,
                            int interval)
Deprecated. 

Enable key repeat for this input context. This will cause keyPressed to get called repeatedly at a set interval while the key is pressed

Parameters:
initial - The interval before key repreating starts after a key press
interval - The interval between key repeats in ms

enableKeyRepeat

public void enableKeyRepeat()
Enable key repeat for this input context. Uses the system settings for repeat interval configuration.


disableKeyRepeat

public void disableKeyRepeat()
Disable key repeat for this input context


isKeyRepeatEnabled

public boolean isKeyRepeatEnabled()
Check if key repeat is enabled

Returns:
True if key repeat is enabled

pause

public void pause()
Pauses the polling and sending of input events.


resume

public void resume()
Resumes the polling and sending of input events.



Copyright © 2006 New Dawn Software. All Rights Reserved.