Haiku: implement get_mouse_pos() and get_mouse_button_state()

This commit is contained in:
Kostadin Damyanov 2015-06-18 22:41:33 +03:00
parent 2102d35e9c
commit f10eb8ffa1
3 changed files with 17 additions and 11 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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());
}