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 android
::input_events
is conditional
(android
)
21 # Input to the App, propagated through `App::input`.
25 # Mouse and touch input events
26 interface PointerEvent
29 # X position on screen (in pixels)
30 fun x
: Float is abstract
32 # Y position on screen (in pixels)
33 fun y
: Float is abstract
35 # Is down? either going down or already down
36 fun pressed
: Bool is abstract
38 # Is it not currently pressed down? The opposite of `pressed`.
39 fun depressed
: Bool do return not pressed
41 # Is this a movement event?
42 fun is_move
: Bool is abstract
44 # Unique identifier of this pointer among other active pointers
46 # This value is useful to differentiate between pointers (or fingers) on
47 # multi-touch systems. This value does not change for the same pointer
48 # while it touches the screen.
49 fun pointer_id
: Int do return 0
52 # A motion event on screen composed of many `PointerEvent`
54 # Example of a `MotionEvent` a gesture such as pinching using two fingers.
58 # A pointer just went down?
59 fun just_went_down
: Bool is abstract
61 # Which pointer is down, if any
62 fun down_pointer
: nullable PointerEvent is abstract
65 # Specific touch event
69 # Pressure level of input
70 fun pressure
: Float is abstract
73 # Keyboard or other keys event
77 # Key is currently down?
78 fun is_down
: Bool is abstract
80 # Key is currently up?
81 fun is_up
: Bool do return not is_down
83 # Key is the up arrow key?
84 fun is_arrow_up
: Bool is abstract
86 # Key is the left arrow key?
87 fun is_arrow_left
: Bool is abstract
89 # Key is the down arrow key?
90 fun is_arrow_down
: Bool is abstract
92 # Key is the right arrow key?
93 fun is_arrow_right
: Bool is abstract
95 # Key code, is plateform specific
96 fun code
: Int is abstract
98 # Get Char value of key, if any
99 fun to_c
: nullable Char is abstract
101 # Name of the key that raised `self`
103 # Use mainly for debug since it is implementation dependent.
104 fun name
: String is abstract
107 # Mobile hardware (or pseudo hardware) event
108 interface MobileKeyEvent
111 # Key is back button? (mostly for Android)
112 fun is_back_key
: Bool is abstract
114 # Key is menu button? (mostly for Android)
115 fun is_menu_key
: Bool is abstract
117 # Key is search button? (mostly for Android)
118 fun is_search_key
: Bool is abstract
120 # Key is home button? (mostly for Android)
121 fun is_home_key
: Bool is abstract
124 # Sensor events like accelerometer, gyroscope etc for mobile apps
125 interface SensorEvent
129 # Quit event, used for window close button