This commit is contained in:
2024-08-06 05:50:12 +02:00
parent 304defa642
commit ebafc90985
11 changed files with 10531 additions and 25 deletions
+2172
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+4
View File
@@ -1,5 +1,9 @@
package android package android
//
// Based on NDK r26b (26.1.10909125)
//
// Apparently the app still needs to have a manifest, it also MUST use the nativeactivity activity. // Apparently the app still needs to have a manifest, it also MUST use the nativeactivity activity.
// Apparently the native code MUST be built as a shared library and then loaded by the JNI(?) // Apparently the native code MUST be built as a shared library and then loaded by the JNI(?)
// Good ref: https://github.com/xlab/android-go/blob/master/examples/build-android.sh // Good ref: https://github.com/xlab/android-go/blob/master/examples/build-android.sh
+762
View File
@@ -0,0 +1,762 @@
//+build android
package android
Keycode :: enum {
/** Unknown key code. */
UNKNOWN = 0,
/** Soft Left key.
* Usually situated below the display on phones and used as a multi-function
* feature key for selecting a software defined function shown on the bottom left
* of the display. */
SOFT_LEFT = 1,
/** Soft Right key.
* Usually situated below the display on phones and used as a multi-function
* feature key for selecting a software defined function shown on the bottom right
* of the display. */
SOFT_RIGHT = 2,
/** Home key.
* This key is handled by the framework and is never delivered to applications. */
HOME = 3,
/** Back key. */
BACK = 4,
/** Call key. */
CALL = 5,
/** End Call key. */
ENDCALL = 6,
/** '0' key. */
KEY_0 = 7,
/** '1' key. */
KEY_1 = 8,
/** '2' key. */
KEY_2 = 9,
/** '3' key. */
KEY_3 = 10,
/** '4' key. */
KEY_4 = 11,
/** '5' key. */
KEY_5 = 12,
/** '6' key. */
KEY_6 = 13,
/** '7' key. */
KEY_7 = 14,
/** '8' key. */
KEY_8 = 15,
/** '9' key. */
KEY_9 = 16,
/** '*' key. */
STAR = 17,
/** '#' key. */
POUND = 18,
/** Directional Pad Up key.
* May also be synthesized from trackball motions. */
DPAD_UP = 19,
/** Directional Pad Down key.
* May also be synthesized from trackball motions. */
DPAD_DOWN = 20,
/** Directional Pad Left key.
* May also be synthesized from trackball motions. */
DPAD_LEFT = 21,
/** Directional Pad Right key.
* May also be synthesized from trackball motions. */
DPAD_RIGHT = 22,
/** Directional Pad Center key.
* May also be synthesized from trackball motions. */
DPAD_CENTER = 23,
/** Volume Up key.
* Adjusts the speaker volume up. */
VOLUME_UP = 24,
/** Volume Down key.
* Adjusts the speaker volume down. */
VOLUME_DOWN = 25,
/** Power key. */
POWER = 26,
/** Camera key.
* Used to launch a camera application or take pictures. */
CAMERA = 27,
/** Clear key. */
CLEAR = 28,
/** 'A' key. */
A = 29,
/** 'B' key. */
B = 30,
/** 'C' key. */
C = 31,
/** 'D' key. */
D = 32,
/** 'E' key. */
E = 33,
/** 'F' key. */
F = 34,
/** 'G' key. */
G = 35,
/** 'H' key. */
H = 36,
/** 'I' key. */
I = 37,
/** 'J' key. */
J = 38,
/** 'K' key. */
K = 39,
/** 'L' key. */
L = 40,
/** 'M' key. */
M = 41,
/** 'N' key. */
N = 42,
/** 'O' key. */
O = 43,
/** 'P' key. */
P = 44,
/** 'Q' key. */
Q = 45,
/** 'R' key. */
R = 46,
/** 'S' key. */
S = 47,
/** 'T' key. */
T = 48,
/** 'U' key. */
U = 49,
/** 'V' key. */
V = 50,
/** 'W' key. */
W = 51,
/** 'X' key. */
X = 52,
/** 'Y' key. */
Y = 53,
/** 'Z' key. */
Z = 54,
/** ',' key. */
COMMA = 55,
/** '.' key. */
PERIOD = 56,
/** Left Alt modifier key. */
ALT_LEFT = 57,
/** Right Alt modifier key. */
ALT_RIGHT = 58,
/** Left Shift modifier key. */
SHIFT_LEFT = 59,
/** Right Shift modifier key. */
SHIFT_RIGHT = 60,
/** Tab key. */
TAB = 61,
/** Space key. */
SPACE = 62,
/** Symbol modifier key.
* Used to enter alternate symbols. */
SYM = 63,
/** Explorer special function key.
* Used to launch a browser application. */
EXPLORER = 64,
/** Envelope special function key.
* Used to launch a mail application. */
ENVELOPE = 65,
/** Enter key. */
ENTER = 66,
/** Backspace key.
* Deletes characters before the insertion point, unlike {@link FORWARD_DEL}. */
DEL = 67,
/** '`' (backtick) key. */
GRAVE = 68,
/** '-'. */
MINUS = 69,
/** '=' key. */
EQUALS = 70,
/** '[' key. */
LEFT_BRACKET = 71,
/** ']' key. */
RIGHT_BRACKET = 72,
/** '\' key. */
BACKSLASH = 73,
/** ';' key. */
SEMICOLON = 74,
/** ''' (apostrophe) key. */
APOSTROPHE = 75,
/** '/' key. */
SLASH = 76,
/** '@' key. */
AT = 77,
/** Number modifier key.
* Used to enter numeric symbols.
* This key is not {@link NUM_LOCK}; it is more like {@link AKEYCODE_ALT_LEFT}. */
NUM = 78,
/** Headset Hook key.
* Used to hang up calls and stop media. */
HEADSETHOOK = 79,
/** Camera Focus key.
* Used to focus the camera. */
FOCUS = 80,
/** '+' key. */
PLUS = 81,
/** Menu key. */
MENU = 82,
/** Notification key. */
NOTIFICATION = 83,
/** Search key. */
SEARCH = 84,
/** Play/Pause media key. */
MEDIA_PLAY_PAUSE= 85,
/** Stop media key. */
MEDIA_STOP = 86,
/** Play Next media key. */
MEDIA_NEXT = 87,
/** Play Previous media key. */
MEDIA_PREVIOUS = 88,
/** Rewind media key. */
MEDIA_REWIND = 89,
/** Fast Forward media key. */
MEDIA_FAST_FORWARD = 90,
/** Mute key.
* Mutes the microphone, unlike {@link VOLUME_MUTE}. */
MUTE = 91,
/** Page Up key. */
PAGE_UP = 92,
/** Page Down key. */
PAGE_DOWN = 93,
/** Picture Symbols modifier key.
* Used to switch symbol sets (Emoji, Kao-moji). */
PICTSYMBOLS = 94,
/** Switch Charset modifier key.
* Used to switch character sets (Kanji, Katakana). */
SWITCH_CHARSET = 95,
/** A Button key.
* On a game controller, the A button should be either the button labeled A
* or the first button on the bottom row of controller buttons. */
BUTTON_A = 96,
/** B Button key.
* On a game controller, the B button should be either the button labeled B
* or the second button on the bottom row of controller buttons. */
BUTTON_B = 97,
/** C Button key.
* On a game controller, the C button should be either the button labeled C
* or the third button on the bottom row of controller buttons. */
BUTTON_C = 98,
/** X Button key.
* On a game controller, the X button should be either the button labeled X
* or the first button on the upper row of controller buttons. */
BUTTON_X = 99,
/** Y Button key.
* On a game controller, the Y button should be either the button labeled Y
* or the second button on the upper row of controller buttons. */
BUTTON_Y = 100,
/** Z Button key.
* On a game controller, the Z button should be either the button labeled Z
* or the third button on the upper row of controller buttons. */
BUTTON_Z = 101,
/** L1 Button key.
* On a game controller, the L1 button should be either the button labeled L1 (or L)
* or the top left trigger button. */
BUTTON_L1 = 102,
/** R1 Button key.
* On a game controller, the R1 button should be either the button labeled R1 (or R)
* or the top right trigger button. */
BUTTON_R1 = 103,
/** L2 Button key.
* On a game controller, the L2 button should be either the button labeled L2
* or the bottom left trigger button. */
BUTTON_L2 = 104,
/** R2 Button key.
* On a game controller, the R2 button should be either the button labeled R2
* or the bottom right trigger button. */
BUTTON_R2 = 105,
/** Left Thumb Button key.
* On a game controller, the left thumb button indicates that the left (or only)
* joystick is pressed. */
BUTTON_THUMBL = 106,
/** Right Thumb Button key.
* On a game controller, the right thumb button indicates that the right
* joystick is pressed. */
BUTTON_THUMBR = 107,
/** Start Button key.
* On a game controller, the button labeled Start. */
BUTTON_START = 108,
/** Select Button key.
* On a game controller, the button labeled Select. */
BUTTON_SELECT = 109,
/** Mode Button key.
* On a game controller, the button labeled Mode. */
BUTTON_MODE = 110,
/** Escape key. */
ESCAPE = 111,
/** Forward Delete key.
* Deletes characters ahead of the insertion point, unlike {@link DEL}. */
FORWARD_DEL = 112,
/** Left Control modifier key. */
CTRL_LEFT = 113,
/** Right Control modifier key. */
CTRL_RIGHT = 114,
/** Caps Lock key. */
CAPS_LOCK = 115,
/** Scroll Lock key. */
SCROLL_LOCK = 116,
/** Left Meta modifier key. */
META_LEFT = 117,
/** Right Meta modifier key. */
META_RIGHT = 118,
/** Function modifier key. */
FUNCTION = 119,
/** System Request / Print Screen key. */
SYSRQ = 120,
/** Break / Pause key. */
BREAK = 121,
/** Home Movement key.
* Used for scrolling or moving the cursor around to the start of a line
* or to the top of a list. */
MOVE_HOME = 122,
/** End Movement key.
* Used for scrolling or moving the cursor around to the end of a line
* or to the bottom of a list. */
MOVE_END = 123,
/** Insert key.
* Toggles insert / overwrite edit mode. */
INSERT = 124,
/** Forward key.
* Navigates forward in the history stack. Complement of {@link BACK}. */
FORWARD = 125,
/** Play media key. */
MEDIA_PLAY = 126,
/** Pause media key. */
MEDIA_PAUSE = 127,
/** Close media key.
* May be used to close a CD tray, for example. */
MEDIA_CLOSE = 128,
/** Eject media key.
* May be used to eject a CD tray, for example. */
MEDIA_EJECT = 129,
/** Record media key. */
MEDIA_RECORD = 130,
/** F1 key. */
F1 = 131,
/** F2 key. */
F2 = 132,
/** F3 key. */
F3 = 133,
/** F4 key. */
F4 = 134,
/** F5 key. */
F5 = 135,
/** F6 key. */
F6 = 136,
/** F7 key. */
F7 = 137,
/** F8 key. */
F8 = 138,
/** F9 key. */
F9 = 139,
/** F10 key. */
F10 = 140,
/** F11 key. */
F11 = 141,
/** F12 key. */
F12 = 142,
/** Num Lock key.
* This is the Num Lock key; it is different from {@link NUM}.
* This key alters the behavior of other keys on the numeric keypad. */
NUM_LOCK = 143,
/** Numeric keypad '0' key. */
NUMPAD_0 = 144,
/** Numeric keypad '1' key. */
NUMPAD_1 = 145,
/** Numeric keypad '2' key. */
NUMPAD_2 = 146,
/** Numeric keypad '3' key. */
NUMPAD_3 = 147,
/** Numeric keypad '4' key. */
NUMPAD_4 = 148,
/** Numeric keypad '5' key. */
NUMPAD_5 = 149,
/** Numeric keypad '6' key. */
NUMPAD_6 = 150,
/** Numeric keypad '7' key. */
NUMPAD_7 = 151,
/** Numeric keypad '8' key. */
NUMPAD_8 = 152,
/** Numeric keypad '9' key. */
NUMPAD_9 = 153,
/** Numeric keypad '/' key (for division). */
NUMPAD_DIVIDE = 154,
/** Numeric keypad '*' key (for multiplication). */
NUMPAD_MULTIPLY = 155,
/** Numeric keypad '-' key (for subtraction). */
NUMPAD_SUBTRACT = 156,
/** Numeric keypad '+' key (for addition). */
NUMPAD_ADD = 157,
/** Numeric keypad '.' key (for decimals or digit grouping). */
NUMPAD_DOT = 158,
/** Numeric keypad ',' key (for decimals or digit grouping). */
NUMPAD_COMMA = 159,
/** Numeric keypad Enter key. */
NUMPAD_ENTER = 160,
/** Numeric keypad '=' key. */
NUMPAD_EQUALS = 161,
/** Numeric keypad '(' key. */
NUMPAD_LEFT_PAREN = 162,
/** Numeric keypad ')' key. */
NUMPAD_RIGHT_PAREN = 163,
/** Volume Mute key.
* Mutes the speaker, unlike {@link MUTE}.
* This key should normally be implemented as a toggle such that the first press
* mutes the speaker and the second press restores the original volume. */
VOLUME_MUTE = 164,
/** Info key.
* Common on TV remotes to show additional information related to what is
* currently being viewed. */
INFO = 165,
/** Channel up key.
* On TV remotes, increments the television channel. */
CHANNEL_UP = 166,
/** Channel down key.
* On TV remotes, decrements the television channel. */
CHANNEL_DOWN = 167,
/** Zoom in key. */
ZOOM_IN = 168,
/** Zoom out key. */
ZOOM_OUT = 169,
/** TV key.
* On TV remotes, switches to viewing live TV. */
TV = 170,
/** Window key.
* On TV remotes, toggles picture-in-picture mode or other windowing functions. */
WINDOW = 171,
/** Guide key.
* On TV remotes, shows a programming guide. */
GUIDE = 172,
/** DVR key.
* On some TV remotes, switches to a DVR mode for recorded shows. */
DVR = 173,
/** Bookmark key.
* On some TV remotes, bookmarks content or web pages. */
BOOKMARK = 174,
/** Toggle captions key.
* Switches the mode for closed-captioning text, for example during television shows. */
CAPTIONS = 175,
/** Settings key.
* Starts the system settings activity. */
SETTINGS = 176,
/** TV power key.
* On TV remotes, toggles the power on a television screen. */
TV_POWER = 177,
/** TV input key.
* On TV remotes, switches the input on a television screen. */
TV_INPUT = 178,
/** Set-top-box power key.
* On TV remotes, toggles the power on an external Set-top-box. */
STB_POWER = 179,
/** Set-top-box input key.
* On TV remotes, switches the input mode on an external Set-top-box. */
STB_INPUT = 180,
/** A/V Receiver power key.
* On TV remotes, toggles the power on an external A/V Receiver. */
AVR_POWER = 181,
/** A/V Receiver input key.
* On TV remotes, switches the input mode on an external A/V Receiver. */
AVR_INPUT = 182,
/** Red "programmable" key.
* On TV remotes, acts as a contextual/programmable key. */
PROG_RED = 183,
/** Green "programmable" key.
* On TV remotes, actsas a contextual/programmable key. */
PROG_GREEN = 184,
/** Yellow "programmable" key.
* On TV remotes, acts as a contextual/programmable key. */
PROG_YELLOW = 185,
/** Blue "programmable" key.
* On TV remotes, acts as a contextual/programmable key. */
PROG_BLUE = 186,
/** App switch key.
* Should bring up the application switcher dialog. */
APP_SWITCH = 187,
/** Generic Game Pad Button #1.*/
BUTTON_1 = 188,
/** Generic Game Pad Button #2.*/
BUTTON_2 = 189,
/** Generic Game Pad Button #3.*/
BUTTON_3 = 190,
/** Generic Game Pad Button #4.*/
BUTTON_4 = 191,
/** Generic Game Pad Button #5.*/
BUTTON_5 = 192,
/** Generic Game Pad Button #6.*/
BUTTON_6 = 193,
/** Generic Game Pad Button #7.*/
BUTTON_7 = 194,
/** Generic Game Pad Button #8.*/
BUTTON_8 = 195,
/** Generic Game Pad Button #9.*/
BUTTON_9 = 196,
/** Generic Game Pad Button #10.*/
BUTTON_10 = 197,
/** Generic Game Pad Button #11.*/
BUTTON_11 = 198,
/** Generic Game Pad Button #12.*/
BUTTON_12 = 199,
/** Generic Game Pad Button #13.*/
BUTTON_13 = 200,
/** Generic Game Pad Button #14.*/
BUTTON_14 = 201,
/** Generic Game Pad Button #15.*/
BUTTON_15 = 202,
/** Generic Game Pad Button #16.*/
BUTTON_16 = 203,
/** Language Switch key.
* Toggles the current input language such as switching between English and Japanese on
* a QWERTY keyboard. On some devices, the same function may be performed by
* pressing Shift+Spacebar. */
LANGUAGE_SWITCH = 204,
/** Manner Mode key.
* Toggles silent or vibrate mode on and off to make the device behave more politely
* in certain settings such as on a crowded train. On some devices, the key may only
* operate when long-pressed. */
MANNER_MODE = 205,
/** 3D Mode key.
* Toggles the display between 2D and 3D mode. */
3D_MODE = 206,
/** Contacts special function key.
* Used to launch an address book application. */
CONTACTS = 207,
/** Calendar special function key.
* Used to launch a calendar application. */
CALENDAR = 208,
/** Music special function key.
* Used to launch a music player application. */
MUSIC = 209,
/** Calculator special function key.
* Used to launch a calculator application. */
CALCULATOR = 210,
/** Japanese full-width / half-width key. */
ZENKAKU_HANKAKU = 211,
/** Japanese alphanumeric key. */
EISU = 212,
/** Japanese non-conversion key. */
MUHENKAN = 213,
/** Japanese conversion key. */
HENKAN = 214,
/** Japanese katakana / hiragana key. */
KATAKANA_HIRAGANA = 215,
/** Japanese Yen key. */
YEN = 216,
/** Japanese Ro key. */
RO = 217,
/** Japanese kana key. */
KANA = 218,
/** Assist key.
* Launches the global assist activity. Not delivered to applications. */
ASSIST = 219,
/** Brightness Down key.
* Adjusts the screen brightness down. */
BRIGHTNESS_DOWN = 220,
/** Brightness Up key.
* Adjusts the screen brightness up. */
BRIGHTNESS_UP = 221,
/** Audio Track key.
* Switches the audio tracks. */
MEDIA_AUDIO_TRACK = 222,
/** Sleep key.
* Puts the device to sleep. Behaves somewhat like {@link POWER} but it
* has no effect if the device is already asleep. */
SLEEP = 223,
/** Wakeup key.
* Wakes up the device. Behaves somewhat like {@link POWER} but it
* has no effect if the device is already awake. */
WAKEUP = 224,
/** Pairing key.
* Initiates peripheral pairing mode. Useful for pairing remote control
* devices or game controllers, especially if no other input mode is
* available. */
PAIRING = 225,
/** Media Top Menu key.
* Goes to the top of media menu. */
MEDIA_TOP_MENU = 226,
/** '11' key. */
11 = 227,
/** '12' key. */
12 = 228,
/** Last Channel key.
* Goes to the last viewed channel. */
LAST_CHANNEL = 229,
/** TV data service key.
* Displays data services like weather, sports. */
TV_DATA_SERVICE = 230,
/** Voice Assist key.
* Launches the global voice assist activity. Not delivered to applications. */
VOICE_ASSIST = 231,
/** Radio key.
* Toggles TV service / Radio service. */
TV_RADIO_SERVICE = 232,
/** Teletext key.
* Displays Teletext service. */
TV_TELETEXT = 233,
/** Number entry key.
* Initiates to enter multi-digit channel nubmber when each digit key is assigned
* for selecting separate channel. Corresponds to Number Entry Mode (0x1D) of CEC
* User Control Code. */
TV_NUMBER_ENTRY = 234,
/** Analog Terrestrial key.
* Switches to analog terrestrial broadcast service. */
TV_TERRESTRIAL_ANALOG = 235,
/** Digital Terrestrial key.
* Switches to digital terrestrial broadcast service. */
TV_TERRESTRIAL_DIGITAL = 236,
/** Satellite key.
* Switches to digital satellite broadcast service. */
TV_SATELLITE = 237,
/** BS key.
* Switches to BS digital satellite broadcasting service available in Japan. */
TV_SATELLITE_BS = 238,
/** CS key.
* Switches to CS digital satellite broadcasting service available in Japan. */
TV_SATELLITE_CS = 239,
/** BS/CS key.
* Toggles between BS and CS digital satellite services. */
TV_SATELLITE_SERVICE = 240,
/** Toggle Network key.
* Toggles selecting broacast services. */
TV_NETWORK = 241,
/** Antenna/Cable key.
* Toggles broadcast input source between antenna and cable. */
TV_ANTENNA_CABLE = 242,
/** HDMI #1 key.
* Switches to HDMI input #1. */
TV_INPUT_HDMI_1 = 243,
/** HDMI #2 key.
* Switches to HDMI input #2. */
TV_INPUT_HDMI_2 = 244,
/** HDMI #3 key.
* Switches to HDMI input #3. */
TV_INPUT_HDMI_3 = 245,
/** HDMI #4 key.
* Switches to HDMI input #4. */
TV_INPUT_HDMI_4 = 246,
/** Composite #1 key.
* Switches to composite video input #1. */
TV_INPUT_COMPOSITE_1 = 247,
/** Composite #2 key.
* Switches to composite video input #2. */
TV_INPUT_COMPOSITE_2 = 248,
/** Component #1 key.
* Switches to component video input #1. */
TV_INPUT_COMPONENT_1 = 249,
/** Component #2 key.
* Switches to component video input #2. */
TV_INPUT_COMPONENT_2 = 250,
/** VGA #1 key.
* Switches to VGA (analog RGB) input #1. */
TV_INPUT_VGA_1 = 251,
/** Audio description key.
* Toggles audio description off / on. */
TV_AUDIO_DESCRIPTION = 252,
/** Audio description mixing volume up key.
* Louden audio description volume as compared with normal audio volume. */
TV_AUDIO_DESCRIPTION_MIX_UP = 253,
/** Audio description mixing volume down key.
* Lessen audio description volume as compared with normal audio volume. */
TV_AUDIO_DESCRIPTION_MIX_DOWN = 254,
/** Zoom mode key.
* Changes Zoom mode (Normal, Full, Zoom, Wide-zoom, etc.) */
TV_ZOOM_MODE = 255,
/** Contents menu key.
* Goes to the title list. Corresponds to Contents Menu (0x0B) of CEC User Control
* Code */
TV_CONTENTS_MENU = 256,
/** Media context menu key.
* Goes to the context menu of media contents. Corresponds to Media Context-sensitive
* Menu (0x11) of CEC User Control Code. */
TV_MEDIA_CONTEXT_MENU = 257,
/** Timer programming key.
* Goes to the timer recording menu. Corresponds to Timer Programming (0x54) of
* CEC User Control Code. */
TV_TIMER_PROGRAMMING = 258,
/** Help key. */
HELP = 259,
NAVIGATE_PREVIOUS = 260,
NAVIGATE_NEXT = 261,
NAVIGATE_IN = 262,
NAVIGATE_OUT = 263,
/** Primary stem key for Wear
* Main power/reset button on watch. */
STEM_PRIMARY = 264,
/** Generic stem key 1 for Wear */
STEM_1 = 265,
/** Generic stem key 2 for Wear */
STEM_2 = 266,
/** Generic stem key 3 for Wear */
STEM_3 = 267,
/** Directional Pad Up-Left */
DPAD_UP_LEFT = 268,
/** Directional Pad Down-Left */
DPAD_DOWN_LEFT = 269,
/** Directional Pad Up-Right */
DPAD_UP_RIGHT = 270,
/** Directional Pad Down-Right */
DPAD_DOWN_RIGHT = 271,
/** Skip forward media key */
MEDIA_SKIP_FORWARD = 272,
/** Skip backward media key */
MEDIA_SKIP_BACKWARD = 273,
/** Step forward media key.
* Steps media forward one from at a time. */
MEDIA_STEP_FORWARD = 274,
/** Step backward media key.
* Steps media backward one from at a time. */
MEDIA_STEP_BACKWARD = 275,
/** Put device to sleep unless a wakelock is held. */
SOFT_SLEEP = 276,
/** Cut key. */
CUT = 277,
/** Copy key. */
COPY = 278,
/** Paste key. */
PASTE = 279,
/** fingerprint navigation key, up. */
SYSTEM_NAVIGATION_UP = 280,
/** fingerprint navigation key, down. */
SYSTEM_NAVIGATION_DOWN = 281,
/** fingerprint navigation key, left. */
SYSTEM_NAVIGATION_LEFT = 282,
/** fingerprint navigation key, right. */
SYSTEM_NAVIGATION_RIGHT = 283,
/** all apps */
ALL_APPS = 284,
/** refresh key */
REFRESH = 285,
/** Thumbs up key. Apps can use this to let user upvote content. */
THUMBS_UP = 286,
/** Thumbs down key. Apps can use this to let user downvote content. */
THUMBS_DOWN = 287,
/** Used to switch current account that is consuming content.
* May be consumed by system to switch current viewer profile. */
PROFILE_SWITCH = 288,
/** Video Application key #1. */
VIDEO_APP_1 = 289,
/** Video Application key #2. */
VIDEO_APP_2 = 290,
/** Video Application key #3. */
VIDEO_APP_3 = 291,
/** Video Application key #4. */
VIDEO_APP_4 = 292,
/** Video Application key #5. */
VIDEO_APP_5 = 293,
/** Video Application key #6. */
VIDEO_APP_6 = 294,
/** Video Application key #7. */
VIDEO_APP_7 = 295,
/** Video Application key #8. */
VIDEO_APP_8 = 296,
/** Featured Application key #1. */
FEATURED_APP_1 = 297,
/** Featured Application key #2. */
FEATURED_APP_2 = 298,
/** Featured Application key #3. */
FEATURED_APP_3 = 299,
/** Featured Application key #4. */
FEATURED_APP_4 = 300,
/** Demo Application key #1. */
DEMO_APP_1 = 301,
/** Demo Application key #2. */
DEMO_APP_2 = 302,
/** Demo Application key #3. */
DEMO_APP_3 = 303,
/** Demo Application key #4. */
DEMO_APP_4 = 304,
}
+213 -3
View File
@@ -1,10 +1,96 @@
//+build android //+build android
package android package android
import "core:c"
foreign import android "system:android" foreign import android "system:android"
/** Option for for ALooper_prepare(). */
/**
* This looper will accept calls to ALooper_addFd() that do not
* have a callback (that is provide NULL for the callback). In
* this case the caller of ALooper_pollOnce() or ALooper_pollAll()
* MUST check the return from these functions to discover when
* data is available on such fds and process it.
*/
ALOOPER_PREPARE_ALLOW_NON_CALLBACKS = 1<<0
/** Result from ALooper_pollOnce() and ALooper_pollAll(). */
ALooperPollResult :: enum i32 {
/**
* The poll was awoken using wake() before the timeout expired
* and no callbacks were executed and no other file descriptors were ready.
*/
WAKE = -1,
/**
* Result from ALooper_pollOnce() and ALooper_pollAll():
* One or more callbacks were executed.
*/
CALLBACK = -2,
/**
* Result from ALooper_pollOnce() and ALooper_pollAll():
* The timeout expired.
*/
TIMEOUT = -3,
/**
* Result from ALooper_pollOnce() and ALooper_pollAll():
* An error occurred.
*/
ERROR = -4,
}
PollResultOrIdent :: union {
ALooperPollResult,
i32,
}
/**
* Flags for file descriptor events that a looper can monitor.
*
* These flag bits can be combined to monitor multiple events at once.
*/
ALooperFdFlagsBits :: enum i32 {
/**
* The file descriptor is available for read operations.
*/
INPUT = 0,
/**
* The file descriptor is available for write operations.
*/
OUTPUT = 1,
/**
* The file descriptor has encountered an error condition.
*
* The looper always sends notifications about errors; it is not necessary
* to specify this event flag in the requested event set.
*/
ERROR = 2,
/**
* The file descriptor was hung up.
* For example, indicates that the remote end of a pipe or socket was closed.
*
* The looper always sends notifications about hangups; it is not necessary
* to specify this event flag in the requested event set.
*/
HANGUP = 3,
/**
* The file descriptor is invalid.
* For example, the file descriptor was closed prematurely.
*
* The looper always sends notifications about invalid file descriptors; it is not necessary
* to specify this event flag in the requested event set.
*/
INVALID = 4,
}
ALooperFdFlags :: bit_set[ALooperFdFlagsBits; i32]
/** /**
* ALooper * ALooper
* *
@@ -20,11 +106,135 @@ foreign import android "system:android"
*/ */
ALooper :: struct{} ALooper :: struct{}
/**
* For callback-based event loops, this is the prototype of the function
* that is called when a file descriptor event occurs.
* It is given the file descriptor it is associated with,
* a bitmask of the poll events that were triggered (typically ALOOPER_EVENT_INPUT),
* and the data pointer that was originally supplied.
*
* Implementations should return 1 to continue receiving callbacks, or 0
* to have this file descriptor and callback unregistered from the looper.
*/
ALooper_callbackFunc :: #type proc "c" (fd: i32, events: ALooperFdFlags, data: rawptr) -> i32
foreign android { foreign android {
/**
* Returns the looper associated with the calling thread, or NULL if
* there is not one.
*/
ALooper_forThread :: proc() -> ^ALooper ---
/**
* Prepares a looper associated with the calling thread, and returns it.
* If the thread already has a looper, it is returned. Otherwise, a new
* one is created, associated with the thread, and returned.
*
* The opts may be ALOOPER_PREPARE_ALLOW_NON_CALLBACKS or 0.
*/
ALooper_prepare :: proc(opts: i32) -> ^ALooper ---
/**
* Acquire a reference on the given ALooper object. This prevents the object
* from being deleted until the reference is removed. This is only needed
* to safely hand an ALooper from one thread to another.
*/
ALooper_acquire :: proc(looper: ^ALooper) ---
/**
* Remove a reference that was previously acquired with ALooper_acquire().
*/
ALooper_release :: proc(looper: ^ALooper) ---
/**
* Waits for events to be available, with optional timeout in milliseconds.
* Invokes callbacks for all file descriptors on which an event occurred.
*
* If the timeout is zero, returns immediately without blocking.
* If the timeout is negative, waits indefinitely until an event appears.
*
* Returns ALOOPER_POLL_WAKE if the poll was awoken using wake() before
* the timeout expired and no callbacks were invoked and no other file
* descriptors were ready.
*
* Returns ALOOPER_POLL_CALLBACK if one or more callbacks were invoked.
*
* Returns ALOOPER_POLL_TIMEOUT if there was no data before the given
* timeout expired.
*
* Returns ALOOPER_POLL_ERROR if an error occurred.
*
* Returns a value >= 0 containing an identifier (the same identifier
* `ident` passed to ALooper_addFd()) if its file descriptor has data
* and it has no callback function (requiring the caller here to
* handle it). In this (and only this) case outFd, outEvents and
* outData will contain the poll events and data associated with the
* fd, otherwise they will be set to NULL.
*
* This method does not return until it has finished invoking the appropriate callbacks
* for all file descriptors that were signalled.
*/
ALooper_pollOnce :: proc(timeoutMillis: i32, outFd: ^i32, outEvents: ^i32, outData: ^rawptr) -> PollResultOrIdent ---
/** /**
* Like ALooper_pollOnce(), but performs all pending callbacks until all * Like ALooper_pollOnce(), but performs all pending callbacks until all
* data has been consumed or a file descriptor is available with no callback. * data has been consumed or a file descriptor is available with no callback.
* This function will never return ALOOPER_POLL_CALLBACK. * This function will never return ALOOPER_POLL_CALLBACK.
*/ */
ALooper_pollAll :: proc(timeoutMillis: c.int, outFd: ^c.int, outEvents: ^c.int, outData: ^rawptr) -> c.int --- ALooper_pollAll :: proc(timeoutMillis: i32, outFd: ^i32, outEvents: ^i32, outData: ^rawptr) -> PollResultOrIdent ---
/**
* Wakes the poll asynchronously.
*
* This method can be called on any thread.
* This method returns immediately.
*/
ALooper_wake :: proc(looper: ^ALooper) ---
/**
* Adds a new file descriptor to be polled by the looper.
* If the same file descriptor was previously added, it is replaced.
*
* "fd" is the file descriptor to be added.
* "ident" is an identifier for this event, which is returned from ALooper_pollOnce().
* The identifier must be >= 0, or ALOOPER_POLL_CALLBACK if providing a non-NULL callback.
* "events" are the poll events to wake up on. Typically this is ALOOPER_EVENT_INPUT.
* "callback" is the function to call when there is an event on the file descriptor.
* "data" is a private data pointer to supply to the callback.
*
* There are two main uses of this function:
*
* (1) If "callback" is non-NULL, then this function will be called when there is
* data on the file descriptor. It should execute any events it has pending,
* appropriately reading from the file descriptor. The 'ident' is ignored in this case.
*
* (2) If "callback" is NULL, the 'ident' will be returned by ALooper_pollOnce
* when its file descriptor has data available, requiring the caller to take
* care of processing it.
*
* Returns 1 if the file descriptor was added or -1 if an error occurred.
*
* This method can be called on any thread.
* This method may block briefly if it needs to wake the poll.
*/
ALooper_addFd :: proc(looper: ^ALooper, fd: i32, ident: i32, events: ALooperFdFlags, callback: ALooper_callbackFunc, data: rawptr) -> i32 ---
/**
* Removes a previously added file descriptor from the looper.
*
* When this method returns, it is safe to close the file descriptor since the looper
* will no longer have a reference to it. However, it is possible for the callback to
* already be running or for it to run one last time if the file descriptor was already
* signalled. Calling code is responsible for ensuring that this case is safely handled.
* For example, if the callback takes care of removing itself during its own execution either
* by returning 0 or by calling this method, then it can be guaranteed to not be invoked
* again at any later time unless registered anew.
*
* Returns 1 if the file descriptor was removed, 0 if none was previously registered
* or -1 if an error occurred.
*
* This method can be called on any thread.
* This method may block briefly if it needs to wake the poll.
*/
ALooper_removeFd :: proc(looper: ^ALooper, fd: i32) -> i32 ---
} }
+262
View File
@@ -0,0 +1,262 @@
//+build android
package android
foreign import android "system:android"
/**
* The corresponding C type for android.net.Network#getNetworkHandle() return
* values. The Java signed long value can be safely cast to a net_handle_t:
*
* [C] ((net_handle_t) java_long_network_handle)
* [C++] static_cast<net_handle_t>(java_long_network_handle)
*
* as appropriate.
*/
net_handle_t :: distinct u64
uid_t :: u32
/**
* The value NETWORK_UNSPECIFIED indicates no specific network.
*
* For some functions (documented below), a previous binding may be cleared
* by an invocation with NETWORK_UNSPECIFIED.
*
* Depending on the context it may indicate an error. It is expressly
* not used to indicate some notion of the "current default network".
*/
NETWORK_UNSPECIFIED :: net_handle_t(0)
/**
* Possible values of the flags argument to android_res_nsend and android_res_nquery.
* Values are ORed together.
*/
ResNsendFlagsBits :: enum u32 {
/**
* Send a single request to a single resolver and fail on timeout or network errors
*/
RESOLV_NO_RETRY = 0,
/**
* Don't lookup this request in the cache, and don't cache the result of the lookup.
* This flag implies {@link #ANDROID_RESOLV_NO_CACHE_LOOKUP}.
*/
RESOLV_NO_CACHE_STORE = 1,
/**
* Don't lookup the request in cache.
*/
RESOLV_NO_CACHE_LOOKUP = 2,
}
ResNsendFlags :: bit_set[ResNsendFlagsBits; u32]
foreign android {
/**
* All functions below that return an i32 return 0 on success or -1
* on failure with an appropriate errno value set.
*/
/**
* Set the network to be used by the given socket file descriptor.
*
* To clear a previous socket binding, invoke with NETWORK_UNSPECIFIED.
*
* This is the equivalent of: [android.net.Network#bindSocket()](https://developer.android.com/reference/android/net/Network.html#bindSocket(java.net.Socket))
*
* Available since API level 23.
*/
android_setsocknetwork :: proc(network: net_handle_t, fd: i32) -> i32 ---
/**
* Binds the current process to |network|. All sockets created in the future
* (and not explicitly bound via android_setsocknetwork()) will be bound to
* |network|. All host name resolutions will be limited to |network| as well.
* Note that if the network identified by |network| ever disconnects, all
* sockets created in this way will cease to work and all host name
* resolutions will fail. This is by design so an application doesn't
* accidentally use sockets it thinks are still bound to a particular network.
*
* To clear a previous process binding, invoke with NETWORK_UNSPECIFIED.
*
* This is the equivalent of: [android.net.ConnectivityManager#bindProcessToNetwork()](https://developer.android.com/reference/android/net/ConnectivityManager.html#bindProcessToNetwork(android.net.Network))
*
* Available since API level 23.
*/
android_setprocnetwork :: proc(network: net_handle_t) -> i32 ---
/**
* Gets the |network| bound to the current process, as per android_setprocnetwork.
*
* This is the equivalent of: [android.net.ConnectivityManager#getBoundNetworkForProcess()](https://developer.android.com/reference/android/net/ConnectivityManager.html#getBoundNetworkForProcess(android.net.Network))
* Returns 0 on success, or -1 setting errno to EINVAL if a null pointer is
* passed in.
*
*
* Available since API level 31.
*/
android_getprocnetwork :: proc(network: ^net_handle_t) -> i32 ---
/**
* Binds domain name resolutions performed by this process to |network|.
* android_setprocnetwork takes precedence over this setting.
*
* To clear a previous process binding, invoke with NETWORK_UNSPECIFIED.
* On success 0 is returned. On error -1 is returned, and errno is set.
*
* Available since API level 31.
*/
android_setprocdns :: proc(network: net_handle_t) -> i32 ---
/**
* Gets the |network| to which domain name resolutions are bound on the
* current process.
*
* Returns 0 on success, or -1 setting errno to EINVAL if a null pointer is
* passed in.
*
* Available since API level 31.
*/
android_getprocdns :: proc(network: ^net_handle_t) -> i32 ---
/**
* Perform hostname resolution via the DNS servers associated with |network|.
*
* All arguments (apart from |network|) are used identically as those passed
* to getaddrinfo(3). Return and error values are identical to those of
* getaddrinfo(3), and in particular gai_strerror(3) can be used as expected.
* Similar to getaddrinfo(3):
* - |hints| may be NULL (in which case man page documented defaults apply)
* - either |node| or |service| may be NULL, but not both
* - |res| must not be NULL
*
* This is the equivalent of: [android.net.Network#getAllByName()](https://developer.android.com/reference/android/net/Network.html#getAllByName(java.lang.String))
*
* Available since API level 23.
*/
android_getaddrinfofornetwork :: proc(network: net_handle_t, node: cstring, service: cstring, hints: ^addrinfo, res: ^^addrinfo) -> i32 ---
/**
* Look up the {|ns_class|, |ns_type|} Resource Record (RR) associated
* with Domain Name |dname| on the given |network|.
* The typical value for |ns_class| is ns_c_in, while |type| can be any
* record type (for instance, ns_t_aaaa or ns_t_txt).
* |flags| is a additional config to control actual querying behavior, see
* ResNsendFlags for detail.
*
* Returns a file descriptor to watch for read events, or a negative
* POSIX error code (see errno.h) if an immediate error occurs.
*
* Available since API level 29.
*/
android_res_nquery :: proc(network: net_handle_t, dname: cstring, ns_class: i32, ns_type: i32, flags: ResNsendFlags) -> i32 ---
/**
* Issue the query |msg| on the given |network|.
* |flags| is a additional config to control actual querying behavior, see
* ResNsendFlags for detail.
*
* Returns a file descriptor to watch for read events, or a negative
* POSIX error code (see errno.h) if an immediate error occurs.
*
* Available since API level 29.
*/
android_res_nsend :: proc(network: net_handle_t, msg: [^]byte, msglen: uint, flags: ResNsendFlags) -> i32 ---
/**
* Read a result for the query associated with the |fd| descriptor.
* Closes |fd| before returning.
*
* Available since 29.
*
* Returns:
* < 0: negative POSIX error code (see errno.h for possible values). |rcode| is not set.
* >= 0: length of |answer|. |rcode| is the resolver return code (e.g., ns_r_nxdomain)
*/
android_res_nresult :: proc(fd: i32, rcode: ^int, answer: [^]byte, anslen: uint) -> i32 ---
/**
* Attempts to cancel the in-progress query associated with the |nsend_fd|
* descriptor.
*
* Available since API level 29.
*/
android_res_cancel :: proc(nsend_fd: i32) ---
/*
* Set the socket tag and owning UID for traffic statistics on the specified
* socket.
*
* Subsequent calls always replace any existing parameters. The socket tag and
* uid (if set) are kept when the socket is sent to another process using binder
* IPCs or other mechanisms such as UNIX socket fd passing. Any app can accept
* blame for future traffic performed on a socket originally created by another
* app by calling this method with its own UID (or calling
* android_tag_socket(int sockfd, int tag)). However, only apps holding the
* android.Manifest.permission#UPDATE_DEVICE_STATS permission may assign blame
* to another UIDs. If unset (default) the socket tag is 0, and the uid is the
* socket creator's uid.
*
* Returns 0 on success, or a negative POSIX error code (see errno.h) on
* failure.
*
* Available since API level 33.
*/
android_tag_socket_with_uid :: proc(sockfd: i32, tag: u32, uid: uid_t) -> i32 ---
/*
* Set the socket tag for traffic statistics on the specified socket.
*
* This function tags the socket with the caller's UID (accepting blame for
* future traffic performed on this socket) even if the socket was originally
* opened by another UID or was previously tagged by another UID. Subsequent
* calls always replace any existing parameters. The socket tag is kept when the
* socket is sent to another process using binder IPCs or other mechanisms such
* as UNIX socket fd passing. The tag is a value defined by the caller and used
* together with uid for data traffic accounting, so that the function callers
* can account different types of data usage for a uid.
*
* Returns 0 on success, or a negative POSIX error code (see errno.h) on
* failure.
*
* Some possible error codes:
* -EBADF Bad socketfd.
* -EPERM No permission.
* -EAFNOSUPPORT Socket family is neither AF_INET nor AF_INET6.
* -EPROTONOSUPPORT Socket protocol is neither IPPROTO_UDP nor IPPROTO_TCP.
* -EMFILE Too many stats entries.
* There are still other error codes that may provided by -errno of
* [getsockopt()](https://man7.org/linux/man-pages/man2/getsockopt.2.html) or by
* BPF maps read/write sys calls, which are set appropriately.
*
* Available since API level 33.
*/
android_tag_socket :: proc(sockfd: i32, tag: u32) -> i32 ---
/*
* Untag a network socket.
*
* Future traffic on this socket will no longer be associated with any
* previously configured tag and uid. If the socket was created by another UID
* or was previously tagged by another UID, calling this function will clear the
* statistics parameters, and thus the UID blamed for traffic on the socket will
* be the UID that originally created the socket, even if the socket was
* subsequently tagged by a different UID.
*
* Returns 0 on success, or a negative POSIX error code (see errno.h) on
* failure.
*
* One of possible error code:
* -EBADF Bad socketfd.
* Other error codes are either provided by -errno of
* [getsockopt()](https://man7.org/linux/man-pages/man2/getsockopt.2.html) or by
* BPF map element deletion sys call, which are set appropriately.
*
* Available since API level 33.
*/
android_untag_socket :: proc(sockfd: i32) -> i32 ---
}
+95 -4
View File
@@ -1,7 +1,43 @@
//+build android //+build android
package android package android
import "core:c" foreign import android "system:android"
/**
* Flags for ANativeActivity_showSoftInput see the Java InputMethodManager
* API for documentation.
*/
ShowSoftInputFlags :: enum u32 {
/**
* Implicit request to show the input window, not as the result
* of a direct request by the user.
*/
IMPLICIT = 0x0001,
/**
* The user has forced the input method open (such as by
* long-pressing menu) so it should not be closed until they
* explicitly do so.
*/
FORCED = 0x0002,
}
/**
* Flags for ANativeActivity_hideSoftInput see the Java InputMethodManager
* API for documentation.
*/
HideSoftInputFlags :: enum {
/**
* The soft input window should only be hidden if it was not
* explicitly shown by the user.
*/
IMPLICIT_ONLY = 0x0001,
/**
* The soft input window should normally be hidden, unless it was
* originally shown with {@link ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED}.
*/
NOT_ALWAYS = 0x0002,
}
/** /**
* This structure defines the native side of an android.app.NativeActivity. * This structure defines the native side of an android.app.NativeActivity.
@@ -54,7 +90,7 @@ ANativeActivity :: struct {
/** /**
* The platform's SDK version code. * The platform's SDK version code.
*/ */
sdkVersion: c.int32_t, sdkVersion: i32,
/** /**
* This is the native instance of the application. It is not used by * This is the native instance of the application. It is not used by
@@ -105,7 +141,7 @@ ANativeActivityCallbacks :: struct {
* saved state will be persisted, so it can not contain any active * saved state will be persisted, so it can not contain any active
* entities (pointers to memory, file descriptors, etc). * entities (pointers to memory, file descriptors, etc).
*/ */
onSaveInstanceState: #type proc "c" (activity: ^ANativeActivity, outSize: ^c.size_t) -> rawptr, onSaveInstanceState: #type proc "c" (activity: ^ANativeActivity, outSize: ^uint) -> rawptr,
/** /**
* NativeActivity has paused. See Java documentation for Activity.onPause() * NativeActivity has paused. See Java documentation for Activity.onPause()
@@ -129,7 +165,7 @@ ANativeActivityCallbacks :: struct {
* Focus has changed in this NativeActivity's window. This is often used, * Focus has changed in this NativeActivity's window. This is often used,
* for example, to pause a game when it loses input focus. * for example, to pause a game when it loses input focus.
*/ */
onWindowFocusChanged: #type proc "c" (activity: ^ANativeActivity, hasFocus: c.int), onWindowFocusChanged: #type proc "c" (activity: ^ANativeActivity, hasFocus: i32),
/** /**
* The drawing window for this native activity has been created. You * The drawing window for this native activity has been created. You
@@ -194,3 +230,58 @@ ANativeActivityCallbacks :: struct {
onLowMemory: #type proc "c" (activity: ^ANativeActivity), onLowMemory: #type proc "c" (activity: ^ANativeActivity),
} }
/**
* This is the function that must be in the native code to instantiate the
* application's native activity. It is called with the activity instance (see
* above); if the code is being instantiated from a previously saved instance,
* the savedState will be non-NULL and point to the saved data. You must make
* any copy of this data you need -- it will be released after you return from
* this function.
*/
ANativeActivity_createFunc :: #type proc "c" (activity: ^ANativeActivity, savedState: rawptr, savedStateSize: uint)
foreign android {
/**
* Finish the given activity. Its finish() method will be called, causing it
* to be stopped and destroyed. Note that this method can be called from
* *any* thread it will send a message to the main thread of the process
* where the Java finish call will take place.
*/
ANativeActivity_finish :: proc(activity: ^ANativeActivity) ---
/**
* Change the window format of the given activity. Calls getWindow().setFormat()
* of the given activity. Note that this method can be called from
* *any* thread it will send a message to the main thread of the process
* where the Java finish call will take place.
*/
// TODO: wtf is format here ?? is there an enum or constants for this proc?
// I think this might be AHardwareBuffer_Format, but annoyingly so, it's u32 while this proc requires i32.
ANativeActivity_setWindowFormat :: proc(activity: ^ANativeActivity, format: i32) ---
/**
* Change the window flags of the given activity. Calls getWindow().setFlags()
* of the given activity. Note that this method can be called from
* *any* thread it will send a message to the main thread of the process
* where the Java finish call will take place. See window.h for flag constants.
*/
ANativeActivity_setWindowFlags :: proc(activity: ^ANativeActivity, addFlags: WindowFlags, removeFlags: WindowFlags) ---
/**
* Show the IME while in the given activity. Calls InputMethodManager.showSoftInput()
* for the given activity. Note that this method can be called from
* *any* thread it will send a message to the main thread of the process
* where the Java finish call will take place.
*/
ANativeActivity_showSoftInput :: proc(activity: ^ANativeActivity, flags: ShowSoftInputFlags) ---
/**
* Hide the IME while in the given activity. Calls InputMethodManager.hideSoftInput()
* for the given activity. Note that this method can be called from
* *any* thread it will send a message to the main thread of the process
* where the Java finish call will take place.
*/
ANativeActivity_hideSoftInput :: proc(activity: ^ANativeActivity, flags: HideSoftInputFlags) ---
}
+259 -18
View File
@@ -1,6 +1,74 @@
//+build android //+build android
package android package android
/**
* Legacy window pixel format names, kept for backwards compatibility.
* New code and APIs should use AHARDWAREBUFFER_FORMAT_*.
*/
ANativeWindow_LegacyFormat :: enum {
// NOTE: these values must match the values from graphics/common/x.x/types.hal
/** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Alpha: 8 bits. **/
RGBA_8888 = AHardwareBuffer_Format.R8G8B8A8_UNORM,
/** Red: 8 bits, Green: 8 bits, Blue: 8 bits, Unused: 8 bits. **/
RGBX_8888 = AHardwareBuffer_Format.R8G8B8X8_UNORM,
/** Red: 5 bits, Green: 6 bits, Blue: 5 bits. **/
RGB_565 = AHardwareBuffer_Format.R5G6B5_UNORM,
}
/**
* Transforms that can be applied to buffers as they are displayed to a window.
*
* Supported transforms are any combination of horizontal mirror, vertical
* mirror, and clockwise 90 degree rotation, in that order. Rotations of 180
* and 270 degrees are made up of those basic transforms.
*/
ANativeWindowTransform :: enum i32 {
IDENTITY = 0x00,
MIRROR_HORIZONTAL = 0x01,
MIRROR_VERTICAL = 0x02,
ROTATE_90 = 0x04,
ROTATE_180 = MIRROR_HORIZONTAL | MIRROR_VERTICAL,
ROTATE_270 = ROTATE_180 | ROTATE_90,
}
/** Compatibility value for ANativeWindow_setFrameRate. */
ANativeWindow_FrameRateCompatibility :: enum i8 {
/**
* There are no inherent restrictions on the frame rate of this window. When
* the system selects a frame rate other than what the app requested, the
* app will be able to run at the system frame rate without requiring pull
* down. This value should be used when displaying game content, UIs, and
* anything that isn't video.
*/
DEFAULT = 0,
/**
* This window is being used to display content with an inherently fixed
* frame rate, e.g.\ a video that has a specific frame rate. When the system
* selects a frame rate other than what the app requested, the app will need
* to do pull down or use some other technique to adapt to the system's
* frame rate. The user experience is likely to be worse (e.g. more frame
* stuttering) than it would be if the system had chosen the app's requested
* frame rate. This value should be used for video content.
*/
FIXED_SOURCE = 1
}
/** Change frame rate strategy value for ANativeWindow_setFrameRate. */
// Available since API level 31.
ANativeWindow_ChangeFrameRateStrategy :: enum i8 {
/**
* Change the frame rate only if the transition is going to be seamless.
*/
ONLY_IF_SEAMLESS = 0,
/**
* Change the frame rate even if the transition is going to be non-seamless,
* i.e. with visual interruptions for the user.
*/
ALWAYS = 1
}
/** /**
* Opaque type that provides access to a native window. * Opaque type that provides access to a native window.
* *
@@ -8,28 +76,46 @@ package android
*/ */
ANativeWindow :: struct{} ANativeWindow :: struct{}
/**
* Struct that represents a windows buffer.
*
* A pointer can be obtained using {@link ANativeWindow_lock()}.
*/
ANativeWindow_Buffer :: struct {
/// The number of pixels that are shown horizontally.
width: i32,
/// The number of pixels that are shown vertically.
height: i32,
/// The number of *pixels* that a line in the buffer takes in
/// memory. This may be >= width.
stride: i32,
/// The format of the buffer. One of AHardwareBuffer_Format.
// TODO: u32/i32 mismatch with the enum.
int32_t format,
/// The actual bits.
bits: rawptr,
/// Do not touch.
reserved: [6]u32,
}
foreign import android "system:android" foreign import android "system:android"
foreign android { foreign android {
/** /**
* Change the format and size of the window buffers. * Acquire a reference on the given {@link ANativeWindow} object. This prevents the object
* * from being deleted until the reference is removed.
* The width and height control the number of pixels in the buffers, not the */
* dimensions of the window on screen. If these are different than the ANativeWindow_acquire :: proc(window: ^ANativeWindow) ---
* window's physical size, then its buffer will be scaled to match that size
* when compositing it to the screen. The width and height must be either both zero /**
* or both non-zero. * Remove a reference that was previously acquired with {@link ANativeWindow_acquire()}.
* */
* For all of these parameters, if 0 is supplied then the window's base ANativeWindow_release :: proc(window: ^ANativeWindow) ---
* value will come back in force.
*
* \param window pointer to an ANativeWindow object.
* \param width width of the buffers in pixels.
* \param height height of the buffers in pixels.
* \param format one of the AHardwareBuffer_Format constants.
* \return 0 for success, or a negative value on error.
*/
ANativeWindow_setBuffersGeometry :: proc(window: ^ANativeWindow, width: i32, height: i32, format: i32) -> i32 ---
/** /**
* Return the current width in pixels of the window surface. * Return the current width in pixels of the window surface.
@@ -44,4 +130,159 @@ foreign android {
* \return a negative value on error. * \return a negative value on error.
*/ */
ANativeWindow_getHeight :: proc(window: ^ANativeWindow) -> i32 --- ANativeWindow_getHeight :: proc(window: ^ANativeWindow) -> i32 ---
/**
* Return the current pixel format (AHARDWAREBUFFER_FORMAT_*) of the window surface.
*
* \return a negative value on error.
*/
// TODO: should return AHardwarebuffer_Format but i32/u32 mismatch
ANativeWindow_getFormat :: proc(window: ^ANativeWindow) -> i32 ---
/**
* Change the format and size of the window buffers.
*
* The width and height control the number of pixels in the buffers, not the
* dimensions of the window on screen. If these are different than the
* window's physical size, then its buffer will be scaled to match that size
* when compositing it to the screen. The width and height must be either both zero
* or both non-zero.
*
* For all of these parameters, if 0 is supplied then the window's base
* value will come back in force.
*
* \param window pointer to an ANativeWindow object.
* \param width width of the buffers in pixels.
* \param height height of the buffers in pixels.
* \param format one of the AHardwareBuffer_Format constants.
* \return 0 for success, or a negative value on error.
*/
ANativeWindow_setBuffersGeometry :: proc(window: ^ANativeWindow, width: i32, height: i32, format: i32) -> i32 ---
/**
* Lock the window's next drawing surface for writing.
* inOutDirtyBounds is used as an in/out parameter, upon entering the
* function, it contains the dirty region, that is, the region the caller
* intends to redraw. When the function returns, inOutDirtyBounds is updated
* with the actual area the caller needs to redraw -- this region is often
* extended by {@link ANativeWindow_lock}.
*
* \return 0 for success, or a negative value on error.
*/
ANativeWindow_lock :: proc(window: ^ANativeWindow, outBuffer: ^ANativeWindow_Buffer, inOutDirtyBounds: ^ARect) -> i32 ---
/**
* Unlock the window's drawing surface after previously locking it,
* posting the new buffer to the display.
*
* \return 0 for success, or a negative value on error.
*/
ANativeWindow_unlockAndPost :: proc(window: ^ANativeWindow) -> i32 ---
/**
* Set a transform that will be applied to future buffers posted to the window.
*
* Available since API level 26.
*
* \param window pointer to an ANativeWindow object.
* \param transform combination of {@link ANativeWindowTransform} flags
* \return 0 for success, or -EINVAL if \p transform is invalid
*/
ANativeWindow_setBuffersTransform :: proc(window: ^ANativeWindow, transform: ANativeWindowTransform) -> i32 ---
/**
* All buffers queued after this call will be associated with the dataSpace
* parameter specified.
*
* dataSpace specifies additional information about the buffer.
* For example, it can be used to convey the color space of the image data in
* the buffer, or it can be used to indicate that the buffers contain depth
* measurement data instead of color images. The default dataSpace is 0,
* ADATASPACE_UNKNOWN, unless it has been overridden by the producer.
*
* Available since API level 28.
*
* \param window pointer to an ANativeWindow object.
* \param dataSpace data space of all buffers queued after this call.
* \return 0 for success, -EINVAL if window is invalid or the dataspace is not
* supported.
*/
ANativeWindow_setBuffersDataSpace :: proc(window: ^ANativeWindow, dataSpace: ADataSpace) -> i32 ---
/**
* Get the dataspace of the buffers in window.
*
* Available since API level 28.
*
* \return the dataspace of buffers in window, ADATASPACE_UNKNOWN is returned if
* dataspace is unknown, or -EINVAL if window is invalid.
*/
ANativeWindow_getBuffersDataSpace :: proc(window: ^ANativeWindow) -> ADataSpace ---
/**
* Same as ANativeWindow_setFrameRateWithChangeStrategy(window, frameRate, compatibility,
* ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS).
*
* See ANativeWindow_setFrameRateWithChangeStrategy().
*
* Available since API level 30.
*/
ANativeWindow_setFrameRate :: proc(window: ^ANativeWindow, frameRate: f32, compatibility: ANativeWindow_FrameRateCompatibility) -> i32 ---
/**
* Provides a hint to the window that buffers should be preallocated ahead of
* time. Note that the window implementation is not guaranteed to preallocate
* any buffers, for instance if an implementation disallows allocation of new
* buffers, or if there is insufficient memory in the system to preallocate
* additional buffers
*
* Available since API level 30.
*/
ANativeWindow_tryAllocateBuffers :: proc(window: ^ANativeWindow) ---
/**
* Sets the intended frame rate for this window.
*
* On devices that are capable of running the display at different refresh
* rates, the system may choose a display refresh rate to better match this
* window's frame rate. Usage of this API won't introduce frame rate throttling,
* or affect other aspects of the application's frame production
* pipeline. However, because the system may change the display refresh rate,
* calls to this function may result in changes to Choreographer callback
* timings, and changes to the time interval at which the system releases
* buffers back to the application.
*
* Note that this only has an effect for windows presented on the display. If
* this ANativeWindow is consumed by something other than the system compositor,
* e.g. a media codec, this call has no effect.
*
* You can register for changes in the refresh rate using
* \a AChoreographer_registerRefreshRateCallback.
*
* Available since API level 31.
*
* \param window pointer to an ANativeWindow object.
*
* \param frameRate The intended frame rate of this window, in frames per
* second. 0 is a special value that indicates the app will accept the system's
* choice for the display frame rate, which is the default behavior if this
* function isn't called. The frameRate param does <em>not</em> need to be a
* valid refresh rate for this device's display - e.g., it's fine to pass 30fps
* to a device that can only run the display at 60fps.
*
* \param compatibility The frame rate compatibility of this window. The
* compatibility value may influence the system's choice of display refresh
* rate. See the ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_* values for more info.
* This parameter is ignored when frameRate is 0.
*
* \param changeFrameRateStrategy Whether display refresh rate transitions caused by this
* window should be seamless.
* A seamless transition is one that doesn't have any visual interruptions, such as a black
* screen for a second or two. See the ANATIVEWINDOW_CHANGE_FRAME_RATE_* values.
* This parameter is ignored when frameRate is 0.
*
* \return 0 for success, -EINVAL if the window, frame rate, or compatibility
* value are invalid.
*/
ANativeWindow_setFrameRateWithChangeStrategy :: proc(window: ^ANativeWindow, frameRate: f32, compatibility: ANativeWindow_FrameRateCompatibility, changeFrameRateStrategy: ANativeWindow_ChangeFrameRateStrategy) -> i32 ---
} }
+25
View File
@@ -0,0 +1,25 @@
//+build android
package android
foreign import android "system:android"
foreign android {
/**
* Return the ANativeWindow associated with a Java Surface object,
* for interacting with it through native code. This acquires a reference
* on the ANativeWindow that is returned be sure to use ANativeWindow_release()
* when done with it so that it doesn't leak.
*/
ANativeWindow_fromSurface :: proc(env: ^JNIEnv, surface: jobject) -> ^ANativeWindow ---
/**
* Return a Java Surface object derived from the ANativeWindow, for interacting
* with it through Java code. The returned Java object acquires a reference on
* the ANativeWindow maintains it through general Java object's life cycle;
* and will automatically release the reference when the Java object gets garbage
* collected.
*
* Available since API level 26.
*/
ANativeWindow_toSurface :: proc(env: ^JNIEnv, window: ^ANativeWindow) -> jobject ---
}
+41
View File
@@ -0,0 +1,41 @@
//+build android
package android
/**
* Set to 1 if this is an NDK, unset otherwise. See
* https://android.googlesource.com/platform/bionic/+/master/docs/defines.md.
*/
__ANDROID_NDK__ :: 1
/**
* Major version of this NDK.
*
* For example: 16 for r16.
*/
__NDK_MAJOR__ :: 26
/**
* Minor version of this NDK.
*
* For example: 0 for r16 and 1 for r16b.
*/
__NDK_MINOR__ :: 1
/**
* Set to 0 if this is a release build, or 1 for beta 1,
* 2 for beta 2, and so on.
*/
__NDK_BETA__ :: 0
/**
* Build number for this NDK.
*
* For a local development build of the NDK, this is -1.
*/
__NDK_BUILD__ :: 10909125
/**
* Set to 1 if this is a canary build, 0 if not.
*/
__NDK_CANARY__ :: 0
+191
View File
@@ -0,0 +1,191 @@
//+build android
package android
/**
* Window flags, as per the Java API at android.view.WindowManager.LayoutParams.
*/
WindowFlagsBits :: enum u32 {
/**
* As long as this window is visible to the user, allow the lock
* screen to activate while the screen is on. This can be used
* independently, or in combination with {@link
* KEEP_SCREEN_ON} and/or {@link
* SHOW_WHEN_LOCKED}
*/
ALLOW_LOCK_WHILE_SCREEN_ON = 0,
/** Everything behind this window will be dimmed. */
DIM_BEHIND = 1,
/**
* Blur everything behind this window.
* @deprecated Blurring is no longer supported.
*/
BLUR_BEHIND = 2,
/**
* This window won't ever get key input focus, so the
* user can not send key or other button events to it. Those will
* instead go to whatever focusable window is behind it. This flag
* will also enable {@link NOT_TOUCH_MODAL} whether or not that
* is explicitly set.
*
* Setting this flag also implies that the window will not need to
* interact with
* a soft input method, so it will be Z-ordered and positioned
* independently of any active input method (typically this means it
* gets Z-ordered on top of the input method, so it can use the full
* screen for its content and cover the input method if needed. You
* can use {@link ALT_FOCUSABLE_IM} to modify this behavior.
*/
NOT_FOCUSABLE = 3,
/** this window can never receive touch events. */
NOT_TOUCHABLE = 4,
/**
* Even when this window is focusable (its
* {@link NOT_FOCUSABLE} is not set), allow any pointer events
* outside of the window to be sent to the windows behind it. Otherwise
* it will consume all pointer events itself, regardless of whether they
* are inside of the window.
*/
NOT_TOUCH_MODAL = 5,
/**
* When set, if the device is asleep when the touch
* screen is pressed, you will receive this first touch event. Usually
* the first touch event is consumed by the system since the user can
* not see what they are pressing on.
*
* @deprecated This flag has no effect.
*/
TOUCHABLE_WHEN_WAKING = 6,
/**
* As long as this window is visible to the user, keep
* the device's screen turned on and bright.
*/
KEEP_SCREEN_ON = 7,
/**
* Place the window within the entire screen, ignoring
* decorations around the border (such as the status bar). The
* window must correctly position its contents to take the screen
* decoration into account.
*/
LAYOUT_IN_SCREEN = 8,
/** allow window to extend outside of the screen. */
LAYOUT_NO_LIMITS = 9,
/**
* Hide all screen decorations (such as the status
* bar) while this window is displayed. This allows the window to
* use the entire display space for itself -- the status bar will
* be hidden when an app window with this flag set is on the top
* layer. A fullscreen window will ignore a value of
* <a href="/reference/android/view/WindowManager.LayoutParams#SOFT_INPUT_ADJUST_RESIZE">
* SOFT_INPUT_ADJUST_RESIZE</a>; the window will stay
* fullscreen and will not resize.
*/
FULLSCREEN = 10,
/**
* Override {@link FULLSCREEN} and force the
* screen decorations (such as the status bar) to be shown.
*/
FORCE_NOT_FULLSCREEN = 11,
/**
* Turn on dithering when compositing this window to
* the screen.
* @deprecated This flag is no longer used.
*/
DITHER = 12,
/**
* Treat the content of the window as secure, preventing
* it from appearing in screenshots or from being viewed on non-secure
* displays.
*/
SECURE = 13,
/**
* A special mode where the layout parameters are used
* to perform scaling of the surface when it is composited to the
* screen.
*/
SCALED = 14,
/**
* Intended for windows that will often be used when the user is
* holding the screen against their face, it will aggressively
* filter the event stream to prevent unintended presses in this
* situation that may not be desired for a particular window, when
* such an event stream is detected, the application will receive
* a {@link AMOTION_EVENT_ACTION_CANCEL} to indicate this so
* applications can handle this accordingly by taking no action on
* the event until the finger is released.
*/
IGNORE_CHEEK_PRESSES = 15,
/**
* A special option only for use in combination with
* {@link LAYOUT_IN_SCREEN}. When requesting layout in the
* screen your window may appear on top of or behind screen decorations
* such as the status bar. By also including this flag, the window
* manager will report the inset rectangle needed to ensure your
* content is not covered by screen decorations.
*/
LAYOUT_INSET_DECOR = 16,
/**
* Invert the state of {@link NOT_FOCUSABLE} with
* respect to how this window interacts with the current method.
* That is, if FLAG_NOT_FOCUSABLE is set and this flag is set,
* then the window will behave as if it needs to interact with the
* input method and thus be placed behind/away from it; if {@link
* NOT_FOCUSABLE} is not set and this flag is set,
* then the window will behave as if it doesn't need to interact
* with the input method and can be placed to use more space and
* cover the input method.
*/
ALT_FOCUSABLE_IM = 17,
/**
* If you have set {@link NOT_TOUCH_MODAL}, you
* can set this flag to receive a single special MotionEvent with
* the action
* {@link AMOTION_EVENT_ACTION_OUTSIDE} for
* touches that occur outside of your window. Note that you will not
* receive the full down/move/up gesture, only the location of the
* first down as an {@link AMOTION_EVENT_ACTION_OUTSIDE}.
*/
WATCH_OUTSIDE_TOUCH = 18,
/**
* Special flag to let windows be shown when the screen
* is locked. This will let application windows take precedence over
* key guard or any other lock screens. Can be used with
* {@link KEEP_SCREEN_ON} to turn screen on and display windows
* directly before showing the key guard window. Can be used with
* {@link DISMISS_KEYGUARD} to automatically fully dismisss
* non-secure keyguards. This flag only applies to the top-most
* full-screen window.
*/
SHOW_WHEN_LOCKED = 19,
/**
* Ask that the system wallpaper be shown behind
* your window. The window surface must be translucent to be able
* to actually see the wallpaper behind it; this flag just ensures
* that the wallpaper surface will be there if this window actually
* has translucent regions.
*/
SHOW_WALLPAPER = 20,
/**
* When set as a window is being added or made
* visible, once the window has been shown then the system will
* poke the power manager's user activity (as if the user had woken
* up the device) to turn the screen on.
*/
TURN_SCREEN_ON = 21,
/**
* When set the window will cause the keyguard to
* be dismissed, only if it is not a secure lock keyguard. Because such
* a keyguard is not needed for security, it will never re-appear if
* the user navigates to another window (in contrast to
* {@link SHOW_WHEN_LOCKED}, which will only temporarily
* hide both secure and non-secure keyguards but ensure they reappear
* when the user moves to another UI that doesn't hide them).
* If the keyguard is currently active and is secure (requires an
* unlock pattern) than the user will still need to confirm it before
* seeing this window, unless {@link SHOW_WHEN_LOCKED} has
* also been set.
*/
DISMISS_KEYGUARD = 22,
}
WindowFlags :: bit_set[WindowFlagsBits; u32]