Pārlūkot izejas kodu

Added wheel_left and wheel_right

rdb 17 gadi atpakaļ
vecāks
revīzija
f5eaaf86a1

+ 12 - 0
panda/src/glxdisplay/config_glxdisplay.cxx

@@ -65,6 +65,18 @@ ConfigVariableInt x_wheel_down_button
           "mouse button number does the system report when the mouse wheel "
           "mouse button number does the system report when the mouse wheel "
           "is rolled one notch down?"));
           "is rolled one notch down?"));
 
 
+ConfigVariableInt x_wheel_left_button
+("x-wheel-left-button", 6,
+ PRC_DESC("This is the mouse button index of the wheel_left event: which "
+          "mouse button number does the system report when one scrolls "
+          "to the left?"));
+
+ConfigVariableInt x_wheel_right_button
+("x-wheel-right-button", 7,
+ PRC_DESC("This is the mouse button index of the wheel_right event: which "
+          "mouse button number does the system report when one scrolls "
+          "to the right?"));
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: init_libglxdisplay
 //     Function: init_libglxdisplay
 //  Description: Initializes the library.  This must be called at
 //  Description: Initializes the library.  This must be called at

+ 2 - 0
panda/src/glxdisplay/config_glxdisplay.h

@@ -32,5 +32,7 @@ extern ConfigVariableBool glx_get_os_address;
 
 
 extern ConfigVariableInt x_wheel_up_button;
 extern ConfigVariableInt x_wheel_up_button;
 extern ConfigVariableInt x_wheel_down_button;
 extern ConfigVariableInt x_wheel_down_button;
+extern ConfigVariableInt x_wheel_left_button;
+extern ConfigVariableInt x_wheel_right_button;
 
 
 #endif /* __CONFIG_GLXDISPLAY_H__ */
 #endif /* __CONFIG_GLXDISPLAY_H__ */

+ 4 - 0
panda/src/glxdisplay/glxGraphicsWindow.cxx

@@ -1666,6 +1666,10 @@ get_mouse_button(XButtonEvent &button_event) {
     return MouseButton::wheel_up();
     return MouseButton::wheel_up();
   } else if (index == x_wheel_down_button) {
   } else if (index == x_wheel_down_button) {
     return MouseButton::wheel_down();
     return MouseButton::wheel_down();
+  } else if (index == x_wheel_left_button) {
+    return MouseButton::wheel_left();
+  } else if (index == x_wheel_right_button) {
+    return MouseButton::wheel_right();
   } else {
   } else {
     return MouseButton::button(index - 1);
     return MouseButton::button(index - 1);
   }
   }

+ 29 - 1
panda/src/putil/mouseButton.cxx

@@ -21,6 +21,8 @@
 ButtonHandle MouseButton::_buttons[num_mouse_buttons];
 ButtonHandle MouseButton::_buttons[num_mouse_buttons];
 ButtonHandle MouseButton::_wheel_up;
 ButtonHandle MouseButton::_wheel_up;
 ButtonHandle MouseButton::_wheel_down;
 ButtonHandle MouseButton::_wheel_down;
+ButtonHandle MouseButton::_wheel_left;
+ButtonHandle MouseButton::_wheel_right;
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: MouseButton::button
 //     Function: MouseButton::button
@@ -115,6 +117,30 @@ wheel_down() {
   return _wheel_down;
   return _wheel_down;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: MouseButton::wheel_left
+//       Access: Public, Static
+//  Description: Returns the ButtonHandle generated when the mouse
+//               is scrolled to the left. Usually, you'll only
+//               find the horizontal scroll on laptops.
+////////////////////////////////////////////////////////////////////
+ButtonHandle MouseButton::
+wheel_left() {
+  return _wheel_left;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: MouseButton::wheel_right
+//       Access: Public, Static
+//  Description: Returns the ButtonHandle generated when the mouse
+//               is scrolled to the right. Usually, you'll only
+//               find the horizontal scroll on laptops.
+////////////////////////////////////////////////////////////////////
+ButtonHandle MouseButton::
+wheel_right() {
+  return _wheel_right;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: MouseButton::is_mouse_button
 //     Function: MouseButton::is_mouse_button
 //       Access: Public, Static
 //       Access: Public, Static
@@ -129,7 +155,7 @@ is_mouse_button(ButtonHandle button) {
     }
     }
   }
   }
 
 
-  return button == _wheel_up || button == _wheel_down;
+  return button == _wheel_up || button == _wheel_down || button == _wheel_left || button == _wheel_right;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -151,4 +177,6 @@ init_mouse_buttons() {
 
 
   ButtonRegistry::ptr()->register_button(_wheel_up, "wheel_up");
   ButtonRegistry::ptr()->register_button(_wheel_up, "wheel_up");
   ButtonRegistry::ptr()->register_button(_wheel_down, "wheel_down");
   ButtonRegistry::ptr()->register_button(_wheel_down, "wheel_down");
+  ButtonRegistry::ptr()->register_button(_wheel_left, "wheel_left");
+  ButtonRegistry::ptr()->register_button(_wheel_right, "wheel_right");
 }
 }

+ 4 - 0
panda/src/putil/mouseButton.h

@@ -35,6 +35,8 @@ PUBLISHED:
   static ButtonHandle five();
   static ButtonHandle five();
   static ButtonHandle wheel_up();
   static ButtonHandle wheel_up();
   static ButtonHandle wheel_down();
   static ButtonHandle wheel_down();
+  static ButtonHandle wheel_left();
+  static ButtonHandle wheel_right();
 
 
   static bool is_mouse_button(ButtonHandle button);
   static bool is_mouse_button(ButtonHandle button);
 
 
@@ -45,6 +47,8 @@ public:
   static ButtonHandle _buttons[num_mouse_buttons];
   static ButtonHandle _buttons[num_mouse_buttons];
   static ButtonHandle _wheel_up;
   static ButtonHandle _wheel_up;
   static ButtonHandle _wheel_down;
   static ButtonHandle _wheel_down;
+  static ButtonHandle _wheel_left;
+  static ButtonHandle _wheel_right;
 };
 };
 
 
 #endif
 #endif