wheel_up/down

This commit is contained in:
David Rose 2006-08-31 00:36:23 +00:00
parent 03900c447c
commit 6f71e9eb80
4 changed files with 41 additions and 8 deletions

View File

@ -51,7 +51,18 @@ ConfigVariableBool glx_get_os_address
"directly using standard operating system calls to locate "
"addresses of extension functions. This will be done only "
"if glxGetProcAddress() cannot be used for some reason."));
ConfigVariableInt glx_wheel_up_button
("glx-wheel-up-button", 4,
PRC_DESC("This is the mouse button index of the wheel_up event: which "
"mouse button number does the system report when the mouse wheel "
"is rolled one notch up?"));
ConfigVariableInt glx_wheel_down_button
("glx-wheel-down-button", 5,
PRC_DESC("This is the mouse button index of the wheel_down event: which "
"mouse button number does the system report when the mouse wheel "
"is rolled one notch down?"));
////////////////////////////////////////////////////////////////////
// Function: init_libglxdisplay

View File

@ -23,6 +23,7 @@
#include "notifyCategoryProxy.h"
#include "configVariableString.h"
#include "configVariableBool.h"
#include "configVariableInt.h"
NotifyCategoryDecl(glxdisplay, EXPCL_PANDAGL, EXPTP_PANDAGL);
@ -33,4 +34,7 @@ extern ConfigVariableBool glx_error_abort;
extern ConfigVariableBool glx_get_proc_address;
extern ConfigVariableBool glx_get_os_address;
extern ConfigVariableInt glx_wheel_up_button;
extern ConfigVariableInt glx_wheel_down_button;
#endif /* __CONFIG_GLXDISPLAY_H__ */

View File

@ -301,13 +301,13 @@ process_events() {
case ButtonPress:
// This refers to the mouse buttons.
button = MouseButton::button(event.xbutton.button - 1);
button = get_mouse_button(event.xbutton);
_input_devices[0].set_pointer_in_window(event.xbutton.x, event.xbutton.y);
_input_devices[0].button_down(button);
break;
case ButtonRelease:
button = MouseButton::button(event.xbutton.button - 1);
button = get_mouse_button(event.xbutton);
_input_devices[0].set_pointer_in_window(event.xbutton.x, event.xbutton.y);
_input_devices[0].button_up(button);
break;
@ -903,7 +903,7 @@ handle_keypress(XKeyEvent &event) {
_input_devices[0].set_pointer_in_window(event.x, event.y);
// Now get the raw unshifted button.
ButtonHandle button = get_button(&event);
ButtonHandle button = get_button(event);
if (button != ButtonHandle::none()) {
_input_devices[0].button_down(button);
}
@ -920,7 +920,7 @@ handle_keyrelease(XKeyEvent &event) {
_input_devices[0].set_pointer_in_window(event.x, event.y);
// Now get the raw unshifted button.
ButtonHandle button = get_button(&event);
ButtonHandle button = get_button(event);
if (button != ButtonHandle::none()) {
_input_devices[0].button_up(button);
}
@ -933,8 +933,8 @@ handle_keyrelease(XKeyEvent &event) {
// keyboard button indicated by the given key event.
////////////////////////////////////////////////////////////////////
ButtonHandle glxGraphicsWindow::
get_button(XKeyEvent *key_event) {
KeySym key = XLookupKeysym(key_event, 0);
get_button(XKeyEvent &key_event) {
KeySym key = XLookupKeysym(&key_event, 0);
switch (key) {
case XK_BackSpace:
@ -1210,6 +1210,23 @@ get_button(XKeyEvent *key_event) {
return ButtonHandle::none();
}
////////////////////////////////////////////////////////////////////
// Function: glxGraphicsWindow::get_mouse_button
// Access: Private
// Description: Returns the Panda ButtonHandle corresponding to the
// mouse button indicated by the given button event.
////////////////////////////////////////////////////////////////////
ButtonHandle glxGraphicsWindow::
get_mouse_button(XButtonEvent &button_event) {
int index = button_event.button;
if (index == glx_wheel_up_button) {
return MouseButton::wheel_up();
} else if (index == glx_wheel_down_button) {
return MouseButton::wheel_down();
} else {
return MouseButton::button(index - 1);
}
}
////////////////////////////////////////////////////////////////////
// Function: glxGraphicsWindow::check_event
// Access: Private, Static

View File

@ -64,7 +64,8 @@ private:
void handle_keypress(XKeyEvent &event);
void handle_keyrelease(XKeyEvent &event);
ButtonHandle get_button(XKeyEvent *key_event);
ButtonHandle get_button(XKeyEvent &key_event);
ButtonHandle get_mouse_button(XButtonEvent &button_event);
static Bool check_event(Display *display, XEvent *event, char *arg);