playdate_system/event.rs
1pub use sys::ffi::PDSystemEvent as SystemEvent;
2
3
4pub trait SystemEventExt {
5 #![allow(non_upper_case_globals)]
6
7 /// Program initialization.
8 ///
9 /// After loading pdex.bin into memory, the system calls your event handler with this event.
10 ///
11 /// Then you can supply your own run loop update function
12 /// by calling [`System::set_update_callback`](crate::System::set_update_callback)
13 /// or [`Update::set_update_handler`](crate::update::Update::set_update_handler) here.
14 ///
15 /// If you don’t provide an update callback, the system initializes a Lua context
16 /// and calls your event handler again with event [`InitLua`](SystemEventExt::InitLua).
17 #[doc(alias = "sys::ffi::PDSystemEvent::kEventInit")]
18 const Init: SystemEvent = SystemEvent::kEventInit;
19
20 /// Program initialization in __lua context__.
21 #[doc(alias = "sys::ffi::PDSystemEvent::kEventInitLua")]
22 const InitLua: SystemEvent = SystemEvent::kEventInitLua;
23
24 /// System going to locked state.
25 #[doc(alias = "sys::ffi::PDSystemEvent::kEventLockage")]
26 const Lock: SystemEvent = SystemEvent::kEventLock;
27
28 /// System has been unlocked by user.
29 #[doc(alias = "sys::ffi::PDSystemEvent::kEventUnlock")]
30 const Unlock: SystemEvent = SystemEvent::kEventUnlock;
31
32 /// Program execution paused.
33 #[doc(alias = "sys::ffi::PDSystemEvent::kEventPause")]
34 const Pause: SystemEvent = SystemEvent::kEventPause;
35
36 /// Program execution resumed after [pause](SystemEventExt::Pause).
37 #[doc(alias = "sys::ffi::PDSystemEvent::kEventResume")]
38 const Resume: SystemEvent = SystemEvent::kEventResume;
39
40 /// Program termination.
41 #[doc(alias = "sys::ffi::PDSystemEvent::kEventTerminate")]
42 const Terminate: SystemEvent = SystemEvent::kEventTerminate;
43
44 /// Simulator key is pressed.
45 ///
46 /// When an arbitrary key is pressed __in the Simulator__
47 /// your event handler is called with this event and the keycode of the key in the last argument.
48 ///
49 /// See also [`KeyReleased`](SystemEventExt::KeyReleased).
50 #[doc(alias = "sys::ffi::PDSystemEvent::kEventKeyPressed")]
51 const KeyPressed: SystemEvent = SystemEvent::kEventKeyPressed;
52
53 /// Simulator key is released.
54 ///
55 /// When an arbitrary key is released __in the Simulator__
56 /// your event handler is called with this event and the keycode of the key in the last argument.
57 ///
58 /// See also [`KeyPressed`](SystemEventExt::KeyPressed).
59 #[doc(alias = "sys::ffi::PDSystemEvent::kEventKeyReleased")]
60 const KeyReleased: SystemEvent = SystemEvent::kEventKeyReleased;
61
62 /// Low power warning by system.
63 ///
64 /// At this point, it's a good idea to persistently save anything you need, such as a save-game.
65 #[doc(alias = "sys::ffi::PDSystemEvent::kEventLowPower")]
66 const LowPower: SystemEvent = SystemEvent::kEventLowPower;
67}
68
69
70impl SystemEventExt for SystemEvent {}