2016-12-13 07:28:30 -06:00
|
|
|
//! iOS support
|
|
|
|
|
//!
|
|
|
|
|
//! # Building app
|
|
|
|
|
//! To build ios app you will need rustc built for this targets:
|
|
|
|
|
//!
|
|
|
|
|
//! - armv7-apple-ios
|
|
|
|
|
//! - armv7s-apple-ios
|
|
|
|
|
//! - i386-apple-ios
|
|
|
|
|
//! - aarch64-apple-ios
|
|
|
|
|
//! - x86_64-apple-ios
|
|
|
|
|
//!
|
|
|
|
|
//! Then
|
|
|
|
|
//!
|
|
|
|
|
//! ```
|
|
|
|
|
//! cargo build --target=...
|
|
|
|
|
//! ```
|
|
|
|
|
//! The simplest way to integrate your app into xcode environment is to build it
|
|
|
|
|
//! as a static library. Wrap your main function and export it.
|
|
|
|
|
//!
|
|
|
|
|
//! ```rust, ignore
|
|
|
|
|
//! #[no_mangle]
|
2018-06-14 19:42:18 -04:00
|
|
|
//! pub extern fn start_winit_app() {
|
2016-12-13 07:28:30 -06:00
|
|
|
//! start_inner()
|
|
|
|
|
//! }
|
|
|
|
|
//!
|
|
|
|
|
//! fn start_inner() {
|
|
|
|
|
//! ...
|
|
|
|
|
//! }
|
|
|
|
|
//! ```
|
|
|
|
|
//!
|
2018-06-14 19:42:18 -04:00
|
|
|
//! Compile project and then drag resulting .a into Xcode project. Add winit.h to xcode.
|
2016-12-13 07:28:30 -06:00
|
|
|
//!
|
2016-12-13 07:37:13 -06:00
|
|
|
//! ```ignore
|
2018-06-14 19:42:18 -04:00
|
|
|
//! void start_winit_app();
|
2016-12-13 07:28:30 -06:00
|
|
|
//! ```
|
|
|
|
|
//!
|
2018-06-14 19:42:18 -04:00
|
|
|
//! Use start_winit_app inside your xcode's main function.
|
2016-12-13 07:28:30 -06:00
|
|
|
//!
|
|
|
|
|
//!
|
|
|
|
|
//! # App lifecycle and events
|
|
|
|
|
//!
|
|
|
|
|
//! iOS environment is very different from other platforms and you must be very
|
|
|
|
|
//! careful with it's events. Familiarize yourself with
|
|
|
|
|
//! [app lifecycle](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/).
|
|
|
|
|
//!
|
|
|
|
|
//!
|
2018-06-14 19:42:18 -04:00
|
|
|
//! This is how those event are represented in winit:
|
2016-12-13 07:28:30 -06:00
|
|
|
//!
|
2019-06-22 04:59:31 +02:00
|
|
|
//! - applicationDidBecomeActive is Resumed
|
|
|
|
|
//! - applicationWillResignActive is Suspended
|
2023-07-28 17:19:53 +01:00
|
|
|
//! - applicationWillTerminate is LoopExiting
|
2016-12-13 07:28:30 -06:00
|
|
|
//!
|
2023-07-28 17:19:53 +01:00
|
|
|
//! Keep in mind that after LoopExiting event is received every attempt to draw with
|
2016-12-13 07:28:30 -06:00
|
|
|
//! opengl will result in segfault.
|
|
|
|
|
//!
|
2023-07-28 17:19:53 +01:00
|
|
|
//! Also note that app may not receive the LoopExiting event if suspended; it might be SIGKILL'ed.
|
2016-12-13 07:28:30 -06:00
|
|
|
|
2022-12-25 09:57:27 +02:00
|
|
|
#![cfg(ios_platform)]
|
2022-06-10 13:43:33 +03:00
|
|
|
#![allow(clippy::let_unit_value)]
|
2015-06-05 16:38:21 +03:00
|
|
|
|
2019-05-25 18:10:41 -07:00
|
|
|
mod app_state;
|
|
|
|
|
mod event_loop;
|
|
|
|
|
mod ffi;
|
|
|
|
|
mod monitor;
|
2022-09-08 20:30:34 +02:00
|
|
|
mod uikit;
|
2019-05-25 18:10:41 -07:00
|
|
|
mod view;
|
|
|
|
|
mod window;
|
|
|
|
|
|
2019-05-29 21:29:54 -04:00
|
|
|
use std::fmt;
|
|
|
|
|
|
2024-01-15 21:51:01 +01:00
|
|
|
use crate::event::DeviceId as RootDeviceId;
|
|
|
|
|
|
2022-02-16 22:09:03 +01:00
|
|
|
pub(crate) use self::{
|
|
|
|
|
event_loop::{
|
2024-01-31 17:29:59 +04:00
|
|
|
ActiveEventLoop, EventLoop, EventLoopProxy, OwnedDisplayHandle,
|
2024-01-15 11:58:11 -08:00
|
|
|
PlatformSpecificEventLoopAttributes,
|
2022-02-16 22:09:03 +01:00
|
|
|
},
|
2023-12-26 22:12:33 +01:00
|
|
|
monitor::{MonitorHandle, VideoModeHandle},
|
2024-01-31 17:29:59 +04:00
|
|
|
window::{PlatformSpecificWindowAttributes, Window, WindowId},
|
2019-05-25 18:10:41 -07:00
|
|
|
};
|
2023-12-16 22:02:17 +02:00
|
|
|
pub(crate) use crate::cursor::NoCustomCursor as PlatformCustomCursor;
|
2023-12-22 22:20:41 +01:00
|
|
|
pub(crate) use crate::cursor::NoCustomCursor as PlatformCustomCursorBuilder;
|
2020-03-07 19:42:21 +00:00
|
|
|
pub(crate) use crate::icon::NoIcon as PlatformIcon;
|
2023-07-31 00:39:01 +04:00
|
|
|
pub(crate) use crate::platform_impl::Fullscreen;
|
2020-03-07 19:42:21 +00:00
|
|
|
|
2024-01-15 21:51:01 +01:00
|
|
|
/// There is no way to detect which device that performed a certain event in
|
|
|
|
|
/// UIKit (i.e. you can't differentiate between different external keyboards,
|
2024-02-19 11:58:44 +07:00
|
|
|
/// or whether it was the main touchscreen, assistive technologies, or some
|
2024-01-15 21:51:01 +01:00
|
|
|
/// other pointer device that caused a touch event).
|
2017-09-04 12:41:10 +02:00
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
2024-01-15 21:51:01 +01:00
|
|
|
pub struct DeviceId;
|
2018-12-21 09:51:48 -07:00
|
|
|
|
|
|
|
|
impl DeviceId {
|
2021-08-30 19:40:02 +02:00
|
|
|
pub const unsafe fn dummy() -> Self {
|
2024-01-15 21:51:01 +01:00
|
|
|
DeviceId
|
2016-12-13 07:28:30 -06:00
|
|
|
}
|
|
|
|
|
}
|
2017-04-22 13:52:35 -07:00
|
|
|
|
2024-01-15 21:51:01 +01:00
|
|
|
pub(crate) const DEVICE_ID: RootDeviceId = RootDeviceId(DeviceId);
|
2019-05-29 21:29:54 -04:00
|
|
|
|
2023-05-28 20:02:59 +02:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
|
|
|
pub struct KeyEventExtra {}
|
|
|
|
|
|
2019-05-29 21:29:54 -04:00
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub enum OsError {}
|
|
|
|
|
|
|
|
|
|
impl fmt::Display for OsError {
|
2022-06-10 13:43:33 +03:00
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
|
write!(f, "os error")
|
2019-05-29 21:29:54 -04:00
|
|
|
}
|
|
|
|
|
}
|