diff --git a/panda/src/glxdisplay/config_glxdisplay.cxx b/panda/src/glxdisplay/config_glxdisplay.cxx index 3235ecad98..328a5b6a44 100644 --- a/panda/src/glxdisplay/config_glxdisplay.cxx +++ b/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 " "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 // Description: Initializes the library. This must be called at diff --git a/panda/src/glxdisplay/config_glxdisplay.h b/panda/src/glxdisplay/config_glxdisplay.h index ddf5e172c4..3912618492 100644 --- a/panda/src/glxdisplay/config_glxdisplay.h +++ b/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_down_button; +extern ConfigVariableInt x_wheel_left_button; +extern ConfigVariableInt x_wheel_right_button; #endif /* __CONFIG_GLXDISPLAY_H__ */ diff --git a/panda/src/glxdisplay/glxGraphicsWindow.cxx b/panda/src/glxdisplay/glxGraphicsWindow.cxx index da3a6210b0..e8ad8a5e6c 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.cxx +++ b/panda/src/glxdisplay/glxGraphicsWindow.cxx @@ -1666,6 +1666,10 @@ get_mouse_button(XButtonEvent &button_event) { return MouseButton::wheel_up(); } else if (index == x_wheel_down_button) { 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 { return MouseButton::button(index - 1); } diff --git a/panda/src/putil/mouseButton.cxx b/panda/src/putil/mouseButton.cxx index 4910bf554b..a0cbbc5485 100644 --- a/panda/src/putil/mouseButton.cxx +++ b/panda/src/putil/mouseButton.cxx @@ -21,6 +21,8 @@ ButtonHandle MouseButton::_buttons[num_mouse_buttons]; ButtonHandle MouseButton::_wheel_up; ButtonHandle MouseButton::_wheel_down; +ButtonHandle MouseButton::_wheel_left; +ButtonHandle MouseButton::_wheel_right; //////////////////////////////////////////////////////////////////// // Function: MouseButton::button @@ -115,6 +117,30 @@ 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 // 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_down, "wheel_down"); + ButtonRegistry::ptr()->register_button(_wheel_left, "wheel_left"); + ButtonRegistry::ptr()->register_button(_wheel_right, "wheel_right"); } diff --git a/panda/src/putil/mouseButton.h b/panda/src/putil/mouseButton.h index e1663eba0e..0199b822f4 100644 --- a/panda/src/putil/mouseButton.h +++ b/panda/src/putil/mouseButton.h @@ -35,6 +35,8 @@ PUBLISHED: static ButtonHandle five(); static ButtonHandle wheel_up(); static ButtonHandle wheel_down(); + static ButtonHandle wheel_left(); + static ButtonHandle wheel_right(); static bool is_mouse_button(ButtonHandle button); @@ -45,6 +47,8 @@ public: static ButtonHandle _buttons[num_mouse_buttons]; static ButtonHandle _wheel_up; static ButtonHandle _wheel_down; + static ButtonHandle _wheel_left; + static ButtonHandle _wheel_right; }; #endif