Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5474 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Nov 3, 2005, 2:13:48 PM (19 years ago)
Author:
patrick
Message:

orxonox/lib/event: fixed the mouse button bug

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/defs/debug.h

    r5440 r5474  
    7070  // ENGINES
    7171  #define DEBUG_MODULE_GRAPHICS              2
    72   #define DEBUG_MODULE_EVENT                 2
     72  #define DEBUG_MODULE_EVENT                 4
    7373  #define DEBUG_MODULE_PHYSICS               2
    7474  #define DEBUG_MODULE_GARBAGE_COLLECTOR     2
  • trunk/src/lib/event/event_handler.cc

    r5388 r5474  
    279279        case SDL_MOUSEBUTTONUP:
    280280          ev.bPressed = false;
    281           ev.type = event.button.button + SDLK_LAST;
     281          ev.type = event.button.button + SDLK_LAST -1;
     282          printf(">>>>>>>>>>type = %i\n", ev.type);
    282283          break;
    283284        case SDL_MOUSEBUTTONDOWN:
    284285          ev.bPressed = true;
    285           ev.type = event.button.button + SDLK_LAST;
     286          ev.type = event.button.button + SDLK_LAST -1;
    286287          break;
    287288        case SDL_JOYAXISMOTION:
  • trunk/src/lib/event/key_mapper.cc

    r5299 r5474  
    133133  {
    134134    PRINTF(3)("Keys: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());
     135    // map the name to an sdl index
    135136    index = nameToIndex (iniParser->getCurrentValue());
    136     this->mapKeys(iniParser->getCurrentName(), index[1]);
     137    // map the index to a internal name
     138    this->mapKeys(iniParser->getCurrentName(), index);
    137139    iniParser->nextVar();
    138140  }
     
    151153    PRINTF(3)("MISC: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());
    152154    index = nameToIndex (iniParser->getCurrentValue());
    153     this->mapKeys(iniParser->getCurrentName(), index[1]);
     155    this->mapKeys(iniParser->getCurrentName(), index);
    154156    iniParser->nextVar();
    155157  }
     
    165167  coord[1] = -1;
    166168  int c;
    167   if( (c = keynameToSDLK (name)) != -1)
    168     {
     169  if( (c = keynameToSDLK (name)) != -1) {
    169170      coord[1] = c;
    170171      coord[0] = 0;
    171172    }
    172   if( (c = buttonnameToSDLB (name)) != -1)
    173     {
     173  if( (c = buttonnameToSDLB (name)) != -1) {
    174174      coord[1] = c;
    175175      coord[0] = 1;
     
    184184 * @param id of the key
    185185*/
    186 void KeyMapper::mapKeys(const char* name, int keyID)
    187 {
    188   for(int i = 0; map[i].pValue != NULL; ++i )
     186void KeyMapper::mapKeys(const char* name, int* index)
     187{
     188  for( int i = 0; map[i].pValue != NULL; ++i )
    189189    {
    190190      if( !strcmp (name, map[i].pName))
    191191      {
    192         *map[i].pValue = keyID;
    193         PRINTF(4)("Mapping %s to '%s' (id %i)\n", name, SDLKToKeyname(keyID), keyID);
    194         break;
     192        if( index[0] == 0)
     193        {
     194          *map[i].pValue = index[1];
     195          PRINTF(4)("Mapping %s to '%s' (id %i)\n", name, SDLKToKeyname(index[1]), index[1]);
     196          break;
     197        }
     198        else {
     199          *map[i].pValue = index[1];
     200          PRINTF(4)("Mapping %s to '%s' (id %i)\n", name, SDLBToButtonname(index[1]), index[1]);
     201          break;
     202        }
    195203      }
    196204    }
  • trunk/src/lib/event/key_mapper.h

    r5039 r5474  
    3636 private:
    3737  int* nameToIndex (const char* name);
    38   void mapKeys(const char* name, int keyID);
     38  void mapKeys(const char* name, int* index);
    3939
    4040 public:
  • trunk/src/lib/event/key_names.cc

    r4780 r5474  
    1515
    1616#include "key_names.h"
     17#include "event_def.h"
    1718
    1819#include "stdincl.h"
     
    2425int buttonnameToSDLB(const char* name)
    2526{
    26         if( !strcmp (name, "BUTTON_LEFT")) return SDL_BUTTON_LEFT;
     27        if( !strcmp (name, "BUTTON_LEFT"))
     28          return EV_MOUSE_BUTTON_LEFT;
    2729        if( !strcmp (name, "BUTTON_MIDDLE")) return SDL_BUTTON_MIDDLE;
    2830        if( !strcmp (name, "BUTTON_RIGHT")) return SDL_BUTTON_RIGHT;
     
    3234}
    3335
    34 char* SDLBToButtonname( int button)
     36const char* SDLBToButtonname( int button)
    3537{
    36         if( button == SDL_BUTTON_LEFT) return "BUTTON_LEFT";
     38        if( button == EV_MOUSE_BUTTON_LEFT) return "BUTTON_LEFT";
    3739        if( button == SDL_BUTTON_MIDDLE) return "BUTTON_MIDDLE";
    3840        if( button == SDL_BUTTON_RIGHT) return "BUTTON_RIGHT";
     
    180182}
    181183
    182 char* SDLKToKeyname( int key)
     184const char* SDLKToKeyname( int key)
    183185{
    184186        if( key == SDLK_BACKSPACE) return "BACKSPACE";
  • trunk/src/lib/event/key_names.h

    r5039 r5474  
    2020      * @return a pointer to a string containing the name of the mouse button
    2121*/
    22 char* SDLBToButtonname( int button);
     22const char* SDLBToButtonname( int button);
    2323
    2424/**
     
    3434      * @return a pointer to a string containig the name of the key
    3535*/
    36 char* SDLKToKeyname( int key);
     36const char* SDLKToKeyname( int key);
    3737
    3838
Note: See TracChangeset for help on using the changeset viewer.