mirror of
https://github.com/libretro/RetroArch
synced 2025-03-20 01:21:03 +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
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef IOS
|
#ifdef IOS
|
||||||
|
#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;
|
val = apple->mouse_rel_x;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
val = apple->mouse_rel_x;
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
val = apple->window_pos_x - apple->mouse_x_last;
|
val = apple->window_pos_x - apple->mouse_x_last;
|
||||||
apple->mouse_x_last = apple->window_pos_x;
|
apple->mouse_x_last = apple->window_pos_x;
|
||||||
@ -466,7 +475,16 @@ static int16_t cocoa_input_state(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef IOS
|
#ifdef IOS
|
||||||
|
#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;
|
val = apple->mouse_rel_y;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
val = apple->mouse_rel_y;
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
val = apple->window_pos_y - apple->mouse_y_last;
|
val = apple->window_pos_y - apple->mouse_y_last;
|
||||||
apple->mouse_y_last = apple->window_pos_y;
|
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};
|
menu_input_pointer_hw_state_t touchscreen_hw_state = {0};
|
||||||
|
|
||||||
/* Read mouse */
|
/* 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)
|
if (menu_mouse_enable)
|
||||||
menu_input_get_mouse_hw_state(
|
menu_input_get_mouse_hw_state(
|
||||||
p_disp,
|
p_disp,
|
||||||
@ -5736,7 +5742,7 @@ unsigned menu_event(
|
|||||||
input_overlay_enable,
|
input_overlay_enable,
|
||||||
overlay_active,
|
overlay_active,
|
||||||
&mouse_hw_state);
|
&mouse_hw_state);
|
||||||
|
#endif
|
||||||
/* Read touchscreen
|
/* Read touchscreen
|
||||||
* Note: Could forgo this if mouse is currently active,
|
* Note: Could forgo this if mouse is currently active,
|
||||||
* but this is 'cleaner' code... (if performance is a
|
* but this is 'cleaner' code... (if performance is a
|
||||||
|
@ -22,6 +22,7 @@ import UIKit
|
|||||||
@objc public protocol EmulatorTouchMouseHandlerDelegate: AnyObject {
|
@objc public protocol EmulatorTouchMouseHandlerDelegate: AnyObject {
|
||||||
func handleMouseClick(isLeftClick: Bool, isPressed: Bool)
|
func handleMouseClick(isLeftClick: Bool, isPressed: Bool)
|
||||||
func handleMouseMove(x: CGFloat, y: CGFloat)
|
func handleMouseMove(x: CGFloat, y: CGFloat)
|
||||||
|
func handlePointerMove(x: CGFloat, y: CGFloat)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objcMembers public class EmulatorTouchMouseHandler: NSObject, UIPointerInteractionDelegate {
|
@objcMembers public class EmulatorTouchMouseHandler: NSObject, UIPointerInteractionDelegate {
|
||||||
@ -60,8 +61,6 @@ import UIKit
|
|||||||
|
|
||||||
private let mediumHaptic = UIImpactFeedbackGenerator(style: .medium)
|
private let mediumHaptic = UIImpactFeedbackGenerator(style: .medium)
|
||||||
|
|
||||||
private var previousPoint: CGPoint = CGPoint(x: 0, y: 0)
|
|
||||||
|
|
||||||
public init(view: UIView, delegate: EmulatorTouchMouseHandlerDelegate? = nil) {
|
public init(view: UIView, delegate: EmulatorTouchMouseHandlerDelegate? = nil) {
|
||||||
self.view = view
|
self.view = view
|
||||||
self.delegate = delegate
|
self.delegate = delegate
|
||||||
@ -212,17 +211,8 @@ import UIKit
|
|||||||
defaultRegion: UIPointerRegion
|
defaultRegion: UIPointerRegion
|
||||||
) -> UIPointerRegion? {
|
) -> UIPointerRegion? {
|
||||||
guard !enabled else { return defaultRegion }
|
guard !enabled else { return defaultRegion }
|
||||||
let a = self.previousPoint
|
let location = request.location;
|
||||||
let b = request.location
|
delegate?.handlePointerMove(x: location.x, y: location.y)
|
||||||
delegate?.handleMouseMove(x: b.x-a.x, y: b.y-a.y)
|
|
||||||
self.previousPoint=b
|
|
||||||
return defaultRegion
|
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;
|
return;
|
||||||
apple->mouse_rel_x = (int16_t)x;
|
apple->mouse_rel_x = (int16_t)x;
|
||||||
apple->mouse_rel_y = (int16_t)y;
|
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
|
#endif
|
||||||
|
|
||||||
#pragma mark GCDWebServerDelegate
|
#pragma mark GCDWebServerDelegate
|
||||||
|
@ -298,7 +298,10 @@ enum
|
|||||||
- (void)sendEvent:(UIEvent *)event
|
- (void)sendEvent:(UIEvent *)event
|
||||||
{
|
{
|
||||||
[super sendEvent:event];
|
[super sendEvent:event];
|
||||||
|
if (@available(iOS 13.4, *)) {
|
||||||
|
if (event.type == UIEventTypeHover)
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (event.allTouches.count)
|
if (event.allTouches.count)
|
||||||
handle_touch_event(event.allTouches.allObjects);
|
handle_touch_event(event.allTouches.allObjects);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user