Implemented independantly for each platforms and technologies.
mnit :: SensorEvent
Sensor events like accelerometer, gyroscope etc for mobile appscore :: union_find
union–find algorithm using an efficient disjoint-set data structureaccept_scroll_and_zoom
gamnit :: camera_control_android
Two fingers camera manipulation, pinch to zoom and slide to scrollgamnit :: camera_control_linux
Mouse wheel and middle mouse button to control cameraegl
, sdl
and x11
EulerCamera
and App::frame_core_draw
to get a stereoscopic view
# Defines abstract classes for user and general inputs to the application.
# Implemented independantly for each platforms and technologies.
module input
import android::input_events is conditional(android)
# Input to the App, propagated through `App::input`.
interface InputEvent
end
# Mouse and touch input events
interface PointerEvent
super InputEvent
# X position on screen (in pixels)
fun x: Float is abstract
# Y position on screen (in pixels)
fun y: Float is abstract
# Is down? either going down or already down
fun pressed: Bool is abstract
# Is it not currently pressed down? The opposite of `pressed`.
fun depressed: Bool do return not pressed
# Is this a movement event?
fun is_move: Bool is abstract
# Unique identifier of this pointer among other active pointers
#
# This value is useful to differentiate between pointers (or fingers) on
# multi-touch systems. This value does not change for the same pointer
# while it touches the screen.
fun pointer_id: Int do return 0
end
# A motion event on screen composed of many `PointerEvent`
#
# Example of a `MotionEvent` a gesture such as pinching using two fingers.
interface MotionEvent
super InputEvent
# A pointer just went down?
fun just_went_down: Bool is abstract
# Which pointer is down, if any
fun down_pointer: nullable PointerEvent is abstract
end
# Specific touch event
interface TouchEvent
super PointerEvent
# Pressure level of input
fun pressure: Float is abstract
end
# Keyboard or other keys event
interface KeyEvent
super InputEvent
# Key is currently down?
fun is_down: Bool is abstract
# Key is currently up?
fun is_up: Bool do return not is_down
# Key is the up arrow key?
fun is_arrow_up: Bool is abstract
# Key is the left arrow key?
fun is_arrow_left: Bool is abstract
# Key is the down arrow key?
fun is_arrow_down: Bool is abstract
# Key is the right arrow key?
fun is_arrow_right: Bool is abstract
# Key code, is plateform specific
fun code: Int is abstract
# Get Char value of key, if any
fun to_c: nullable Char is abstract
# Name of the key that raised `self`
#
# Use mainly for debug since it is implementation dependent.
fun name: String is abstract
end
# Mobile hardware (or pseudo hardware) event
interface MobileKeyEvent
super KeyEvent
# Key is back button? (mostly for Android)
fun is_back_key: Bool is abstract
# Key is search button? (mostly for Android)
fun is_search_key: Bool is abstract
# Key is home button? (mostly for Android)
fun is_home_key: Bool is abstract
end
# Sensor events like accelerometer, gyroscope etc for mobile apps
interface SensorEvent
super InputEvent
end
# Quit event, used for window close button
interface QuitEvent
super InputEvent
end
lib/mnit/input.nit:15,1--132,3