Added wheel_left and wheel_right

This commit is contained in:
rdb 2008-12-28 18:48:33 +00:00
parent a0ecc0d1c3
commit f5eaaf86a1
5 changed files with 51 additions and 1 deletions

View File

@ -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

View File

@ -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__ */

View File

@ -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);
}

View File

@ -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");
}

View File

@ -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