Commit Graph

127 Commits

Author SHA1 Message Date
Sam Lantinga
14661d3f30 Added support for mousewheel on iOS 2020-04-14 17:31:31 -07:00
Sam Lantinga
3e4856c97f Fixed mouse button mapping on iOS 2020-04-13 23:07:54 -07:00
Sam Lantinga
e1215e857f Fixed mouse button mapping on iOS 2020-04-13 22:50:46 -07:00
Sam Lantinga
dbf7f84fd9 Implemented left/right mouse click detection on iOS 2020-04-13 22:29:10 -07:00
Sam Lantinga
171ba00a6a Hide the mouse cursor appropriately on iOS 2020-04-13 19:44:26 -07:00
Sam Lantinga
6f3fa02e27 Make sure we're using the bounds of the view for our mouse region 2020-04-13 18:25:38 -07:00
Sam Lantinga
cab1ee9cbc Don't build iOS mouse support on Apple TV 2020-04-13 15:57:04 -07:00
Sam Lantinga
e5d3629931 Added support for new mouse APIs in iOS 13.4 2020-04-13 15:46:12 -07:00
Ryan C. Gordon
a791689086 metal: Added some support interfaces to Apple's Metal API (thanks, Caleb!).
Caleb Cornett's comments:

"A few weeks ago, Alex added a partial Metal API to SDL2:

https://hg.libsdl.org/SDL/rev/22c8e7cd8d38

I noticed it was missing a few features that would help Metal become a
first-class citizen in SDL, so I went ahead and wrote them! Here are the new
APIs:

1. SDL_WINDOW_METAL flag for SDL_CreateWindow(). This allows the programmer
to specify that they intend to create a window for use with SDL_MetalView.
The flag is used to ensure correct usage of the API and to prevent
accidentally defaulting to OpenGL on iOS.

2. SDL_Metal_GetLayer(). This function takes a SDL_MetalView and returns a
pointer to the view's backing CAMetalLayer. This simplifies things
considerably, since in the current version of the SDL_Metal API the
programmer is required to bridge-cast a SDL_MetalView handle to an NSView or
UIView (depending on the platform) and then extract the layer from there.
SDL_Metal_GetLayer automatically handles all of that, making the operation
simple and cross-platform.

3. SDL_Metal_GetDrawableSize(). This function already exists in the current
SDL_Metal API (and is used behind-the-scenes for SDL_Vulkan_GetDrawableSize
on Apple platforms) but was not publicly exposed. My patch exposes this
function for public use. It works just like you'd expect.

Tested on macOS 10.14 and iOS 12.4."

Fixes Bugzilla #4796.
2020-04-10 00:37:35 -04:00
Sam Lantinga
d4f1b520c9 Added support for press/release hardware keyboard events in iOS 13.4 2020-04-08 19:16:31 -07:00
David Ludwig
6e7465bd60 Fixed Bug 4883, redux - connect SDL_GetDisplayDPI to UIKit_GetDisplayDPI
SDL_GetDisplayDPI was failing on iOS, as UIKit_GetDisplayDPI was
not getting assigned to SDL's internal field in SDL_VideoDevice:
GetDisplayDPI.
2020-03-28 15:43:55 -04:00
Sam Lantinga
55a2a12ddf Fixed compile warning 2020-03-16 22:34:33 -07:00
Sam Lantinga
62a3d6c004 Fixed build 2020-01-30 14:58:41 -08:00
Sam Lantinga
37278066f2 Export SDL functions for iOS application delegates 2020-01-30 14:51:33 -08:00
Sam Lantinga
c9c89783cb Miscellaneous pending fixes 2020-01-29 20:09:08 -08:00
Sam Lantinga
a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Sam Lantinga
bc430d405c Update for bug 4883 - Add approximation for display DPI on iOS
Aaron Barany

I realized I made a minor mistake in my patch: I changed the constructor prototype for SDL_DisplayData, but didn't update the declaration in the .h file. The compiler and linker don't complain, but it would probably be best to fix in case a later change runs into a problem from the mismatch. I have attached a patch to fix this.
2019-12-16 10:26:36 -08:00
Sam Lantinga
140918bb6f Fixed bug 4883 - Add approximation for display DPI on iOS
Aaron Barany

There appears to be no way to directly access the display DPI on iOS, so as an approximation the DPI for the iPhone 1 is used as a base value and is multiplied by the screen's scale. This should at least give a ballpark number for the various screen scales. (based on https://stackoverflow.com/questions/25756087/detecting-iphone-6-6-screen-sizes-in-point-values it appears that both 2x and 3x are used)

I have updated the patch to use a table of current devices and use a computation as a fallback. I have also updated the fallback computation to be more accurate.
2019-12-08 11:36:40 -08:00
Sam Lantinga
b7576025e3 Fixed bug 4882 - Fix build for iOS when disabling OpenGL
Aaron Barany

Since OpenGL is deprecated on iOS, it is advantageous to be able to remove all OpenGL related code when building SDL for iOS. This patch adds the necessary #if checks to compile in this case.
2019-12-03 22:07:58 -08:00
Alex Szpakowski
bda618a2af iOS: remove some unused code, minor code style cleanup. 2019-10-27 11:41:48 -03:00
Alex Szpakowski
df49e2a572 iOS: replace a deprecated function call with a non-deprecated equivalent. 2019-10-27 11:41:11 -03:00
Sam Lantinga
bf9092cf4a Removed unused variable 2019-10-17 17:47:11 -07:00
Alex Szpakowski
79cd6cfc94 iOS: Fix issues with Split VIew on iPad (bugs #4586, #4705). 2019-08-15 19:38:12 -03:00
Sam Lantinga
2a1adf71ab Fixed bug 4747 - [Patch] SDL_ShowMessageBox ignores BUTTON_RETURNKEY_DEFAULT flag
Caleb Cornett

SDL_ShowMessageBox on UIKit doesn't do anything special with buttons that are marked with the flag SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT. According to Apple's documentation on UIAlertController, a button can respond to a return key if it's marked as the preferredAction of the controller. SDL doesn't set a preferredAction currently, so I've attached a patch to fix that.
2019-08-05 23:52:16 -07:00
Alex Szpakowski
aebaa316c7 Add public APIs for creating a Metal view attached to an SDL window. Add SDL_metal.h. 2019-08-05 12:35:32 -03:00
Sam Lantinga
63197c4338 Fix bug where the wrong button was the default in the old message box because buttons were added backwards, breaking the indexing used by GetButtonIndex.
Add messagebox flags to explicilty request left-to-right button order or right-to-left.  If neither is specified it'll be some platform default.
2019-08-02 17:19:50 -07:00
Alex Szpakowski
d5ec735a33 Add a windowID field to SDL_TouchFingerEvent (bug #4331).
This is unimplemented on some platforms and will cause compile errors when building those platform backends for now.
2019-08-01 18:22:12 -03:00
Ethan Lee
bf9bf602e7 Copypaste SDL_NSLog to UIKit backend, document it as such 2019-07-17 23:20:57 -04:00
Alex Szpakowski
027887da15 iOS: Fix the window size not being set properly when Split View is used on an iPad (bug #4586). 2019-07-01 14:52:56 -03:00
Alex Szpakowski
f4625f52f2 iOS: remove some code which could affect the state of UIViews that aren't owned by SDL.
It was originally added to work around an input event problem in the code of a specific app which mixed SDL and native UIViews, but that app solved its problems in a better manner since then.
2019-06-16 13:52:27 -03:00
Sam Lantinga
1213fe79d8 Worked around "Undefined symbol: ___isPlatformVersionAtLeast()" link error on Xcode 11 beta 2019-06-14 13:56:42 -07:00
Alex Szpakowski
74e86a51d8 iOS: Remove didAddSubview override in NSWindow, its code breaks things which rely on focus changing within SDL's UIWindow (bug #4659). 2019-06-12 19:15:56 -03:00
Sam Lantinga
69d27a69cd Fixed bug 4570 - Support Vulkan Portability rather than MoltenVK specifically
Dzmitry Malyshau

Current code, search paths, and error messages are written to only consider MoltenVK on macOS as a Vulkan Portability implementation. It's not the only implementation available to the users. gfx-portability [1] has been shown to run a number of titles well, including Dota2, Dolphin Emulator, and vkQuake3, often out-performing MoltenVK in frame rate and stability (see Dolphin benchmark [2]).

There is no reason for SDL to be that specific, it's not using any MVK-specific functions other than the WSI initialization ("VK_MVK_macos_surface"). gfx-portability exposes this extension as well, and a more generic WSI extension is in process. It would be good if SDL was written in a more generic way that expect a Vulkan Portability library as opposed to MoltenVK specifically.

[1] https://github.com/gfx-rs/portability
[2] https://gfx-rs.github.io/2019/03/22/dolphin-macos-performance.html
2019-06-11 18:13:46 -07:00
Sam Lantinga
e43550c039 Fixed bug 4658 - iOS 12 fullscreen flag and SDL_HINT_IOS_HIDE_HOME_INDICATOR not working
Caleb Cornett

On iOS 12, creating a window with the SDL_WINDOW_FULLSCREEN flag does not dim the home indicator or defer system gestures. The same goes for setting the SDL_HINT_IOS_HIDE_HOME_INDICATOR to "2" -- it has no effect at all.

I've tracked down the source of this misbehavior to a timing issue. The initial `setNeedsUpdate...` calls were happening too early and getting applied to the launch screen by mistake. In the attached patch, I've added a call to those functions right after the launch screen is hidden so that they apply to the main view controller instead. This appears to fix the issue, at least on my iPhone 6s Plus.
2019-06-09 14:08:18 -07:00
Alex Szpakowski
9b5811592d iOS: return SDL_GetWindowSize from SDL_GL_GetDrawableSize if there's no GLES view in the window (matches the behaviour of SDL_GL_GetDrawableSize on other platforms). Addresses bug #4629. 2019-05-26 18:53:36 -03:00
Sam Lantinga
7ec514d48f Improved iOS Bluetooth keyboard support
* Don't stop text input after the return key is pressed
* Handle arrow and escape keys
2019-05-22 17:39:51 -07:00
Sam Lantinga
a4e33b9cc4 Added support for Bluetooth keyboards on iOS
In this case the keyboard is shown and immediately hidden, but we still want to accept text input
2019-05-20 14:31:03 -07:00
Sam Lantinga
582a3c994d Fixed mouse focus for touch events on iOS 2019-05-20 14:08:35 -07:00
Sam Lantinga
59da5b7202 [SDL] ios Touch Fix. 2019-05-14 07:55:42 -07:00
Alex Szpakowski
90b08881ab iOS: Remove code trying to support compilation on the iOS 7 SDK, the deployment target has been set to iOS 8 for years and there's other unconditionally compiled code that depends on newer SDKs so that code is useless. 2019-04-17 20:41:05 -03:00
Sam Lantinga
b6f33a6870 https://bugzilla.libsdl.org/show_bug.cgi?id=4577
SDL_GetWindowDisplayMode was returning an incorrect result on iPhone Plus devices (tested on iOS 12.1/12.2).  The problem was that the value returned by UIScreenMode was assumed to be the physical pixels on the display, rather than the scaled retina pixels.  The fix is to use the scale returned by UIScreen.scale rather than the nativeScale.
2019-04-05 07:51:11 -07:00
Sylvain Becker
9d28156f12 Bug 4576: remove touch/mouse duplication for IOS 2019-04-02 17:18:47 +02:00
Sam Lantinga
de82759c84 Added support for building SDL as a dynamic library on iOS 2019-03-19 07:53:33 -07:00
Sam Lantinga
82758efc46 [iOS DAC] Fix touch events getting from SDL2 to source2. 2019-03-12 14:45:04 -07:00
Sam Lantinga
5e13087b0f Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Alex Szpakowski
5029d50ea8 Add SDL_TouchDeviceType enum and SDL_GetTouchDeviceType(SDL_TouchID id).
Touch device types include SDL_TOUCH_DEVICE_DIRECT (a touch screen with window-relative coordinates for touches), SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE (a trackpad-style device with absolute device coordinates), and SDL_TOUCH_DEVICE_INDIRECT_RELATIVE (a trackpad-style device with screen cursor-relative coordinates).

Phone screens are an example of a direct device type. Mac trackpads are the indirect-absolute touch device type. The Apple TV remote is an indirect-relative touch device type.
2018-11-10 16:15:48 -04:00
Alex Szpakowski
e2ad654f2e iOS: Don't ignore the requested alpha bit size when determining whether to use an RGBA8 backbuffer. 2018-10-14 17:26:10 -03:00
Alex Szpakowski
d9094421e1 metal: Fix high dpi and resizing on macOS, and clean up iOS code. Fixes bug #4250. 2018-10-12 17:55:42 -03:00
Sam Lantinga
5febdfcece Fixed whitespace 2018-09-24 11:49:25 -07:00
Sam Lantinga
0b3a350c90 Fixed Chinese IME support (thanks ???!) 2018-09-10 23:01:33 -07:00