diff --git a/panda/src/pgui/pgEntry.cxx b/panda/src/pgui/pgEntry.cxx index e828edc8f7..e948d63785 100644 --- a/panda/src/pgui/pgEntry.cxx +++ b/panda/src/pgui/pgEntry.cxx @@ -181,7 +181,9 @@ press(const MouseWatcherParameter ¶m, bool background) { if (button == MouseButton::one() || button == MouseButton::two() || - button == MouseButton::three()) { + button == MouseButton::three() || + button == MouseButton::four() || + button == MouseButton::five()) { // Mouse button; set focus. set_focus(true); diff --git a/panda/src/putil/mouseButton.cxx b/panda/src/putil/mouseButton.cxx index ac139c675f..24665ba07f 100644 --- a/panda/src/putil/mouseButton.cxx +++ b/panda/src/putil/mouseButton.cxx @@ -75,6 +75,28 @@ three() { return _buttons[2]; } +//////////////////////////////////////////////////////////////////// +// Function: MouseButton::four +// Access: Public, Static +// Description: Returns the ButtonHandle associated with the +// fourth mouse button. +//////////////////////////////////////////////////////////////////// +ButtonHandle MouseButton:: +four() { + return _buttons[3]; +} + +//////////////////////////////////////////////////////////////////// +// Function: MouseButton::five +// Access: Public, Static +// Description: Returns the ButtonHandle associated with the +// fifth mouse button. +//////////////////////////////////////////////////////////////////// +ButtonHandle MouseButton:: +five() { + return _buttons[4]; +} + //////////////////////////////////////////////////////////////////// // Function: MouseButton::wheel_up // Access: Public, Static @@ -105,7 +127,7 @@ wheel_down() { //////////////////////////////////////////////////////////////////// bool MouseButton:: is_mouse_button(ButtonHandle button) { - for (int i = 0; i < num_mouse_buttons; i++) { + for (int i = 0; i < num_mouse_buttons; ++i) { if (button == _buttons[i]) { return true; } @@ -124,7 +146,7 @@ void MouseButton:: init_mouse_buttons() { char numstr[20]; - for (int i = 0; i < num_mouse_buttons; i++) { + for (int i = 0; i < num_mouse_buttons; ++i) { sprintf(numstr, "mouse%d", i + 1); nassertv(strlen(numstr) < 20); diff --git a/panda/src/putil/mouseButton.h b/panda/src/putil/mouseButton.h index e633eea402..9579b2dde0 100644 --- a/panda/src/putil/mouseButton.h +++ b/panda/src/putil/mouseButton.h @@ -35,6 +35,8 @@ PUBLISHED: static ButtonHandle one(); static ButtonHandle two(); static ButtonHandle three(); + static ButtonHandle four(); + static ButtonHandle five(); static ButtonHandle wheel_up(); static ButtonHandle wheel_down(); @@ -43,7 +45,7 @@ PUBLISHED: public: static void init_mouse_buttons(); - enum { num_mouse_buttons = 3 }; + enum { num_mouse_buttons = 5 }; static ButtonHandle _buttons[num_mouse_buttons]; static ButtonHandle _wheel_up; static ButtonHandle _wheel_down; diff --git a/panda/src/tform/trackball.cxx b/panda/src/tform/trackball.cxx index 7a774ab45c..74ae52756e 100644 --- a/panda/src/tform/trackball.cxx +++ b/panda/src/tform/trackball.cxx @@ -27,9 +27,11 @@ TypeHandle Trackball::_type_handle; // These are used internally. -#define B1_MASK 0x1 -#define B2_MASK 0x2 -#define B3_MASK 0x4 +#define B1_MASK 0x01 +#define B2_MASK 0x02 +#define B3_MASK 0x04 +#define B4_MASK 0x08 +#define B5_MASK 0x10 //////////////////////////////////////////////////////////////////// // Function: Trackball::Constructor @@ -62,6 +64,8 @@ Trackball(const string &name) : watch_button(MouseButton::one()); watch_button(MouseButton::two()); watch_button(MouseButton::three()); + watch_button(MouseButton::four()); + watch_button(MouseButton::five()); } //////////////////////////////////////////////////////////////////// @@ -554,6 +558,12 @@ do_transmit_data(const DataNodeTransmit &input, DataNodeTransmit &output) { if (is_down(MouseButton::three())) { this_button |= B3_MASK; } + if (is_down(MouseButton::four())) { + this_button |= B4_MASK; + } + if (is_down(MouseButton::five())) { + this_button |= B5_MASK; + } float x = this_x - _lastx; float y = this_y - _lasty; diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index b639ac6b93..628a040c20 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -1110,6 +1110,22 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { _input_devices[0].set_pointer_in_window(translate_mouse(LOWORD(lparam)), translate_mouse(HIWORD(lparam))); _input_devices[0].button_down(MouseButton::button(2), get_message_time()); break; + + case WM_XBUTTONDOWN: + { + if (_lost_keypresses) { + resend_lost_keypresses(); + } + SetCapture(hwnd); + int whichButton = GET_XBUTTON_WPARAM(wparam); + _input_devices[0].set_pointer_in_window(translate_mouse(LOWORD(lparam)), translate_mouse(HIWORD(lparam))); + if (whichButton == XBUTTON1) { + _input_devices[0].button_down(MouseButton::button(3), get_message_time()); + } else if (whichButton == XBUTTON2) { + _input_devices[0].button_down(MouseButton::button(4), get_message_time()); + } + } + break; case WM_LBUTTONUP: if (_lost_keypresses) { @@ -1135,6 +1151,21 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { _input_devices[0].button_up(MouseButton::button(2), get_message_time()); break; + case WM_XBUTTONUP: + { + if (_lost_keypresses) { + resend_lost_keypresses(); + } + ReleaseCapture(); + int whichButton = GET_XBUTTON_WPARAM(wparam); + if (whichButton == XBUTTON1) { + _input_devices[0].button_up(MouseButton::button(3), get_message_time()); + } else if (whichButton == XBUTTON2) { + _input_devices[0].button_up(MouseButton::button(4), get_message_time()); + } + } + break; + case WM_MOUSEWHEEL: { int delta = GET_WHEEL_DELTA_WPARAM(wparam); @@ -2092,7 +2123,7 @@ handle_raw_input(HRAWINPUT hraw) { return; } - for (int i = 1; i < (int)(_input_devices.size()); i++) { + for (int i = 1; i < (int)(_input_devices.size()); ++i) { if (_input_device_handle[i] == raw->header.hDevice) { int adjx = raw->data.mouse.lLastX; int adjy = raw->data.mouse.lLastY; @@ -2123,6 +2154,18 @@ handle_raw_input(HRAWINPUT hraw) { if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_3_UP) { _input_devices[i].button_up(MouseButton::button(1), get_message_time()); } + if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_4_DOWN) { + _input_devices[i].button_down(MouseButton::button(3), get_message_time()); + } + if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_4_UP) { + _input_devices[i].button_up(MouseButton::button(3), get_message_time()); + } + if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_5_DOWN) { + _input_devices[i].button_down(MouseButton::button(4), get_message_time()); + } + if (raw->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_5_UP) { + _input_devices[i].button_up(MouseButton::button(4), get_message_time()); + } } } }