Files
ndk-odin/input.odin
T

1309 lines
48 KiB
Odin

//+build android
package android
foreign import android "system:android"
/**
* Key states (may be returned by queries about the current state of a
* particular key code, scan code or switch).
*/
KeyState :: enum {
/** The key state is unknown or the requested key itself is not supported. */
UNKNOWN = -1,
/** The key is up. */
UP = 0,
/** The key is down. */
DOWN = 1,
/** The key is down but is a virtual key press that is being emulated by the system. */
VIRTUAL = 2
}
/**
* Meta key / modifier state.
*/
MetaKeyStateBits :: enum i32 {
ALT_ON = 1,
ALT_LEFT_ON = 4,
ALT_RIGHT_ON = 5,
SHIFT_ON = 0,
SHIFT_LEFT_ON = 6,
SHIFT_RIGHT_ON = 7,
SYM_ON = 2,
FUNCTION_ON = 3,
CTRL_ON = 12,
CTRL_LEFT_ON = 13,
CTRL_RIGHT_ON = 14,
META_ON = 16,
META_LEFT_ON = 17,
META_RIGHT_ON = 18,
CAPS_LOCK_ON = 20,
NUM_LOCK_ON = 21,
SCROLL_LOCK_ON = 22,
}
MetaKeyState :: bit_set[MetaKeyStateBits; i32]
/**
* Input event types.
*/
InputEventType :: enum i32 {
/** Indicates that the input event is a key event. */
KEY = 1,
/** Indicates that the input event is a motion event. */
MOTION = 2,
/** Focus event */
FOCUS = 3,
/** Capture event */
CAPTURE = 4,
/** Drag event */
DRAG = 5,
/** TouchMode event */
TOUCH_MODE = 6,
}
/**
* Key event actions.
*/
KeyEventAction :: enum i32 {
/** The key has been pressed down. */
DOWN = 0,
/** The key has been released. */
UP = 1,
/**
* Multiple duplicate key events have occurred in a row, or a
* complex string is being delivered. The repeat_count property
* of the key event contains the number of times the given key
* code should be executed.
*/
MULTIPLE = 2
}
/**
* Key event flags.
*/
KeyEventFlagsBits :: enum {
/** This mask is set if the device woke because of this key event. */
WOKE_HERE = 0,
/** This mask is set if the key event was generated by a software keyboard. */
SOFT_KEYBOARD = 1,
/** This mask is set if we don't want the key event to cause us to leave touch mode. */
KEEP_TOUCH_MODE = 2,
/**
* This mask is set if an event was known to come from a trusted
* part of the system. That is, the event is known to come from
* the user, and could not have been spoofed by a third party
* component.
*/
FROM_SYSTEM = 3,
/**
* This mask is used for compatibility, to identify enter keys that are
* coming from an IME whose enter key has been auto-labelled "next" or
* "done". This allows TextView to dispatch these as normal enter keys
* for old applications, but still do the appropriate action when
* receiving them.
*/
EDITOR_ACTION = 4,
/**
* When associated with up key events, this indicates that the key press
* has been canceled. Typically this is used with virtual touch screen
* keys, where the user can slide from the virtual key area on to the
* display: in that case, the application will receive a canceled up
* event and should not perform the action normally associated with the
* key. Note that for this to work, the application can not perform an
* action for a key until it receives an up or the long press timeout has
* expired.
*/
CANCELED = 5,
/**
* This key event was generated by a virtual (on-screen) hard key area.
* Typically this is an area of the touchscreen, outside of the regular
* display, dedicated to "hardware" buttons.
*/
VIRTUAL_HARD_KEY = 6,
/**
* This flag is set for the first key repeat that occurs after the
* long press timeout.
*/
LONG_PRESS = 7,
/**
* Set when a key event has #AKEY_EVENT_FLAG_CANCELED set because a long
* press action was executed while it was down.
*/
CANCELED_LONG_PRESS = 8,
/**
* Set for #AKEY_EVENT_ACTION_UP when this event's key code is still being
* tracked from its initial down. That is, somebody requested that tracking
* started on the key down and a long press has not caused
* the tracking to be canceled.
*/
FLAG_TRACKING = 9,
/**
* Set when a key event has been synthesized to implement default behavior
* for an event that the application did not handle.
* Fallback key events are generated by unhandled trackball motions
* (to emulate a directional keypad) and by certain unhandled key presses
* that are declared in the key map (such as special function numeric keypad
* keys when numlock is off).
*/
FLAG_FALLBACK = 10,
}
KeyEventFlags :: bit_set[KeyEventFlagsBits]
MotionEventActionEnum :: enum u8 {
/** A pressed gesture has started, the motion contains the initial starting location. */
DOWN = 0,
/**
* A pressed gesture has finished, the motion contains the final release location
* as well as any intermediate points since the last down or move event.
*/
UP = 1,
/**
* A change has happened during a press gesture (between #AMOTION_EVENT_ACTION_DOWN and
* #AMOTION_EVENT_ACTION_UP). The motion contains the most recent point, as well as
* any intermediate points since the last down or move event.
*/
MOVE = 2,
/**
* The current gesture has been aborted.
* You will not receive any more points in it. You should treat this as
* an up event, but not perform any action that you normally would.
*/
CANCEL = 3,
/**
* A movement has happened outside of the normal bounds of the UI element.
* This does not provide a full gesture, but only the initial location of the movement/touch.
*/
OUTSIDE = 4,
/**
* A non-primary pointer has gone down.
* The bits in #AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
*/
POINTER_DOWN = 5,
/**
* A non-primary pointer has gone up.
* The bits in #AMOTION_EVENT_ACTION_POINTER_INDEX_MASK indicate which pointer changed.
*/
POINTER_UP = 6,
/**
* A change happened but the pointer is not down (unlike #AMOTION_EVENT_ACTION_MOVE).
* The motion contains the most recent point, as well as any intermediate points since
* the last hover move event.
*/
HOVER_MOVE = 7,
/**
* The motion event contains relative vertical and/or horizontal scroll offsets.
* Use {@link AMotionEvent_getAxisValue} to retrieve the information from
* #AMOTION_EVENT_AXIS_VSCROLL and #AMOTION_EVENT_AXIS_HSCROLL.
* The pointer may or may not be down when this event is dispatched.
* This action is always delivered to the winder under the pointer, which
* may not be the window currently touched.
*/
SCROLL = 8,
/** The pointer is not down but has entered the boundaries of a window or view. */
HOVER_ENTER = 9,
/** The pointer is not down but has exited the boundaries of a window or view. */
HOVER_EXIT = 10,
/* One or more buttons have been pressed. */
BUTTON_PRESS = 11,
/* One or more buttons have been released. */
BUTTON_RELEASE = 12,
}
// 0xRRRRIIAA
// R = reserved
// I = pointer index
// A = action
// Odin parses the bit_fields as LSB
MotionEventAction :: bit_field i32 {
action: MotionEventActionEnum | 8,
pointer_index: u8 | 8,
reserved: i16 | 16,
}
/**
* Motion event flags.
*/
MotionEventFlagsBits :: enum i32 {
/**
* This flag indicates that the window that received this motion event is partly
* or wholly obscured by another visible window above it. This flag is set to true
* even if the event did not directly pass through the obscured area.
* A security sensitive application can check this flag to identify situations in which
* a malicious application may have covered up part of its content for the purpose
* of misleading the user or hijacking touches. An appropriate response might be
* to drop the suspect touches or to take additional precautions to confirm the user's
* actual intent.
*/
WINDOW_IS_OBSCURED = 0,
}
MotionEventFlags :: bit_set[MotionEventFlagsBits; i32]
/**
* Motion event edge touch flags.
*/
MotionEventEdgeFlagsBits :: enum i32 {
/** Flag indicating the motion event intersected the top edge of the screen. */
TOP = 0,
/** Flag indicating the motion event intersected the bottom edge of the screen. */
BOTTOM = 1,
/** Flag indicating the motion event intersected the left edge of the screen. */
LEFT = 2,
/** Flag indicating the motion event intersected the right edge of the screen. */
RIGHT = 3,
}
MotionEventEdgeFlags :: bit_set[MotionEventEdgeFlagsBits; i32]
/**
* Constants that identify each individual axis of a motion event.
* @anchor AMOTION_EVENT_AXIS
*/
MotionEventAxis :: enum i32 {
/**
* Axis constant: X axis of a motion event.
*
* - For a touch screen, reports the absolute X screen position of the center of
* the touch contact area. The units are display pixels.
* - For a touch pad, reports the absolute X surface position of the center of the touch
* contact area. The units are device-dependent.
* - For a mouse, reports the absolute X screen position of the mouse pointer.
* The units are display pixels.
* - For a trackball, reports the relative horizontal displacement of the trackball.
* The value is normalized to a range from -1.0 (left) to 1.0 (right).
* - For a joystick, reports the absolute X position of the joystick.
* The value is normalized to a range from -1.0 (left) to 1.0 (right).
*/
X = 0,
/**
* Axis constant: Y axis of a motion event.
*
* - For a touch screen, reports the absolute Y screen position of the center of
* the touch contact area. The units are display pixels.
* - For a touch pad, reports the absolute Y surface position of the center of the touch
* contact area. The units are device-dependent.
* - For a mouse, reports the absolute Y screen position of the mouse pointer.
* The units are display pixels.
* - For a trackball, reports the relative vertical displacement of the trackball.
* The value is normalized to a range from -1.0 (up) to 1.0 (down).
* - For a joystick, reports the absolute Y position of the joystick.
* The value is normalized to a range from -1.0 (up or far) to 1.0 (down or near).
*/
Y = 1,
/**
* Axis constant: Pressure axis of a motion event.
*
* - For a touch screen or touch pad, reports the approximate pressure applied to the surface
* by a finger or other tool. The value is normalized to a range from
* 0 (no pressure at all) to 1 (normal pressure), although values higher than 1
* may be generated depending on the calibration of the input device.
* - For a trackball, the value is set to 1 if the trackball button is pressed
* or 0 otherwise.
* - For a mouse, the value is set to 1 if the primary mouse button is pressed
* or 0 otherwise.
*/
PRESSURE = 2,
/**
* Axis constant: Size axis of a motion event.
*
* - For a touch screen or touch pad, reports the approximate size of the contact area in
* relation to the maximum detectable size for the device. The value is normalized
* to a range from 0 (smallest detectable size) to 1 (largest detectable size),
* although it is not a linear scale. This value is of limited use.
* To obtain calibrated size information, see
* {@link AMOTION_EVENT_AXIS_TOUCH_MAJOR} or {@link AMOTION_EVENT_AXIS_TOOL_MAJOR}.
*/
SIZE = 3,
/**
* Axis constant: TouchMajor axis of a motion event.
*
* - For a touch screen, reports the length of the major axis of an ellipse that
* represents the touch area at the point of contact.
* The units are display pixels.
* - For a touch pad, reports the length of the major axis of an ellipse that
* represents the touch area at the point of contact.
* The units are device-dependent.
*/
TOUCH_MAJOR = 4,
/**
* Axis constant: TouchMinor axis of a motion event.
*
* - For a touch screen, reports the length of the minor axis of an ellipse that
* represents the touch area at the point of contact.
* The units are display pixels.
* - For a touch pad, reports the length of the minor axis of an ellipse that
* represents the touch area at the point of contact.
* The units are device-dependent.
*
* When the touch is circular, the major and minor axis lengths will be equal to one another.
*/
TOUCH_MINOR = 5,
/**
* Axis constant: ToolMajor axis of a motion event.
*
* - For a touch screen, reports the length of the major axis of an ellipse that
* represents the size of the approaching finger or tool used to make contact.
* - For a touch pad, reports the length of the major axis of an ellipse that
* represents the size of the approaching finger or tool used to make contact.
* The units are device-dependent.
*
* When the touch is circular, the major and minor axis lengths will be equal to one another.
*
* The tool size may be larger than the touch size since the tool may not be fully
* in contact with the touch sensor.
*/
TOOL_MAJOR = 6,
/**
* Axis constant: ToolMinor axis of a motion event.
*
* - For a touch screen, reports the length of the minor axis of an ellipse that
* represents the size of the approaching finger or tool used to make contact.
* - For a touch pad, reports the length of the minor axis of an ellipse that
* represents the size of the approaching finger or tool used to make contact.
* The units are device-dependent.
*
* When the touch is circular, the major and minor axis lengths will be equal to one another.
*
* The tool size may be larger than the touch size since the tool may not be fully
* in contact with the touch sensor.
*/
TOOL_MINOR = 7,
/**
* Axis constant: Orientation axis of a motion event.
*
* - For a touch screen or touch pad, reports the orientation of the finger
* or tool in radians relative to the vertical plane of the device.
* An angle of 0 radians indicates that the major axis of contact is oriented
* upwards, is perfectly circular or is of unknown orientation. A positive angle
* indicates that the major axis of contact is oriented to the right. A negative angle
* indicates that the major axis of contact is oriented to the left.
* The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
* (finger pointing fully right).
* - For a stylus, the orientation indicates the direction in which the stylus
* is pointing in relation to the vertical axis of the current orientation of the screen.
* The range is from -PI radians to PI radians, where 0 is pointing up,
* -PI/2 radians is pointing left, -PI or PI radians is pointing down, and PI/2 radians
* is pointing right. See also #AMOTION_EVENT_AXIS_TILT.
*/
ORIENTATION = 8,
/**
* Axis constant: Vertical Scroll axis of a motion event.
*
* - For a mouse, reports the relative movement of the vertical scroll wheel.
* The value is normalized to a range from -1.0 (down) to 1.0 (up).
*
* This axis should be used to scroll views vertically.
*/
VSCROLL = 9,
/**
* Axis constant: Horizontal Scroll axis of a motion event.
*
* - For a mouse, reports the relative movement of the horizontal scroll wheel.
* The value is normalized to a range from -1.0 (left) to 1.0 (right).
*
* This axis should be used to scroll views horizontally.
*/
HSCROLL = 10,
/**
* Axis constant: Z axis of a motion event.
*
* - For a joystick, reports the absolute Z position of the joystick.
* The value is normalized to a range from -1.0 (high) to 1.0 (low).
* <em>On game pads with two analog joysticks, this axis is often reinterpreted
* to report the absolute X position of the second joystick instead.</em>
*/
Z = 11,
/**
* Axis constant: X Rotation axis of a motion event.
*
* - For a joystick, reports the absolute rotation angle about the X axis.
* The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
*/
RX = 12,
/**
* Axis constant: Y Rotation axis of a motion event.
*
* - For a joystick, reports the absolute rotation angle about the Y axis.
* The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
*/
RY = 13,
/**
* Axis constant: Z Rotation axis of a motion event.
*
* - For a joystick, reports the absolute rotation angle about the Z axis.
* The value is normalized to a range from -1.0 (counter-clockwise) to 1.0 (clockwise).
* On game pads with two analog joysticks, this axis is often reinterpreted
* to report the absolute Y position of the second joystick instead.
*/
RZ = 14,
/**
* Axis constant: Hat X axis of a motion event.
*
* - For a joystick, reports the absolute X position of the directional hat control.
* The value is normalized to a range from -1.0 (left) to 1.0 (right).
*/
HAT_X = 15,
/**
* Axis constant: Hat Y axis of a motion event.
*
* - For a joystick, reports the absolute Y position of the directional hat control.
* The value is normalized to a range from -1.0 (up) to 1.0 (down).
*/
HAT_Y = 16,
/**
* Axis constant: Left Trigger axis of a motion event.
*
* - For a joystick, reports the absolute position of the left trigger control.
* The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
*/
LTRIGGER = 17,
/**
* Axis constant: Right Trigger axis of a motion event.
*
* - For a joystick, reports the absolute position of the right trigger control.
* The value is normalized to a range from 0.0 (released) to 1.0 (fully pressed).
*/
RTRIGGER = 18,
/**
* Axis constant: Throttle axis of a motion event.
*
* - For a joystick, reports the absolute position of the throttle control.
* The value is normalized to a range from 0.0 (fully open) to 1.0 (fully closed).
*/
THROTTLE = 19,
/**
* Axis constant: Rudder axis of a motion event.
*
* - For a joystick, reports the absolute position of the rudder control.
* The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
*/
RUDDER = 20,
/**
* Axis constant: Wheel axis of a motion event.
*
* - For a joystick, reports the absolute position of the steering wheel control.
* The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
*/
WHEEL = 21,
/**
* Axis constant: Gas axis of a motion event.
*
* - For a joystick, reports the absolute position of the gas (accelerator) control.
* The value is normalized to a range from 0.0 (no acceleration)
* to 1.0 (maximum acceleration).
*/
GAS = 22,
/**
* Axis constant: Brake axis of a motion event.
*
* - For a joystick, reports the absolute position of the brake control.
* The value is normalized to a range from 0.0 (no braking) to 1.0 (maximum braking).
*/
BRAKE = 23,
/**
* Axis constant: Distance axis of a motion event.
*
* - For a stylus, reports the distance of the stylus from the screen.
* A value of 0.0 indicates direct contact and larger values indicate increasing
* distance from the surface.
*/
DISTANCE = 24,
/**
* Axis constant: Tilt axis of a motion event.
*
* - For a stylus, reports the tilt angle of the stylus in radians where
* 0 radians indicates that the stylus is being held perpendicular to the
* surface, and PI/2 radians indicates that the stylus is being held flat
* against the surface.
*/
TILT = 25,
/**
* Axis constant: Generic scroll axis of a motion event.
*
* - This is used for scroll axis motion events that can't be classified as strictly
* vertical or horizontal. The movement of a rotating scroller is an example of this.
*/
SCROLL = 26,
/**
* Axis constant: The movement of x position of a motion event.
*
* - For a mouse, reports a difference of x position between the previous position.
* This is useful when pointer is captured, in that case the mouse pointer doesn't
* change the location but this axis reports the difference which allows the app
* to see how the mouse is moved.
*/
RELATIVE_X = 27,
/**
* Axis constant: The movement of y position of a motion event.
*
* Same as #AMOTION_EVENT_AXIS_RELATIVE_X, but for y position.
*/
RELATIVE_Y = 28,
/**
* Axis constant: Generic 1 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*/
GENERIC_1 = 32,
/**
* Axis constant: Generic 2 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*/
GENERIC_2 = 33,
/**
* Axis constant: Generic 3 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*/
GENERIC_3 = 34,
/**
* Axis constant: Generic 4 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*/
GENERIC_4 = 35,
/**
* Axis constant: Generic 5 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*/
GENERIC_5 = 36,
/**
* Axis constant: Generic 6 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*/
GENERIC_6 = 37,
/**
* Axis constant: Generic 7 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*/
GENERIC_7 = 38,
/**
* Axis constant: Generic 8 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*/
GENERIC_8 = 39,
/**
* Axis constant: Generic 9 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*/
GENERIC_9 = 40,
/**
* Axis constant: Generic 10 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*/
GENERIC_10 = 41,
/**
* Axis constant: Generic 11 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*/
GENERIC_11 = 42,
/**
* Axis constant: Generic 12 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*/
GENERIC_12 = 43,
/**
* Axis constant: Generic 13 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*/
GENERIC_13 = 44,
/**
* Axis constant: Generic 14 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*/
GENERIC_14 = 45,
/**
* Axis constant: Generic 15 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*/
GENERIC_15 = 46,
/**
* Axis constant: Generic 16 axis of a motion event.
* The interpretation of a generic axis is device-specific.
*/
GENERIC_16 = 47,
}
/**
* Constants that identify buttons that are associated with motion events.
* Refer to the documentation on the MotionEvent class for descriptions of each button.
*/
// TODO: bit_set this?
MotionEventButton :: enum {
PRIMARY = 1 << 0,
SECONDARY = 1 << 1,
TERTIARY = 1 << 2,
BACK = 1 << 3,
FORWARD = 1 << 4,
STYLUS_PRIMARY = 1 << 5,
STYLUS_SECONDARY = 1 << 6,
}
/**
* Constants that identify tool types.
* Refer to the documentation on the MotionEvent class for descriptions of each tool type.
*/
ToolType :: enum i32 {
UNKNOWN = 0,
FINGER = 1,
STYLUS = 2,
MOUSE = 3,
ERASER = 4,
PALM = 5,
}
/**
* Constants that identify different gesture classification types.
*/
AMotionClassification :: enum i32 {
/**
* Classification constant: None.
*
* No additional information is available about the current motion event stream.
*/
NONE = 0,
/**
* Classification constant: Ambiguous gesture.
*
* The user's intent with respect to the current event stream is not yet determined. Events
* starting in #AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE will eventually resolve into
* either #AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS or #AMOTION_EVENT_CLASSIFICATION_NONE.
* Gestural actions, such as scrolling, should be inhibited until the classification resolves
* to another value or the event stream ends.
*/
AMBIGUOUS_GESTURE = 1,
/**
* Classification constant: Deep press.
*
* The current event stream represents the user intentionally pressing harder on the screen.
* This classification type should be used to accelerate the long press behaviour.
*/
DEEP_PRESS = 2,
}
/**
* Input source masks.
*
* Refer to the documentation on android.view.InputDevice for more details about input sources
* and their correct interpretation.
*/
InputSourceClassBits :: enum i32 {
BUTTON = 0,
POINTER = 1,
NAVIGATION = 2,
POSITION = 3,
JOYSTICK = 4,
}
InputSourceClass :: bit_set[InputSourceClassBits; i32]
/**
* Input sources.
*/
InputSourceDeviceBits :: enum i32 {
KEYBOARD = 0, // BUTTON
DPAD = 1, // BUTTON
GAMEPAD = 2, // BUTTON
TOUCHSCREEN = 4, // POINTER
MOUSE = 5, // POINTER
STYLUS = 6, // POINTER
// This activates both bit 6 and 7 but doing 7 only is fine too.
BLUETOOTH_STYLUS = 7, // POINTER
TRACKBALL = 8, // NAVIGATION
MOUSE_RELATIVE = 9, // NAVIGATION
TOUCHPAD = 12, // POSITION
TOUCH_NAVIGATION = 13, // NONE
ROTARY_ENCODER = 14, // NONE
JOYSTICK = 16, // JOYSTICK
HDMI = 17, // BUTTON
SENSOR = 18, // NONE
}
InputSourceDevice :: bit_set[InputSourceDeviceBits; i32]
// 0xDDDDDDCC
// D = Device
// C = Class
InputSource :: bit_field i32 {
// Transmute to InputSourceClass
class: i32 | 8,
// Transmute to InputSourceDevice
device: i32 | 24,
}
ANY_INPUT_SOURCE :: InputSourceDevice{ // -256 or 0xffffff00
.KEYBOARD,
.DPAD,
.GAMEPAD,
.TOUCHSCREEN,
.MOUSE,
.STYLUS,
.BLUETOOTH_STYLUS,
.TRACKBALL,
.MOUSE_RELATIVE,
.TOUCHPAD,
.TOUCH_NAVIGATION,
.JOYSTICK,
.HDMI,
.SENSOR,
.ROTARY_ENCODER,
}
/**
* Keyboard types.
*
* Refer to the documentation on android.view.InputDevice for more details.
* Note: When adding a new keyboard type here InputDeviceInfo::setKeyboardType needs to be updated.
*/
KeyBoardType :: enum {
NONE = 0,
NON_ALPHABETIC = 1,
TYPE_ALPHABETIC = 2,
}
/**
* Constants used to retrieve information about the range of motion for a particular
* coordinate of a motion event.
*
* Refer to the documentation on android.view.InputDevice for more details about input sources
* and their correct interpretation.
*
* @deprecated These constants are deprecated. Use {@link AMOTION_EVENT_AXIS AMOTION_EVENT_AXIS_*}
* constants instead.
*/
// TODO: should I just delete this ??
MotionRange :: enum {
X = 0,
Y = 1,
PRESSURE = 2,
SIZE = 3,
TOUCH_MAJOR = 4,
TOUCH_MINOR = 5,
TOOL_MAJOR = 6,
TOOL_MINOR = 7,
ORIENTATION = 8,
}
/**
* Input events.
*
* Input events are opaque structures. Use the provided accessors functions to
* read their properties.
*/
AInputEvent :: struct{}
/**
* Input queue
*
* An input queue is the facility through which you retrieve input
* events.
*/
AInputQueue :: struct{}
foreign android {
/** Get the input event type. */
AInputEvent_getType :: proc(event: ^AInputEvent) -> InputEventType ---
/** Get the id for the device that an input event came from.
*
* Input events can be generated by multiple different input devices.
* Use the input device id to obtain information about the input
* device that was responsible for generating a particular event.
*
* An input device id of 0 indicates that the event didn't come from a physical device
* other numbers are arbitrary and you shouldn't depend on the values.
* Use the provided input device query API to obtain information about input devices.
*/
AInputEvent_getDeviceId :: proc(event: ^AInputEvent) -> i32 ---
/** Get the input event source. */
AInputEvent_getSource :: proc(event: ^AInputEvent) -> InputSource ---
/**
* Releases interface objects created by {@link AKeyEvent_fromJava()}
* and {@link AMotionEvent_fromJava()}.
* After returning, the specified {@link AInputEvent}* object becomes invalid and should no longer
* be used. The underlying Java object remains valid and does not change its state.
*
* Available since API level 31.
*/
AInputEvent_release :: proc(event: ^AInputEvent) ---
/** Get the key event action. */
AKeyEvent_getAction :: proc(key_event: ^AInputEvent) -> KeyEventAction ---
/** Get the key event flags. */
AKeyEvent_getFlags :: proc(key_event: ^AInputEvent) -> KeyEventFlags ---
/**
* Get the key code of the key event.
* This is the physical key that was pressed, not the Unicode character.
*/
AKeyEvent_getKeyCode :: proc(key_event: ^AInputEvent) -> Keycode ---
/**
* Get the hardware key id of this key event.
* These values are not reliable and vary from device to device.
*/
AKeyEvent_getScanCode :: proc(key_event: ^AInputEvent) -> i32 ---
/** Get the meta key state. */
AKeyEvent_getMetaState :: proc(key_event: ^AInputEvent) -> MetaKeyState ---
/**
* Get the repeat count of the event.
* For both key up an key down events, this is the number of times the key has
* repeated with the first down starting at 0 and counting up from there. For
* multiple key events, this is the number of down/up pairs that have occurred.
*/
AKeyEvent_getRepeatCount :: proc(key_event: ^AInputEvent) -> i32 ---
/**
* Get the time of the most recent key down event, in the
* java.lang.System.nanoTime() time base. If this is a down event,
* this will be the same as eventTime.
* Note that when chording keys, this value is the down time of the most recently
* pressed key, which may not be the same physical key of this event.
*/
AKeyEvent_getDownTime :: proc(key_event: ^AInputEvent) -> i64 ---
/**
* Get the time this event occurred, in the
* java.lang.System.nanoTime() time base.
*/
AKeyEvent_getEventTime :: proc(key_event: ^AInputEvent) -> i64 ---
/**
* Creates a native {@link AInputEvent}* object that is a copy of the specified Java
* android.view.KeyEvent. The result may be used with generic and KeyEvent-specific AInputEvent_*
* functions. The object returned by this function must be disposed using
* {@link AInputEvent_release()}.
*
* Available since API level 31.
*/
AKeyEvent_fromJava :: proc(env: ^JNIEnv, keyEvent: jobject) -> ^AInputEvent ---
/** Get the combined motion event action code and pointer index. */
AMotionEvent_getAction :: proc(motion_event: ^AInputEvent) -> MotionEventAction ---
/** Get the motion event flags. */
AMotionEvent_getFlags :: proc(motion_event: ^AInputEvent) -> MotionEventFlags ---
/**
* Get the state of any meta / modifier keys that were in effect when the
* event was generated.
*/
AMotionEvent_getMetaState :: proc(motion_event: ^AInputEvent) -> MetaKeyState ---
/** Get the button state of all buttons that are pressed. */
// TODO: Do we have an enum or bit_set for this ??? this might be MotionEventButton but we'll double check by
// writing some code and printing values.
AMotionEvent_getButtonState :: proc(motion_event: ^AInputEvent) -> i32 ---
/**
* Get a bitfield indicating which edges, if any, were touched by this motion event.
* For touch events, clients can use this to determine if the user's finger was
* touching the edge of the display.
*/
AMotionEvent_getEdgeFlags :: proc(motion_event: ^AInputEvent) -> MotionEventEdgeFlags ---
/**
* Get the time when the user originally pressed down to start a stream of
* position events, in the java.lang.System.nanoTime() time base.
*/
AMotionEvent_getDownTime :: proc(motion_event: ^AInputEvent) -> i64 ---
/**
* Get the time when this specific event was generated,
* in the java.lang.System.nanoTime() time base.
*/
AMotionEvent_getEventTime :: proc(motion_event: ^AInputEvent) -> i64 ---
/**
* Get the X coordinate offset.
* For touch events on the screen, this is the delta that was added to the raw
* screen coordinates to adjust for the absolute position of the containing windows
* and views.
*/
AMotionEvent_getXOffset :: proc(motion_event: ^AInputEvent) -> f32 ---
/**
* Get the Y coordinate offset.
* For touch events on the screen, this is the delta that was added to the raw
* screen coordinates to adjust for the absolute position of the containing windows
* and views.
*/
AMotionEvent_getYOffset :: proc(motion_event: ^AInputEvent) -> f32 ---
/**
* Get the precision of the X coordinates being reported.
* You can multiply this number with an X coordinate sample to find the
* actual hardware value of the X coordinate.
*/
AMotionEvent_getXPrecision :: proc(#by_ptr motion_event: AInputEvent) -> f32 ---
/**
* Get the precision of the Y coordinates being reported.
* You can multiply this number with a Y coordinate sample to find the
* actual hardware value of the Y coordinate.
*/
AMotionEvent_getYPrecision :: proc(#by_ptr motion_event: AInputEvent) -> f32 ---
/**
* Get the number of pointers of data contained in this event.
* Always >= 1.
*/
AMotionEvent_getPointerCount :: proc(motion_event: ^AInputEvent) -> uint ---
/**
* Get the pointer identifier associated with a particular pointer
* data index in this event. The identifier tells you the actual pointer
* number associated with the data, accounting for individual pointers
* going up and down since the start of the current gesture.
*/
AMotionEvent_getPointerId :: proc(motion_event: ^AInputEvent, pointer_index: uint) -> i32 ---
/**
* Get the tool type of a pointer for the given pointer index.
* The tool type indicates the type of tool used to make contact such as a
* finger or stylus, if known.
*/
AMotionEvent_getToolType :: proc(motion_event: ^AInputEvent, pointer_index: uint) -> ToolType ---
/**
* Get the original raw X coordinate of this event.
* For touch events on the screen, this is the original location of the event
* on the screen, before it had been adjusted for the containing window
* and views.
*/
AMotionEvent_getRawX :: proc(motion_event: ^AInputEvent, pointer_index: uint) -> f32 ---
/**
* Get the original raw X coordinate of this event.
* For touch events on the screen, this is the original location of the event
* on the screen, before it had been adjusted for the containing window
* and views.
*/
AMotionEvent_getRawY :: proc(motion_event: ^AInputEvent, pointer_index: uint) -> f32 ---
/**
* Get the current X coordinate of this event for the given pointer index.
* Whole numbers are pixels the value may have a fraction for input devices
* that are sub-pixel precise.
*/
AMotionEvent_getX :: proc(motion_event: ^AInputEvent, pointer_index: uint) -> f32 ---
/**
* Get the current Y coordinate of this event for the given pointer index.
* Whole numbers are pixels the value may have a fraction for input devices
* that are sub-pixel precise.
*/
AMotionEvent_getY :: proc(motion_event: ^AInputEvent, pointer_index: uint) -> f32 ---
/**
* Get the current pressure of this event for the given pointer index.
* The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
* although values higher than 1 may be generated depending on the calibration of
* the input device.
*/
AMotionEvent_getPressure :: proc(motion_event: ^AInputEvent, pointer_index: uint) -> f32 ---
/**
* Get the current scaled value of the approximate size for the given pointer index.
* This represents some approximation of the area of the screen being
* pressed the actual value in pixels corresponding to the
* touch is normalized with the device specific range of values
* and scaled to a value between 0 and 1. The value of size can be used to
* determine fat touch events.
*/
AMotionEvent_getSize :: proc(motion_event: ^AInputEvent, pointer_index: uint) -> f32 ---
/**
* Get the current length of the major axis of an ellipse that describes the touch area
* at the point of contact for the given pointer index.
*/
AMotionEvent_getTouchMajor :: proc(motion_event: ^AInputEvent, pointer_index: uint) -> f32 ---
/**
* Get the current length of the minor axis of an ellipse that describes the touch area
* at the point of contact for the given pointer index.
*/
AMotionEvent_getTouchMinor :: proc(motion_event: ^AInputEvent, pointer_index: uint) -> f32 ---
/**
* Get the current length of the major axis of an ellipse that describes the size
* of the approaching tool for the given pointer index.
* The tool area represents the estimated size of the finger or pen that is
* touching the device independent of its actual touch area at the point of contact.
*/
AMotionEvent_getToolMajor :: proc(motion_event: ^AInputEvent, pointer_index: uint) -> f32 ---
/**
* Get the current length of the minor axis of an ellipse that describes the size
* of the approaching tool for the given pointer index.
* The tool area represents the estimated size of the finger or pen that is
* touching the device independent of its actual touch area at the point of contact.
*/
AMotionEvent_getToolMinor :: proc(motion_event: ^AInputEvent, pointer_index: uint) -> f32 ---
/**
* Get the current orientation of the touch area and tool area in radians clockwise from
* vertical for the given pointer index.
* An angle of 0 degrees indicates that the major axis of contact is oriented
* upwards, is perfectly circular or is of unknown orientation. A positive angle
* indicates that the major axis of contact is oriented to the right. A negative angle
* indicates that the major axis of contact is oriented to the left.
* The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
* (finger pointing fully right).
*/
AMotionEvent_getOrientation :: proc(motion_event: ^AInputEvent, pointer_index: uint) -> f32 ---
/** Get the value of the request axis for the given pointer index. */
AMotionEvent_getAxisValue :: proc(motion_event: ^AInputEvent, axis: MotionEventAxis, pointer_index: uint) -> f32 ---
/**
* Get the number of historical points in this event. These are movements that
* have occurred between this event and the previous event. This only applies
* to #AMOTION_EVENT_ACTION_MOVE events -- all other actions will have a size of 0.
* Historical samples are indexed from oldest to newest.
*/
AMotionEvent_getHistorySize :: proc(motion_event: ^AInputEvent) -> uint ---
/**
* Get the time that a historical movement occurred between this event and
* the previous event, in the java.lang.System.nanoTime() time base.
*/
AMotionEvent_getHistoricalEventTime :: proc(motion_event: ^AInputEvent, history_index: uint) -> i64 ---
/**
* Get the historical raw X coordinate of this event for the given pointer index that
* occurred between this event and the previous motion event.
* For touch events on the screen, this is the original location of the event
* on the screen, before it had been adjusted for the containing window
* and views.
* Whole numbers are pixels the value may have a fraction for input devices
* that are sub-pixel precise.
*/
AMotionEvent_getHistoricalRawX :: proc(motion_event: ^AInputEvent, pointer_index: uint, history_index: uint) -> f32 ---
/**
* Get the historical raw Y coordinate of this event for the given pointer index that
* occurred between this event and the previous motion event.
* For touch events on the screen, this is the original location of the event
* on the screen, before it had been adjusted for the containing window
* and views.
* Whole numbers are pixels the value may have a fraction for input devices
* that are sub-pixel precise.
*/
AMotionEvent_getHistoricalRawY :: proc(motion_event: ^AInputEvent, pointer_index: uint, history_index: uint) -> f32 ---
/**
* Get the historical X coordinate of this event for the given pointer index that
* occurred between this event and the previous motion event.
* Whole numbers are pixels the value may have a fraction for input devices
* that are sub-pixel precise.
*/
AMotionEvent_getHistoricalX :: proc(motion_event: ^AInputEvent, pointer_index: uint, history_index: uint) -> f32 ---
/**
* Get the historical Y coordinate of this event for the given pointer index that
* occurred between this event and the previous motion event.
* Whole numbers are pixels the value may have a fraction for input devices
* that are sub-pixel precise.
*/
AMotionEvent_getHistoricalY :: proc(motion_event: ^AInputEvent, pointer_index: uint, history_index: uint) -> f32 ---
/**
* Get the historical pressure of this event for the given pointer index that
* occurred between this event and the previous motion event.
* The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure),
* although values higher than 1 may be generated depending on the calibration of
* the input device.
*/
AMotionEvent_getHistoricalPressure :: proc(motion_event: ^AInputEvent, pointer_index: uint, history_index: uint) -> f32 ---
/**
* Get the current scaled value of the approximate size for the given pointer index that
* occurred between this event and the previous motion event.
* This represents some approximation of the area of the screen being
* pressed the actual value in pixels corresponding to the
* touch is normalized with the device specific range of values
* and scaled to a value between 0 and 1. The value of size can be used to
* determine fat touch events.
*/
AMotionEvent_getHistoricalSize :: proc(motion_event: ^AInputEvent, pointer_index: uint, history_index: uint) -> f32 ---
/**
* Get the historical length of the major axis of an ellipse that describes the touch area
* at the point of contact for the given pointer index that
* occurred between this event and the previous motion event.
*/
AMotionEvent_getHistoricalTouchMajor :: proc(motion_event: ^AInputEvent, pointer_index: uint, history_index: uint) -> f32 ---
/**
* Get the historical length of the minor axis of an ellipse that describes the touch area
* at the point of contact for the given pointer index that
* occurred between this event and the previous motion event.
*/
AMotionEvent_getHistoricalTouchMinor :: proc(motion_event: ^AInputEvent, pointer_index: uint, history_index: uint) -> f32 ---
/**
* Get the historical length of the major axis of an ellipse that describes the size
* of the approaching tool for the given pointer index that
* occurred between this event and the previous motion event.
* The tool area represents the estimated size of the finger or pen that is
* touching the device independent of its actual touch area at the point of contact.
*/
AMotionEvent_getHistoricalToolMajor :: proc(motion_event: ^AInputEvent, pointer_index: uint, history_index: uint) -> f32 ---
/**
* Get the historical length of the minor axis of an ellipse that describes the size
* of the approaching tool for the given pointer index that
* occurred between this event and the previous motion event.
* The tool area represents the estimated size of the finger or pen that is
* touching the device independent of its actual touch area at the point of contact.
*/
AMotionEvent_getHistoricalToolMinor :: proc(motion_event: ^AInputEvent, pointer_index: uint, history_index: uint) -> f32 ---
/**
* Get the historical orientation of the touch area and tool area in radians clockwise from
* vertical for the given pointer index that
* occurred between this event and the previous motion event.
* An angle of 0 degrees indicates that the major axis of contact is oriented
* upwards, is perfectly circular or is of unknown orientation. A positive angle
* indicates that the major axis of contact is oriented to the right. A negative angle
* indicates that the major axis of contact is oriented to the left.
* The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians
* (finger pointing fully right).
*/
AMotionEvent_getHistoricalOrientation :: proc(motion_event: ^AInputEvent, pointer_index: uint, history_index: uint) -> f32 ---
/**
* Get the historical value of the request axis for the given pointer index
* that occurred between this event and the previous motion event.
*/
AMotionEvent_getHistoricalAxisValue :: proc(motion_event: ^AInputEvent, axis: MotionEventAxis, pointer_index: uint, history_index: uint) -> f32 ---
/**
* Get the action button for the motion event. Returns a valid action button when the
* event is associated with a button press or button release action. For other actions
* the return value is undefined.
*
* Available since API level 33.
*
* @see #AMOTION_EVENT_BUTTON_PRIMARY
* @see #AMOTION_EVENT_BUTTON_SECONDARY
* @see #AMOTION_EVENT_BUTTON_TERTIARY
* @see #AMOTION_EVENT_BUTTON_BACK
* @see #AMOTION_EVENT_BUTTON_FORWARD
* @see #AMOTION_EVENT_BUTTON_STYLUS_PRIMARY
* @see #AMOTION_EVENT_BUTTON_STYLUS_SECONDARY
*/
AMotionEvent_getActionButton :: proc(motion_event: ^AInputEvent) -> MotionEventButton ---
/**
* Returns the classification for the current gesture.
* The classification may change as more events become available for the same gesture.
*
* Available since API level 33.
*
* @see #AMOTION_EVENT_CLASSIFICATION_NONE
* @see #AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE
* @see #AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS
*/
AMotionEvent_getClassification :: proc(motion_event: ^AInputEvent) -> AMotionClassification ---
/**
* Creates a native {@link AInputEvent}* object that is a copy of the specified Java
* android.view.MotionEvent. The result may be used with generic and MotionEvent-specific
* AInputEvent_* functions. The object returned by this function must be disposed using
* {@link AInputEvent_release()}.
*
* Available since API level 31.
*/
AMotionEvent_fromJava :: proc(env: ^JNIEnv, motionEvent: jobject) -> ^AInputEvent ---
/**
* Add this input queue to a looper for processing. See
* {@link ALooper_addFd()} for information on the ident, callback, and data params.
*/
AInputQueue_attachLooper :: proc(queue: ^AInputQueue, looper: ^ALooper, ident: i32, callback: ALooper_callbackFunc, data: rawptr) ---
/**
* Remove the input queue from the looper it is currently attached to.
*/
AInputQueue_detachLooper :: proc(queue: ^AInputQueue) ---
/**
* Returns true if there are one or more events available in the
* input queue. Returns 1 if the queue has events 0 if
* it does not have events and a negative value if there is an error.
*/
AInputQueue_hasEvents :: proc(queue: ^AInputQueue) -> i32 ---
/**
* Returns the next available event from the queue. Returns a negative
* value if no events are available or an error has occurred.
*/
AInputQueue_getEvent :: proc(queue: ^AInputQueue, outEvent: ^^AInputEvent) -> i32 ---
/**
* Sends the key for standard pre-dispatching -- that is, possibly deliver
* it to the current IME to be consumed before the app. Returns 0 if it
* was not pre-dispatched, meaning you can process it right now. If non-zero
* is returned, you must abandon the current event processing and allow the
* event to appear again in the event queue (if it does not get consumed during
* pre-dispatching).
*/
AInputQueue_preDispatchEvent :: proc(queue: ^AInputQueue, event: ^AInputEvent) -> i32 ---
/**
* Report that dispatching has finished with the given event.
* This must be called after receiving an event with {@link AInputQueue_getEvent()}.
*/
AInputQueue_finishEvent :: proc(queue: ^AInputQueue, event: ^AInputEvent, handled: i32) ---
/**
* Returns the {@link AInputQueue}* object associated with the supplied Java InputQueue
* object. The returned native object holds a weak reference to the Java object,
* and is only valid as long as the Java object has not yet been disposed. You
* should ensure that there is a strong reference to the Java object and that it
* has not been disposed before using the returned object.
*
* Available since API level 33.
*/
AInputQueue_fromJava :: proc(env: ^JNIEnv, inputQueue: jobject) -> ^AInputQueue ---
}