Haiku: add support for mouse wheel
This commit is contained in:
parent
6f48ddc61d
commit
174df9a276
2 changed files with 35 additions and 0 deletions
|
@ -7,6 +7,7 @@ HaikuDirectWindow::HaikuDirectWindow(BRect p_frame)
|
||||||
last_mouse_pos_valid = false;
|
last_mouse_pos_valid = false;
|
||||||
last_buttons_state = 0;
|
last_buttons_state = 0;
|
||||||
last_button_mask = 0;
|
last_button_mask = 0;
|
||||||
|
last_key_modifier_state = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,6 +75,10 @@ void HaikuDirectWindow::DispatchMessage(BMessage* message, BHandler* handler) {
|
||||||
DispatchMouseMoved(message);
|
DispatchMouseMoved(message);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case B_MOUSE_WHEEL_CHANGED:
|
||||||
|
DispatchMouseWheelChanged(message);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BDirectWindow::DispatchMessage(message, handler);
|
BDirectWindow::DispatchMessage(message, handler);
|
||||||
}
|
}
|
||||||
|
@ -178,7 +183,35 @@ void HaikuDirectWindow::DispatchMouseMoved(BMessage* message) {
|
||||||
input->parse_input_event(motion_event);
|
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) {
|
inline InputModifierState HaikuDirectWindow::GetKeyModifierState(uint32 p_state) {
|
||||||
|
last_key_modifier_state = p_state;
|
||||||
InputModifierState state;
|
InputModifierState state;
|
||||||
|
|
||||||
state.shift = (p_state & B_SHIFT_KEY) != 0;
|
state.shift = (p_state & B_SHIFT_KEY) != 0;
|
||||||
|
|
|
@ -16,6 +16,7 @@ private:
|
||||||
Point2i last_mouse_position;
|
Point2i last_mouse_position;
|
||||||
bool last_mouse_pos_valid;
|
bool last_mouse_pos_valid;
|
||||||
uint32 last_buttons_state;
|
uint32 last_buttons_state;
|
||||||
|
uint32 last_key_modifier_state;
|
||||||
int last_button_mask;
|
int last_button_mask;
|
||||||
|
|
||||||
MainLoop* main_loop;
|
MainLoop* main_loop;
|
||||||
|
@ -25,6 +26,7 @@ private:
|
||||||
|
|
||||||
void DispatchMouseButton(BMessage* message);
|
void DispatchMouseButton(BMessage* message);
|
||||||
void DispatchMouseMoved(BMessage* message);
|
void DispatchMouseMoved(BMessage* message);
|
||||||
|
void DispatchMouseWheelChanged(BMessage* message);
|
||||||
inline InputModifierState GetKeyModifierState(uint32 p_state);
|
inline InputModifierState GetKeyModifierState(uint32 p_state);
|
||||||
inline int GetMouseButtonState(uint32 p_state);
|
inline int GetMouseButtonState(uint32 p_state);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue