Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4386 in orxonox.OLD for orxonox/trunk/src/util/event


Ignore:
Timestamp:
May 29, 2005, 11:33:49 PM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: key mapper implementation precess

Location:
orxonox/trunk/src/util/event
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/util/event/event_handler.cc

    r4381 r4386  
    2222#include "event.h"
    2323
    24 #include "ini_parser.h"
    25 #include "keynames.h"
    2624#include "compiler.h"
    2725#include "debug.h"
  • orxonox/trunk/src/util/event/event_handler.h

    r4369 r4386  
    1616
    1717
    18 //! Key aliasing structure
    19 /**
    20    This structure contains the key aliasing information, e.g. the command strings that
    21    have been bound to the keys.
    22 */
    23 typedef struct
    24 {
    25   char keys[N_STD_KEYS][CMD_LENGHT];
    26   char buttons[N_BUTTONS][CMD_LENGHT];
    27 } KeyBindings;
     18
    2819
    2920
     
    5041 private:
    5142  static EventHandler* singletonRef;
    52   KeyBindings* keyAliases;
    5343  EventListener*** listeners;                         //!< a list of registered listeners
    5444  elState state;
  • orxonox/trunk/src/util/event/key_mapper.cc

    r4369 r4386  
    1616#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_EVENT
    1717
    18 #include "event.h"
     18#include "key_mapper.h"
     19
     20#include "ini_parser.h"
     21#include "keynames.h"
    1922
    2023using namespace std;
     24
     25
     26
     27int KeyMapper::PEV_UP = -1;
     28int KeyMapper::PEV_DOWN = -1;
     29int KeyMapper::PEV_LEFT = -1;
     30int KeyMapper::PEV_RIGHT = -1;
     31int KeyMapper::PEV_STRAFE_LEFT = -1;
     32int KeyMapper::PEV_STRAFE_RIGHT = -1;
     33
     34int KeyMapper::PEV_FIRE1 = -1;
     35int KeyMapper::PEV_FIRE2 = -1;
     36
     37int KeyMapper::PEV_VIEW1 = -1;
     38int KeyMapper::PEV_VIEW2 = -1;
     39int KeyMapper::PEV_VIEW3 = -1;
     40int KeyMapper::PEV_VIEW4 = -1;
     41
    2142
    2243
     
    2849{
    2950   this->setClassID(CL_KEY_MAPPER, "KeyMapper");
    30 
     51   this->keyAliases = NULL;
    3152}
    3253
     
    4162}
    4263
    43 
     64\
    4465/**
    4566   \brief loads new key bindings from a file
     
    115136  while( parser.nextVar (namebuf, valuebuf) != -1)
    116137    {
    117       //index = nameToIndex (valuebuf);     
    118       int c;
    119       if( (c = keynameToSDLK (valuebuf)) != -1)
    120         {
    121           index[1] = c; index[0] = 0;
    122         }
    123       if( (c = buttonnameToSDLB (valuebuf)) != -1)
    124         {
    125           index[1] = c; index[0] = 1;
    126         }
    127 
     138      index = nameToIndex (valuebuf);     
    128139
    129140      switch( index[0])
     
    144155    }
    145156}
     157
     158
     159
     160int* KeyMapper::nameToIndex (char* name)
     161{
     162  coord[0] = -1;
     163  coord[1] = -1;
     164  int c;
     165  if( (c = keynameToSDLK (name)) != -1)
     166    {
     167      coord[1] = c;
     168      coord[0] = 0;
     169    }
     170  if( (c = buttonnameToSDLB (name)) != -1)
     171    {
     172      coord[1] = c;
     173      coord[0] = 1;
     174    }
     175  return coord;
     176}
  • orxonox/trunk/src/util/event/key_mapper.h

    r4368 r4386  
    1111#include "base_object.h"
    1212#include "event_def.h"
     13
     14
     15//! Key aliasing structure
     16/**
     17   This structure contains the key aliasing information, e.g. the command strings that
     18   have been bound to the keys.
     19*/
     20typedef struct
     21{
     22  char keys[N_STD_KEYS][CMD_LENGHT];
     23  char buttons[N_BUTTONS][CMD_LENGHT];
     24} KeyBindings;
    1325
    1426
     
    4456 private:
    4557  KeyBindings* keyAliases;
     58  Sint32 coord[2];
    4659};
    4760
Note: See TracChangeset for help on using the changeset viewer.