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
45 # Unique identifier of this pointer among other active pointers
47 # This value is useful to differentiate between pointers (or fingers) on
48 # multi-touch systems. This value does not change for the same pointer
49 # while it touches the screen.
50 fun pointer_id
: Int do return 0
53 # A motion event on screen composed of many `PointerEvent`
55 # Example of a `MotionEvent` a gesture such as pinching using two fingers.
59 # A pointer just went down?
60 fun just_went_down
: Bool is abstract
62 # Which pointer is down, if any
63 fun down_pointer
: nullable PointerEvent is abstract
66 # Specific touch event
70 # Pressure level of input
71 fun pressure
: Float is abstract
74 # Keyboard or other keys event
78 # Key is currently down?
79 fun is_down
: Bool is abstract
81 # Key is currently up?
82 fun is_up
: Bool do return not is_down
84 # Key is the up arrow key?
85 fun is_arrow_up
: Bool is abstract
87 # Key is the left arrow key?
88 fun is_arrow_left
: Bool is abstract
90 # Key is the down arrow key?
91 fun is_arrow_down
: Bool is abstract
93 # Key is the right arrow key?
94 fun is_arrow_right
: Bool is abstract
96 # Key code, is plateform specific
97 fun code
: Int is abstract
99 # Get Char value of key, if any
100 fun to_c
: nullable Char is abstract
102 # Name of the key that raised `self`
104 # Use mainly for debug since it is implementation dependent.
105 fun name
: String is abstract
108 # Mobile hardware (or pseudo hardware) event
109 interface MobileKeyEvent
112 # Key is back button? (mostly for Android)
113 fun is_back_key
: Bool is abstract
115 # Key is menu button? (mostly for Android)
116 fun is_menu_key
: Bool is abstract
118 # Key is search button? (mostly for Android)
119 fun is_search_key
: Bool is abstract
121 # Key is home button? (mostly for Android)
122 fun is_home_key
: Bool is abstract
125 # Sensor events like accelerometer, gyroscope etc for mobile apps
126 interface SensorEvent
130 # Quit event, used for window close button