GTGE API

com.golden.gamedev.engine
Interface BaseInput

All Known Implementing Classes:
AWTInput

public interface BaseInput

BaseInput interface provides all needed functions for polling keyboard and mouse input.

Common methods of how-to-use BaseInput:

    public class InputEngine implements BaseInput {
       .....

       public static void main(String[] args) {
          BaseInput engine = new InputEngine(...);
          engine.refresh();

          // game loop
          long elapsedTime = 0;
          while (true) {
             // update input
             engine.update(elapsedTime);

             // poll input
             engine.isKeyXXX(KeyEvent.XXX);
             engine.isMouseXXX(MouseEvent.XXX);
          }

          // clean up input engine
          engine.cleanup();
       }
    }
 


Field Summary
static int NO_BUTTON
          Indicates no mouse button is being pressed.
static int NO_KEY
          Indicates no key is being pressed.
 
Method Summary
 void cleanup()
          Releases any system resources hooked by this input engine.
 int getKeyPressed()
          Returns key pressed or NO_KEY if no key is being pressed.
 int getKeyReleased()
          Returns key released or NO_KEY if no key is being released.
 int getMouseDX()
          Returns the delta of mouse x-coordinate.
 int getMouseDY()
          Returns the delta of mouse y-coordinate.
 int getMousePressed()
          Returns mouse button pressed or NO_BUTTON if no button is being pressed.
 int getMouseReleased()
          Returns mouse button released or NO_BUTTON if no button is being released.
 int getMouseX()
          Returns the mouse x-coordinate.
 int getMouseY()
          Returns the mouse y-coordinate.
 boolean isKeyDown(int keyCode)
          Returns true if the specified key is being pressed.
 boolean isKeyPressed(int keyCode)
          Returns true if the specified key is being pressed.
 boolean isKeyReleased(int keyCode)
          Returns true if the specified key is being released.
 boolean isMouseDown(int button)
          Returns true if the specified button is being pressed.
 boolean isMouseExists()
          Returns true, if the mouse pointer is in input component area.
 boolean isMousePressed(int button)
          Returns true if the specified button is being pressed.
 boolean isMouseReleased(int button)
          Returns true if the specified button is being released.
 boolean isMouseVisible()
          Returns mouse pointer visible status.
 void mouseMove(int x, int y)
          Move the mouse to x, y screen coordinate.
 void refresh()
          Refresh all input actions to empty.
 void setMouseVisible(boolean visible)
          Sets mouse pointer visible status.
 void update(long elapsedTime)
          Updates input engine actions, this method need to be called in tight loop.
 

Field Detail

NO_BUTTON

static final int NO_BUTTON
Indicates no mouse button is being pressed.

See Also:
Constant Field Values

NO_KEY

static final int NO_KEY
Indicates no key is being pressed.

See Also:
Constant Field Values
Method Detail

update

void update(long elapsedTime)
Updates input engine actions, this method need to be called in tight loop.


refresh

void refresh()
Refresh all input actions to empty.


cleanup

void cleanup()
Releases any system resources hooked by this input engine.


mouseMove

void mouseMove(int x,
               int y)
Move the mouse to x, y screen coordinate.

Parameters:
x - the x-coordinate of the new mouse location
y - the y-coordinate of the new mouse location

isMouseExists

boolean isMouseExists()
Returns true, if the mouse pointer is in input component area.


getMouseX

int getMouseX()
Returns the mouse x-coordinate.


getMouseY

int getMouseY()
Returns the mouse y-coordinate.


getMouseDX

int getMouseDX()
Returns the delta of mouse x-coordinate.


getMouseDY

int getMouseDY()
Returns the delta of mouse y-coordinate.


getMouseReleased

int getMouseReleased()
Returns mouse button released or NO_BUTTON if no button is being released.

See Also:
MouseEvent.BUTTON1, MouseEvent.BUTTON2, MouseEvent.BUTTON3

isMouseReleased

boolean isMouseReleased(int button)
Returns true if the specified button is being released.

Parameters:
button - the mouse button to be checked
Returns:
true, if the button is released.
See Also:
MouseEvent.BUTTON1, MouseEvent.BUTTON2, MouseEvent.BUTTON3

getMousePressed

int getMousePressed()
Returns mouse button pressed or NO_BUTTON if no button is being pressed.

See Also:
MouseEvent.BUTTON1, MouseEvent.BUTTON2, MouseEvent.BUTTON3

isMousePressed

boolean isMousePressed(int button)
Returns true if the specified button is being pressed.

Parameters:
button - the mouse button to be checked
Returns:
true, if the button is pressed.
See Also:
MouseEvent.BUTTON1, MouseEvent.BUTTON2, MouseEvent.BUTTON3

isMouseDown

boolean isMouseDown(int button)
Returns true if the specified button is being pressed.

Parameters:
button - the mouse button to be checked
Returns:
true, if the button is being pressed.
See Also:
MouseEvent.BUTTON1, MouseEvent.BUTTON2, MouseEvent.BUTTON3

getKeyReleased

int getKeyReleased()
Returns key released or NO_KEY if no key is being released.

See Also:
KeyEvent.VK_1

isKeyReleased

boolean isKeyReleased(int keyCode)
Returns true if the specified key is being released.

Parameters:
keyCode - the key to be checked
Returns:
true, if the key is released.
See Also:
KeyEvent.VK_1

getKeyPressed

int getKeyPressed()
Returns key pressed or NO_KEY if no key is being pressed.

See Also:
KeyEvent.VK_1

isKeyPressed

boolean isKeyPressed(int keyCode)
Returns true if the specified key is being pressed.

Parameters:
keyCode - the key to be checked
Returns:
true, if the key is pressed.
See Also:
KeyEvent.VK_1

isKeyDown

boolean isKeyDown(int keyCode)
Returns true if the specified key is being pressed.

Parameters:
keyCode - the key to be checked
Returns:
true, if the key is being pressed.
See Also:
KeyEvent.VK_1

setMouseVisible

void setMouseVisible(boolean visible)
Sets mouse pointer visible status.

Parameters:
visible - mouse pointer visible status

isMouseVisible

boolean isMouseVisible()
Returns mouse pointer visible status.


GTGE API

Copyright © 2003-2005 Golden T Studios. All rights reserved. Use is subject to license terms.
GoldenStudios.or.id