mirror of https://github.com/encounter/SDL.git
Only lock the pointer for mouse relative mode, there isn't really a concept of grab and confinement on iOS
Locking the pointer prevents the on-screen cursor from moving, which isn't what we want with a grab behavior. Fixes https://github.com/libsdl-org/SDL/issues/4941
This commit is contained in:
parent
66a08aa391
commit
11ae43ca16
|
@ -24,9 +24,10 @@
|
|||
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
#include "SDL_uikitvideo.h"
|
||||
#include "SDL_uikitevents.h"
|
||||
#include "SDL_uikitopengles.h"
|
||||
#include "SDL_uikitvideo.h"
|
||||
#include "SDL_uikitwindow.h"
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
@ -184,20 +185,20 @@ static id mouse_connect_observer = nil;
|
|||
static id mouse_disconnect_observer = nil;
|
||||
static bool mouse_relative_mode = SDL_FALSE;
|
||||
|
||||
static void UpdateMouseGrab()
|
||||
static void UpdatePointerLock()
|
||||
{
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
SDL_Window *window;
|
||||
|
||||
for (window = _this->windows; window != NULL; window = window->next) {
|
||||
SDL_UpdateWindowGrab(window);
|
||||
UIKit_UpdatePointerLock(_this, window);
|
||||
}
|
||||
}
|
||||
|
||||
static int SetGCMouseRelativeMode(SDL_bool enabled)
|
||||
{
|
||||
mouse_relative_mode = enabled;
|
||||
UpdateMouseGrab();
|
||||
UpdatePointerLock();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -245,7 +246,7 @@ static void OnGCMouseConnected(GCMouse *mouse) API_AVAILABLE(macos(11.0), ios(14
|
|||
|
||||
++mice_connected;
|
||||
|
||||
UpdateMouseGrab();
|
||||
UpdatePointerLock();
|
||||
}
|
||||
|
||||
static void OnGCMouseDisconnected(GCMouse *mouse) API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
|
||||
|
@ -262,7 +263,7 @@ static void OnGCMouseDisconnected(GCMouse *mouse) API_AVAILABLE(macos(11.0), ios
|
|||
button.pressedChangedHandler = nil;
|
||||
}
|
||||
|
||||
UpdateMouseGrab();
|
||||
UpdatePointerLock();
|
||||
}
|
||||
|
||||
void SDL_InitGCMouse(void)
|
||||
|
|
|
@ -160,7 +160,7 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
|||
|
||||
#if !TARGET_OS_TV && defined(__IPHONE_13_4)
|
||||
- (UIPointerRegion *)pointerInteraction:(UIPointerInteraction *)interaction regionForRequest:(UIPointerRegionRequest *)request defaultRegion:(UIPointerRegion *)defaultRegion API_AVAILABLE(ios(13.4)){
|
||||
if (request != nil && (!SDL_HasGCMouse() || !SDL_GCMouseRelativeMode())) {
|
||||
if (request != nil && !SDL_GCMouseRelativeMode()) {
|
||||
CGPoint origin = self.bounds.origin;
|
||||
CGPoint point = request.location;
|
||||
|
||||
|
|
|
@ -250,14 +250,7 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
|
|||
|
||||
- (BOOL)prefersPointerLocked
|
||||
{
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
|
||||
if (SDL_HasGCMouse() &&
|
||||
(SDL_GCMouseRelativeMode() || _this->grabbed_window == window)) {
|
||||
return YES;
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
return SDL_GCMouseRelativeMode() ? YES : NO;
|
||||
}
|
||||
|
||||
#endif /* !TARGET_OS_TV */
|
||||
|
|
|
@ -34,6 +34,7 @@ extern void UIKit_RaiseWindow(_THIS, SDL_Window * window);
|
|||
extern void UIKit_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
|
||||
extern void UIKit_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
|
||||
extern void UIKit_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
|
||||
extern void UIKit_UpdatePointerLock(_THIS, SDL_Window * window);
|
||||
extern void UIKit_DestroyWindow(_THIS, SDL_Window * window);
|
||||
extern SDL_bool UIKit_GetWindowWMInfo(_THIS, SDL_Window * window,
|
||||
struct SDL_SysWMinfo * info);
|
||||
|
|
|
@ -322,6 +322,12 @@ UIKit_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
|
|||
|
||||
void
|
||||
UIKit_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
|
||||
{
|
||||
/* There really isn't a concept of window grab or cursor confinement on iOS */
|
||||
}
|
||||
|
||||
void
|
||||
UIKit_UpdatePointerLock(_THIS, SDL_Window * window)
|
||||
{
|
||||
#if !TARGET_OS_TV
|
||||
#if defined(__IPHONE_14_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_14_0
|
||||
|
|
Loading…
Reference in New Issue