summaryrefslogtreecommitdiff
path: root/platform/haiku
diff options
context:
space:
mode:
authorKostadin Damyanov <maxmight@gmail.com>2015-06-18 22:41:33 +0300
committerKostadin Damyanov <maxmight@gmail.com>2015-06-18 22:41:33 +0300
commitf10eb8ffa1a7f6bee9b5228ea1204fd93844e4cc (patch)
tree954e99f563c8af191ff17849d1bcd0cbf4ab5dfe /platform/haiku
parent2102d35e9c18a0cede87e7e45d375153702b3ea5 (diff)
Haiku: implement get_mouse_pos() and get_mouse_button_state()
Diffstat (limited to 'platform/haiku')
-rw-r--r--platform/haiku/haiku_direct_window.cpp13
-rw-r--r--platform/haiku/haiku_direct_window.h8
-rw-r--r--platform/haiku/os_haiku.cpp7
3 files changed, 17 insertions, 11 deletions
diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp
index 6ff4369087..62231565a9 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 bb0ef43da0..be4dcd9e94 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 193927238d..3694244e0a 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());
}