1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Defines abstract classes for user and general inputs to the application.
16 # Implemented independantly for each platforms and technologies.
19 import sdl
is conditional
(linux
)
20 import android
::input_events
is conditional
(android
)
22 # Input to the App, propagated through `App::input`.
26 # Mouse and touch input events
27 interface PointerEvent
30 # X position on screen (in pixels)
31 fun x
: Float is abstract
33 # Y position on screen (in pixels)
34 fun y
: Float is abstract
36 # Is down? either going down or already down
37 fun pressed
: Bool is abstract
39 # Is it not currently pressed down? The opposite of `pressed`.
40 fun depressed
: Bool do return not pressed
42 # Is this a movement event?
43 fun is_move
: Bool is abstract
46 # A motion event on screen composed of many `PointerEvent`
48 # Example of a `MotionEvent` a gesture such as pinching using two fingers.
52 # A pointer just went down?
53 fun just_went_down
: Bool is abstract
55 # Which pointer is down, if any
56 fun down_pointer
: nullable PointerEvent is abstract
59 # Specific touch event
63 # Pressure level of input
64 fun pressure
: Float is abstract
67 # Keyboard or other keys event
71 # Key is currently down?
72 fun is_down
: Bool is abstract
74 # Key is currently up?
75 fun is_up
: Bool do return not is_down
77 # Key is the up arrow key?
78 fun is_arrow_up
: Bool is abstract
80 # Key is the left arrow key?
81 fun is_arrow_left
: Bool is abstract
83 # Key is the down arrow key?
84 fun is_arrow_down
: Bool is abstract
86 # Key is the right arrow key?
87 fun is_arrow_right
: Bool is abstract
89 # Key code, is plateform specific
90 fun code
: Int is abstract
92 # Get Char value of key, if any
93 fun to_c
: nullable Char is abstract
95 # Name of the key that raised `self`
97 # Use mainly for debug since it is implementation dependent.
98 fun name
: String is abstract
101 # Mobile hardware (or pseudo hardware) event
102 interface MobileKeyEvent
105 # Key is back button? (mostly for Android)
106 fun is_back_key
: Bool is abstract
108 # Key is menu button? (mostly for Android)
109 fun is_menu_key
: Bool is abstract
111 # Key is search button? (mostly for Android)
112 fun is_search_key
: Bool is abstract
114 # Key is home button? (mostly for Android)
115 fun is_home_key
: Bool is abstract
118 # Sensor events like accelerometer, gyroscope etc for mobile apps
119 interface SensorEvent
123 # Quit event, used for window close button