diff --git a/src/posix/cocoa/i_common.h b/src/posix/cocoa/i_common.h index 09281713f..453f2898f 100644 --- a/src/posix/cocoa/i_common.h +++ b/src/posix/cocoa/i_common.h @@ -45,12 +45,7 @@ inline bool I_IsHiDPISupported() return NSAppKitVersionNumber >= 1138; } -void I_ProcessKeyboardEvent(NSEvent* event); -void I_ProcessKeyboardFlagsEvent(NSEvent* event); - -void I_ProcessMouseMoveEvent(NSEvent* event); -void I_ProcessMouseButtonEvent(NSEvent* event); -void I_ProcessMouseWheelEvent(NSEvent* event); +void I_ProcessEvent(NSEvent* event); void I_StartupJoysticks(); void I_ShutdownJoysticks(); diff --git a/src/posix/cocoa/i_input.mm b/src/posix/cocoa/i_input.mm index ad2a3d1bd..46f5e4450 100644 --- a/src/posix/cocoa/i_input.mm +++ b/src/posix/cocoa/i_input.mm @@ -535,10 +535,8 @@ void ProcessMouseMoveInGame(NSEvent* theEvent) } } -} // unnamed namespace - -void I_ProcessKeyboardEvent(NSEvent* theEvent) +void ProcessKeyboardEvent(NSEvent* theEvent) { const unsigned short keyCode = [theEvent keyCode]; if (keyCode >= KEY_COUNT) @@ -567,7 +565,7 @@ void I_ProcessKeyboardEvent(NSEvent* theEvent) } } -void I_ProcessKeyboardFlagsEvent(NSEvent* theEvent) +void ProcessKeyboardFlagsEvent(NSEvent* theEvent) { static const uint32_t FLAGS_MASK = NSDeviceIndependentModifierFlagsMask & ~NSNumericPadKeyMask; @@ -606,7 +604,7 @@ void I_ProcessKeyboardFlagsEvent(NSEvent* theEvent) } -void I_ProcessMouseMoveEvent(NSEvent* theEvent) +void ProcessMouseMoveEvent(NSEvent* theEvent) { if (GUICapture) { @@ -618,7 +616,7 @@ void I_ProcessMouseMoveEvent(NSEvent* theEvent) } } -void I_ProcessMouseButtonEvent(NSEvent* theEvent) +void ProcessMouseButtonEvent(NSEvent* theEvent) { event_t event = {}; @@ -669,7 +667,7 @@ void I_ProcessMouseButtonEvent(NSEvent* theEvent) } } -void I_ProcessMouseWheelEvent(NSEvent* theEvent) +void ProcessMouseWheelEvent(NSEvent* theEvent) { const CGFloat delta = [theEvent deltaY]; const bool isZeroDelta = fabs(delta) < 1.0E-5; @@ -696,3 +694,50 @@ void I_ProcessMouseWheelEvent(NSEvent* theEvent) D_PostEvent(&event); } + +} // unnamed namespace + + +void I_ProcessEvent(NSEvent* event) +{ + const NSEventType eventType = [event type]; + + switch (eventType) + { + case NSMouseMoved: + ProcessMouseMoveEvent(event); + break; + + case NSLeftMouseDown: + case NSLeftMouseUp: + case NSRightMouseDown: + case NSRightMouseUp: + case NSOtherMouseDown: + case NSOtherMouseUp: + ProcessMouseButtonEvent(event); + break; + + case NSLeftMouseDragged: + case NSRightMouseDragged: + case NSOtherMouseDragged: + ProcessMouseButtonEvent(event); + ProcessMouseMoveEvent(event); + break; + + case NSScrollWheel: + ProcessMouseWheelEvent(event); + break; + + case NSKeyDown: + case NSKeyUp: + ProcessKeyboardEvent(event); + break; + + case NSFlagsChanged: + ProcessKeyboardFlagsEvent(event); + break; + + default: + break; + } +} diff --git a/src/posix/cocoa/i_main.mm b/src/posix/cocoa/i_main.mm index dcb3b3ed5..323efa8b7 100644 --- a/src/posix/cocoa/i_main.mm +++ b/src/posix/cocoa/i_main.mm @@ -376,48 +376,9 @@ ApplicationController* appCtrl; { break; } - - const NSEventType eventType = [event type]; - - switch (eventType) - { - case NSMouseMoved: - I_ProcessMouseMoveEvent(event); - break; - - case NSLeftMouseDown: - case NSLeftMouseUp: - case NSRightMouseDown: - case NSRightMouseUp: - case NSOtherMouseDown: - case NSOtherMouseUp: - I_ProcessMouseButtonEvent(event); - break; - - case NSLeftMouseDragged: - case NSRightMouseDragged: - case NSOtherMouseDragged: - I_ProcessMouseButtonEvent(event); - I_ProcessMouseMoveEvent(event); - break; - - case NSScrollWheel: - I_ProcessMouseWheelEvent(event); - break; - - case NSKeyDown: - case NSKeyUp: - I_ProcessKeyboardEvent(event); - break; - - case NSFlagsChanged: - I_ProcessKeyboardFlagsEvent(event); - break; - - default: - break; - } - + + I_ProcessEvent(event); + [NSApp sendEvent:event]; }