mirror of
https://github.com/libretro/RetroArch
synced 2025-03-19 16:21:30 +00:00
feat(iOS13): Pointer Movement Accuracy (#14641)
Co-authored-by: Richard <rf2222222@github.com>
This commit is contained in:
parent
61a8b19b2b
commit
c0926ad1a1
@ -450,7 +450,16 @@ static int16_t cocoa_input_state(
|
||||
#endif
|
||||
}
|
||||
#ifdef IOS
|
||||
val = apple->mouse_rel_x;
|
||||
#ifdef HAVE_IOS_TOUCHMOUSE
|
||||
if (apple->window_pos_x > 0) {
|
||||
val = apple->window_pos_x - apple->mouse_x_last;
|
||||
apple->mouse_x_last = apple->window_pos_x;
|
||||
} else {
|
||||
val = apple->mouse_rel_x;
|
||||
}
|
||||
#else
|
||||
val = apple->mouse_rel_x;
|
||||
#endif
|
||||
#else
|
||||
val = apple->window_pos_x - apple->mouse_x_last;
|
||||
apple->mouse_x_last = apple->window_pos_x;
|
||||
@ -466,7 +475,16 @@ static int16_t cocoa_input_state(
|
||||
#endif
|
||||
}
|
||||
#ifdef IOS
|
||||
val = apple->mouse_rel_y;
|
||||
#ifdef HAVE_IOS_TOUCHMOUSE
|
||||
if (apple->window_pos_y > 0) {
|
||||
val = apple->window_pos_y - apple->mouse_y_last;
|
||||
apple->mouse_y_last = apple->window_pos_y;
|
||||
} else {
|
||||
val = apple->mouse_rel_y;
|
||||
}
|
||||
#else
|
||||
val = apple->mouse_rel_y;
|
||||
#endif
|
||||
#else
|
||||
val = apple->window_pos_y - apple->mouse_y_last;
|
||||
apple->mouse_y_last = apple->window_pos_y;
|
||||
|
@ -5723,6 +5723,12 @@ unsigned menu_event(
|
||||
menu_input_pointer_hw_state_t touchscreen_hw_state = {0};
|
||||
|
||||
/* Read mouse */
|
||||
#ifdef HAVE_IOS_TOUCHMOUSE
|
||||
if (menu_mouse_enable) {
|
||||
settings->bools.menu_pointer_enable=true;
|
||||
menu_pointer_enable=true;
|
||||
}
|
||||
#else
|
||||
if (menu_mouse_enable)
|
||||
menu_input_get_mouse_hw_state(
|
||||
p_disp,
|
||||
@ -5736,7 +5742,7 @@ unsigned menu_event(
|
||||
input_overlay_enable,
|
||||
overlay_active,
|
||||
&mouse_hw_state);
|
||||
|
||||
#endif
|
||||
/* Read touchscreen
|
||||
* Note: Could forgo this if mouse is currently active,
|
||||
* but this is 'cleaner' code... (if performance is a
|
||||
|
@ -22,6 +22,7 @@ import UIKit
|
||||
@objc public protocol EmulatorTouchMouseHandlerDelegate: AnyObject {
|
||||
func handleMouseClick(isLeftClick: Bool, isPressed: Bool)
|
||||
func handleMouseMove(x: CGFloat, y: CGFloat)
|
||||
func handlePointerMove(x: CGFloat, y: CGFloat)
|
||||
}
|
||||
|
||||
@objcMembers public class EmulatorTouchMouseHandler: NSObject, UIPointerInteractionDelegate {
|
||||
@ -60,8 +61,6 @@ import UIKit
|
||||
|
||||
private let mediumHaptic = UIImpactFeedbackGenerator(style: .medium)
|
||||
|
||||
private var previousPoint: CGPoint = CGPoint(x: 0, y: 0)
|
||||
|
||||
public init(view: UIView, delegate: EmulatorTouchMouseHandlerDelegate? = nil) {
|
||||
self.view = view
|
||||
self.delegate = delegate
|
||||
@ -212,17 +211,8 @@ import UIKit
|
||||
defaultRegion: UIPointerRegion
|
||||
) -> UIPointerRegion? {
|
||||
guard !enabled else { return defaultRegion }
|
||||
let a = self.previousPoint
|
||||
let b = request.location
|
||||
delegate?.handleMouseMove(x: b.x-a.x, y: b.y-a.y)
|
||||
self.previousPoint=b
|
||||
let location = request.location;
|
||||
delegate?.handlePointerMove(x: location.x, y: location.y)
|
||||
return defaultRegion
|
||||
}
|
||||
|
||||
@available(iOS 13.4, *)
|
||||
public func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? {
|
||||
guard !enabled else { return nil }
|
||||
return UIPointerStyle.hidden()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -371,7 +371,23 @@ void *glkitview_init(void);
|
||||
return;
|
||||
apple->mouse_rel_x = (int16_t)x;
|
||||
apple->mouse_rel_y = (int16_t)y;
|
||||
// use location position to track pointer
|
||||
if (@available(iOS 13.4, *)) {
|
||||
apple->window_pos_x = 0;
|
||||
apple->window_pos_y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)handlePointerMoveWithX:(CGFloat)x y:(CGFloat)y
|
||||
{
|
||||
cocoa_input_data_t *apple = (cocoa_input_data_t*)
|
||||
input_state_get_ptr()->current_data;
|
||||
if (!apple)
|
||||
return;
|
||||
apple->window_pos_x = (int16_t)x;
|
||||
apple->window_pos_y = (int16_t)y;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#pragma mark GCDWebServerDelegate
|
||||
|
@ -298,7 +298,10 @@ enum
|
||||
- (void)sendEvent:(UIEvent *)event
|
||||
{
|
||||
[super sendEvent:event];
|
||||
|
||||
if (@available(iOS 13.4, *)) {
|
||||
if (event.type == UIEventTypeHover)
|
||||
return;
|
||||
}
|
||||
if (event.allTouches.count)
|
||||
handle_touch_event(event.allTouches.allObjects);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user