Gosu::Input Class Reference

Manages initialization and shutdown of the input system. More...

List of all members.

Public Member Functions

 ~Input ()
bool down (Button btn) const
 Returns true if a button is currently pressed.
double mouseX () const
 Returns the horizontal position of the mouse relative to the top left corner of the window given to Input's constructor.
double mouseY () const
 See mouseX.
void setMousePosition (double x, double y)
 Immediately moves the mouse as far towards the desired position as possible.
void setMouseFactors (double factorX, double factorY)
void update ()
 Collects new information about which buttons are pressed, where the mouse is and calls onButtonUp/onButtonDown, if assigned.
TextInputtextInput () const
 Returns the currently active TextInput instance, or 0.
void setTextInput (TextInput *input)
 Sets the currently active TextInput, or clears it (input = 0).

Static Public Member Functions

static wchar_t idToChar (Button btn)
 Returns the character a button usually produces, or 0.
static Button charToId (wchar_t ch)
 Returns the button that has to be pressed to produce the given character, or noButton.

Public Attributes

boost::function< void(Button)> onButtonDown
 Assignable events that are called by update.
boost::function< void(Button)> onButtonUp


Detailed Description

Manages initialization and shutdown of the input system.

Only one Input instance can exist per application.

Definition at line 78 of file Input.hpp.


Constructor & Destructor Documentation

Gosu::Input::~Input (  ) 


Member Function Documentation

static Button Gosu::Input::charToId ( wchar_t  ch  )  [static]

Returns the button that has to be pressed to produce the given character, or noButton.

bool Gosu::Input::down ( Button  btn  )  const

Returns true if a button is currently pressed.

Updated every tick.

static wchar_t Gosu::Input::idToChar ( Button  btn  )  [static]

Returns the character a button usually produces, or 0.

double Gosu::Input::mouseX (  )  const

Returns the horizontal position of the mouse relative to the top left corner of the window given to Input's constructor.

double Gosu::Input::mouseY (  )  const

See mouseX.

void Gosu::Input::setMouseFactors ( double  factorX,
double  factorY 
)

void Gosu::Input::setMousePosition ( double  x,
double  y 
)

Immediately moves the mouse as far towards the desired position as possible.

x and y are relativ to the window just as in the mouse position accessors.

void Gosu::Input::setTextInput ( TextInput input  ) 

Sets the currently active TextInput, or clears it (input = 0).

TextInput* Gosu::Input::textInput (  )  const

Returns the currently active TextInput instance, or 0.

void Gosu::Input::update (  ) 

Collects new information about which buttons are pressed, where the mouse is and calls onButtonUp/onButtonDown, if assigned.


Member Data Documentation

boost::function<void (Button)> Gosu::Input::onButtonDown

Assignable events that are called by update.

You can bind these to your own functions. If you use the Window class, it will assign forward these to its own methods.

Definition at line 134 of file Input.hpp.

boost::function<void (Button)> Gosu::Input::onButtonUp

Definition at line 134 of file Input.hpp.


The documentation for this class was generated from the following file: