CrystalSpace

Public API Reference

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

csInputDefinition Class Reference

This class holds a description of a physical source of input events, such as a keyboard key, mouse or joystick button, or a mouse or joystick axis. More...

#include <csutil/inputdef.h>

List of all members.

Public Member Functions

 csInputDefinition (uint32 honorModifiers=0, bool useCookedCode=false)
 Default constructor.
 csInputDefinition (const csInputDefinition &other)
 Copy constructor.
 csInputDefinition (iEvent *event, uint32 honorModifiers=0, bool useCookedCode=false)
 Construct an input description from an iEvent (usually a button).
 csInputDefinition (iEvent *event, int axis)
 Construct an input description from an iEvent (usually an axis).
 csInputDefinition (const char *string, uint32 honorModifiers=0, bool useCookedCode=false)
 Construct an input description from a string.
csString ToString (bool distinguishModifiers=true) const
 Gets the string representation of the description.
bool IsValid () const
 Returns a boolean indicating whether the object contains a valid input.
int GetType () const
 Returns the event type of the description (a csev... constant).
void SetType (int t)
 Set the event type of the description (a csev... constant).
bool GetKeyCode (utf32_char &code, bool &isCooked) const
 Gives the key code of the description, assuming it is a keyboard type.
bool SetKeyCode (utf32_char code)
 Sets the key code of the description, assuming it is a keyboard type.
int GetNumber () const
 Returns the numeric value of the description.
void SetNumber (int n)
 Sets the numeric value of the description.
const csKeyModifiersGetModifiers () const
 Returns the keyboard modifiers of the description.
void SetModifiers (const csKeyModifiers &mods)
 Sets the keyboard modifiers of the description.
uint32 ComputeHash () const
 Generate a hash value from the object.
bool Compare (csInputDefinition const &) const
 Return a boolean indicating whether the two definitions are equal.

Static Public Member Functions

bool ParseKey (const char *iStr, utf32_char *oKeyCode, utf32_char *oCookedCode, csKeyModifiers *oModifiers)
 Helper function to parse a string (eg.
bool ParseOther (const char *iStr, int *oType, int *oNumeric, csKeyModifiers *oModifiers)
 Helper function to parse a string (eg.
csString GetKeyString (utf32_char code, const csKeyModifiers *mods, bool distinguishModifiers=true)
 Helper function to return a string (eg.
csString GetOtherString (int type, int num, const csKeyModifiers *mods, bool distinguishModifiers=true)
 Helper function to return a string (eg.
unsigned int ComputeHash (const csInputDefinition &key)
 Allows this class to be used as a csHash key handler.
bool CompareKeys (const csInputDefinition &key1, const csInputDefinition &key2)
 Allows this class to be used as a csHash key handler.

Friends

class csInputBinder


Detailed Description

This class holds a description of a physical source of input events, such as a keyboard key, mouse or joystick button, or a mouse or joystick axis.

Definition at line 40 of file inputdef.h.


Constructor & Destructor Documentation

csInputDefinition::csInputDefinition uint32  honorModifiers = 0,
bool  useCookedCode = false
 

Default constructor.

Parameters:
honorModifiers A bitmask of modifier keys that will be recognised.
useCookedCode If true, will use the cooked key code instead of raw.

csInputDefinition::csInputDefinition const csInputDefinition other  ) 
 

Copy constructor.

csInputDefinition::csInputDefinition iEvent event,
uint32  honorModifiers = 0,
bool  useCookedCode = false
 

Construct an input description from an iEvent (usually a button).

Parameters:
event The event to analyse for input data.
honorModifiers A bitmask of modifier keys that will be recognised.
useCookedCode If true, will use the cooked key code instead of raw.

csInputDefinition::csInputDefinition iEvent event,
int  axis
 

Construct an input description from an iEvent (usually an axis).

Parameters:
event The event to analyse for input data.
axis Events include all axes, so choose: 0 = x, 1 = y.

csInputDefinition::csInputDefinition const char *  string,
uint32  honorModifiers = 0,
bool  useCookedCode = false
 

Construct an input description from a string.

Parameters:
string The string to parse, e.g. "mouse1", "shift+a".
honorModifiers A bitmask of modifier keys that will be recognised.
useCookedCode If true, will use the cooked key code instead of raw.


Member Function Documentation

bool csInputDefinition::Compare csInputDefinition const &   )  const
 

Return a boolean indicating whether the two definitions are equal.

Referenced by CompareKeys().

bool csInputDefinition::CompareKeys const csInputDefinition key1,
const csInputDefinition key2
[inline, static]
 

Allows this class to be used as a csHash key handler.

Definition at line 225 of file inputdef.h.

References Compare().

unsigned int csInputDefinition::ComputeHash const csInputDefinition key  )  [inline, static]
 

Allows this class to be used as a csHash key handler.

Definition at line 221 of file inputdef.h.

References ComputeHash().

uint32 csInputDefinition::ComputeHash  )  const
 

Generate a hash value from the object.

Referenced by ComputeHash().

bool csInputDefinition::GetKeyCode utf32_char code,
bool &  isCooked
const [inline]
 

Gives the key code of the description, assuming it is a keyboard type.

Parameters:
code Will be set to the key code.
isCooked Will be set to true if the code is cooked, false if raw.
Returns:
False if the description is not a keyboard type.

Definition at line 126 of file inputdef.h.

csString csInputDefinition::GetKeyString utf32_char  code,
const csKeyModifiers mods,
bool  distinguishModifiers = true
[static]
 

Helper function to return a string (eg.

"Ctrl+A") from values describing a keyboard event.

Parameters:
code The key code, treated as a raw code although raw vs. cooked doesn't matter here.
mods The keyboard modifiers. Will be ignored if 0.
distinguishModifiers Whether to output distinguished modifiers (eg. "LCtrl" as opposed to just "Ctrl").
Returns:
The description string.

const csKeyModifiers& csInputDefinition::GetModifiers  )  const [inline]
 

Returns the keyboard modifiers of the description.

Definition at line 152 of file inputdef.h.

References csKeyModifiers.

int csInputDefinition::GetNumber  )  const [inline]
 

Returns the numeric value of the description.

Returns:
If non-keyboard button event, the button number. If axis event, the axis number (0 = x, 1 = y).

Definition at line 142 of file inputdef.h.

csString csInputDefinition::GetOtherString int  type,
int  num,
const csKeyModifiers mods,
bool  distinguishModifiers = true
[static]
 

Helper function to return a string (eg.

"MouseX", "Alt+Mouse1") from values describing a non-keyboard event.

Parameters:
type The event type of the description (a csev... constant).
num For button events, the button number. For axis events, the axis number (0 = x, 1 = y).
mods The keyboard modifiers. Will be ignored if 0.
distinguishModifiers Whether to output distinguished modifiers (eg. "LCtrl" as opposed to just "Ctrl").
Returns:
The description string.

int csInputDefinition::GetType  )  const [inline]
 

Returns the event type of the description (a csev... constant).

Definition at line 115 of file inputdef.h.

bool csInputDefinition::IsValid  )  const
 

Returns a boolean indicating whether the object contains a valid input.

bool csInputDefinition::ParseKey const char *  iStr,
utf32_char oKeyCode,
utf32_char oCookedCode,
csKeyModifiers oModifiers
[static]
 

Helper function to parse a string (eg.

"Ctrl+A") into values describing a keyboard event, returning both raw and cooked key codes.

Parameters:
iStr The string to parse.
oKeyCode Will be set to the raw code of the parsed description.
oCookedCode Will be set to the cooked code of the description.
oModifiers The modifiers of the description.
Returns:
Whether the string could be successfully parsed.
Remarks:
Any of the output parameters may be null, in which case they are ignored.

bool csInputDefinition::ParseOther const char *  iStr,
int *  oType,
int *  oNumeric,
csKeyModifiers oModifiers
[static]
 

Helper function to parse a string (eg.

"MouseX", "Alt+Mouse1") into values describing a non-keyboard event.

Parameters:
iStr The string to parse.
oType Will be set to the event type of the description (a csev... constant).
oNumeric For button events, will be set to the button number. For axis events, will be set to the axis number (0 = x, 1 = y).
oModifiers Will be populated with the modifiers of the description.
Returns:
Whether the string could be successfully parsed.
Remarks:
Any of the output parameters may be null, in which case they are ignored.

bool csInputDefinition::SetKeyCode utf32_char  code  )  [inline]
 

Sets the key code of the description, assuming it is a keyboard type.

Definition at line 132 of file inputdef.h.

void csInputDefinition::SetModifiers const csKeyModifiers mods  )  [inline]
 

Sets the keyboard modifiers of the description.

Definition at line 155 of file inputdef.h.

References csKeyModifiers.

void csInputDefinition::SetNumber int  n  )  [inline]
 

Sets the numeric value of the description.

Parameters:
n If non-keyboard button event, the button number. If axis event, the axis number (0 = x, 1 = y).

Definition at line 149 of file inputdef.h.

void csInputDefinition::SetType int  t  )  [inline]
 

Set the event type of the description (a csev... constant).

Definition at line 118 of file inputdef.h.

csString csInputDefinition::ToString bool  distinguishModifiers = true  )  const
 

Gets the string representation of the description.

Parameters:
distinguishModifiers If false, left and right modifiers will be output as plain-old modifiers (e.g. "LAlt" and "RAlt" become just "Alt").
Returns:
The string representation of the description (e.g. "mouse1", "shift+a").


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.3.9.1