diff options
author | Kostadin Damyanov <maxmight@gmail.com> | 2015-06-21 22:18:27 +0300 |
---|---|---|
committer | Kostadin Damyanov <maxmight@gmail.com> | 2015-06-21 22:18:27 +0300 |
commit | 174df9a276b26eb6594e3387f71e3fe8c1706253 (patch) | |
tree | 8760f322f209d8173a541ceaaca28477aef620bb /platform | |
parent | 6f48ddc61db9a06e0751356e712fc87ded9ae3c3 (diff) |
Haiku: add support for mouse wheel
Diffstat (limited to 'platform')
-rw-r--r-- | platform/haiku/haiku_direct_window.cpp | 33 | ||||
-rw-r--r-- | platform/haiku/haiku_direct_window.h | 2 |
2 files changed, 35 insertions, 0 deletions
diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index 3fccab10dd..8c8069af49 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -7,6 +7,7 @@ HaikuDirectWindow::HaikuDirectWindow(BRect p_frame) last_mouse_pos_valid = false; last_buttons_state = 0; last_button_mask = 0; + last_key_modifier_state = 0; } @@ -74,6 +75,10 @@ void HaikuDirectWindow::DispatchMessage(BMessage* message, BHandler* handler) { DispatchMouseMoved(message); break; + case B_MOUSE_WHEEL_CHANGED: + DispatchMouseWheelChanged(message); + break; + default: BDirectWindow::DispatchMessage(message, handler); } @@ -178,7 +183,35 @@ void HaikuDirectWindow::DispatchMouseMoved(BMessage* message) { input->parse_input_event(motion_event); } +void HaikuDirectWindow::DispatchMouseWheelChanged(BMessage* message) { + float wheel_delta_y = 0; + if (message->FindFloat("be:wheel_delta_y", &wheel_delta_y) != B_OK) { + return; + } + + InputEvent mouse_event; + mouse_event.ID = ++event_id; + mouse_event.type = InputEvent::MOUSE_BUTTON; + mouse_event.device = 0; + + mouse_event.mouse_button.button_index = wheel_delta_y < 0 ? 4 : 5; + mouse_event.mouse_button.mod = GetKeyModifierState(last_key_modifier_state); + mouse_event.mouse_button.button_mask = last_button_mask; + mouse_event.mouse_button.x = last_mouse_position.x; + mouse_event.mouse_button.y = last_mouse_position.y; + mouse_event.mouse_button.global_x = last_mouse_position.x; + mouse_event.mouse_button.global_y = last_mouse_position.y; + + mouse_event.mouse_button.pressed = true; + input->parse_input_event(mouse_event); + + mouse_event.ID = ++event_id; + mouse_event.mouse_button.pressed = false; + input->parse_input_event(mouse_event); +} + inline InputModifierState HaikuDirectWindow::GetKeyModifierState(uint32 p_state) { + last_key_modifier_state = p_state; InputModifierState state; state.shift = (p_state & B_SHIFT_KEY) != 0; diff --git a/platform/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h index c985cdc5d6..5355ab4dd4 100644 --- a/platform/haiku/haiku_direct_window.h +++ b/platform/haiku/haiku_direct_window.h @@ -16,6 +16,7 @@ private: Point2i last_mouse_position; bool last_mouse_pos_valid; uint32 last_buttons_state; + uint32 last_key_modifier_state; int last_button_mask; MainLoop* main_loop; @@ -25,6 +26,7 @@ private: void DispatchMouseButton(BMessage* message); void DispatchMouseMoved(BMessage* message); + void DispatchMouseWheelChanged(BMessage* message); inline InputModifierState GetKeyModifierState(uint32 p_state); inline int GetMouseButtonState(uint32 p_state); |