From f10eb8ffa1a7f6bee9b5228ea1204fd93844e4cc Mon Sep 17 00:00:00 2001 From: Kostadin Damyanov Date: Thu, 18 Jun 2015 22:41:33 +0300 Subject: [PATCH] Haiku: implement get_mouse_pos() and get_mouse_button_state() --- platform/haiku/haiku_direct_window.cpp | 13 ++++++++----- platform/haiku/haiku_direct_window.h | 8 ++++++-- platform/haiku/os_haiku.cpp | 7 +++---- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index 6ff43690872..62231565a91 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -6,6 +6,7 @@ HaikuDirectWindow::HaikuDirectWindow(BRect p_frame) { last_mouse_pos_valid = false; last_buttons_state = 0; + last_button_mask = 0; } @@ -154,11 +155,11 @@ void HaikuDirectWindow::DispatchMouseMoved(BMessage* message) { uint32 buttons = message->FindInt32("buttons"); if (!last_mouse_pos_valid) { - last_mouse_pos = pos; + last_mouse_position = pos; last_mouse_pos_valid = true; } - Point2i rel = pos - last_mouse_pos; + Point2i rel = pos - last_mouse_position; InputEvent motion_event; motion_event.ID = ++event_id; @@ -178,7 +179,7 @@ void HaikuDirectWindow::DispatchMouseMoved(BMessage* message) { motion_event.mouse_motion.relative_x = rel.x; motion_event.mouse_motion.relative_y = rel.y; - last_mouse_pos=pos; + last_mouse_position = pos; input->parse_input_event(motion_event); } @@ -194,8 +195,8 @@ inline InputModifierState HaikuDirectWindow::GetKeyModifierState(uint32 p_state) return state; } -inline unsigned int HaikuDirectWindow::GetMouseButtonState(uint32 p_state) { - unsigned int state = 0; +inline int HaikuDirectWindow::GetMouseButtonState(uint32 p_state) { + int state = 0; if (p_state & B_PRIMARY_MOUSE_BUTTON) { state |= 1 << 0; @@ -209,5 +210,7 @@ inline unsigned int HaikuDirectWindow::GetMouseButtonState(uint32 p_state) { state |= 1 << 2; } + last_button_mask = state; + return state; } diff --git a/platform/haiku/haiku_direct_window.h b/platform/haiku/haiku_direct_window.h index bb0ef43da0f..be4dcd9e94e 100644 --- a/platform/haiku/haiku_direct_window.h +++ b/platform/haiku/haiku_direct_window.h @@ -13,9 +13,10 @@ class HaikuDirectWindow : public BDirectWindow { private: unsigned int event_id; - Point2i last_mouse_pos; + Point2i last_mouse_position; bool last_mouse_pos_valid; uint32 last_buttons_state; + int last_button_mask; InputDefault* input; HaikuGLView* view; @@ -24,7 +25,7 @@ private: void DispatchMouseButton(BMessage* message); void DispatchMouseMoved(BMessage* message); inline InputModifierState GetKeyModifierState(uint32 p_state); - inline unsigned int GetMouseButtonState(uint32 p_state); + inline int GetMouseButtonState(uint32 p_state); public: HaikuDirectWindow(BRect p_frame); @@ -38,6 +39,9 @@ public: virtual void DirectConnected(direct_buffer_info* info); virtual void MessageReceived(BMessage* message); virtual void DispatchMessage(BMessage* message, BHandler* handler); + + inline Point2i GetLastMousePosition() { return last_mouse_position; }; + inline int GetLastButtonMask() { return last_button_mask; }; }; #endif diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index 193927238df..3694244e0a7 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -174,19 +174,18 @@ void OS_Haiku::swap_buffers() { } Point2 OS_Haiku::get_mouse_pos() const { - ERR_PRINT("get_mouse_pos() NOT IMPLEMENTED"); + return window->GetLastMousePosition(); } int OS_Haiku::get_mouse_button_state() const { - ERR_PRINT("get_mouse_button_state() NOT IMPLEMENTED"); + return window->GetLastButtonMask(); } void OS_Haiku::set_cursor_shape(CursorShape p_shape) { - ERR_PRINT("set_cursor_shape() NOT IMPLEMENTED"); + //ERR_PRINT("set_cursor_shape() NOT IMPLEMENTED"); } void OS_Haiku::set_window_title(const String& p_title) { - //ERR_PRINT("set_window_title() NOT IMPLEMENTED"); window->SetTitle(p_title.utf8().get_data()); }