diff options
Diffstat (limited to 'platform/osx')
-rw-r--r-- | platform/osx/os_osx.mm | 62 |
1 files changed, 25 insertions, 37 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index c6c2e6dab1..7a914a88fb 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -788,6 +788,22 @@ static int translateKey(unsigned int key) { */ } +inline void sendScrollEvent(int button, double factor) { + InputEvent ev; + ev.type = InputEvent::MOUSE_BUTTON; + ev.mouse_button.button_index = button; + ev.mouse_button.factor = factor; + ev.mouse_button.pressed = true; + ev.mouse_button.x = mouse_x; + ev.mouse_button.y = mouse_y; + ev.mouse_button.global_x = mouse_x; + ev.mouse_button.global_y = mouse_y; + ev.mouse_button.button_mask = button_mask; + OS_OSX::singleton->push_input(ev); + ev.mouse_button.pressed = false; + OS_OSX::singleton->push_input(ev); +} + - (void)scrollWheel:(NSEvent *)event { double deltaX, deltaY; @@ -797,48 +813,21 @@ static int translateKey(unsigned int key) { deltaY = [event scrollingDeltaY]; if ([event hasPreciseScrollingDeltas]) { - deltaX *= 0.1; - deltaY *= 0.1; + deltaX *= 0.03; + deltaY *= 0.03; } - } else { + } else +#endif // MAC_OS_X_VERSION_MAX_ALLOWED + { deltaX = [event deltaX]; deltaY = [event deltaY]; } -#else - deltaX = [event deltaX]; - deltaY = [event deltaY]; -#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/ - - if (fabs(deltaY)) { - - InputEvent ev; - ev.type = InputEvent::MOUSE_BUTTON; - ev.mouse_button.button_index = deltaY > 0 ? BUTTON_WHEEL_UP : BUTTON_WHEEL_DOWN; - ev.mouse_button.pressed = true; - ev.mouse_button.x = mouse_x; - ev.mouse_button.y = mouse_y; - ev.mouse_button.global_x = mouse_x; - ev.mouse_button.global_y = mouse_y; - ev.mouse_button.button_mask = button_mask; - OS_OSX::singleton->push_input(ev); - ev.mouse_button.pressed = false; - OS_OSX::singleton->push_input(ev); - } if (fabs(deltaX)) { - - InputEvent ev; - ev.type = InputEvent::MOUSE_BUTTON; - ev.mouse_button.button_index = deltaX < 0 ? BUTTON_WHEEL_RIGHT : BUTTON_WHEEL_LEFT; - ev.mouse_button.pressed = true; - ev.mouse_button.x = mouse_x; - ev.mouse_button.y = mouse_y; - ev.mouse_button.global_x = mouse_x; - ev.mouse_button.global_y = mouse_y; - ev.mouse_button.button_mask = button_mask; - OS_OSX::singleton->push_input(ev); - ev.mouse_button.pressed = false; - OS_OSX::singleton->push_input(ev); + sendScrollEvent(0 > deltaX ? BUTTON_WHEEL_RIGHT : BUTTON_WHEEL_LEFT, fabs(deltaX * 0.3)); + } + if (fabs(deltaY)) { + sendScrollEvent(0 < deltaY ? BUTTON_WHEEL_UP : BUTTON_WHEEL_DOWN, fabs(deltaY * 0.3)); } } @@ -1630,7 +1619,6 @@ void OS_OSX::process_events() { void OS_OSX::push_input(const InputEvent &p_event) { InputEvent ev = p_event; - //print_line("EV: "+String(ev)); input->parse_input_event(ev); } |