CrystalSpace

Public API Reference

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

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

Static Public Member Functions

static csString GetKeyString (iEventNameRegistry *reg, utf32_char code, const csKeyModifiers *mods, bool distinguishModifiers=true)
 Helper function to return a string (eg.
static csString GetOtherString (iEventNameRegistry *reg, csEventID type, uint device, int num, const csKeyModifiers *mods, bool distinguishModifiers=true)
 Helper function to return a string (eg.
static bool ParseKey (iEventNameRegistry *reg, const char *iStr, utf32_char *oKeyCode, utf32_char *oCookedCode, csKeyModifiers *oModifiers)
 Helper function to parse a string (eg.
static bool ParseOther (iEventNameRegistry *reg, const char *iStr, csEventID *oType, uint *oDevice, int *oNumeric, csKeyModifiers *oModifiers)
 Helper function to parse a string (eg.

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 45 of file inputdef.h.


Constructor & Destructor Documentation

csInputDefinition::csInputDefinition ( iEventNameRegistry name_reg,
uint32  honorModifiers = 0,
bool  useCookedCode = false 
)

Default constructor.

Parameters:
name_reg A pointer to the event name registry.
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 ( iEventNameRegistry name_reg,
iEvent event,
uint32  honorModifiers = 0,
bool  useCookedCode = false 
)

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

Parameters:
name_reg A pointer to the event name registry.
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 ( iEventNameRegistry name_reg,
iEvent event,
uint8  axis 
)

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

Parameters:
name_reg A pointer to the event name registry.
event The event to analyse for input data.
axis Events include all axes, so choose: 0 = x, 1 = y.
csInputDefinition::csInputDefinition ( iEventNameRegistry name_reg,
const char *  string,
uint32  honorModifiers = 0,
bool  useCookedCode = false 
)

Construct an input description from a string.

Parameters:
name_reg A pointer to the event name registry.
string The string to parse, e.g. "mousebutton1", "shift+a".
honorModifiers A bitmask of modifier keys that will be recognised.
useCookedCode If true, will use the cooked key code instead of raw. More precisely, the syntax for string is (in EBNF):

 [ mod ("+"|"-") ]* ( ( devNumber? ("mouse" | "joystick") ( "X" | "Y" | ("Axis" axisNumber) | ("Button" buttonNumber) | buttonNumber ) ) | key )
 

So the fourth axis of the third joystick is "2JoystickAxis3", and its first button is "2JoystickButton0" or "2Joystick0". The leading number must be omitted for the first (primary) input device, e.g., "MouseAxis0" or "JoystickButton3".


Member Function Documentation

int csInputDefinition::Compare ( csInputDefinition const &   )  const

Returns a number indicating the relation of the two definitions.

uint32 csInputDefinition::ComputeHash (  )  const

Generate a hash value from the object.

const uint csInputDefinition::GetDeviceNumber (  )  const [inline]

Returns the (basis-0) device number of the description.

Definition at line 177 of file inputdef.h.

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 148 of file inputdef.h.

static csString csInputDefinition::GetKeyString ( iEventNameRegistry reg,
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:
reg A pointer to the event name registry.
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 174 of file inputdef.h.

csEventID csInputDefinition::GetName (  )  const [inline]

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

Definition at line 137 of file inputdef.h.

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 164 of file inputdef.h.

static csString csInputDefinition::GetOtherString ( iEventNameRegistry reg,
csEventID  type,
uint  device,
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:
reg A pointer to the event name registry.
type The event type of the description (a csev... identifier).
device For mouse and joystick events, the device number, basis 0 (first mouse is 0, second joystick is 1, etc).
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.
bool csInputDefinition::IsValid (  )  const

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

static bool csInputDefinition::ParseKey ( iEventNameRegistry reg,
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:
reg A pointer to the event name registry.
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.
static bool csInputDefinition::ParseOther ( iEventNameRegistry reg,
const char *  iStr,
csEventID oType,
uint oDevice,
int *  oNumeric,
csKeyModifiers oModifiers 
) [static]

Helper function to parse a string (eg.

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

Parameters:
reg A pointer to the event name registry.
iStr The string to parse.
oType Will be set to the event name of the description (a csev... identifier).
oDevice For mouse and joystick events, will be set to the device number, basis 0 (e.g., the third joystick device is "2").
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 154 of file inputdef.h.

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

Sets the keyboard modifiers of the description.

Definition at line 180 of file inputdef.h.

void csInputDefinition::SetName ( csEventID  n  )  [inline]

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

Definition at line 140 of file inputdef.h.

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 171 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. "mousebutton1", "shift+a").

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

Generated for Crystal Space 1.4.1 by doxygen 1.7.1