Otter  0.9.88
2d Game Development Framework based on SFML.Net
 All Classes Namespaces Functions Variables Enumerations Properties
Otter.Input Class Reference

Class used for managing input from the keyboard, mouse, and joysticks. Updated by the active Game. More...

Public Member Functions

bool KeyPressed (Key k)
 Check if a key has been pressed this update. More...
 
bool KeyPressed (char c)
 Check if a key has been pressed this update. More...
 
bool KeyReleased (Key k)
 Check if a key has been released this update. More...
 
bool KeyReleased (char c)
 Check if a key has been released this update. More...
 
bool KeyDown (Key k)
 Check if a key is currently down. More...
 
bool KeyDown (char c)
 Check if a key is currently down. More...
 
bool KeyUp (Key k)
 Check if a key is currently up. More...
 
bool KeyUp (char c)
 Check if a key is currently up. More...
 
bool ButtonPressed (int button, int joystick=0)
 Check if a joystick button is pressed. More...
 
bool ButtonPressed (AxisButton button, int joystick=0)
 Check if a joystick AxisButton is pressed. More...
 
bool ButtonReleased (int button, int joystick=0)
 Check if the joystick button is released. More...
 
bool ButtonReleased (AxisButton button, int joystick=0)
 Check if the joystick AxisButton is released. More...
 
bool ButtonDown (int button, int joystick=0)
 Check if the joystick button is down. More...
 
bool ButtonDown (AxisButton button, int joystick=0)
 Check if the joystick AxisButton is down. More...
 
bool ButtonUp (int button, int joystick=0)
 Check if the joystick button is up. More...
 
bool ButtonUp (AxisButton button, int joystick=0)
 Check if the joystick button is up. More...
 
float GetAxis (JoyAxis axis, int joystick=0)
 Get the value of a joystick axis from -100 to 100. More...
 
void SetAxisThreshold (JoyAxis axis, float threshold)
 Set the threshold for an axis to act as an AxisButton. Defaults to 50 or one half of the joystick's total range. More...
 
float GetAxisThreshold (JoyAxis axis)
 Gets the axis threshold for an axis to act as an AxisButton. More...
 
bool MouseButtonPressed (MouseButton b)
 Check if a MouseButton is pressed. More...
 
bool MouseButtonReleased (MouseButton b)
 Check if a MouseButton is pressed. More...
 
bool MouseButtonDown (MouseButton b)
 Check if a MouseButton is pressed. More...
 
bool MouseButtonUp (MouseButton b)
 Check if a MouseButton is pressed. More...
 
void ClearKeystring ()
 Clear the string of recently pressed keys. More...
 

Static Public Member Functions

static Key CharToKey (char key)
 Convert a char to a Key code. More...
 

Public Attributes

string KeyString = ""
 The current string of keys that were pressed. More...
 

Static Public Attributes

static Input Instance
 A reference to the current active instance. More...
 
static int KeystringSize = 500
 The maximum size of the string of recent key presses. More...
 
static bool CenteredMouse = false
 Determines if the mouse should be locked to the center of the screen. More...
 

Properties

static int JoysticksConnected [get]
 The current number of joysticks connected. More...
 
static int JoysticksSupported [get]
 The maximum possible amount of joysticks that can be connected. More...
 
Game Game [get, set]
 The reference to the game that owns this class. More...
 
Key LastKey [get, set]
 The last known key that was pressed. More...
 
MouseButton LastMouseButton [get, set]
 The last known mouse button that was pressed. More...
 
List< int > LastButton [get, set]
 The last known button pressed on each joystick. More...
 
int MouseDeltaX [get, set]
 The X movement of the mouse since the last update. Only updates if the mouse is locked inside the Game window. More...
 
int MouseDeltaY [get, set]
 The Y movement of the mouse since the last update. Only updates if the mouse is locked inside the Game window. More...
 
int MouseX [get]
 The current X position of the mouse. More...
 
int MouseY [get]
 The current Y position of the mouse. More...
 
int MouseRawX [get, set]
 The raw X position of the mouse. This can be set. More...
 
int MouseRawY [get, set]
 The raw Y position of the mouse. This can be set. More...
 
float MouseScreenX [get]
 The X position of the mouse in screen space. More...
 
float MouseScreenY [get]
 The Y position of the mouse in screen space. More...
 
float MouseWheelDelta [get]
 The change in the mouse wheel value this update. More...
 
int GameMouseX [get, set]
 The X position of the mouse in the game. Use if the mouse is locked in the game window. This can be set if the mouse is locked inside the game window. More...
 
int GameMouseY [get, set]
 The Y position of the mouse in the game. Use if the mouse is locked in the game window. This can be set if the mouse is locked inside the game window. More...
 

Detailed Description

Class used for managing input from the keyboard, mouse, and joysticks. Updated by the active Game.

Member Function Documentation

bool Otter.Input.ButtonDown ( int  button,
int  joystick = 0 
)

Check if the joystick button is down.

Parameters
buttonThe button to check.
joystickThe joystick to check.
Returns
True if the button is down.
bool Otter.Input.ButtonDown ( AxisButton  button,
int  joystick = 0 
)

Check if the joystick AxisButton is down.

Parameters
buttonThe AxisButton to check.
joystickThe joystick to check.
Returns
True if the AxisButton is down.
bool Otter.Input.ButtonPressed ( int  button,
int  joystick = 0 
)

Check if a joystick button is pressed.

Parameters
buttonThe button to check.
joystickThe joystick to check.
Returns
True if the button is pressed.
bool Otter.Input.ButtonPressed ( AxisButton  button,
int  joystick = 0 
)

Check if a joystick AxisButton is pressed.

Parameters
buttonThe AxisButton to check.
joystickThe joystick to check.
Returns
True if the button is pressed.
bool Otter.Input.ButtonReleased ( int  button,
int  joystick = 0 
)

Check if the joystick button is released.

Parameters
buttonThe button to check.
joystickThe joystick to check.
Returns
True if the button is released.
bool Otter.Input.ButtonReleased ( AxisButton  button,
int  joystick = 0 
)

Check if the joystick AxisButton is released.

Parameters
buttonThe AxisButton to check.
joystickThe joystick to check.
Returns
True if the AxisButton is released.
bool Otter.Input.ButtonUp ( int  button,
int  joystick = 0 
)

Check if the joystick button is up.

Parameters
buttonThe button to check.
joystickThe joystick to check.
Returns
True if the button is up.
bool Otter.Input.ButtonUp ( AxisButton  button,
int  joystick = 0 
)

Check if the joystick button is up.

Parameters
buttonThe AxisButton to check.
joystickThe joystick to check.
Returns
True if the AxisButton is up.
static Key Otter.Input.CharToKey ( char  key)
static

Convert a char to a Key code.

Parameters
keyThe char to convert into a Key.
Returns
The Key. Returns Key.Unknown if no match is found.
void Otter.Input.ClearKeystring ( )

Clear the string of recently pressed keys.

float Otter.Input.GetAxis ( JoyAxis  axis,
int  joystick = 0 
)

Get the value of a joystick axis from -100 to 100.

Parameters
axisThe axis to check.
joystickThe joystick to check.
Returns
The axis value from -100 to 100.
float Otter.Input.GetAxisThreshold ( JoyAxis  axis)

Gets the axis threshold for an axis to act as an AxisButton.

Parameters
axisThe JoyAxis.
bool Otter.Input.KeyDown ( Key  k)

Check if a key is currently down.

Parameters
kThe key to check.
Returns
True if the key is down.
bool Otter.Input.KeyDown ( char  c)

Check if a key is currently down.

Parameters
cThe key to check.
Returns
True if the key is down.
bool Otter.Input.KeyPressed ( Key  k)

Check if a key has been pressed this update.

Parameters
kThe key to check.
Returns
True if the key has been pressed.
bool Otter.Input.KeyPressed ( char  c)

Check if a key has been pressed this update.

Parameters
cThe key to check.
Returns
True if the key has been pressed.
bool Otter.Input.KeyReleased ( Key  k)

Check if a key has been released this update.

Parameters
kThe key to check.
Returns
True if the key has been released.
bool Otter.Input.KeyReleased ( char  c)

Check if a key has been released this update.

Parameters
cThe key to check.
Returns
True if the key has been released.
bool Otter.Input.KeyUp ( Key  k)

Check if a key is currently up.

Parameters
kThe key to check.
Returns
True if the key is up.
bool Otter.Input.KeyUp ( char  c)

Check if a key is currently up.

Parameters
cThe key to check.
Returns
True if the key is up.
bool Otter.Input.MouseButtonDown ( MouseButton  b)

Check if a MouseButton is pressed.

Parameters
bThe MouseButton to check.
Returns
True if the MouseButton is pressed.
bool Otter.Input.MouseButtonPressed ( MouseButton  b)

Check if a MouseButton is pressed.

Parameters
bThe MouseButton to check.
Returns
True if the MouseButton is pressed.
bool Otter.Input.MouseButtonReleased ( MouseButton  b)

Check if a MouseButton is pressed.

Parameters
bThe MouseButton to check.
Returns
True if the MouseButton is pressed.
bool Otter.Input.MouseButtonUp ( MouseButton  b)

Check if a MouseButton is pressed.

Parameters
bThe MouseButton to check.
Returns
True if the MouseButton is pressed.
void Otter.Input.SetAxisThreshold ( JoyAxis  axis,
float  threshold 
)

Set the threshold for an axis to act as an AxisButton. Defaults to 50 or one half of the joystick's total range.

Parameters
axisThe JoyAxis to set.
thresholdThe threshold that the axis must pass to act as a button press.

Member Data Documentation

bool Otter.Input.CenteredMouse = false
static

Determines if the mouse should be locked to the center of the screen.

Input Otter.Input.Instance
static

A reference to the current active instance.

string Otter.Input.KeyString = ""

The current string of keys that were pressed.

int Otter.Input.KeystringSize = 500
static

The maximum size of the string of recent key presses.

Property Documentation

Game Otter.Input.Game
getset

The reference to the game that owns this class.

int Otter.Input.GameMouseX
getset

The X position of the mouse in the game. Use if the mouse is locked in the game window. This can be set if the mouse is locked inside the game window.

int Otter.Input.GameMouseY
getset

The Y position of the mouse in the game. Use if the mouse is locked in the game window. This can be set if the mouse is locked inside the game window.

int Otter.Input.JoysticksConnected
staticget

The current number of joysticks connected.

int Otter.Input.JoysticksSupported
staticget

The maximum possible amount of joysticks that can be connected.

List<int> Otter.Input.LastButton
getset

The last known button pressed on each joystick.

Key Otter.Input.LastKey
getset

The last known key that was pressed.

MouseButton Otter.Input.LastMouseButton
getset

The last known mouse button that was pressed.

int Otter.Input.MouseDeltaX
getset

The X movement of the mouse since the last update. Only updates if the mouse is locked inside the Game window.

int Otter.Input.MouseDeltaY
getset

The Y movement of the mouse since the last update. Only updates if the mouse is locked inside the Game window.

int Otter.Input.MouseRawX
getset

The raw X position of the mouse. This can be set.

int Otter.Input.MouseRawY
getset

The raw Y position of the mouse. This can be set.

float Otter.Input.MouseScreenX
get

The X position of the mouse in screen space.

float Otter.Input.MouseScreenY
get

The Y position of the mouse in screen space.

float Otter.Input.MouseWheelDelta
get

The change in the mouse wheel value this update.

int Otter.Input.MouseX
get

The current X position of the mouse.

int Otter.Input.MouseY
get

The current Y position of the mouse.


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