Planeshift
|
Manages button functions and triggers. More...
#include <pscharcontrol.h>
Public Member Functions | |
const csPDelArray< psControl > & | GetAllTriggers () |
Get the full array of triggers. | |
psControl * | GetMappedTrigger (psControl::Device device, uint button, uint32 mods) |
Gets a mapped trigger for a device by button. | |
csArray< psControl * > * | GetMappedTriggers (psControl::Device device, uint button) |
Gets all mapped triggers for a device by button ignoring mods. | |
psControl * | GetTrigger (const char *name) |
Gets a trigger from the master list by name. | |
bool | HandleEvent (iEvent &event) |
bool | MapTrigger (const char *name, psControl::Device device, uint button, uint32 mods) |
Sets a trigger to the desired button. | |
void | NewTrigger (const char *name, psControl::PressType type, psControl::TriggerFunction function) |
Creates a new trigger. | |
psControlManager (iEventNameRegistry *eventname_reg, psTriggerHandler *handler) | |
void | ResetAllTriggers () |
Resets all mappings. | |
void | ResetTrigger (psControl *trigger) |
Resets a trigger's mapping. | |
bool | SetTriggerData (const char *name, const void *ptr) |
Assign 'ptr' to all psControls starting with 'name'. | |
Protected Types | |
typedef csHash< psControl *, uint > | psControlMap |
Each device gets a hash map of buttons to triggers. | |
Protected Member Functions | |
csArray< psControl * > * | GetArrayFromMap (const psControlMap &ctrlmap, uint button) |
Gets the controls from a map with the specified button. | |
void | HandleButton (psControl::Device device, uint button, uint32 mods, bool newState) |
Handles an input event. | |
Static Protected Member Functions | |
static psControl * | GetFromMap (const psControlMap &ctrlmap, uint button, uint32 mods) |
Gets the control from a map with the specified button and mods (if not found, finds without mods) | |
Protected Attributes | |
csEventID | event_key_down |
csEventID | event_key_up |
csEventID | event_mouse_down |
csEventID | event_mouse_up |
psControlMap | keyboard |
List of all keyboard triggers. | |
psControlMap | mouse |
List of all mouse triggers. | |
csPDelArray< psControl > | triggers |
Master list of all triggers. |
Manages button functions and triggers.
Each game function which may be controled by a button has a psControl object called a "trigger". After creating a trigger using the NewTrigger() function, from psCharController::CreateKeys(), each trigger is assigned a name and a function to call back to when executed. MapTrigger() is used to set a trigger to a button combination (device + button + mods). A pointer to this is then stored in the psControlMap (hash map) for the device in question. Additional optional data can be assigned to a trigger using SetTriggerData(). (ex: modes/movements) When HandleEvent() receives an input event the device, button, and mods are determined. The trigger is retrieved from the map and the function is executed, passing itself and the button's state as arguments. The trigger function then takes this information and does whatever it does.
Definition at line 122 of file pscharcontrol.h.
typedef csHash<psControl*,uint> psControlManager::psControlMap [protected] |
Each device gets a hash map of buttons to triggers.
Definition at line 157 of file pscharcontrol.h.
psControlManager::psControlManager | ( | iEventNameRegistry * | eventname_reg, |
psTriggerHandler * | handler | ||
) |
const csPDelArray<psControl>& psControlManager::GetAllTriggers | ( | ) | [inline] |
Get the full array of triggers.
Definition at line 148 of file pscharcontrol.h.
csArray<psControl*>* psControlManager::GetArrayFromMap | ( | const psControlMap & | ctrlmap, |
uint | button | ||
) | [protected] |
Gets the controls from a map with the specified button.
static psControl* psControlManager::GetFromMap | ( | const psControlMap & | ctrlmap, |
uint | button, | ||
uint32 | mods | ||
) | [static, protected] |
Gets the control from a map with the specified button and mods (if not found, finds without mods)
psControl* psControlManager::GetMappedTrigger | ( | psControl::Device | device, |
uint | button, | ||
uint32 | mods | ||
) |
Gets a mapped trigger for a device by button.
csArray<psControl*>* psControlManager::GetMappedTriggers | ( | psControl::Device | device, |
uint | button | ||
) |
Gets all mapped triggers for a device by button ignoring mods.
psControl* psControlManager::GetTrigger | ( | const char * | name | ) |
Gets a trigger from the master list by name.
void psControlManager::HandleButton | ( | psControl::Device | device, |
uint | button, | ||
uint32 | mods, | ||
bool | newState | ||
) | [protected] |
Handles an input event.
bool psControlManager::HandleEvent | ( | iEvent & | event | ) |
bool psControlManager::MapTrigger | ( | const char * | name, |
psControl::Device | device, | ||
uint | button, | ||
uint32 | mods | ||
) |
Sets a trigger to the desired button.
void psControlManager::NewTrigger | ( | const char * | name, |
psControl::PressType | type, | ||
psControl::TriggerFunction | function | ||
) |
Creates a new trigger.
void psControlManager::ResetAllTriggers | ( | ) |
Resets all mappings.
void psControlManager::ResetTrigger | ( | psControl * | trigger | ) |
Resets a trigger's mapping.
bool psControlManager::SetTriggerData | ( | const char * | name, |
const void * | ptr | ||
) |
Assign 'ptr' to all psControls starting with 'name'.
csEventID psControlManager::event_key_down [protected] |
Definition at line 165 of file pscharcontrol.h.
csEventID psControlManager::event_key_up [protected] |
Definition at line 166 of file pscharcontrol.h.
csEventID psControlManager::event_mouse_down [protected] |
Definition at line 167 of file pscharcontrol.h.
csEventID psControlManager::event_mouse_up [protected] |
Definition at line 168 of file pscharcontrol.h.
psControlMap psControlManager::keyboard [protected] |
List of all keyboard triggers.
Definition at line 159 of file pscharcontrol.h.
psControlMap psControlManager::mouse [protected] |
List of all mouse triggers.
Definition at line 160 of file pscharcontrol.h.
csPDelArray<psControl> psControlManager::triggers [protected] |
Master list of all triggers.
Definition at line 162 of file pscharcontrol.h.