adonthell-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Adonthell-commits] CVS: adonthell/src/input control_event.cc, 1.1.1.1,


From: Alexandre Courbot <address@hidden>
Subject: [Adonthell-commits] CVS: adonthell/src/input control_event.cc, 1.1.1.1, 1.2 control_event.h, 1.1.1.1, 1.2 event.cc, 1.1.1.1, 1.2 input.cc, 1.1.1.1, 1.2 joystick_event.cc, 1.1.1.1, 1.2 joystick_event.h, 1.1.1.1, 1.2 keyboard_event.cc, 1.1.1.1, 1.2 keyboard_event.h, 1.1.1.1, 1.2 listener.cc, 1.1.1.1, 1.2 listener.h, 1.1.1.1, 1.2 manager.cc, 1.1.1.1, 1.2 mouse_event.cc, 1.1.1.1, 1.2 mouse_event.h, 1.1.1.1, 1.2
Date: Thu, 24 Jul 2003 08:58:01 -0400

Update of /cvsroot/adonthell/adonthell/src/input
In directory subversions:/tmp/cvs-serv8178/src/input

Modified Files:
        control_event.cc control_event.h event.cc input.cc 
        joystick_event.cc joystick_event.h keyboard_event.cc 
        keyboard_event.h listener.cc listener.h manager.cc 
        mouse_event.cc mouse_event.h 
Log Message:
Applied Fabien's changes and extended them to all the source
(changing using namespace's into real namespace enclosing and fixed some
 consts)


Index: control_event.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/input/control_event.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** control_event.cc    18 Jul 2003 15:16:09 -0000      1.1.1.1
--- control_event.cc    24 Jul 2003 12:57:58 -0000      1.2
***************
*** 24,58 ****
  #include "control_event.h"
  
! using namespace input;
! 
! std::string control_event::Button_symbol[control_event::NBR_BUTTONS] =
  {
!     "no button"
!     "up",
!     "down",
!     "right",
!     "left",
!     "A button",
!     "B button",
!     "C button",
!     "D button"
! };
  
! control_event::control_event(event_type t, button_type b) : 
event(CONTROL_EVENT)
! {
!     Type = t;
!     Button = b;
! }
  
! const std::string & control_event::button_symbol() const
! {
!     return Button_symbol[button()];
! }
  
! control_event::button_type 
control_event::Keyboard_map[keyboard_event::NBR_KEYS] = 
!     { control_event::NO_BUTTON };
! control_event::button_type control_event::Mouse_map[mouse_event::NBR_BUTTONS] 
= 
!     { control_event::NO_BUTTON };
! control_event::button_type 
control_event::Joystick_map[joystick_event::NBR_BUTTONS * 
!                                                        
joystick_event::max_nbr_joysticks] = 
!     { control_event::NO_BUTTON };
--- 24,59 ----
  #include "control_event.h"
  
! namespace input
  {
!     std::string control_event::Button_symbol[control_event::NBR_BUTTONS] =
!         {
!             "no button"
!             "up",
!             "down",
!             "right",
!             "left",
!             "A button",
!             "B button",
!             "C button",
!             "D button"
!         };
  
!     control_event::control_event(event_type t, button_type b) : 
event(CONTROL_EVENT)
!     {
!         Type = t;
!         Button = b;
!     }
  
!     const std::string & control_event::button_symbol() const
!     {
!         return Button_symbol[button()];
!     }
  
!     control_event::button_type 
control_event::Keyboard_map[keyboard_event::NBR_KEYS] = 
!         { control_event::NO_BUTTON };
!     control_event::button_type 
control_event::Mouse_map[mouse_event::NBR_BUTTONS] = 
!         { control_event::NO_BUTTON };
!     control_event::button_type 
control_event::Joystick_map[joystick_event::NBR_BUTTONS * 
!                                                            
joystick_event::max_nbr_joysticks] = 
!         { control_event::NO_BUTTON };
! }

Index: control_event.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/input/control_event.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** control_event.h     18 Jul 2003 15:16:09 -0000      1.1.1.1
--- control_event.h     24 Jul 2003 12:57:58 -0000      1.2
***************
*** 199,203 ****
  }
  
  PYTHON_AS_CALLBACK_ARGUMENT(input::control_event)
! 
  #endif
--- 199,204 ----
  }
  
+ #ifndef SWIG
  PYTHON_AS_CALLBACK_ARGUMENT(input::control_event)
! #endif // SWIG
  #endif

Index: event.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/input/event.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** event.cc    18 Jul 2003 15:16:09 -0000      1.1.1.1
--- event.cc    24 Jul 2003 12:57:58 -0000      1.2
***************
*** 25,36 ****
  #include "event.h"
  
! using namespace input;
! 
! event::event (input_type t)
! {
!     Type = t; 
! }
! 
! event::~event()
  {
  }
--- 25,37 ----
  #include "event.h"
  
! namespace input
  {
+     event::event (input_type t)
+     {
+         Type = t; 
+     }
+     
+     event::~event()
+     {
+     }
  }

Index: input.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/input/input.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** input.cc    18 Jul 2003 15:16:09 -0000      1.1.1.1
--- input.cc    24 Jul 2003 12:57:58 -0000      1.2
***************
*** 47,103 ****
  static void (*inputcleanup)() = 0;
  
! 
! bool input::init(const std::string & backend_name)
  {
!     if (lt_dlinit()) 
!     { 
!         std::cerr << lt_dlerror() << std::endl;
!         std::cerr << "Error initializing liblt!\n"; 
!         return false;
!     }
  
!     dlhandle = base::get_module(std::string("/input/") + backend_name);
      
!     if (!dlhandle) goto bigerror;
  
!     inputinit = (bool(*)()) lt_dlsym(dlhandle, "input_init");
!     if (!inputinit)
!     {
!         std::cerr << lt_dlerror() << std::endl;
!         goto bigerror;
!     }
      
!     inputcleanup = (void(*)()) lt_dlsym(dlhandle, "input_cleanup");
!     if (!inputcleanup)
!     {
!         std::cerr << lt_dlerror() << std::endl;
!         goto bigerror;
!     }
  
!     input::manager::update_p = (void(*)()) lt_dlsym(dlhandle, 
"input_manager_update");
!     if (!input::manager::update_p)
!     {
!         std::cerr << lt_dlerror() << std::endl;
!         goto bigerror;
!     }
! 
!     goto success;
      
!  bigerror:
!     if (dlhandle) lt_dlclose(dlhandle);
!     lt_dlexit();
!     return false;
  
!  success:
          
!     return inputinit();
! }
  
! void input::cleanup()
! {
!     if (inputcleanup) inputcleanup();
!     inputcleanup = NULL;
  
!     if (dlhandle) lt_dlclose(dlhandle);
!     lt_dlexit();
  }
--- 47,105 ----
  static void (*inputcleanup)() = 0;
  
! namespace input
  {
!     bool init(const std::string & backend_name)
!     {
!         if (lt_dlinit()) 
!         { 
!             std::cerr << lt_dlerror() << std::endl;
!             std::cerr << "Error initializing liblt!\n"; 
!             return false;
!         }
  
!         dlhandle = base::get_module(std::string("/input/") + backend_name);
      
!         if (!dlhandle) goto bigerror;
  
!         inputinit = (bool(*)()) lt_dlsym(dlhandle, "input_init");
!         if (!inputinit)
!         {
!             std::cerr << lt_dlerror() << std::endl;
!             goto bigerror;
!         }
      
!         inputcleanup = (void(*)()) lt_dlsym(dlhandle, "input_cleanup");
!         if (!inputcleanup)
!         {
!             std::cerr << lt_dlerror() << std::endl;
!             goto bigerror;
!         }
! 
!         input::manager::update_p = (void(*)()) lt_dlsym(dlhandle, 
"input_manager_update");
!         if (!input::manager::update_p)
!         {
!             std::cerr << lt_dlerror() << std::endl;
!             goto bigerror;
!         }
  
!         goto success;
      
!     bigerror:
!         if (dlhandle) lt_dlclose(dlhandle);
!         lt_dlexit();
!         return false;
  
!     success:
          
!         return inputinit();
!     }
  
!     void cleanup()
!     {
!         if (inputcleanup) inputcleanup();
!         inputcleanup = NULL;
  
!         if (dlhandle) lt_dlclose(dlhandle);
!         lt_dlexit();
!     }
  }

Index: joystick_event.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/input/joystick_event.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** joystick_event.cc   18 Jul 2003 15:16:09 -0000      1.1.1.1
--- joystick_event.cc   24 Jul 2003 12:57:58 -0000      1.2
***************
*** 25,75 ****
  #include "joystick_event.h"
  
! using namespace input;
! 
! std::string joystick_event::Button_symbol[joystick_event::NBR_BUTTONS] =
  {
!     "no button",
!     "button 0",
!     "button 1",
!     "button 2",
!     "button 3",
!     "button 4",
!     "button 5",
!     "button 6",
!     "button 7",
!     "button 8",
!     "button 9",
!     "axis 0 fore",
!     "axis 0 back",
!     "axis 1 fore",
!     "axis 1 back",
!     "axis 2 fore",
!     "axis 2 back",
!     "axis 3 fore",
!     "axis 3 back",
!     "axis 4 fore",
!     "axis 4 back",
!     "axis 5 fore",
!     "axis 5 back",
!     "axis 6 fore",
!     "axis 6 back",
!     "axis 7 fore",
!     "axis 7 back",
!     "axis 8 fore",
!     "axis 8 back",
!     "axis 9 fore",
!     "axis 9 back"
! };
  
! joystick_event::joystick_event(u_int8 joynbr, event_type t, button_type b)
!     : event (event::JOYSTICK_EVENT)
! {
!     Joynbr = joynbr;
!     Type = t;
!     Button = b;
! }
  
! const std::string & joystick_event::button_symbol() const
! {
!     return Button_symbol[button()];
  }
--- 25,76 ----
  #include "joystick_event.h"
  
! namespace input
  {
!     std::string joystick_event::Button_symbol[joystick_event::NBR_BUTTONS] =
!         {
!             "no button",
!             "button 0",
!             "button 1",
!             "button 2",
!             "button 3",
!             "button 4",
!             "button 5",
!             "button 6",
!             "button 7",
!             "button 8",
!             "button 9",
!             "axis 0 fore",
!             "axis 0 back",
!             "axis 1 fore",
!             "axis 1 back",
!             "axis 2 fore",
!             "axis 2 back",
!             "axis 3 fore",
!             "axis 3 back",
!             "axis 4 fore",
!             "axis 4 back",
!             "axis 5 fore",
!             "axis 5 back",
!             "axis 6 fore",
!             "axis 6 back",
!             "axis 7 fore",
!             "axis 7 back",
!             "axis 8 fore",
!             "axis 8 back",
!             "axis 9 fore",
!             "axis 9 back"
!         };
  
!     joystick_event::joystick_event(u_int8 joynbr, event_type t, button_type b)
!         : event (event::JOYSTICK_EVENT)
!     {
!         Joynbr = joynbr;
!         Type = t;
!         Button = b;
!     }
  
!     const std::string & joystick_event::button_symbol() const
!     {
!         return Button_symbol[button()];
!     }
  }

Index: joystick_event.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/input/joystick_event.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** joystick_event.h    18 Jul 2003 15:16:09 -0000      1.1.1.1
--- joystick_event.h    24 Jul 2003 12:57:58 -0000      1.2
***************
*** 132,136 ****
  }
  
  PYTHON_AS_CALLBACK_ARGUMENT(input::joystick_event)
! 
  #endif
--- 132,137 ----
  }
  
+ #ifndef SWIG
  PYTHON_AS_CALLBACK_ARGUMENT(input::joystick_event)
! #endif // SWIG
  #endif

Index: keyboard_event.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/input/keyboard_event.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** keyboard_event.cc   18 Jul 2003 15:16:09 -0000      1.1.1.1
--- keyboard_event.cc   24 Jul 2003 12:57:58 -0000      1.2
***************
*** 24,270 ****
  #include "keyboard_event.h"
  
! using namespace input;
! 
! std::string keyboard_event::Key_symbol[keyboard_event::NBR_KEYS] =
  {
!     "unknown",
!     "backspace",
!     "tab",
!     "clear",
!     "return",
!     "pause",
!     "escape",
!     "space",
!     "!",
!     "\"",
!     "hash", // FIXME: Find correct symbol
!     "$",
!     "&",
!     "'",
!     "(",
!     ")",
!     "*",
!     "+",
!     ",",
!     "-",
!     ",",
!     "/",
!     "0",
!     "1",
!     "2",
!     "3",
!     "4",
!     "5",
!     "6",
!     "7",
!     "8",
!     "9",
!     ":",
!     ";",
!     "<",
!     "=",
!     ">",
!     "?",
!     "@",
!     "[",
!     "\\",
!     "]",
!     "#", // FIXME
!     "_",
!     "`",
!     "a",
!     "b",
!     "c",
!     "d",
!     "e",
!     "f",
!     "g",
!     "h",
!     "i",
!     "j",
!     "k",
!     "l",
!     "m",
!     "n",
!     "o",
!     "p",
!     "q",
!     "r",
!     "s",
!     "t",
!     "u",
!     "v",
!     "w",
!     "x",
!     "y",
!     "z",
!     "world 0",
!     "world 1",
!     "world 2",
!     "world 3",
!     "world 4",
!     "world 5",
!     "world 6",
!     "world 7",
!     "world 8",
!     "world 9",
!     "world 10",
!     "world 11",
!     "world 12",
!     "world 13",
!     "world 14",
!     "world 15",
!     "world 16",
!     "world 17",
!     "world 18",
!     "world 19",
!     "world 20",
!     "world 21",
!     "world 22",
!     "world 23",
!     "world 24",
!     "world 25",
!     "world 26",
!     "world 27",
!     "world 28",
!     "world 29",
!     "world 30",
!     "world 31",
!     "world 32",
!     "world 33",
!     "world 34",
!     "world 35",
!     "world 36",
!     "world 37",
!     "world 38",
!     "world 39",
!     "world 40",
!     "world 41",
!     "world 42",
!     "world 43",
!     "world 44",
!     "world 45",
!     "world 46",
!     "world 47",
!     "world 48",
!     "world 49",
!     "world 50",
!     "world 51",
!     "world 52",
!     "world 53",
!     "world 54",
!     "world 55",
!     "world 56",
!     "world 57",
!     "world 58",
!     "world 59",
!     "world 60",
!     "world 61",
!     "world 62",
!     "world 63",
!     "world 64",
!     "world 65",
!     "world 66",
!     "world 67",
!     "world 68",
!     "world 69",
!     "world 70",
!     "world 71",
!     "world 72",
!     "world 73",
!     "world 74",
!     "world 75",
!     "world 76",
!     "world 77",
!     "world 78",
!     "world 79",
!     "world 80",
!     "world 81",
!     "world 82",
!     "world 83",
!     "world 84",
!     "world 85",
!     "world 86",
!     "world 87",
!     "world 88",
!     "world 89",
!     "world 90",
!     "world 91",
!     "world 92",
!     "world 93",
!     "world 94",
!     "world 95",
!     "delete",
!     "keypad 0",
!     "keypad 1",
!     "keypad 2",
!     "keypad 3",
!     "keypad 4",
!     "keypad 5",
!     "keypad 6",
!     "keypad 7",
!     "keypad 8",
!     "keypad 9",
!     "keypad .",
!     "keypad /",
!     "keypad *",
!     "keypad -",
!     "keypad +",
!     "keypad enter",
!     "keypad =",
!     "up",
!     "down",
!     "right",
!     "left",
!     "insert",
!     "home",
!     "end",
!     "pageup",
!     "pagedown",
!     "f1",
!     "f2",
!     "f3",
!     "f4",
!     "f5",
!     "f6",
!     "f7",
!     "f8",
!     "f9",
!     "f10",
!     "f11",
!     "f12",
!     "f13",
!     "f14",
!     "f15",
!     "num lock",
!     "caps lock",
!     "scroll lock",
!     "right shift",
!     "left shift",
!     "right control",
!     "left control",
!     "right alt",
!     "left alt",
!     "right meta",
!     "left meta",
!     "left super",
!     "right super",
!     "mode",
!     "compose",
!     "help",
!     "print",
!     "sysreq",
!     "break",
!     "menu",
!     "power",
!     "euro"
! };
  
! keyboard_event::keyboard_event (event_type t, key_type k, u_int16 u) : event 
(KEYBOARD_EVENT), Type(t), Key(k), Unikey(u)
! {
! }
  
! const std::string & keyboard_event::key_symbol() const
! {
!     return Key_symbol[key()];
  }
--- 24,271 ----
  #include "keyboard_event.h"
  
! namespace input
  {
!     std::string keyboard_event::Key_symbol[keyboard_event::NBR_KEYS] =
!         {
!             "unknown",
!             "backspace",
!             "tab",
!             "clear",
!             "return",
!             "pause",
!             "escape",
!             "space",
!             "!",
!             "\"",
!             "hash", // FIXME: Find correct symbol
!             "$",
!             "&",
!             "'",
!             "(",
!             ")",
!             "*",
!             "+",
!             ",",
!             "-",
!             ",",
!             "/",
!             "0",
!             "1",
!             "2",
!             "3",
!             "4",
!             "5",
!             "6",
!             "7",
!             "8",
!             "9",
!             ":",
!             ";",
!             "<",
!             "=",
!             ">",
!             "?",
!             "@",
!             "[",
!             "\\",
!             "]",
!             "#", // FIXME
!             "_",
!             "`",
!             "a",
!             "b",
!             "c",
!             "d",
!             "e",
!             "f",
!             "g",
!             "h",
!             "i",
!             "j",
!             "k",
!             "l",
!             "m",
!             "n",
!             "o",
!             "p",
!             "q",
!             "r",
!             "s",
!             "t",
!             "u",
!             "v",
!             "w",
!             "x",
!             "y",
!             "z",
!             "world 0",
!             "world 1",
!             "world 2",
!             "world 3",
!             "world 4",
!             "world 5",
!             "world 6",
!             "world 7",
!             "world 8",
!             "world 9",
!             "world 10",
!             "world 11",
!             "world 12",
!             "world 13",
!             "world 14",
!             "world 15",
!             "world 16",
!             "world 17",
!             "world 18",
!             "world 19",
!             "world 20",
!             "world 21",
!             "world 22",
!             "world 23",
!             "world 24",
!             "world 25",
!             "world 26",
!             "world 27",
!             "world 28",
!             "world 29",
!             "world 30",
!             "world 31",
!             "world 32",
!             "world 33",
!             "world 34",
!             "world 35",
!             "world 36",
!             "world 37",
!             "world 38",
!             "world 39",
!             "world 40",
!             "world 41",
!             "world 42",
!             "world 43",
!             "world 44",
!             "world 45",
!             "world 46",
!             "world 47",
!             "world 48",
!             "world 49",
!             "world 50",
!             "world 51",
!             "world 52",
!             "world 53",
!             "world 54",
!             "world 55",
!             "world 56",
!             "world 57",
!             "world 58",
!             "world 59",
!             "world 60",
!             "world 61",
!             "world 62",
!             "world 63",
!             "world 64",
!             "world 65",
!             "world 66",
!             "world 67",
!             "world 68",
!             "world 69",
!             "world 70",
!             "world 71",
!             "world 72",
!             "world 73",
!             "world 74",
!             "world 75",
!             "world 76",
!             "world 77",
!             "world 78",
!             "world 79",
!             "world 80",
!             "world 81",
!             "world 82",
!             "world 83",
!             "world 84",
!             "world 85",
!             "world 86",
!             "world 87",
!             "world 88",
!             "world 89",
!             "world 90",
!             "world 91",
!             "world 92",
!             "world 93",
!             "world 94",
!             "world 95",
!             "delete",
!             "keypad 0",
!             "keypad 1",
!             "keypad 2",
!             "keypad 3",
!             "keypad 4",
!             "keypad 5",
!             "keypad 6",
!             "keypad 7",
!             "keypad 8",
!             "keypad 9",
!             "keypad .",
!             "keypad /",
!             "keypad *",
!             "keypad -",
!             "keypad +",
!             "keypad enter",
!             "keypad =",
!             "up",
!             "down",
!             "right",
!             "left",
!             "insert",
!             "home",
!             "end",
!             "pageup",
!             "pagedown",
!             "f1",
!             "f2",
!             "f3",
!             "f4",
!             "f5",
!             "f6",
!             "f7",
!             "f8",
!             "f9",
!             "f10",
!             "f11",
!             "f12",
!             "f13",
!             "f14",
!             "f15",
!             "num lock",
!             "caps lock",
!             "scroll lock",
!             "right shift",
!             "left shift",
!             "right control",
!             "left control",
!             "right alt",
!             "left alt",
!             "right meta",
!             "left meta",
!             "left super",
!             "right super",
!             "mode",
!             "compose",
!             "help",
!             "print",
!             "sysreq",
!             "break",
!             "menu",
!             "power",
!             "euro"
!         };
  
!     keyboard_event::keyboard_event (event_type t, key_type k, u_int16 u) : 
event (KEYBOARD_EVENT), Type(t), Key(k), Unikey(u)
!     {
!     }
  
!     const std::string & keyboard_event::key_symbol() const
!     {
!         return Key_symbol[key()];
!     }
  }

Index: keyboard_event.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/input/keyboard_event.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** keyboard_event.h    18 Jul 2003 15:16:09 -0000      1.1.1.1
--- keyboard_event.h    24 Jul 2003 12:57:58 -0000      1.2
***************
*** 343,347 ****
  }
  
  PYTHON_AS_CALLBACK_ARGUMENT(input::keyboard_event)
! 
  #endif
--- 343,348 ----
  }
  
+ #ifndef SWIG
  PYTHON_AS_CALLBACK_ARGUMENT(input::keyboard_event)
! #endif // SWIG
  #endif

Index: listener.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/input/listener.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** listener.cc 18 Jul 2003 15:16:09 -0000      1.1.1.1
--- listener.cc 24 Jul 2003 12:57:58 -0000      1.2
***************
*** 24,119 ****
  #include "listener.h"
  
! using namespace input;
! 
! listener::listener () : Keyboard_callback(NULL), Mouse_callback(NULL), 
Joystick_callback(NULL), Control_callback(NULL)
  {
! }
  
! listener::~listener()
! {
!     disconnect_keyboard_function();
!     disconnect_mouse_function();
!     disconnect_joystick_function();
!     disconnect_control_function();
! }
  
  
! void listener::connect_keyboard_function(base::functor_1ret<keyboard_event *, 
int> * f)
! {
!     disconnect_keyboard_function();
!     Keyboard_callback = f;
! }
  
! void listener::connect_mouse_function(base::functor_1ret<mouse_event *, int> 
* f)
! {
!     disconnect_mouse_function();
!     Mouse_callback = f;
! }
  
! void listener::connect_joystick_function(base::functor_1ret<joystick_event *, 
int> * f)
! {
!     disconnect_joystick_function();
!     Joystick_callback = f;
! }
  
! void listener::connect_control_function(base::functor_1ret<control_event *, 
int> * f)
! {
!     disconnect_control_function();
!     Control_callback = f;
! }
  
  
! void listener::disconnect_keyboard_function()
! {
!     if (Keyboard_callback)
      {
!         delete Keyboard_callback;
!         Keyboard_callback = NULL;
      }
- }
  
! void listener::disconnect_mouse_function()
! {
!     if (Mouse_callback)
      {
!         delete Mouse_callback;
!         Mouse_callback = NULL;
      }
- }
  
! void listener::disconnect_joystick_function()
! {
!     if (Joystick_callback)
      {
!         delete Joystick_callback;
!         Joystick_callback = NULL;
      }
- }
  
! void listener::disconnect_control_function()
! {
!     if (Control_callback)
      {
!         delete Control_callback;
!         Control_callback = NULL;
      }
- }
  
  
! int listener::raise_event (event * ev)
! {
!     switch(ev->type())
      {
!         case event::CONTROL_EVENT:
!             if (Control_callback) return (*Control_callback)((control_event 
*)ev);
!         case event::KEYBOARD_EVENT:
!             if (Keyboard_callback) return 
(*Keyboard_callback)((keyboard_event *)ev);
!         case event::JOYSTICK_EVENT:
!             if (Joystick_callback) return 
(*Joystick_callback)((joystick_event *)ev);
!         case event::MOUSE_EVENT:
!             if (Mouse_callback) return (*Mouse_callback)((mouse_event *)ev);
!         default:
!             break;
      }
-     return 0;
  }
--- 24,120 ----
  #include "listener.h"
  
! namespace input
  {
!     listener::listener () : Keyboard_callback(NULL), Mouse_callback(NULL), 
Joystick_callback(NULL), Control_callback(NULL)
!     {
!     }
  
!     listener::~listener()
!     {
!         disconnect_keyboard_function();
!         disconnect_mouse_function();
!         disconnect_joystick_function();
!         disconnect_control_function();
!     }
  
  
!     void 
listener::connect_keyboard_function(base::functor_1ret<keyboard_event *, int> * 
f)
!     {
!         disconnect_keyboard_function();
!         Keyboard_callback = f;
!     }
  
!     void listener::connect_mouse_function(base::functor_1ret<mouse_event *, 
int> * f)
!     {
!         disconnect_mouse_function();
!         Mouse_callback = f;
!     }
  
!     void 
listener::connect_joystick_function(base::functor_1ret<joystick_event *, int> * 
f)
!     {
!         disconnect_joystick_function();
!         Joystick_callback = f;
!     }
  
!     void listener::connect_control_function(base::functor_1ret<control_event 
*, int> * f)
!     {
!         disconnect_control_function();
!         Control_callback = f;
!     }
  
  
!     void listener::disconnect_keyboard_function()
      {
!         if (Keyboard_callback)
!         {
!             delete Keyboard_callback;
!             Keyboard_callback = NULL;
!         }
      }
  
!     void listener::disconnect_mouse_function()
      {
!         if (Mouse_callback)
!         {
!             delete Mouse_callback;
!             Mouse_callback = NULL;
!         }
      }
  
!     void listener::disconnect_joystick_function()
      {
!         if (Joystick_callback)
!         {
!             delete Joystick_callback;
!             Joystick_callback = NULL;
!         }
      }
  
!     void listener::disconnect_control_function()
      {
!         if (Control_callback)
!         {
!             delete Control_callback;
!             Control_callback = NULL;
!         }
      }
  
  
!     int listener::raise_event (event * ev)
      {
!         switch(ev->type())
!         {
!             case event::CONTROL_EVENT:
!                 if (Control_callback) return 
(*Control_callback)((control_event *)ev);
!             case event::KEYBOARD_EVENT:
!                 if (Keyboard_callback) return 
(*Keyboard_callback)((keyboard_event *)ev);
!             case event::JOYSTICK_EVENT:
!                 if (Joystick_callback) return 
(*Joystick_callback)((joystick_event *)ev);
!             case event::MOUSE_EVENT:
!                 if (Mouse_callback) return (*Mouse_callback)((mouse_event 
*)ev);
!             default:
!                 break;
!         }
!         return 0;
      }
  }

Index: listener.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/input/listener.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** listener.h  18 Jul 2003 15:16:09 -0000      1.1.1.1
--- listener.h  24 Jul 2003 12:57:58 -0000      1.2
***************
*** 135,139 ****
  }
  
  PYTHON_AS_CALLBACK_ARGUMENT(input::listener)
! 
  #endif
--- 135,140 ----
  }
  
+ #ifndef SWIG
  PYTHON_AS_CALLBACK_ARGUMENT(input::listener)
! #endif // SWIG
  #endif

Index: manager.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/input/manager.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** manager.cc  18 Jul 2003 15:16:09 -0000      1.1.1.1
--- manager.cc  24 Jul 2003 12:57:58 -0000      1.2
***************
*** 28,105 ****
  #include <algorithm>
  
! using namespace input;
! 
! std::list <listener *> manager::listeners;
! void (*manager::update_p)() = NULL;
  
  
! void manager::raise_event(event & ev)
! {
!     for (std::list<listener *>::iterator it = listeners.begin(); 
!          it != listeners.end(); it++)
      {
!         bool res = (*it)->raise_event(&ev);
!         if (res) break;
!     }
  
!     // Check if the event is mapped to a virtual controller event
!     switch (ev.type())
!     {
!         case event::KEYBOARD_EVENT:
          {
!             keyboard_event & ke = (keyboard_event &)ev;
!             if (control_event::keyboard_mapping(ke.key()) != 
control_event::NO_BUTTON)
              {
!                 control_event ce(ke.type() == keyboard_event::KEY_PUSHED ?
!                                  control_event::BUTTON_PUSHED : 
!                                  control_event::BUTTON_RELEASED, 
!                                  control_event::keyboard_mapping(ke.key()));
!                 raise_event(ce);
              }
-             break;
-         }
  
!         case event::MOUSE_EVENT:
!         {
!             mouse_event & me = (mouse_event &)ev;
!             if (control_event::mouse_mapping(me.button()) != 
control_event::NO_BUTTON)
              {
!                 control_event ce(me.type() == mouse_event::BUTTON_PUSHED ?
!                                  control_event::BUTTON_PUSHED :
!                                  control_event::BUTTON_RELEASED, 
!                                  control_event::mouse_mapping(me.button()));
!                 raise_event(ce);
              }
-             break;
-         }
  
!         case event::JOYSTICK_EVENT:
!         {
!             joystick_event & je = (joystick_event &)ev;
!             if (control_event::joystick_mapping(je.button()) != 
control_event::NO_BUTTON)
              {
!                 control_event ce(je.type() == joystick_event::BUTTON_PUSHED ? 
!                                  control_event::BUTTON_PUSHED : 
!                                  control_event::BUTTON_RELEASED,
!                                  
control_event::joystick_mapping(je.button()));
!                 raise_event(ce);
              }
-             break;
-         }
          
!         default:
!             break;
      }
- }
  
! bool manager::give_focus(listener * l)
! {
!     std::list<listener *>::iterator it = std::find(listeners.begin(), 
listeners.end(), l);
!     if (it != listeners.end())
      {
!         listeners.erase(it);
!         listeners.push_front(l);
!         return true;
      }
-     return false;
  }
--- 28,106 ----
  #include <algorithm>
  
! namespace input
! {
!     std::list <listener *> manager::listeners;
!     void (*manager::update_p)() = NULL;
  
  
!     void manager::raise_event(event & ev)
      {
!         for (std::list<listener *>::iterator it = listeners.begin(); 
!              it != listeners.end(); it++)
!         {
!             bool res = (*it)->raise_event(&ev);
!             if (res) break;
!         }
  
!         // Check if the event is mapped to a virtual controller event
!         switch (ev.type())
          {
!             case event::KEYBOARD_EVENT:
              {
!                 keyboard_event & ke = (keyboard_event &)ev;
!                 if (control_event::keyboard_mapping(ke.key()) != 
control_event::NO_BUTTON)
!                 {
!                     control_event ce(ke.type() == keyboard_event::KEY_PUSHED ?
!                                      control_event::BUTTON_PUSHED : 
!                                      control_event::BUTTON_RELEASED, 
!                                      
control_event::keyboard_mapping(ke.key()));
!                     raise_event(ce);
!                 }
!                 break;
              }
  
!             case event::MOUSE_EVENT:
              {
!                 mouse_event & me = (mouse_event &)ev;
!                 if (control_event::mouse_mapping(me.button()) != 
control_event::NO_BUTTON)
!                 {
!                     control_event ce(me.type() == mouse_event::BUTTON_PUSHED ?
!                                      control_event::BUTTON_PUSHED :
!                                      control_event::BUTTON_RELEASED, 
!                                      
control_event::mouse_mapping(me.button()));
!                     raise_event(ce);
!                 }
!                 break;
              }
  
!             case event::JOYSTICK_EVENT:
              {
!                 joystick_event & je = (joystick_event &)ev;
!                 if (control_event::joystick_mapping(je.button()) != 
control_event::NO_BUTTON)
!                 {
!                     control_event ce(je.type() == 
joystick_event::BUTTON_PUSHED ? 
!                                      control_event::BUTTON_PUSHED : 
!                                      control_event::BUTTON_RELEASED,
!                                      
control_event::joystick_mapping(je.button()));
!                     raise_event(ce);
!                 }
!                 break;
              }
          
!             default:
!                 break;
!         }
      }
  
!     bool manager::give_focus(listener * l)
      {
!         std::list<listener *>::iterator it = std::find(listeners.begin(), 
listeners.end(), l);
!         if (it != listeners.end())
!         {
!             listeners.erase(it);
!             listeners.push_front(l);
!             return true;
!         }
!         return false;
      }
  }

Index: mouse_event.cc
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/input/mouse_event.cc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** mouse_event.cc      18 Jul 2003 15:16:09 -0000      1.1.1.1
--- mouse_event.cc      24 Jul 2003 12:57:58 -0000      1.2
***************
*** 26,52 ****
  #include "mouse_event.h"
  
! using namespace input;
! 
! std::string mouse_event::Button_symbol[mouse_event::NBR_BUTTONS] =
  {
!     "no button",
!     "left button",
!     "middle button",
!     "right_button",
!     "wheel up",
!     "wheel down"
! };
  
! mouse_event::mouse_event (event_type t, button_type b, u_int16 xpos, u_int16 
ypos)
!     : event (MOUSE_EVENT)
! {
!     Type = t;
!     Button = b;
!     X = xpos;
!     Y = ypos;
! }
  
! const std::string & mouse_event::button_symbol() const
! {
!     return Button_symbol[button()];
  }
--- 26,53 ----
  #include "mouse_event.h"
  
! namespace input
  {
!     std::string mouse_event::Button_symbol[mouse_event::NBR_BUTTONS] =
!         {
!             "no button",
!             "left button",
!             "middle button",
!             "right_button",
!             "wheel up",
!             "wheel down"
!         };
  
!     mouse_event::mouse_event (event_type t, button_type b, u_int16 xpos, 
u_int16 ypos)
!         : event (MOUSE_EVENT)
!     {
!         Type = t;
!         Button = b;
!         X = xpos;
!         Y = ypos;
!     }
  
!     const std::string & mouse_event::button_symbol() const
!     {
!         return Button_symbol[button()];
!     }
  }

Index: mouse_event.h
===================================================================
RCS file: /cvsroot/adonthell/adonthell/src/input/mouse_event.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** mouse_event.h       18 Jul 2003 15:16:09 -0000      1.1.1.1
--- mouse_event.h       24 Jul 2003 12:57:58 -0000      1.2
***************
*** 134,138 ****
  }
  
  PYTHON_AS_CALLBACK_ARGUMENT(input::mouse_event)
! 
  #endif
--- 134,139 ----
  }
  
+ #ifndef SWIG
  PYTHON_AS_CALLBACK_ARGUMENT(input::mouse_event)
! #endif // SWIG
  #endif





reply via email to

[Prev in Thread] Current Thread [Next in Thread]