+
+#include "common/gamesdk_common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define GAMETEXTINPUT_MAJOR_VERSION 4
+#define GAMETEXTINPUT_MINOR_VERSION 0
+#define GAMETEXTINPUT_BUGFIX_VERSION 0
+#define GAMETEXTINPUT_PACKED_VERSION \
+ ANDROID_GAMESDK_PACKED_VERSION(GAMETEXTINPUT_MAJOR_VERSION, \
+ GAMETEXTINPUT_MINOR_VERSION, \
+ GAMETEXTINPUT_BUGFIX_VERSION)
+
+/**
+ * This struct holds a span within a region of text from start (inclusive) to
+ * end (exclusive). An empty span or cursor position is specified with
+ * start==end. An undefined span is specified with start = end = SPAN_UNDEFINED.
+ */
+typedef struct GameTextInputSpan {
+ /** The start of the region (inclusive). */
+ int32_t start;
+ /** The end of the region (exclusive). */
+ int32_t end;
+} GameTextInputSpan;
+
+/**
+ * Values with special meaning in a GameTextInputSpan.
+ */
+enum GameTextInputSpanFlag : int32_t { SPAN_UNDEFINED = -1 };
+
+/**
+ * This struct holds the state of an editable section of text.
+ * The text can have a selection and a composing region defined on it.
+ * A composing region is used by IMEs that allow input using multiple steps to
+ * compose a glyph or word. Use functions GameTextInput_getState and
+ * GameTextInput_setState to read and modify the state that an IME is editing.
+ */
+typedef struct GameTextInputState {
+ /**
+ * Text owned by the state, as a modified UTF-8 string. Null-terminated.
+ * https://en.wikipedia.org/wiki/UTF-8#Modified_UTF-8
+ */
+ const char *text_UTF8;
+ /**
+ * Length in bytes of text_UTF8, *not* including the null at end.
+ */
+ int32_t text_length;
+ /**
+ * A selection defined on the text.
+ */
+ GameTextInputSpan selection;
+ /**
+ * A composing region defined on the text.
+ */
+ GameTextInputSpan composingRegion;
+} GameTextInputState;
+
+/**
+ * A callback called by GameTextInput_getState.
+ * @param context User-defined context.
+ * @param state State, owned by the library, that will be valid for the duration
+ * of the callback.
+ */
+typedef void (*GameTextInputGetStateCallback)(
+ void *context, const struct GameTextInputState *state);
+
+/**
+ * Opaque handle to the GameTextInput API.
+ */
+typedef struct GameTextInput GameTextInput;
+
+/**
+ * Initialize the GameTextInput library.
+ * If called twice without GameTextInput_destroy being called, the same pointer
+ * will be returned and a warning will be issued.
+ * @param env A JNI env valid on the calling thread.
+ * @param max_string_size The maximum length of a string that can be edited. If
+ * zero, the maximum defaults to 65536 bytes. A buffer of this size is allocated
+ * at initialization.
+ * @return A handle to the library.
+ */
+GameTextInput *GameTextInput_init(JNIEnv *env, uint32_t max_string_size);
+
+/**
+ * When using GameTextInput, you need to create a gametextinput.InputConnection
+ * on the Java side and pass it using this function to the library, unless using
+ * GameActivity in which case this will be done for you. See the GameActivity
+ * source code or GameTextInput samples for examples of usage.
+ * @param input A valid GameTextInput library handle.
+ * @param inputConnection A gametextinput.InputConnection object.
+ */
+void GameTextInput_setInputConnection(GameTextInput *input,
+ jobject inputConnection);
+
+/**
+ * Unless using GameActivity, it is required to call this function from your
+ * Java gametextinput.Listener.stateChanged method to convert eventState and
+ * trigger any event callbacks. When using GameActivity, this does not need to
+ * be called as event processing is handled by the Activity.
+ * @param input A valid GameTextInput library handle.
+ * @param eventState A Java gametextinput.State object.
+ */
+void GameTextInput_processEvent(GameTextInput *input, jobject eventState);
+
+/**
+ * Free any resources owned by the GameTextInput library.
+ * Any subsequent calls to the library will fail until GameTextInput_init is
+ * called again.
+ * @param input A valid GameTextInput library handle.
+ */
+void GameTextInput_destroy(GameTextInput *input);
+
+/**
+ * Flags to be passed to GameTextInput_showIme.
+ */
+enum ShowImeFlags : uint32_t {
+ SHOW_IME_UNDEFINED = 0, // Default value.
+ SHOW_IMPLICIT =
+ 1, // Indicates that the user has forced the input method open so it
+ // should not be closed until they explicitly do so.
+ SHOW_FORCED = 2 // Indicates that this is an implicit request to show the
+ // input window, not as the result of a direct request by
+ // the user. The window may not be shown in this case.
+};
+
+/**
+ * Show the IME. Calls InputMethodManager.showSoftInput().
+ * @param input A valid GameTextInput library handle.
+ * @param flags Defined in ShowImeFlags above. For more information see:
+ * https://developer.android.com/reference/android/view/inputmethod/InputMethodManager
+ */
+void GameTextInput_showIme(GameTextInput *input, uint32_t flags);
+
+/**
+ * Flags to be passed to GameTextInput_hideIme.
+ */
+enum HideImeFlags : uint32_t {
+ HIDE_IME_UNDEFINED = 0, // Default value.
+ HIDE_IMPLICIT_ONLY =
+ 1, // Indicates that the soft input window should only be hidden if it
+ // was not explicitly shown by the user.
+ HIDE_NOT_ALWAYS =
+ 2, // Indicates that the soft input window should normally be hidden,
+ // unless it was originally shown with SHOW_FORCED.
+};
+
+/**
+ * Hide the IME. Calls InputMethodManager.hideSoftInputFromWindow().
+ * @param input A valid GameTextInput library handle.
+ * @param flags Defined in HideImeFlags above. For more information see:
+ * https://developer.android.com/reference/android/view/inputmethod/InputMethodManager
+ */
+void GameTextInput_hideIme(GameTextInput *input, uint32_t flags);
+
+/**
+ * Restarts the input method. Calls InputMethodManager.restartInput().
+ * @param input A valid GameTextInput library handle.
+ */
+void GameTextInput_restartInput(GameTextInput *input);
+
+/**
+ * Call a callback with the current GameTextInput state, which may have been
+ * modified by changes in the IME and calls to GameTextInput_setState. We use a
+ * callback rather than returning the state in order to simplify ownership of
+ * text_UTF8 strings. These strings are only valid during the calling of the
+ * callback.
+ * @param input A valid GameTextInput library handle.
+ * @param callback A function that will be called with valid state.
+ * @param context Context used by the callback.
+ */
+void GameTextInput_getState(GameTextInput *input,
+ GameTextInputGetStateCallback callback,
+ void *context);
+
+/**
+ * Set the current GameTextInput state. This state is reflected to any active
+ * IME.
+ * @param input A valid GameTextInput library handle.
+ * @param state The state to set. Ownership is maintained by the caller and must
+ * remain valid for the duration of the call.
+ */
+void GameTextInput_setState(GameTextInput *input,
+ const GameTextInputState *state);
+
+/**
+ * Type of the callback needed by GameTextInput_setEventCallback that will be
+ * called every time the IME state changes.
+ * @param context User-defined context set in GameTextInput_setEventCallback.
+ * @param current_state Current IME state, owned by the library and valid during
+ * the callback.
+ */
+typedef void (*GameTextInputEventCallback)(
+ void *context, const GameTextInputState *current_state);
+
+/**
+ * Optionally set a callback to be called whenever the IME state changes.
+ * Not necessary if you are using GameActivity, which handles these callbacks
+ * for you.
+ * @param input A valid GameTextInput library handle.
+ * @param callback Called by the library when the IME state changes.
+ * @param context Context passed as first argument to the callback.
+ * This function is deprecated. Don't perform any complex processing inside
+ * the callback other than copying the state variable. Using any synchronization
+ * primitives inside this callback may cause a deadlock.
+ */
+void GameTextInput_setEventCallback(GameTextInput *input,
+ GameTextInputEventCallback callback,
+ void *context);
+
+/**
+ * Type of the callback needed by GameTextInput_setImeInsetsCallback that will
+ * be called every time the IME window insets change.
+ * @param context User-defined context set in
+ * GameTextInput_setImeWIndowInsetsCallback.
+ * @param current_insets Current IME insets, owned by the library and valid
+ * during the callback.
+ */
+typedef void (*GameTextInputImeInsetsCallback)(void *context,
+ const ARect *current_insets);
+
+/**
+ * Optionally set a callback to be called whenever the IME insets change.
+ * Not necessary if you are using GameActivity, which handles these callbacks
+ * for you.
+ * @param input A valid GameTextInput library handle.
+ * @param callback Called by the library when the IME insets change.
+ * @param context Context passed as first argument to the callback.
+ */
+void GameTextInput_setImeInsetsCallback(GameTextInput *input,
+ GameTextInputImeInsetsCallback callback,
+ void *context);
+
+/**
+ * Get the current window insets for the IME.
+ * @param input A valid GameTextInput library handle.
+ * @param insets Filled with the current insets by this function.
+ */
+void GameTextInput_getImeInsets(const GameTextInput *input, ARect *insets);
+
+/**
+ * Unless using GameActivity, it is required to call this function from your
+ * Java gametextinput.Listener.onImeInsetsChanged method to
+ * trigger any event callbacks. When using GameActivity, this does not need to
+ * be called as insets processing is handled by the Activity.
+ * @param input A valid GameTextInput library handle.
+ * @param eventState A Java gametextinput.State object.
+ */
+void GameTextInput_processImeInsets(GameTextInput *input, const ARect *insets);
+
+/**
+ * Convert a GameTextInputState struct to a Java gametextinput.State object.
+ * Don't forget to delete the returned Java local ref when you're done.
+ * @param input A valid GameTextInput library handle.
+ * @param state Input state to convert.
+ * @return A Java object of class gametextinput.State. The caller is required to
+ * delete this local reference.
+ */
+jobject GameTextInputState_toJava(const GameTextInput *input,
+ const GameTextInputState *state);
+
+/**
+ * Convert from a Java gametextinput.State object into a C GameTextInputState
+ * struct.
+ * @param input A valid GameTextInput library handle.
+ * @param state A Java gametextinput.State object.
+ * @param callback A function called with the C struct, valid for the duration
+ * of the call.
+ * @param context Context passed to the callback.
+ */
+void GameTextInputState_fromJava(const GameTextInput *input, jobject state,
+ GameTextInputGetStateCallback callback,
+ void *context);
+
+/**
+ * Definitions for inputType argument of GameActivity_setImeEditorInfo()
+ *
+ *
+ * |-------|-------|-------|-------|
+ * 1111 TYPE_MASK_CLASS
+ * 11111111 TYPE_MASK_VARIATION
+ * 111111111111 TYPE_MASK_FLAGS
+ * |-------|-------|-------|-------|
+ * TYPE_NULL
+ * |-------|-------|-------|-------|
+ * 1 TYPE_CLASS_TEXT
+ * 1 TYPE_TEXT_VARIATION_URI
+ * 1 TYPE_TEXT_VARIATION_EMAIL_ADDRESS
+ * 11 TYPE_TEXT_VARIATION_EMAIL_SUBJECT
+ * 1 TYPE_TEXT_VARIATION_SHORT_MESSAGE
+ * 1 1 TYPE_TEXT_VARIATION_LONG_MESSAGE
+ * 11 TYPE_TEXT_VARIATION_PERSON_NAME
+ * 111 TYPE_TEXT_VARIATION_POSTAL_ADDRESS
+ * 1 TYPE_TEXT_VARIATION_PASSWORD
+ * 1 1 TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
+ * 1 1 TYPE_TEXT_VARIATION_WEB_EDIT_TEXT
+ * 1 11 TYPE_TEXT_VARIATION_FILTER
+ * 11 TYPE_TEXT_VARIATION_PHONETIC
+ * 11 1 TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS
+ * 111 TYPE_TEXT_VARIATION_WEB_PASSWORD
+ * 1 TYPE_TEXT_FLAG_CAP_CHARACTERS
+ * 1 TYPE_TEXT_FLAG_CAP_WORDS
+ * 1 TYPE_TEXT_FLAG_CAP_SENTENCES
+ * 1 TYPE_TEXT_FLAG_AUTO_CORRECT
+ * 1 TYPE_TEXT_FLAG_AUTO_COMPLETE
+ * 1 TYPE_TEXT_FLAG_MULTI_LINE
+ * 1 TYPE_TEXT_FLAG_IME_MULTI_LINE
+ * 1 TYPE_TEXT_FLAG_NO_SUGGESTIONS
+ * 1 TYPE_TEXT_FLAG_ENABLE_TEXT_CONVERSION_SUGGESTIONS
+ * |-------|-------|-------|-------|
+ * 1 TYPE_CLASS_NUMBER
+ * 1 TYPE_NUMBER_VARIATION_PASSWORD
+ * 1 TYPE_NUMBER_FLAG_SIGNED
+ * 1 TYPE_NUMBER_FLAG_DECIMAL
+ * |-------|-------|-------|-------|
+ * 11 TYPE_CLASS_PHONE
+ * |-------|-------|-------|-------|
+ * 1 TYPE_CLASS_DATETIME
+ * 1 TYPE_DATETIME_VARIATION_DATE
+ * 1 TYPE_DATETIME_VARIATION_TIME
+ * |-------|-------|-------|-------|
+ */
+
+enum GameTextInputType : uint32_t {
+ /**
+ * Mask of bits that determine the overall class
+ * of text being given. Currently supported classes are:
+ * {@link #TYPE_CLASS_TEXT}, {@link #TYPE_CLASS_NUMBER},
+ * {@link #TYPE_CLASS_PHONE}, {@link #TYPE_CLASS_DATETIME}.
+ * IME authors: If the class is not one you
+ * understand, assume {@link #TYPE_CLASS_TEXT} with NO variation
+ * or flags.
+ */
+ TYPE_MASK_CLASS = 0x0000000f,
+
+ /**
+ * Mask of bits that determine the variation of
+ * the base content class.
+ */
+ TYPE_MASK_VARIATION = 0x00000ff0,
+
+ /**
+ * Mask of bits that provide addition bit flags
+ * of options.
+ */
+ TYPE_MASK_FLAGS = 0x00fff000,
+
+ /**
+ * Special content type for when no explicit type has been specified.
+ * This should be interpreted to mean that the target input connection
+ * is not rich, it can not process and show things like candidate text nor
+ * retrieve the current text, so the input method will need to run in a
+ * limited "generate key events" mode, if it supports it. Note that some
+ * input methods may not support it, for example a voice-based input
+ * method will likely not be able to generate key events even if this
+ * flag is set.
+ */
+ TYPE_NULL = 0x00000000,
+
+ // ----------------------------------------------------------------------
+
+ /**
+ * Class for normal text. This class supports the following flags (only
+ * one of which should be set):
+ * {@link #TYPE_TEXT_FLAG_CAP_CHARACTERS},
+ * {@link #TYPE_TEXT_FLAG_CAP_WORDS}, and.
+ * {@link #TYPE_TEXT_FLAG_CAP_SENTENCES}. It also supports the
+ * following variations:
+ * {@link #TYPE_TEXT_VARIATION_NORMAL}, and
+ * {@link #TYPE_TEXT_VARIATION_URI}. If you do not recognize the
+ * variation, normal should be assumed.
+ */
+ TYPE_CLASS_TEXT = 0x00000001,
+
+ /**
+ * Flag for {@link #TYPE_CLASS_TEXT}: capitalize all characters. Overrides
+ * {@link #TYPE_TEXT_FLAG_CAP_WORDS} and
+ * {@link #TYPE_TEXT_FLAG_CAP_SENTENCES}. This value is explicitly defined
+ * to be the same as {@link TextUtils#CAP_MODE_CHARACTERS}. Of course,
+ * this only affects languages where there are upper-case and lower-case
+ * letters.
+ */
+ TYPE_TEXT_FLAG_CAP_CHARACTERS = 0x00001000,
+
+ /**
+ * Flag for {@link #TYPE_CLASS_TEXT}: capitalize the first character of
+ * every word. Overrides {@link #TYPE_TEXT_FLAG_CAP_SENTENCES}. This
+ * value is explicitly defined
+ * to be the same as {@link TextUtils#CAP_MODE_WORDS}. Of course,
+ * this only affects languages where there are upper-case and lower-case
+ * letters.
+ */
+ TYPE_TEXT_FLAG_CAP_WORDS = 0x00002000,
+
+ /**
+ * Flag for {@link #TYPE_CLASS_TEXT}: capitalize the first character of
+ * each sentence. This value is explicitly defined
+ * to be the same as {@link TextUtils#CAP_MODE_SENTENCES}. For example
+ * in English it means to capitalize after a period and a space (note that
+ * other languages may have different characters for period, or not use
+ * spaces, or use different grammatical rules). Of course, this only affects
+ * languages where there are upper-case and lower-case letters.
+ */
+ TYPE_TEXT_FLAG_CAP_SENTENCES = 0x00004000,
+
+ /**
+ * Flag for {@link #TYPE_CLASS_TEXT}: the user is entering free-form
+ * text that should have auto-correction applied to it. Without this flag,
+ * the IME will not try to correct typos. You should always set this flag
+ * unless you really expect users to type non-words in this field, for
+ * example to choose a name for a character in a game.
+ * Contrast this with {@link #TYPE_TEXT_FLAG_AUTO_COMPLETE} and
+ * {@link #TYPE_TEXT_FLAG_NO_SUGGESTIONS}:
+ * {@code TYPE_TEXT_FLAG_AUTO_CORRECT} means that the IME will try to
+ * auto-correct typos as the user is typing, but does not define whether
+ * the IME offers an interface to show suggestions.
+ */
+ TYPE_TEXT_FLAG_AUTO_CORRECT = 0x00008000,
+
+ /**
+ * Flag for {@link #TYPE_CLASS_TEXT}: the text editor (which means
+ * the application) is performing auto-completion of the text being entered
+ * based on its own semantics, which it will present to the user as they type.
+ * This generally means that the input method should not be showing
+ * candidates itself, but can expect the editor to supply its own
+ * completions/candidates from
+ * {@link android.view.inputmethod.InputMethodSession#displayCompletions
+ * InputMethodSession.displayCompletions()} as a result of the editor calling
+ * {@link android.view.inputmethod.InputMethodManager#displayCompletions
+ * InputMethodManager.displayCompletions()}.
+ * Note the contrast with {@link #TYPE_TEXT_FLAG_AUTO_CORRECT} and
+ * {@link #TYPE_TEXT_FLAG_NO_SUGGESTIONS}:
+ * {@code TYPE_TEXT_FLAG_AUTO_COMPLETE} means the editor should show an
+ * interface for displaying suggestions, but instead of supplying its own
+ * it will rely on the Editor to pass completions/corrections.
+ */
+ TYPE_TEXT_FLAG_AUTO_COMPLETE = 0x00010000,
+
+ /**
+ * Flag for {@link #TYPE_CLASS_TEXT}: multiple lines of text can be
+ * entered into the field. If this flag is not set, the text field
+ * will be constrained to a single line. The IME may also choose not to
+ * display an enter key when this flag is not set, as there should be no
+ * need to create new lines.
+ */
+ TYPE_TEXT_FLAG_MULTI_LINE = 0x00020000,
+
+ /**
+ * Flag for {@link #TYPE_CLASS_TEXT}: the regular text view associated
+ * with this should not be multi-line, but when a fullscreen input method
+ * is providing text it should use multiple lines if it can.
+ */
+ TYPE_TEXT_FLAG_IME_MULTI_LINE = 0x00040000,
+
+ /**
+ * Flag for {@link #TYPE_CLASS_TEXT}: the input method does not need to
+ * display any dictionary-based candidates. This is useful for text views that
+ * do not contain words from the language and do not benefit from any
+ * dictionary-based completions or corrections. It overrides the
+ * {@link #TYPE_TEXT_FLAG_AUTO_CORRECT} value when set.
+ * Please avoid using this unless you are certain this is what you want.
+ * Many input methods need suggestions to work well, for example the ones
+ * based on gesture typing. Consider clearing
+ * {@link #TYPE_TEXT_FLAG_AUTO_CORRECT} instead if you just do not
+ * want the IME to correct typos.
+ * Note the contrast with {@link #TYPE_TEXT_FLAG_AUTO_CORRECT} and
+ * {@link #TYPE_TEXT_FLAG_AUTO_COMPLETE}:
+ * {@code TYPE_TEXT_FLAG_NO_SUGGESTIONS} means the IME does not need to
+ * show an interface to display suggestions. Most IMEs will also take this to
+ * mean they do not need to try to auto-correct what the user is typing.
+ */
+ TYPE_TEXT_FLAG_NO_SUGGESTIONS = 0x00080000,
+
+ /**
+ * Flag for {@link #TYPE_CLASS_TEXT}: Let the IME know the text conversion
+ * suggestions are required by the application. Text conversion suggestion is
+ * for the transliteration languages which has pronunciation characters and
+ * target characters. When the user is typing the pronunciation charactes, the
+ * IME could provide the possible target characters to the user. When this
+ * flag is set, the IME should insert the text conversion suggestions through
+ * {@link Builder#setTextConversionSuggestions(List)} and
+ * the {@link TextAttribute} with initialized with the text conversion
+ * suggestions is provided by the IME to the application. To receive the
+ * additional information, the application needs to implement {@link
+ * InputConnection#setComposingText(CharSequence, int, TextAttribute)},
+ * {@link InputConnection#setComposingRegion(int, int, TextAttribute)}, and
+ * {@link InputConnection#commitText(CharSequence, int, TextAttribute)}.
+ */
+ TYPE_TEXT_FLAG_ENABLE_TEXT_CONVERSION_SUGGESTIONS = 0x00100000,
+
+ // ----------------------------------------------------------------------
+
+ /**
+ * Default variation of {@link #TYPE_CLASS_TEXT}: plain old normal text.
+ */
+ TYPE_TEXT_VARIATION_NORMAL = 0x00000000,
+
+ /**
+ * Variation of {@link #TYPE_CLASS_TEXT}: entering a URI.
+ */
+ TYPE_TEXT_VARIATION_URI = 0x00000010,
+
+ /**
+ * Variation of {@link #TYPE_CLASS_TEXT}: entering an e-mail address.
+ */
+ TYPE_TEXT_VARIATION_EMAIL_ADDRESS = 0x00000020,
+
+ /**
+ * Variation of {@link #TYPE_CLASS_TEXT}: entering the subject line of
+ * an e-mail.
+ */
+ TYPE_TEXT_VARIATION_EMAIL_SUBJECT = 0x00000030,
+
+ /**
+ * Variation of {@link #TYPE_CLASS_TEXT}: entering a short, possibly informal
+ * message such as an instant message or a text message.
+ */
+ TYPE_TEXT_VARIATION_SHORT_MESSAGE = 0x00000040,
+
+ /**
+ * Variation of {@link #TYPE_CLASS_TEXT}: entering the content of a long,
+ * possibly formal message such as the body of an e-mail.
+ */
+ TYPE_TEXT_VARIATION_LONG_MESSAGE = 0x00000050,
+
+ /**
+ * Variation of {@link #TYPE_CLASS_TEXT}: entering the name of a person.
+ */
+ TYPE_TEXT_VARIATION_PERSON_NAME = 0x00000060,
+
+ /**
+ * Variation of {@link #TYPE_CLASS_TEXT}: entering a postal mailing address.
+ */
+ TYPE_TEXT_VARIATION_POSTAL_ADDRESS = 0x00000070,
+
+ /**
+ * Variation of {@link #TYPE_CLASS_TEXT}: entering a password.
+ */
+ TYPE_TEXT_VARIATION_PASSWORD = 0x00000080,
+
+ /**
+ * Variation of {@link #TYPE_CLASS_TEXT}: entering a password, which should
+ * be visible to the user.
+ */
+ TYPE_TEXT_VARIATION_VISIBLE_PASSWORD = 0x00000090,
+
+ /**
+ * Variation of {@link #TYPE_CLASS_TEXT}: entering text inside of a web form.
+ */
+ TYPE_TEXT_VARIATION_WEB_EDIT_TEXT = 0x000000a0,
+
+ /**
+ * Variation of {@link #TYPE_CLASS_TEXT}: entering text to filter contents
+ * of a list etc.
+ */
+ TYPE_TEXT_VARIATION_FILTER = 0x000000b0,
+
+ /**
+ * Variation of {@link #TYPE_CLASS_TEXT}: entering text for phonetic
+ * pronunciation, such as a phonetic name field in contacts. This is mostly
+ * useful for languages where one spelling may have several phonetic
+ * readings, like Japanese.
+ */
+ TYPE_TEXT_VARIATION_PHONETIC = 0x000000c0,
+
+ /**
+ * Variation of {@link #TYPE_CLASS_TEXT}: entering e-mail address inside
+ * of a web form. This was added in
+ * {@link android.os.Build.VERSION_CODES#HONEYCOMB}. An IME must target
+ * this API version or later to see this input type; if it doesn't, a request
+ * for this type will be seen as {@link #TYPE_TEXT_VARIATION_EMAIL_ADDRESS}
+ * when passed through {@link
+ * android.view.inputmethod.EditorInfo#makeCompatible(int)
+ * EditorInfo.makeCompatible(int)}.
+ */
+ TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS = 0x000000d0,
+
+ /**
+ * Variation of {@link #TYPE_CLASS_TEXT}: entering password inside
+ * of a web form. This was added in
+ * {@link android.os.Build.VERSION_CODES#HONEYCOMB}. An IME must target
+ * this API version or later to see this input type; if it doesn't, a request
+ * for this type will be seen as {@link #TYPE_TEXT_VARIATION_PASSWORD}
+ * when passed through {@link
+ * android.view.inputmethod.EditorInfo#makeCompatible(int)
+ * EditorInfo.makeCompatible(int)}.
+ */
+ TYPE_TEXT_VARIATION_WEB_PASSWORD = 0x000000e0,
+
+ // ----------------------------------------------------------------------
+
+ /**
+ * Class for numeric text. This class supports the following flags:
+ * {@link #TYPE_NUMBER_FLAG_SIGNED} and
+ * {@link #TYPE_NUMBER_FLAG_DECIMAL}. It also supports the following
+ * variations: {@link #TYPE_NUMBER_VARIATION_NORMAL} and
+ * {@link #TYPE_NUMBER_VARIATION_PASSWORD}.
+ *
IME authors: If you do not recognize
+ * the variation, normal should be assumed.
+ */
+ TYPE_CLASS_NUMBER = 0x00000002,
+
+ /**
+ * Flag of {@link #TYPE_CLASS_NUMBER}: the number is signed, allowing
+ * a positive or negative sign at the start.
+ */
+ TYPE_NUMBER_FLAG_SIGNED = 0x00001000,
+
+ /**
+ * Flag of {@link #TYPE_CLASS_NUMBER}: the number is decimal, allowing
+ * a decimal point to provide fractional values.
+ */
+ TYPE_NUMBER_FLAG_DECIMAL = 0x00002000,
+
+ // ----------------------------------------------------------------------
+
+ /**
+ * Default variation of {@link #TYPE_CLASS_NUMBER}: plain normal
+ * numeric text. This was added in
+ * {@link android.os.Build.VERSION_CODES#HONEYCOMB}. An IME must target
+ * this API version or later to see this input type; if it doesn't, a request
+ * for this type will be dropped when passed through
+ * {@link android.view.inputmethod.EditorInfo#makeCompatible(int)
+ * EditorInfo.makeCompatible(int)}.
+ */
+ TYPE_NUMBER_VARIATION_NORMAL = 0x00000000,
+
+ /**
+ * Variation of {@link #TYPE_CLASS_NUMBER}: entering a numeric password.
+ * This was added in {@link android.os.Build.VERSION_CODES#HONEYCOMB}. An
+ * IME must target this API version or later to see this input type; if it
+ * doesn't, a request for this type will be dropped when passed
+ * through {@link android.view.inputmethod.EditorInfo#makeCompatible(int)
+ * EditorInfo.makeCompatible(int)}.
+ */
+ TYPE_NUMBER_VARIATION_PASSWORD = 0x00000010,
+
+ // ----------------------------------------------------------------------
+ /**
+ * Class for a phone number. This class currently supports no variations
+ * or flags.
+ */
+ TYPE_CLASS_PHONE = 0x00000003,
+
+ // ----------------------------------------------------------------------
+
+ /**
+ * Class for dates and times. It supports the
+ * following variations:
+ * {@link #TYPE_DATETIME_VARIATION_NORMAL}
+ * {@link #TYPE_DATETIME_VARIATION_DATE}, and
+ * {@link #TYPE_DATETIME_VARIATION_TIME}.
+ */
+ TYPE_CLASS_DATETIME = 0x00000004,
+
+ /**
+ * Default variation of {@link #TYPE_CLASS_DATETIME}: allows entering
+ * both a date and time.
+ */
+ TYPE_DATETIME_VARIATION_NORMAL = 0x00000000,
+
+ /**
+ * Default variation of {@link #TYPE_CLASS_DATETIME}: allows entering
+ * only a date.
+ */
+ TYPE_DATETIME_VARIATION_DATE = 0x00000010,
+
+ /**
+ * Default variation of {@link #TYPE_CLASS_DATETIME}: allows entering
+ * only a time.
+ */
+ TYPE_DATETIME_VARIATION_TIME = 0x00000020,
+};
+
+/**
+ * actionId and imeOptions argument of GameActivity_setImeEditorInfo().
+ *
+ *
+ * |-------|-------|-------|-------|
+ * 1111 IME_MASK_ACTION
+ * |-------|-------|-------|-------|
+ * IME_ACTION_UNSPECIFIED
+ * 1 IME_ACTION_NONE
+ * 1 IME_ACTION_GO
+ * 11 IME_ACTION_SEARCH
+ * 1 IME_ACTION_SEND
+ * 1 1 IME_ACTION_NEXT
+ * 11 IME_ACTION_DONE
+ * 111 IME_ACTION_PREVIOUS
+ * 1 IME_FLAG_NO_PERSONALIZED_LEARNING
+ * 1 IME_FLAG_NO_FULLSCREEN
+ * 1 IME_FLAG_NAVIGATE_PREVIOUS
+ * 1 IME_FLAG_NAVIGATE_NEXT
+ * 1 IME_FLAG_NO_EXTRACT_UI
+ * 1 IME_FLAG_NO_ACCESSORY_ACTION
+ * 1 IME_FLAG_NO_ENTER_ACTION
+ * 1 IME_FLAG_FORCE_ASCII
+ * |-------|-------|-------|-------|
+ */
+
+enum GameTextInputActionType : uint32_t {
+ /**
+ * Set of bits in {@link #imeOptions} that provide alternative actions
+ * associated with the "enter" key. This both helps the IME provide
+ * better feedback about what the enter key will do, and also allows it
+ * to provide alternative mechanisms for providing that command.
+ */
+ IME_MASK_ACTION = 0x000000ff,
+
+ /**
+ * Bits of {@link #IME_MASK_ACTION}: no specific action has been
+ * associated with this editor, let the editor come up with its own if
+ * it can.
+ */
+ IME_ACTION_UNSPECIFIED = 0x00000000,
+
+ /**
+ * Bits of {@link #IME_MASK_ACTION}: there is no available action.
+ */
+ IME_ACTION_NONE = 0x00000001,
+
+ /**
+ * Bits of {@link #IME_MASK_ACTION}: the action key performs a "go"
+ * operation to take the user to the target of the text they typed.
+ * Typically used, for example, when entering a URL.
+ */
+ IME_ACTION_GO = 0x00000002,
+
+ /**
+ * Bits of {@link #IME_MASK_ACTION}: the action key performs a "search"
+ * operation, taking the user to the results of searching for the text
+ * they have typed (in whatever context is appropriate).
+ */
+ IME_ACTION_SEARCH = 0x00000003,
+
+ /**
+ * Bits of {@link #IME_MASK_ACTION}: the action key performs a "send"
+ * operation, delivering the text to its target. This is typically used
+ * when composing a message in IM or SMS where sending is immediate.
+ */
+ IME_ACTION_SEND = 0x00000004,
+
+ /**
+ * Bits of {@link #IME_MASK_ACTION}: the action key performs a "next"
+ * operation, taking the user to the next field that will accept text.
+ */
+ IME_ACTION_NEXT = 0x00000005,
+
+ /**
+ * Bits of {@link #IME_MASK_ACTION}: the action key performs a "done"
+ * operation, typically meaning there is nothing more to input and the
+ * IME will be closed.
+ */
+ IME_ACTION_DONE = 0x00000006,
+
+ /**
+ * Bits of {@link #IME_MASK_ACTION}: like {@link #IME_ACTION_NEXT}, but
+ * for moving to the previous field. This will normally not be used to
+ * specify an action (since it precludes {@link #IME_ACTION_NEXT}), but
+ * can be returned to the app if it sets {@link #IME_FLAG_NAVIGATE_PREVIOUS}.
+ */
+ IME_ACTION_PREVIOUS = 0x00000007,
+};
+
+enum GameTextInputImeOptions : uint32_t {
+ /**
+ * Flag of {@link #imeOptions}: used to request that the IME should not update
+ * any personalized data such as typing history and personalized language
+ * model based on what the user typed on this text editing object. Typical
+ * use cases are: - When the application is in a special mode, where
+ * user's activities are expected to be not recorded in the application's
+ * history. Some web browsers and chat applications may have this kind of
+ * modes.
- When storing typing history does not make much sense.
+ * Specifying this flag in typing games may help to avoid typing history from
+ * being filled up with words that the user is less likely to type in their
+ * daily life. Another example is that when the application already knows
+ * that the expected input is not a valid word (e.g. a promotion code that is
+ * not a valid word in any natural language).
+ *
+ *
+ * Applications need to be aware that the flag is not a guarantee, and some
+ * IMEs may not respect it.
+ */
+ IME_FLAG_NO_PERSONALIZED_LEARNING = 0x1000000,
+
+ /**
+ * Flag of {@link #imeOptions}: used to request that the IME never go
+ * into fullscreen mode.
+ * By default, IMEs may go into full screen mode when they think
+ * it's appropriate, for example on small screens in landscape
+ * orientation where displaying a software keyboard may occlude
+ * such a large portion of the screen that the remaining part is
+ * too small to meaningfully display the application UI.
+ * If this flag is set, compliant IMEs will never go into full screen mode,
+ * and always leave some space to display the application UI.
+ * Applications need to be aware that the flag is not a guarantee, and
+ * some IMEs may ignore it.
+ */
+ IME_FLAG_NO_FULLSCREEN = 0x2000000,
+
+ /**
+ * Flag of {@link #imeOptions}: like {@link #IME_FLAG_NAVIGATE_NEXT}, but
+ * specifies there is something interesting that a backward navigation
+ * can focus on. If the user selects the IME's facility to backward
+ * navigate, this will show up in the application as an {@link
+ * #IME_ACTION_PREVIOUS} at {@link InputConnection#performEditorAction(int)
+ * InputConnection.performEditorAction(int)}.
+ */
+ IME_FLAG_NAVIGATE_PREVIOUS = 0x4000000,
+
+ /**
+ * Flag of {@link #imeOptions}: used to specify that there is something
+ * interesting that a forward navigation can focus on. This is like using
+ * {@link #IME_ACTION_NEXT}, except allows the IME to be multiline (with
+ * an enter key) as well as provide forward navigation. Note that some
+ * IMEs may not be able to do this, especially when running on a small
+ * screen where there is little space. In that case it does not need to
+ * present a UI for this option. Like {@link #IME_ACTION_NEXT}, if the
+ * user selects the IME's facility to forward navigate, this will show up
+ * in the application at {@link InputConnection#performEditorAction(int)
+ * InputConnection.performEditorAction(int)}.
+ */
+ IME_FLAG_NAVIGATE_NEXT = 0x8000000,
+
+ /**
+ * Flag of {@link #imeOptions}: used to specify that the IME does not need
+ * to show its extracted text UI. For input methods that may be fullscreen,
+ * often when in landscape mode, this allows them to be smaller and let part
+ * of the application be shown behind, through transparent UI parts in the
+ * fullscreen IME. The part of the UI visible to the user may not be
+ * responsive to touch because the IME will receive touch events, which may
+ * confuse the user; use {@link #IME_FLAG_NO_FULLSCREEN} instead for a better
+ * experience. Using this flag is discouraged and it may become deprecated in
+ * the future. Its meaning is unclear in some situations and it may not work
+ * appropriately on older versions of the platform.
+ */
+ IME_FLAG_NO_EXTRACT_UI = 0x10000000,
+
+ /**
+ * Flag of {@link #imeOptions}: used in conjunction with one of the actions
+ * masked by {@link #IME_MASK_ACTION}, this indicates that the action
+ * should not be available as an accessory button on the right of the
+ * extracted text when the input method is full-screen. Note that by setting
+ * this flag, there can be cases where the action is simply never available to
+ * the user. Setting this generally means that you think that in fullscreen
+ * mode, where there is little space to show the text, it's not worth taking
+ * some screen real estate to display the action and it should be used instead
+ * to show more text.
+ */
+ IME_FLAG_NO_ACCESSORY_ACTION = 0x20000000,
+
+ /**
+ * Flag of {@link #imeOptions}: used in conjunction with one of the actions
+ * masked by {@link #IME_MASK_ACTION}. If this flag is not set, IMEs will
+ * normally replace the "enter" key with the action supplied. This flag
+ * indicates that the action should not be available in-line as a replacement
+ * for the "enter" key. Typically this is because the action has such a
+ * significant impact or is not recoverable enough that accidentally hitting
+ * it should be avoided, such as sending a message. Note that
+ * {@link android.widget.TextView} will automatically set this flag for you
+ * on multi-line text views.
+ */
+ IME_FLAG_NO_ENTER_ACTION = 0x40000000,
+
+ /**
+ * Flag of {@link #imeOptions}: used to request an IME that is capable of
+ * inputting ASCII characters. The intention of this flag is to ensure that
+ * the user can type Roman alphabet characters in a {@link
+ * android.widget.TextView}. It is typically used for an account ID or
+ * password input. A lot of the time, IMEs are already able to input ASCII
+ * even without being told so (such IMEs already respect this flag in a
+ * sense), but there are cases when this is not the default. For instance,
+ * users of languages using a different script like Arabic, Greek, Hebrew or
+ * Russian typically have a keyboard that can't input ASCII characters by
+ * default. Applications need to be aware that the flag is not a guarantee,
+ * and some IMEs may not respect it. However, it is strongly recommended for
+ * IME authors to respect this flag especially when their IME could end up
+ * with a state where only languages using non-ASCII are enabled.
+ */
+ IME_FLAG_FORCE_ASCII = 0x80000000,
+
+ /**
+ * Flag of {@link #internalImeOptions}: flag is set when app window containing
+ * this
+ * {@link EditorInfo} is using {@link Configuration#ORIENTATION_PORTRAIT}
+ * mode.
+ * @hide
+ */
+ IME_INTERNAL_FLAG_APP_WINDOW_PORTRAIT = 0x00000001,
+
+ /**
+ * Generic unspecified type for {@link #imeOptions}.
+ */
+ IME_NULL = 0x00000000,
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+/** @} */
diff --git a/android-activity/android-games-sdk/game-text-input/prefab-src/modules/game-text-input/module.json b/android-activity/android-games-sdk/game-text-input/prefab-src/modules/game-text-input/module.json
new file mode 100644
index 00000000..1a64fccd
--- /dev/null
+++ b/android-activity/android-games-sdk/game-text-input/prefab-src/modules/game-text-input/module.json
@@ -0,0 +1,8 @@
+{
+ "export_libraries": [],
+ "library_name": null,
+ "android": {
+ "export_libraries": null,
+ "library_name": null
+ }
+}
diff --git a/android-activity/android-games-sdk/game-text-input/prefab-src/modules/game-text-input/src/game-text-input/gametextinput.cpp b/android-activity/android-games-sdk/game-text-input/prefab-src/modules/game-text-input/src/game-text-input/gametextinput.cpp
new file mode 100644
index 00000000..70a59389
--- /dev/null
+++ b/android-activity/android-games-sdk/game-text-input/prefab-src/modules/game-text-input/src/game-text-input/gametextinput.cpp
@@ -0,0 +1,386 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "game-text-input/gametextinput.h"
+
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+#define LOG_TAG "GameTextInput"
+
+static constexpr int32_t DEFAULT_MAX_STRING_SIZE = 1 << 16;
+
+// Cache of field ids in the Java GameTextInputState class
+struct StateClassInfo {
+ jfieldID text;
+ jfieldID selectionStart;
+ jfieldID selectionEnd;
+ jfieldID composingRegionStart;
+ jfieldID composingRegionEnd;
+};
+
+// Main GameTextInput object.
+struct GameTextInput {
+ public:
+ GameTextInput(JNIEnv *env, uint32_t max_string_size);
+ ~GameTextInput();
+ void setState(const GameTextInputState &state);
+ GameTextInputState getState() const {
+ std::lock_guard lock(currentStateMutex_);
+ return currentState_;
+ }
+ void setInputConnection(jobject inputConnection);
+ void processEvent(jobject textInputEvent);
+ void showIme(uint32_t flags);
+ void hideIme(uint32_t flags);
+ void restartInput();
+ void setEventCallback(GameTextInputEventCallback callback, void *context);
+ jobject stateToJava(const GameTextInputState &state) const;
+ void stateFromJava(jobject textInputEvent,
+ GameTextInputGetStateCallback callback,
+ void *context) const;
+ void setImeInsetsCallback(GameTextInputImeInsetsCallback callback,
+ void *context);
+ void processImeInsets(const ARect *insets);
+ const ARect &getImeInsets() const { return currentInsets_; }
+
+ private:
+ // Copy string and set other fields
+ void setStateInner(const GameTextInputState &state);
+ static void processCallback(void *context, const GameTextInputState *state);
+ JNIEnv *env_ = nullptr;
+ // Cached at initialization from
+ // com/google/androidgamesdk/gametextinput/State.
+ jclass stateJavaClass_ = nullptr;
+ // The latest text input update.
+ GameTextInputState currentState_ = {};
+ // A mutex to protect currentState_.
+ mutable std::mutex currentStateMutex_;
+ // An instance of gametextinput.InputConnection.
+ jclass inputConnectionClass_ = nullptr;
+ jobject inputConnection_ = nullptr;
+ jmethodID inputConnectionSetStateMethod_;
+ jmethodID setSoftKeyboardActiveMethod_;
+ jmethodID restartInputMethod_;
+ void (*eventCallback_)(void *context,
+ const struct GameTextInputState *state) = nullptr;
+ void *eventCallbackContext_ = nullptr;
+ void (*insetsCallback_)(void *context, const struct ARect *insets) = nullptr;
+ ARect currentInsets_ = {};
+ void *insetsCallbackContext_ = nullptr;
+ StateClassInfo stateClassInfo_ = {};
+ // Constant-sized buffer used to store state text.
+ std::vector stateStringBuffer_;
+};
+
+std::unique_ptr s_gameTextInput;
+
+extern "C" {
+
+///////////////////////////////////////////////////////////
+/// GameTextInputState C Functions
+///////////////////////////////////////////////////////////
+
+// Convert to a Java structure.
+jobject currentState_toJava(const GameTextInput *gameTextInput,
+ const GameTextInputState *state) {
+ if (state == nullptr) return NULL;
+ return gameTextInput->stateToJava(*state);
+}
+
+// Convert from Java structure.
+void currentState_fromJava(const GameTextInput *gameTextInput,
+ jobject textInputEvent,
+ GameTextInputGetStateCallback callback,
+ void *context) {
+ gameTextInput->stateFromJava(textInputEvent, callback, context);
+}
+
+///////////////////////////////////////////////////////////
+/// GameTextInput C Functions
+///////////////////////////////////////////////////////////
+
+struct GameTextInput *GameTextInput_init(JNIEnv *env,
+ uint32_t max_string_size) {
+ if (s_gameTextInput.get() != nullptr) {
+ __android_log_print(ANDROID_LOG_WARN, LOG_TAG,
+ "Warning: called GameTextInput_init twice without "
+ "calling GameTextInput_destroy");
+ return s_gameTextInput.get();
+ }
+ // Don't use make_unique, for C++11 compatibility
+ s_gameTextInput =
+ std::unique_ptr(new GameTextInput(env, max_string_size));
+ return s_gameTextInput.get();
+}
+
+void GameTextInput_destroy(GameTextInput *input) {
+ if (input == nullptr || s_gameTextInput.get() == nullptr) return;
+ s_gameTextInput.reset();
+}
+
+void GameTextInput_setState(GameTextInput *input,
+ const GameTextInputState *state) {
+ if (state == nullptr) return;
+ input->setState(*state);
+}
+
+void GameTextInput_getState(GameTextInput *input,
+ GameTextInputGetStateCallback callback,
+ void *context) {
+ GameTextInputState state = input->getState();
+ callback(context, &state);
+}
+
+void GameTextInput_setInputConnection(GameTextInput *input,
+ jobject inputConnection) {
+ input->setInputConnection(inputConnection);
+}
+
+void GameTextInput_processEvent(GameTextInput *input, jobject textInputEvent) {
+ input->processEvent(textInputEvent);
+}
+
+void GameTextInput_processImeInsets(GameTextInput *input, const ARect *insets) {
+ input->processImeInsets(insets);
+}
+
+void GameTextInput_showIme(struct GameTextInput *input, uint32_t flags) {
+ input->showIme(flags);
+}
+
+void GameTextInput_hideIme(struct GameTextInput *input, uint32_t flags) {
+ input->hideIme(flags);
+}
+
+void GameTextInput_restartInput(struct GameTextInput *input) {
+ input->restartInput();
+}
+
+void GameTextInput_setEventCallback(struct GameTextInput *input,
+ GameTextInputEventCallback callback,
+ void *context) {
+ input->setEventCallback(callback, context);
+}
+
+void GameTextInput_setImeInsetsCallback(struct GameTextInput *input,
+ GameTextInputImeInsetsCallback callback,
+ void *context) {
+ input->setImeInsetsCallback(callback, context);
+}
+
+void GameTextInput_getImeInsets(const GameTextInput *input, ARect *insets) {
+ *insets = input->getImeInsets();
+}
+
+} // extern "C"
+
+///////////////////////////////////////////////////////////
+/// GameTextInput C++ class Implementation
+///////////////////////////////////////////////////////////
+
+GameTextInput::GameTextInput(JNIEnv *env, uint32_t max_string_size)
+ : env_(env),
+ stateStringBuffer_(max_string_size == 0 ? DEFAULT_MAX_STRING_SIZE
+ : max_string_size) {
+ stateJavaClass_ = (jclass)env_->NewGlobalRef(
+ env_->FindClass("com/google/androidgamesdk/gametextinput/State"));
+ inputConnectionClass_ = (jclass)env_->NewGlobalRef(env_->FindClass(
+ "com/google/androidgamesdk/gametextinput/InputConnection"));
+ inputConnectionSetStateMethod_ =
+ env_->GetMethodID(inputConnectionClass_, "setState",
+ "(Lcom/google/androidgamesdk/gametextinput/State;)V");
+ setSoftKeyboardActiveMethod_ = env_->GetMethodID(
+ inputConnectionClass_, "setSoftKeyboardActive", "(ZI)V");
+ restartInputMethod_ =
+ env_->GetMethodID(inputConnectionClass_, "restartInput", "()V");
+
+ stateClassInfo_.text =
+ env_->GetFieldID(stateJavaClass_, "text", "Ljava/lang/String;");
+ stateClassInfo_.selectionStart =
+ env_->GetFieldID(stateJavaClass_, "selectionStart", "I");
+ stateClassInfo_.selectionEnd =
+ env_->GetFieldID(stateJavaClass_, "selectionEnd", "I");
+ stateClassInfo_.composingRegionStart =
+ env_->GetFieldID(stateJavaClass_, "composingRegionStart", "I");
+ stateClassInfo_.composingRegionEnd =
+ env_->GetFieldID(stateJavaClass_, "composingRegionEnd", "I");
+}
+
+GameTextInput::~GameTextInput() {
+ if (stateJavaClass_ != NULL) {
+ env_->DeleteGlobalRef(stateJavaClass_);
+ stateJavaClass_ = NULL;
+ }
+ if (inputConnectionClass_ != NULL) {
+ env_->DeleteGlobalRef(inputConnectionClass_);
+ inputConnectionClass_ = NULL;
+ }
+ if (inputConnection_ != NULL) {
+ env_->DeleteGlobalRef(inputConnection_);
+ inputConnection_ = NULL;
+ }
+}
+
+void GameTextInput::setState(const GameTextInputState &state) {
+ if (inputConnection_ == nullptr) return;
+ jobject jstate = stateToJava(state);
+ env_->CallVoidMethod(inputConnection_, inputConnectionSetStateMethod_,
+ jstate);
+ env_->DeleteLocalRef(jstate);
+ setStateInner(state);
+}
+
+void GameTextInput::setStateInner(const GameTextInputState &state) {
+ std::lock_guard lock(currentStateMutex_);
+
+ // Check if we're setting using our own string (other parts may be
+ // different)
+ if (state.text_UTF8 == currentState_.text_UTF8) {
+ currentState_ = state;
+ return;
+ }
+ // Otherwise, copy across the string.
+ auto bytes_needed =
+ std::min(static_cast(state.text_length + 1),
+ static_cast(stateStringBuffer_.size()));
+ currentState_.text_UTF8 = stateStringBuffer_.data();
+ std::copy(state.text_UTF8, state.text_UTF8 + bytes_needed - 1,
+ stateStringBuffer_.data());
+ currentState_.text_length = state.text_length;
+ currentState_.selection = state.selection;
+ currentState_.composingRegion = state.composingRegion;
+ stateStringBuffer_[bytes_needed - 1] = 0;
+}
+
+void GameTextInput::setInputConnection(jobject inputConnection) {
+ if (inputConnection_ != NULL) {
+ env_->DeleteGlobalRef(inputConnection_);
+ }
+ inputConnection_ = env_->NewGlobalRef(inputConnection);
+}
+
+/*static*/ void GameTextInput::processCallback(
+ void *context, const GameTextInputState *state) {
+ auto thiz = static_cast(context);
+ if (state != nullptr) thiz->setStateInner(*state);
+}
+
+void GameTextInput::processEvent(jobject textInputEvent) {
+ stateFromJava(textInputEvent, processCallback, this);
+ if (eventCallback_) {
+ std::lock_guard lock(currentStateMutex_);
+ eventCallback_(eventCallbackContext_, ¤tState_);
+ }
+}
+
+void GameTextInput::showIme(uint32_t flags) {
+ if (inputConnection_ == nullptr) return;
+ env_->CallVoidMethod(inputConnection_, setSoftKeyboardActiveMethod_, true,
+ static_cast(flags));
+}
+
+void GameTextInput::setEventCallback(GameTextInputEventCallback callback,
+ void *context) {
+ eventCallback_ = callback;
+ eventCallbackContext_ = context;
+}
+
+void GameTextInput::setImeInsetsCallback(
+ GameTextInputImeInsetsCallback callback, void *context) {
+ insetsCallback_ = callback;
+ insetsCallbackContext_ = context;
+}
+
+void GameTextInput::processImeInsets(const ARect *insets) {
+ currentInsets_ = *insets;
+ if (insetsCallback_) {
+ insetsCallback_(insetsCallbackContext_, ¤tInsets_);
+ }
+}
+
+void GameTextInput::hideIme(uint32_t flags) {
+ if (inputConnection_ == nullptr) return;
+ env_->CallVoidMethod(inputConnection_, setSoftKeyboardActiveMethod_, false,
+ static_cast(flags));
+}
+
+void GameTextInput::restartInput() {
+ if (inputConnection_ == nullptr) return;
+ env_->CallVoidMethod(inputConnection_, restartInputMethod_);
+}
+
+jobject GameTextInput::stateToJava(const GameTextInputState &state) const {
+ static jmethodID constructor = nullptr;
+ if (constructor == nullptr) {
+ constructor = env_->GetMethodID(stateJavaClass_, "",
+ "(Ljava/lang/String;IIII)V");
+ if (constructor == nullptr) {
+ __android_log_print(ANDROID_LOG_ERROR, LOG_TAG,
+ "Can't find gametextinput.State constructor");
+ return nullptr;
+ }
+ }
+ const char *text = state.text_UTF8;
+ if (text == nullptr) {
+ static char empty_string[] = "";
+ text = empty_string;
+ }
+ // Note that this expects 'modified' UTF-8 which is not the same as UTF-8
+ // https://en.wikipedia.org/wiki/UTF-8#Modified_UTF-8
+ jstring jtext = env_->NewStringUTF(text);
+ jobject jobj =
+ env_->NewObject(stateJavaClass_, constructor, jtext,
+ state.selection.start, state.selection.end,
+ state.composingRegion.start, state.composingRegion.end);
+ env_->DeleteLocalRef(jtext);
+ return jobj;
+}
+
+void GameTextInput::stateFromJava(jobject textInputEvent,
+ GameTextInputGetStateCallback callback,
+ void *context) const {
+ jstring text =
+ (jstring)env_->GetObjectField(textInputEvent, stateClassInfo_.text);
+ // Note this is 'modified' UTF-8, not true UTF-8. It has no NULLs in it,
+ // except at the end. It's actually not specified whether the value returned
+ // by GetStringUTFChars includes a null at the end, but it *seems to* on
+ // Android.
+ const char *text_chars = env_->GetStringUTFChars(text, NULL);
+ int text_len = env_->GetStringUTFLength(
+ text); // Length in bytes, *not* including the null.
+ int selectionStart =
+ env_->GetIntField(textInputEvent, stateClassInfo_.selectionStart);
+ int selectionEnd =
+ env_->GetIntField(textInputEvent, stateClassInfo_.selectionEnd);
+ int composingRegionStart =
+ env_->GetIntField(textInputEvent, stateClassInfo_.composingRegionStart);
+ int composingRegionEnd =
+ env_->GetIntField(textInputEvent, stateClassInfo_.composingRegionEnd);
+ GameTextInputState state{text_chars,
+ text_len,
+ {selectionStart, selectionEnd},
+ {composingRegionStart, composingRegionEnd}};
+ callback(context, &state);
+ env_->ReleaseStringUTFChars(text, text_chars);
+ env_->DeleteLocalRef(text);
+}
diff --git a/android-activity/android-games-sdk/game-text-input/prefab-src/prefab.json b/android-activity/android-games-sdk/game-text-input/prefab-src/prefab.json
new file mode 100644
index 00000000..5b3ea1ec
--- /dev/null
+++ b/android-activity/android-games-sdk/game-text-input/prefab-src/prefab.json
@@ -0,0 +1,9 @@
+{
+ "name": "game-text-input",
+ "schema_version": 1,
+ "dependencies": [],
+ "version": "0.0.1",
+ "cpp_files": [
+ "src/game-text-input/gametextinput.cpp"
+ ]
+}
diff --git a/android-activity/android-games-sdk/import-games-sdk.sh b/android-activity/android-games-sdk/import-games-sdk.sh
new file mode 100755
index 00000000..83bdf9f3
--- /dev/null
+++ b/android-activity/android-games-sdk/import-games-sdk.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+set -xe
+
+# Copies the native, prefab-src for GameActivity + GameTextInput from the
+# upstream, android-games-sdk, including our android-activity integration
+# changes.
+#
+# This code is maintained out-of-tree, based on a fork of Google's AGDK repo, so
+# it's more practical to try and upstream changes we make, or to rebase on new
+# versions.
+
+if [ $# -ne 1 ]; then
+ echo "Usage: $0 "
+ exit 1
+fi
+
+SOURCE_DIR="$1"
+TOP_DIR=$(git rev-parse --show-toplevel)
+DEST_DIR="$TOP_DIR/android-activity/android-games-sdk"
+
+if [ ! -d "$SOURCE_DIR" ]; then
+ echo "Error: Source directory '$SOURCE_DIR' does not exist."
+ exit 1
+fi
+
+if [ ! -d "$DEST_DIR" ]; then
+ echo "Error: expected find destination directory $DEST_DIR"
+ exit 1
+fi
+
+rm -fr "$DEST_DIR/game-activity"
+rm -fr "$DEST_DIR/game-text-input"
+rm -fr "$DEST_DIR/src/common"
+rm -fr "$DEST_DIR/include/common"
+
+mkdir -p "$DEST_DIR/game-activity"
+mkdir -p "$DEST_DIR/game-text-input"
+mkdir -p "$DEST_DIR/include/common"
+mkdir -p "$DEST_DIR/src/common"
+
+cp -av "$SOURCE_DIR/game-activity/prefab-src" "$DEST_DIR/game-activity"
+cp -av "$SOURCE_DIR/game-text-input/prefab-src" "$DEST_DIR/game-text-input"
+cp -av "$SOURCE_DIR/include/common/gamesdk_common.h" "$DEST_DIR/include/common"
+cp -av "$SOURCE_DIR/src/common/system_utils.h" "$DEST_DIR/src/common"
+cp -av "$SOURCE_DIR/src/common/system_utils.cpp" "$DEST_DIR/src/common"
\ No newline at end of file
diff --git a/android-activity/android-games-sdk/include/common/gamesdk_common.h b/android-activity/android-games-sdk/include/common/gamesdk_common.h
new file mode 100644
index 00000000..25ce8139
--- /dev/null
+++ b/android-activity/android-games-sdk/include/common/gamesdk_common.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * This is the main interface to the Android Performance Tuner library, also
+ * known as Tuning Fork.
+ *
+ * It is part of the Android Games SDK and produces best results when integrated
+ * with the Swappy Frame Pacing Library.
+ *
+ * See the documentation at
+ * https://developer.android.com/games/sdk/performance-tuner/custom-engine for
+ * more information on using this library in a native Android game.
+ *
+ */
+
+#pragma once
+
+// There are separate versions for each GameSDK component that use this format:
+#define ANDROID_GAMESDK_PACKED_VERSION(MAJOR, MINOR, BUGFIX) \
+ ((MAJOR << 16) | (MINOR << 8) | (BUGFIX))
+// Accessors
+#define ANDROID_GAMESDK_MAJOR_VERSION(PACKED) ((PACKED) >> 16)
+#define ANDROID_GAMESDK_MINOR_VERSION(PACKED) (((PACKED) >> 8) & 0xff)
+#define ANDROID_GAMESDK_BUGFIX_VERSION(PACKED) ((PACKED) & 0xff)
+
+#define AGDK_STRINGIFY(NUMBER) #NUMBER
+#define AGDK_STRING_VERSION(MAJOR, MINOR, BUGFIX) \
+ AGDK_STRINGIFY(MAJOR) "." AGDK_STRINGIFY(MINOR) "." AGDK_STRINGIFY(BUGFIX)
diff --git a/android-activity/android-games-sdk/src/common/system_utils.cpp b/android-activity/android-games-sdk/src/common/system_utils.cpp
new file mode 100644
index 00000000..efc5b743
--- /dev/null
+++ b/android-activity/android-games-sdk/src/common/system_utils.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "system_utils.h"
+
+#include
+#include
+#include
+
+namespace gamesdk {
+
+#if __ANDROID_API__ >= 26
+std::string getSystemPropViaCallback(const char* key,
+ const char* default_value = "") {
+ const prop_info* prop = __system_property_find(key);
+ if (prop == nullptr) {
+ return default_value;
+ }
+ std::string return_value;
+ auto thunk = [](void* cookie, const char* /*name*/, const char* value,
+ uint32_t /*serial*/) {
+ if (value != nullptr) {
+ std::string* r = static_cast(cookie);
+ *r = value;
+ }
+ };
+ __system_property_read_callback(prop, thunk, &return_value);
+ return return_value;
+}
+#else
+std::string getSystemPropViaGet(const char* key,
+ const char* default_value = "") {
+ char buffer[PROP_VALUE_MAX + 1] = ""; // +1 for terminator
+ int bufferLen = __system_property_get(key, buffer);
+ if (bufferLen > 0)
+ return buffer;
+ else
+ return "";
+}
+#endif
+
+std::string GetSystemProp(const char* key, const char* default_value) {
+#if __ANDROID_API__ >= 26
+ return getSystemPropViaCallback(key, default_value);
+#else
+ return getSystemPropViaGet(key, default_value);
+#endif
+}
+
+int GetSystemPropAsInt(const char* key, int default_value) {
+ std::string prop = GetSystemProp(key);
+ return prop == "" ? default_value : strtoll(prop.c_str(), nullptr, 10);
+}
+
+bool GetSystemPropAsBool(const char* key, bool default_value) {
+ return GetSystemPropAsInt(key, default_value) != 0;
+}
+
+} // namespace gamesdk
\ No newline at end of file
diff --git a/android-activity/android-games-sdk/src/common/system_utils.h b/android-activity/android-games-sdk/src/common/system_utils.h
new file mode 100644
index 00000000..488374bc
--- /dev/null
+++ b/android-activity/android-games-sdk/src/common/system_utils.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include "string"
+
+namespace gamesdk {
+
+// Get the value of the given system property
+std::string GetSystemProp(const char* key, const char* default_value = "");
+
+// Get the value of the given system property as an integer
+int GetSystemPropAsInt(const char* key, int default_value = 0);
+
+// Get the value of the given system property as a bool
+bool GetSystemPropAsBool(const char* key, bool default_value = false);
+
+} // namespace gamesdk
\ No newline at end of file
diff --git a/android-activity/build.rs b/android-activity/build.rs
index 6b08f62e..94e44b52 100644
--- a/android-activity/build.rs
+++ b/android-activity/build.rs
@@ -1,23 +1,87 @@
-#![allow(dead_code)]
-
fn build_glue_for_game_activity() {
+ let android_games_sdk =
+ std::env::var("ANDROID_GAMES_SDK").unwrap_or_else(|_err| "android-games-sdk".to_string());
+
+ let activity_path = |src_inc, name| {
+ format!("{android_games_sdk}/game-activity/prefab-src/modules/game-activity/{src_inc}/game-activity/{name}")
+ };
+ let textinput_path = |src_inc, name| {
+ format!("{android_games_sdk}/game-text-input/prefab-src/modules/game-text-input/{src_inc}/game-text-input/{name}")
+ };
+
+ for f in ["GameActivity.cpp", "GameActivityEvents.cpp"] {
+ println!("cargo:rerun-if-changed={}", activity_path("src", f));
+ }
+
+ for f in [
+ "GameActivity.h",
+ "GameActivityEvents.h",
+ "GameActivityLog.h",
+ "GameActivityEvents_internal.h",
+ ] {
+ println!("cargo:rerun-if-changed={}", activity_path("include", f));
+ }
+
cc::Build::new()
.cpp(true)
- .include("game-activity-csrc")
- .file("game-activity-csrc/game-activity/GameActivity.cpp")
+ .include("android-games-sdk/src/common")
+ .file("android-games-sdk/src/common/system_utils.cpp")
+ .extra_warnings(false)
+ .cpp_link_stdlib("c++_static")
+ .compile("libgame_common.a");
+
+ println!("cargo:rerun-if-changed=android-games-sdk/src/common/system_utils.cpp");
+ println!("cargo:rerun-if-changed=android-games-sdk/src/common/system_utils.h");
+
+ cc::Build::new()
+ .cpp(true)
+ .include("android-games-sdk/src/common")
+ .include("android-games-sdk/include")
+ .include("android-games-sdk/game-activity/prefab-src/modules/game-activity/include")
+ .include("android-games-sdk/game-text-input/prefab-src/modules/game-text-input/include")
+ .file(activity_path("src", "GameActivity.cpp"))
+ .file(activity_path("src", "GameActivityEvents.cpp"))
.extra_warnings(false)
.cpp_link_stdlib("c++_static")
.compile("libgame_activity.a");
+
+ println!(
+ "cargo:rerun-if-changed={}",
+ textinput_path("include", "gametextinput.h")
+ );
+ println!(
+ "cargo:rerun-if-changed={}",
+ textinput_path("src", "gametextinput.cpp")
+ );
+
cc::Build::new()
.cpp(true)
- .include("game-activity-csrc")
- .file("game-activity-csrc/game-text-input/gametextinput.cpp")
+ .include("android-games-sdk/src/common")
+ .include("android-games-sdk/include")
+ .include("android-games-sdk/game-text-input/prefab-src/modules/game-text-input/include")
+ .file(textinput_path("src", "gametextinput.cpp"))
.cpp_link_stdlib("c++_static")
.compile("libgame_text_input.a");
+
+ println!(
+ "cargo:rerun-if-changed={}",
+ activity_path("src", "native_app_glue/android_native_app_glue.c")
+ );
+ println!(
+ "cargo:rerun-if-changed={}",
+ activity_path("include", "native_app_glue/android_native_app_glue.h")
+ );
+
cc::Build::new()
- .include("game-activity-csrc")
- .include("game-activity-csrc/game-activity/native_app_glue")
- .file("game-activity-csrc/game-activity/native_app_glue/android_native_app_glue.c")
+ .include("android-games-sdk/src/common")
+ .include("android-games-sdk/include")
+ .include("android-games-sdk/game-activity/prefab-src/modules/game-activity/include")
+ .include("android-games-sdk/game-text-input/prefab-src/modules/game-text-input/include")
+ .include(activity_path("include", ""))
+ .file(activity_path(
+ "src",
+ "native_app_glue/android_native_app_glue.c",
+ ))
.extra_warnings(false)
.cpp_link_stdlib("c++_static")
.compile("libnative_app_glue.a");
@@ -28,6 +92,21 @@ fn build_glue_for_game_activity() {
}
fn main() {
- #[cfg(feature = "game-activity")]
- build_glue_for_game_activity();
+ // Enable Cargo's change-detection to avoid re-running build script if
+ // irrelvant parts changed. Using build.rs here is just a dummy used to
+ // disable the default "rerun on every change" behaviour Cargo has.
+ println!("cargo:rerun-if-changed=build.rs");
+
+ if cfg!(feature = "game-activity") {
+ build_glue_for_game_activity();
+ }
+
+ // Whether this is used directly in or as a dependency on docs.rs.
+ //
+ // `cfg(docsrs)` cannot be used, since it's only set for the crate being
+ // built, and not for any dependent crates.
+ println!("cargo:rustc-check-cfg=cfg(used_on_docsrs)");
+ if std::env::var("DOCS_RS").is_ok() {
+ println!("cargo:rustc-cfg=used_on_docsrs");
+ }
}
diff --git a/android-activity/game-activity-csrc/game-activity/GameActivity.cpp b/android-activity/game-activity-csrc/game-activity/GameActivity.cpp
deleted file mode 100644
index a139696f..00000000
--- a/android-activity/game-activity-csrc/game-activity/GameActivity.cpp
+++ /dev/null
@@ -1,1398 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#define LOG_TAG "GameActivity"
-
-#include "GameActivity.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-// TODO(b/187147166): these functions were extracted from the Game SDK
-// (gamesdk/src/common/system_utils.h). system_utils.h/cpp should be used
-// instead.
-namespace {
-
-#if __ANDROID_API__ >= 26
-std::string getSystemPropViaCallback(const char *key,
- const char *default_value = "") {
- const prop_info *prop = __system_property_find(key);
- if (prop == nullptr) {
- return default_value;
- }
- std::string return_value;
- auto thunk = [](void *cookie, const char * /*name*/, const char *value,
- uint32_t /*serial*/) {
- if (value != nullptr) {
- std::string *r = static_cast(cookie);
- *r = value;
- }
- };
- __system_property_read_callback(prop, thunk, &return_value);
- return return_value;
-}
-#else
-std::string getSystemPropViaGet(const char *key,
- const char *default_value = "") {
- char buffer[PROP_VALUE_MAX + 1] = ""; // +1 for terminator
- int bufferLen = __system_property_get(key, buffer);
- if (bufferLen > 0)
- return buffer;
- else
- return "";
-}
-#endif
-
-std::string GetSystemProp(const char *key, const char *default_value = "") {
-#if __ANDROID_API__ >= 26
- return getSystemPropViaCallback(key, default_value);
-#else
- return getSystemPropViaGet(key, default_value);
-#endif
-}
-
-int GetSystemPropAsInt(const char *key, int default_value = 0) {
- std::string prop = GetSystemProp(key);
- return prop == "" ? default_value : strtoll(prop.c_str(), nullptr, 10);
-}
-
-struct OwnedGameTextInputState {
- OwnedGameTextInputState &operator=(const GameTextInputState &rhs) {
- inner = rhs;
- owned_string = std::string(rhs.text_UTF8, rhs.text_length);
- inner.text_UTF8 = owned_string.data();
- return *this;
- }
- GameTextInputState inner;
- std::string owned_string;
-};
-
-} // anonymous namespace
-
-#define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__);
-#define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__);
-#define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__);
-#ifdef NDEBUG
-#define ALOGV(...)
-#else
-#define ALOGV(...) \
- __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__);
-#endif
-
-/* Returns 2nd arg. Used to substitute default value if caller's vararg list
- * is empty.
- */
-#define __android_second(first, second, ...) second
-
-/* If passed multiple args, returns ',' followed by all but 1st arg, otherwise
- * returns nothing.
- */
-#define __android_rest(first, ...) , ##__VA_ARGS__
-
-#define android_printAssert(cond, tag, fmt...) \
- __android_log_assert(cond, tag, \
- __android_second(0, ##fmt, NULL) __android_rest(fmt))
-
-#define CONDITION(cond) (__builtin_expect((cond) != 0, 0))
-
-#ifndef LOG_ALWAYS_FATAL_IF
-#define LOG_ALWAYS_FATAL_IF(cond, ...) \
- ((CONDITION(cond)) \
- ? ((void)android_printAssert(#cond, LOG_TAG, ##__VA_ARGS__)) \
- : (void)0)
-#endif
-
-#ifndef LOG_ALWAYS_FATAL
-#define LOG_ALWAYS_FATAL(...) \
- (((void)android_printAssert(NULL, LOG_TAG, ##__VA_ARGS__)))
-#endif
-
-/*
- * Simplified macro to send a warning system log message using current LOG_TAG.
- */
-#ifndef SLOGW
-#define SLOGW(...) \
- ((void)__android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
-#endif
-
-#ifndef SLOGW_IF
-#define SLOGW_IF(cond, ...) \
- ((__predict_false(cond)) \
- ? ((void)__android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \
- : (void)0)
-#endif
-
-/*
- * Versions of LOG_ALWAYS_FATAL_IF and LOG_ALWAYS_FATAL that
- * are stripped out of release builds.
- */
-#if LOG_NDEBUG
-
-#ifndef LOG_FATAL_IF
-#define LOG_FATAL_IF(cond, ...) ((void)0)
-#endif
-#ifndef LOG_FATAL
-#define LOG_FATAL(...) ((void)0)
-#endif
-
-#else
-
-#ifndef LOG_FATAL_IF
-#define LOG_FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, ##__VA_ARGS__)
-#endif
-#ifndef LOG_FATAL
-#define LOG_FATAL(...) LOG_ALWAYS_FATAL(__VA_ARGS__)
-#endif
-
-#endif
-
-/*
- * Assertion that generates a log message when the assertion fails.
- * Stripped out of release builds. Uses the current LOG_TAG.
- */
-#ifndef ALOG_ASSERT
-#define ALOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ##__VA_ARGS__)
-#endif
-
-#define LOG_TRACE(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
-
-#ifndef NELEM
-#define NELEM(x) ((int)(sizeof(x) / sizeof((x)[0])))
-#endif
-
-/*
- * JNI methods of the GameActivity Java class.
- */
-static struct {
- jmethodID finish;
- jmethodID setWindowFlags;
- jmethodID getWindowInsets;
- jmethodID getWaterfallInsets;
- jmethodID setImeEditorInfoFields;
-} gGameActivityClassInfo;
-
-/*
- * JNI fields of the androidx.core.graphics.Insets Java class.
- */
-static struct {
- jfieldID left;
- jfieldID right;
- jfieldID top;
- jfieldID bottom;
-} gInsetsClassInfo;
-
-/*
- * JNI methods of the WindowInsetsCompat.Type Java class.
- */
-static struct {
- jmethodID methods[GAMECOMMON_INSETS_TYPE_COUNT];
- jclass clazz;
-} gWindowInsetsCompatTypeClassInfo;
-
-/*
- * Contains a command to be executed by the GameActivity
- * on the application main thread.
- */
-struct ActivityWork {
- int32_t cmd;
- int64_t arg1;
- int64_t arg2;
-};
-
-/*
- * The type of commands that can be passed to the GameActivity and that
- * are executed on the application main thread.
- */
-enum {
- CMD_FINISH = 1,
- CMD_SET_WINDOW_FORMAT,
- CMD_SET_WINDOW_FLAGS,
- CMD_SHOW_SOFT_INPUT,
- CMD_HIDE_SOFT_INPUT,
- CMD_SET_SOFT_INPUT_STATE
-};
-
-/*
- * Write a command to be executed by the GameActivity on the application main
- * thread.
- */
-static void write_work(int fd, int32_t cmd, int64_t arg1 = 0,
- int64_t arg2 = 0) {
- ActivityWork work;
- work.cmd = cmd;
- work.arg1 = arg1;
- work.arg2 = arg2;
-
- LOG_TRACE("write_work: cmd=%d", cmd);
-restart:
- int res = write(fd, &work, sizeof(work));
- if (res < 0 && errno == EINTR) {
- goto restart;
- }
-
- if (res == sizeof(work)) return;
-
- if (res < 0) {
- ALOGW("Failed writing to work fd: %s", strerror(errno));
- } else {
- ALOGW("Truncated writing to work fd: %d", res);
- }
-}
-
-/*
- * Read commands to be executed by the GameActivity on the application main
- * thread.
- */
-static bool read_work(int fd, ActivityWork *outWork) {
- int res = read(fd, outWork, sizeof(ActivityWork));
- // no need to worry about EINTR, poll loop will just come back again.
- if (res == sizeof(ActivityWork)) return true;
-
- if (res < 0) {
- ALOGW("Failed reading work fd: %s", strerror(errno));
- } else {
- ALOGW("Truncated reading work fd: %d", res);
- }
- return false;
-}
-
-/*
- * Native state for interacting with the GameActivity class.
- */
-struct NativeCode : public GameActivity {
- NativeCode(void *_dlhandle, GameActivity_createFunc *_createFunc) {
- memset((GameActivity *)this, 0, sizeof(GameActivity));
- memset(&callbacks, 0, sizeof(callbacks));
- memset(&insetsState, 0, sizeof(insetsState));
- dlhandle = _dlhandle;
- createActivityFunc = _createFunc;
- nativeWindow = NULL;
- mainWorkRead = mainWorkWrite = -1;
- gameTextInput = NULL;
- }
-
- ~NativeCode() {
- if (callbacks.onDestroy != NULL) {
- callbacks.onDestroy(this);
- }
- if (env != NULL) {
- if (javaGameActivity != NULL) {
- env->DeleteGlobalRef(javaGameActivity);
- }
- if (javaAssetManager != NULL) {
- env->DeleteGlobalRef(javaAssetManager);
- }
- }
- GameTextInput_destroy(gameTextInput);
- if (looper != NULL && mainWorkRead >= 0) {
- ALooper_removeFd(looper, mainWorkRead);
- }
- ALooper_release(looper);
- looper = NULL;
-
- setSurface(NULL);
- if (mainWorkRead >= 0) close(mainWorkRead);
- if (mainWorkWrite >= 0) close(mainWorkWrite);
- if (dlhandle != NULL) {
- // for now don't unload... we probably should clean this
- // up and only keep one open dlhandle per proc, since there
- // is really no benefit to unloading the code.
- // dlclose(dlhandle);
- }
- }
-
- void setSurface(jobject _surface) {
- if (nativeWindow != NULL) {
- ANativeWindow_release(nativeWindow);
- }
- if (_surface != NULL) {
- nativeWindow = ANativeWindow_fromSurface(env, _surface);
- } else {
- nativeWindow = NULL;
- }
- }
-
- GameActivityCallbacks callbacks;
-
- void *dlhandle;
- GameActivity_createFunc *createActivityFunc;
-
- std::string internalDataPathObj;
- std::string externalDataPathObj;
- std::string obbPathObj;
-
- ANativeWindow *nativeWindow;
- int32_t lastWindowWidth;
- int32_t lastWindowHeight;
-
- // These are used to wake up the main thread to process work.
- int mainWorkRead;
- int mainWorkWrite;
- ALooper *looper;
-
- // Need to hold on to a reference here in case the upper layers destroy our
- // AssetManager.
- jobject javaAssetManager;
-
- GameTextInput *gameTextInput;
- // Set by users in GameActivity_setTextInputState, then passed to
- // GameTextInput.
- OwnedGameTextInputState gameTextInputState;
- std::mutex gameTextInputStateMutex;
-
- ARect insetsState[GAMECOMMON_INSETS_TYPE_COUNT];
-};
-
-extern "C" void GameActivity_finish(GameActivity *activity) {
- NativeCode *code = static_cast(activity);
- write_work(code->mainWorkWrite, CMD_FINISH, 0);
-}
-
-extern "C" void GameActivity_setWindowFlags(GameActivity *activity,
- uint32_t values, uint32_t mask) {
- NativeCode *code = static_cast(activity);
- write_work(code->mainWorkWrite, CMD_SET_WINDOW_FLAGS, values, mask);
-}
-
-extern "C" void GameActivity_showSoftInput(GameActivity *activity,
- uint32_t flags) {
- NativeCode *code = static_cast(activity);
- write_work(code->mainWorkWrite, CMD_SHOW_SOFT_INPUT, flags);
-}
-
-extern "C" void GameActivity_setTextInputState(
- GameActivity *activity, const GameTextInputState *state) {
- NativeCode *code = static_cast(activity);
- std::lock_guard lock(code->gameTextInputStateMutex);
- code->gameTextInputState = *state;
- write_work(code->mainWorkWrite, CMD_SET_SOFT_INPUT_STATE);
-}
-
-extern "C" void GameActivity_getTextInputState(
- GameActivity *activity, GameTextInputGetStateCallback callback,
- void *context) {
- NativeCode *code = static_cast(activity);
- return GameTextInput_getState(code->gameTextInput, callback, context);
-}
-
-extern "C" void GameActivity_hideSoftInput(GameActivity *activity,
- uint32_t flags) {
- NativeCode *code = static_cast(activity);
- write_work(code->mainWorkWrite, CMD_HIDE_SOFT_INPUT, flags);
-}
-
-extern "C" void GameActivity_getWindowInsets(GameActivity *activity,
- GameCommonInsetsType type,
- ARect *insets) {
- if (type < 0 || type >= GAMECOMMON_INSETS_TYPE_COUNT) return;
- NativeCode *code = static_cast(activity);
- *insets = code->insetsState[type];
-}
-
-extern "C" GameTextInput *GameActivity_getTextInput(
- const GameActivity *activity) {
- const NativeCode *code = static_cast(activity);
- return code->gameTextInput;
-}
-
-/*
- * Log the JNI exception, if any.
- */
-static void checkAndClearException(JNIEnv *env, const char *methodName) {
- if (env->ExceptionCheck()) {
- ALOGE("Exception while running %s", methodName);
- env->ExceptionDescribe();
- env->ExceptionClear();
- }
-}
-
-/*
- * Callback for handling native events on the application's main thread.
- */
-static int mainWorkCallback(int fd, int events, void *data) {
- ALOGD("************** mainWorkCallback *********");
- NativeCode *code = (NativeCode *)data;
- if ((events & POLLIN) == 0) {
- return 1;
- }
-
- ActivityWork work;
- if (!read_work(code->mainWorkRead, &work)) {
- return 1;
- }
- LOG_TRACE("mainWorkCallback: cmd=%d", work.cmd);
- switch (work.cmd) {
- case CMD_FINISH: {
- code->env->CallVoidMethod(code->javaGameActivity,
- gGameActivityClassInfo.finish);
- checkAndClearException(code->env, "finish");
- } break;
- case CMD_SET_WINDOW_FLAGS: {
- code->env->CallVoidMethod(code->javaGameActivity,
- gGameActivityClassInfo.setWindowFlags,
- work.arg1, work.arg2);
- checkAndClearException(code->env, "setWindowFlags");
- } break;
- case CMD_SHOW_SOFT_INPUT: {
- GameTextInput_showIme(code->gameTextInput, work.arg1);
- } break;
- case CMD_SET_SOFT_INPUT_STATE: {
- std::lock_guard lock(code->gameTextInputStateMutex);
- GameTextInput_setState(code->gameTextInput,
- &code->gameTextInputState.inner);
- checkAndClearException(code->env, "setTextInputState");
- } break;
- case CMD_HIDE_SOFT_INPUT: {
- GameTextInput_hideIme(code->gameTextInput, work.arg1);
- } break;
- default:
- ALOGW("Unknown work command: %d", work.cmd);
- break;
- }
-
- return 1;
-}
-
-// ------------------------------------------------------------------------
-
-static thread_local std::string g_error_msg;
-
-static jlong loadNativeCode_native(JNIEnv *env, jobject javaGameActivity,
- jstring path, jstring funcName,
- jstring internalDataDir, jstring obbDir,
- jstring externalDataDir, jobject jAssetMgr,
- jbyteArray savedState) {
- LOG_TRACE("loadNativeCode_native");
- const char *pathStr = env->GetStringUTFChars(path, NULL);
- NativeCode *code = NULL;
-
- void *handle = dlopen(pathStr, RTLD_LAZY);
-
- env->ReleaseStringUTFChars(path, pathStr);
-
- if (handle == nullptr) {
- g_error_msg = dlerror();
- ALOGE("GameActivity dlopen(\"%s\") failed: %s", pathStr,
- g_error_msg.c_str());
- return 0;
- }
-
- const char *funcStr = env->GetStringUTFChars(funcName, NULL);
- code = new NativeCode(handle,
- (GameActivity_createFunc *)dlsym(handle, funcStr));
- env->ReleaseStringUTFChars(funcName, funcStr);
-
- if (code->createActivityFunc == nullptr) {
- g_error_msg = dlerror();
- ALOGW("GameActivity_onCreate not found: %s", g_error_msg.c_str());
- delete code;
- return 0;
- }
-
- code->looper = ALooper_forThread();
- if (code->looper == nullptr) {
- g_error_msg = "Unable to retrieve native ALooper";
- ALOGW("%s", g_error_msg.c_str());
- delete code;
- return 0;
- }
- ALooper_acquire(code->looper);
-
- int msgpipe[2];
- if (pipe(msgpipe)) {
- g_error_msg = "could not create pipe: ";
- g_error_msg += strerror(errno);
-
- ALOGW("%s", g_error_msg.c_str());
- delete code;
- return 0;
- }
- code->mainWorkRead = msgpipe[0];
- code->mainWorkWrite = msgpipe[1];
- int result = fcntl(code->mainWorkRead, F_SETFL, O_NONBLOCK);
- SLOGW_IF(result != 0,
- "Could not make main work read pipe "
- "non-blocking: %s",
- strerror(errno));
- result = fcntl(code->mainWorkWrite, F_SETFL, O_NONBLOCK);
- SLOGW_IF(result != 0,
- "Could not make main work write pipe "
- "non-blocking: %s",
- strerror(errno));
- ALooper_addFd(code->looper, code->mainWorkRead, 0, ALOOPER_EVENT_INPUT,
- mainWorkCallback, code);
-
- code->GameActivity::callbacks = &code->callbacks;
- if (env->GetJavaVM(&code->vm) < 0) {
- ALOGW("GameActivity GetJavaVM failed");
- delete code;
- return 0;
- }
- code->env = env;
- code->javaGameActivity = env->NewGlobalRef(javaGameActivity);
-
- const char *dirStr =
- internalDataDir ? env->GetStringUTFChars(internalDataDir, NULL) : "";
- code->internalDataPathObj = dirStr;
- code->internalDataPath = code->internalDataPathObj.c_str();
- if (internalDataDir) env->ReleaseStringUTFChars(internalDataDir, dirStr);
-
- dirStr =
- externalDataDir ? env->GetStringUTFChars(externalDataDir, NULL) : "";
- code->externalDataPathObj = dirStr;
- code->externalDataPath = code->externalDataPathObj.c_str();
- if (externalDataDir) env->ReleaseStringUTFChars(externalDataDir, dirStr);
-
- code->javaAssetManager = env->NewGlobalRef(jAssetMgr);
- code->assetManager = AAssetManager_fromJava(env, jAssetMgr);
-
- dirStr = obbDir ? env->GetStringUTFChars(obbDir, NULL) : "";
- code->obbPathObj = dirStr;
- code->obbPath = code->obbPathObj.c_str();
- if (obbDir) env->ReleaseStringUTFChars(obbDir, dirStr);
-
- jbyte *rawSavedState = NULL;
- jsize rawSavedSize = 0;
- if (savedState != NULL) {
- rawSavedState = env->GetByteArrayElements(savedState, NULL);
- rawSavedSize = env->GetArrayLength(savedState);
- }
- code->createActivityFunc(code, rawSavedState, rawSavedSize);
-
- code->gameTextInput = GameTextInput_init(env, 0);
- GameTextInput_setEventCallback(code->gameTextInput,
- reinterpret_cast(
- code->callbacks.onTextInputEvent),
- code);
-
- if (rawSavedState != NULL) {
- env->ReleaseByteArrayElements(savedState, rawSavedState, 0);
- }
-
- return reinterpret_cast(code);
-}
-
-static jstring getDlError_native(JNIEnv *env, jobject javaGameActivity) {
- jstring result = env->NewStringUTF(g_error_msg.c_str());
- g_error_msg.clear();
- return result;
-}
-
-static void unloadNativeCode_native(JNIEnv *env, jobject javaGameActivity,
- jlong handle) {
- LOG_TRACE("unloadNativeCode_native");
- if (handle != 0) {
- NativeCode *code = (NativeCode *)handle;
- delete code;
- }
-}
-
-static void onStart_native(JNIEnv *env, jobject javaGameActivity,
- jlong handle) {
- ALOGV("onStart_native");
- if (handle != 0) {
- NativeCode *code = (NativeCode *)handle;
- if (code->callbacks.onStart != NULL) {
- code->callbacks.onStart(code);
- }
- }
-}
-
-static void onResume_native(JNIEnv *env, jobject javaGameActivity,
- jlong handle) {
- LOG_TRACE("onResume_native");
- if (handle != 0) {
- NativeCode *code = (NativeCode *)handle;
- if (code->callbacks.onResume != NULL) {
- code->callbacks.onResume(code);
- }
- }
-}
-
-struct SaveInstanceLocals {
- JNIEnv *env;
- jbyteArray array;
-};
-
-static jbyteArray onSaveInstanceState_native(JNIEnv *env,
- jobject javaGameActivity,
- jlong handle) {
- LOG_TRACE("onSaveInstanceState_native");
-
- SaveInstanceLocals locals{
- env, NULL}; // Passed through the user's state prep function.
-
- if (handle != 0) {
- NativeCode *code = (NativeCode *)handle;
- if (code->callbacks.onSaveInstanceState != NULL) {
- code->callbacks.onSaveInstanceState(
- code,
- [](const char *bytes, int len, void *context) {
- auto locals = static_cast(context);
- if (len > 0) {
- locals->array = locals->env->NewByteArray(len);
- if (locals->array != NULL) {
- locals->env->SetByteArrayRegion(
- locals->array, 0, len, (const jbyte *)bytes);
- }
- }
- },
- &locals);
- }
- }
- return locals.array;
-}
-
-static void onPause_native(JNIEnv *env, jobject javaGameActivity,
- jlong handle) {
- LOG_TRACE("onPause_native");
- if (handle != 0) {
- NativeCode *code = (NativeCode *)handle;
- if (code->callbacks.onPause != NULL) {
- code->callbacks.onPause(code);
- }
- }
-}
-
-static void onStop_native(JNIEnv *env, jobject javaGameActivity, jlong handle) {
- LOG_TRACE("onStop_native");
- if (handle != 0) {
- NativeCode *code = (NativeCode *)handle;
- if (code->callbacks.onStop != NULL) {
- code->callbacks.onStop(code);
- }
- }
-}
-
-static void onConfigurationChanged_native(JNIEnv *env, jobject javaGameActivity,
- jlong handle) {
- LOG_TRACE("onConfigurationChanged_native");
- if (handle != 0) {
- NativeCode *code = (NativeCode *)handle;
- if (code->callbacks.onConfigurationChanged != NULL) {
- code->callbacks.onConfigurationChanged(code);
- }
- }
-}
-
-static void onTrimMemory_native(JNIEnv *env, jobject javaGameActivity,
- jlong handle, jint level) {
- LOG_TRACE("onTrimMemory_native");
- if (handle != 0) {
- NativeCode *code = (NativeCode *)handle;
- if (code->callbacks.onTrimMemory != NULL) {
- code->callbacks.onTrimMemory(code, level);
- }
- }
-}
-
-static void onWindowFocusChanged_native(JNIEnv *env, jobject javaGameActivity,
- jlong handle, jboolean focused) {
- LOG_TRACE("onWindowFocusChanged_native");
- if (handle != 0) {
- NativeCode *code = (NativeCode *)handle;
- if (code->callbacks.onWindowFocusChanged != NULL) {
- code->callbacks.onWindowFocusChanged(code, focused ? 1 : 0);
- }
- }
-}
-
-static void onSurfaceCreated_native(JNIEnv *env, jobject javaGameActivity,
- jlong handle, jobject surface) {
- ALOGV("onSurfaceCreated_native");
- LOG_TRACE("onSurfaceCreated_native");
- if (handle != 0) {
- NativeCode *code = (NativeCode *)handle;
- code->setSurface(surface);
-
- if (code->nativeWindow != NULL &&
- code->callbacks.onNativeWindowCreated != NULL) {
- code->callbacks.onNativeWindowCreated(code, code->nativeWindow);
- }
- }
-}
-
-static void onSurfaceChanged_native(JNIEnv *env, jobject javaGameActivity,
- jlong handle, jobject surface, jint format,
- jint width, jint height) {
- LOG_TRACE("onSurfaceChanged_native");
- if (handle != 0) {
- NativeCode *code = (NativeCode *)handle;
- ANativeWindow *oldNativeWindow = code->nativeWindow;
- // Fix for window being destroyed behind the scenes on older Android
- // versions.
- if (oldNativeWindow != NULL) {
- ANativeWindow_acquire(oldNativeWindow);
- }
- code->setSurface(surface);
- if (oldNativeWindow != code->nativeWindow) {
- if (oldNativeWindow != NULL &&
- code->callbacks.onNativeWindowDestroyed != NULL) {
- code->callbacks.onNativeWindowDestroyed(code, oldNativeWindow);
- }
- if (code->nativeWindow != NULL) {
- if (code->callbacks.onNativeWindowCreated != NULL) {
- code->callbacks.onNativeWindowCreated(code,
- code->nativeWindow);
- }
-
- code->lastWindowWidth =
- ANativeWindow_getWidth(code->nativeWindow);
- code->lastWindowHeight =
- ANativeWindow_getHeight(code->nativeWindow);
- }
- } else {
- // Maybe it was resized?
- int32_t newWidth = ANativeWindow_getWidth(code->nativeWindow);
- int32_t newHeight = ANativeWindow_getHeight(code->nativeWindow);
- if (newWidth != code->lastWindowWidth ||
- newHeight != code->lastWindowHeight) {
- if (code->callbacks.onNativeWindowResized != NULL) {
- code->callbacks.onNativeWindowResized(
- code, code->nativeWindow, newWidth, newHeight);
- }
- }
- }
- // Release the window we acquired earlier.
- if (oldNativeWindow != NULL) {
- ANativeWindow_release(oldNativeWindow);
- }
- }
-}
-
-static void onSurfaceRedrawNeeded_native(JNIEnv *env, jobject javaGameActivity,
- jlong handle) {
- LOG_TRACE("onSurfaceRedrawNeeded_native");
- if (handle != 0) {
- NativeCode *code = (NativeCode *)handle;
- if (code->nativeWindow != NULL &&
- code->callbacks.onNativeWindowRedrawNeeded != NULL) {
- code->callbacks.onNativeWindowRedrawNeeded(code,
- code->nativeWindow);
- }
- }
-}
-
-static void onSurfaceDestroyed_native(JNIEnv *env, jobject javaGameActivity,
- jlong handle) {
- LOG_TRACE("onSurfaceDestroyed_native");
- if (handle != 0) {
- NativeCode *code = (NativeCode *)handle;
- if (code->nativeWindow != NULL &&
- code->callbacks.onNativeWindowDestroyed != NULL) {
- code->callbacks.onNativeWindowDestroyed(code, code->nativeWindow);
- }
- code->setSurface(NULL);
- }
-}
-
-static bool enabledAxes[GAME_ACTIVITY_POINTER_INFO_AXIS_COUNT] = {
- /* AMOTION_EVENT_AXIS_X */ true,
- /* AMOTION_EVENT_AXIS_Y */ true,
- // Disable all other axes by default (they can be enabled using
- // `GameActivityPointerAxes_enableAxis`).
- false};
-
-extern "C" void GameActivityPointerAxes_enableAxis(int32_t axis) {
- if (axis < 0 || axis >= GAME_ACTIVITY_POINTER_INFO_AXIS_COUNT) {
- return;
- }
-
- enabledAxes[axis] = true;
-}
-
-extern "C" void GameActivityPointerAxes_disableAxis(int32_t axis) {
- if (axis < 0 || axis >= GAME_ACTIVITY_POINTER_INFO_AXIS_COUNT) {
- return;
- }
-
- enabledAxes[axis] = false;
-}
-
-static bool enabledHistoricalAxes[GAME_ACTIVITY_POINTER_INFO_AXIS_COUNT] = {
- // Disable all axes by default (they can be enabled using
- // `GameActivityPointerAxes_enableHistoricalAxis`).
- false};
-
-extern "C" void GameActivityHistoricalPointerAxes_enableAxis(int32_t axis) {
- if (axis < 0 || axis >= GAME_ACTIVITY_POINTER_INFO_AXIS_COUNT) {
- return;
- }
-
- enabledHistoricalAxes[axis] = true;
-}
-
-extern "C" void GameActivityHistoricalPointerAxes_disableAxis(int32_t axis) {
- if (axis < 0 || axis >= GAME_ACTIVITY_POINTER_INFO_AXIS_COUNT) {
- return;
- }
-
- enabledHistoricalAxes[axis] = false;
-}
-
-extern "C" void GameActivity_setImeEditorInfo(GameActivity *activity,
- int inputType, int actionId,
- int imeOptions) {
- JNIEnv *env;
- if (activity->vm->AttachCurrentThread(&env, NULL) == JNI_OK) {
- env->CallVoidMethod(activity->javaGameActivity,
- gGameActivityClassInfo.setImeEditorInfoFields,
- inputType, actionId, imeOptions);
- }
-}
-
-static struct {
- jmethodID getDeviceId;
- jmethodID getSource;
- jmethodID getAction;
-
- jmethodID getEventTime;
- jmethodID getDownTime;
-
- jmethodID getFlags;
- jmethodID getMetaState;
-
- jmethodID getActionButton;
- jmethodID getButtonState;
- jmethodID getClassification;
- jmethodID getEdgeFlags;
-
- jmethodID getPointerCount;
- jmethodID getPointerId;
- jmethodID getToolType;
- jmethodID getRawX;
- jmethodID getRawY;
- jmethodID getXPrecision;
- jmethodID getYPrecision;
- jmethodID getAxisValue;
-
- jmethodID getHistorySize;
- jmethodID getHistoricalEventTime;
- jmethodID getHistoricalAxisValue;
-} gMotionEventClassInfo;
-
-extern "C" int GameActivityMotionEvent_fromJava(
- JNIEnv *env, jobject motionEvent, GameActivityMotionEvent *out_event,
- GameActivityHistoricalPointerAxes *out_historical) {
- static bool gMotionEventClassInfoInitialized = false;
- if (!gMotionEventClassInfoInitialized) {
- int sdkVersion = GetSystemPropAsInt("ro.build.version.sdk");
- gMotionEventClassInfo = {0};
- jclass motionEventClass = env->FindClass("android/view/MotionEvent");
- gMotionEventClassInfo.getDeviceId =
- env->GetMethodID(motionEventClass, "getDeviceId", "()I");
- gMotionEventClassInfo.getSource =
- env->GetMethodID(motionEventClass, "getSource", "()I");
- gMotionEventClassInfo.getAction =
- env->GetMethodID(motionEventClass, "getAction", "()I");
- gMotionEventClassInfo.getEventTime =
- env->GetMethodID(motionEventClass, "getEventTime", "()J");
- gMotionEventClassInfo.getDownTime =
- env->GetMethodID(motionEventClass, "getDownTime", "()J");
- gMotionEventClassInfo.getFlags =
- env->GetMethodID(motionEventClass, "getFlags", "()I");
- gMotionEventClassInfo.getMetaState =
- env->GetMethodID(motionEventClass, "getMetaState", "()I");
- if (sdkVersion >= 23) {
- gMotionEventClassInfo.getActionButton =
- env->GetMethodID(motionEventClass, "getActionButton", "()I");
- }
- if (sdkVersion >= 14) {
- gMotionEventClassInfo.getButtonState =
- env->GetMethodID(motionEventClass, "getButtonState", "()I");
- }
- if (sdkVersion >= 29) {
- gMotionEventClassInfo.getClassification =
- env->GetMethodID(motionEventClass, "getClassification", "()I");
- }
- gMotionEventClassInfo.getEdgeFlags =
- env->GetMethodID(motionEventClass, "getEdgeFlags", "()I");
- gMotionEventClassInfo.getPointerCount =
- env->GetMethodID(motionEventClass, "getPointerCount", "()I");
- gMotionEventClassInfo.getPointerId =
- env->GetMethodID(motionEventClass, "getPointerId", "(I)I");
- gMotionEventClassInfo.getToolType =
- env->GetMethodID(motionEventClass, "getToolType", "(I)I");
- if (sdkVersion >= 29) {
- gMotionEventClassInfo.getRawX =
- env->GetMethodID(motionEventClass, "getRawX", "(I)F");
- gMotionEventClassInfo.getRawY =
- env->GetMethodID(motionEventClass, "getRawY", "(I)F");
- }
- gMotionEventClassInfo.getXPrecision =
- env->GetMethodID(motionEventClass, "getXPrecision", "()F");
- gMotionEventClassInfo.getYPrecision =
- env->GetMethodID(motionEventClass, "getYPrecision", "()F");
- gMotionEventClassInfo.getAxisValue =
- env->GetMethodID(motionEventClass, "getAxisValue", "(II)F");
-
- gMotionEventClassInfo.getHistorySize =
- env->GetMethodID(motionEventClass, "getHistorySize", "()I");
- gMotionEventClassInfo.getHistoricalEventTime =
- env->GetMethodID(motionEventClass, "getHistoricalEventTime", "(I)J");
- gMotionEventClassInfo.getHistoricalAxisValue =
- env->GetMethodID(motionEventClass, "getHistoricalAxisValue", "(III)F");
-
- gMotionEventClassInfoInitialized = true;
- }
-
- int historySize =
- env->CallIntMethod(motionEvent, gMotionEventClassInfo.getHistorySize);
- historySize =
- std::min(historySize, GAMEACTIVITY_MAX_NUM_HISTORICAL_IN_MOTION_EVENT);
-
- int localEnabledHistoricalAxis[GAME_ACTIVITY_POINTER_INFO_AXIS_COUNT];
- int enabledHistoricalAxisCount = 0;
-
- for (int axisIndex = 0;
- axisIndex < GAME_ACTIVITY_POINTER_INFO_AXIS_COUNT;
- ++axisIndex) {
- if (enabledHistoricalAxes[axisIndex]) {
- localEnabledHistoricalAxis[enabledHistoricalAxisCount++] = axisIndex;
- }
- }
- out_event->historicalCount = enabledHistoricalAxisCount == 0 ? 0 : historySize;
- out_event->historicalStart = 0; // Free for caller to use
-
- // The historical event times aren't unique per-pointer but for simplicity
- // we output a per-pointer event time, copied from here...
- int64_t historicalEventTimes[GAMEACTIVITY_MAX_NUM_HISTORICAL_IN_MOTION_EVENT];
- for (int histIndex = 0; histIndex < historySize; ++histIndex) {
- historicalEventTimes[histIndex] =
- env->CallLongMethod(motionEvent,
- gMotionEventClassInfo.getHistoricalEventTime, histIndex) *
- 1000000;
- }
-
- int pointerCount =
- env->CallIntMethod(motionEvent, gMotionEventClassInfo.getPointerCount);
- pointerCount =
- std::min(pointerCount, GAMEACTIVITY_MAX_NUM_POINTERS_IN_MOTION_EVENT);
- out_event->pointerCount = pointerCount;
- for (int i = 0; i < pointerCount; ++i) {
- out_event->pointers[i] = {
- /*id=*/env->CallIntMethod(motionEvent,
- gMotionEventClassInfo.getPointerId, i),
- /*toolType=*/env->CallIntMethod(motionEvent,
- gMotionEventClassInfo.getToolType, i),
- /*axisValues=*/{0},
- /*rawX=*/gMotionEventClassInfo.getRawX
- ? env->CallFloatMethod(motionEvent,
- gMotionEventClassInfo.getRawX, i)
- : 0,
- /*rawY=*/gMotionEventClassInfo.getRawY
- ? env->CallFloatMethod(motionEvent,
- gMotionEventClassInfo.getRawY, i)
- : 0,
- };
-
- for (int axisIndex = 0;
- axisIndex < GAME_ACTIVITY_POINTER_INFO_AXIS_COUNT; ++axisIndex) {
- if (enabledAxes[axisIndex]) {
- out_event->pointers[i].axisValues[axisIndex] =
- env->CallFloatMethod(motionEvent,
- gMotionEventClassInfo.getAxisValue,
- axisIndex, i);
- }
- }
-
- if (enabledHistoricalAxisCount > 0) {
- for (int histIndex = 0; histIndex < historySize; ++histIndex) {
- int pointerHistIndex = historySize * i;
- out_historical[pointerHistIndex].eventTime = historicalEventTimes[histIndex];
- for (int c = 0; c < enabledHistoricalAxisCount; ++c) {
- int axisIndex = localEnabledHistoricalAxis[c];
- out_historical[pointerHistIndex].axisValues[axisIndex] =
- env->CallFloatMethod(motionEvent,
- gMotionEventClassInfo.getHistoricalAxisValue,
- axisIndex, i, histIndex);
- }
- }
- }
- }
-
- out_event->deviceId =
- env->CallIntMethod(motionEvent, gMotionEventClassInfo.getDeviceId);
- out_event->source =
- env->CallIntMethod(motionEvent, gMotionEventClassInfo.getSource);
- out_event->action =
- env->CallIntMethod(motionEvent, gMotionEventClassInfo.getAction);
- out_event->eventTime =
- env->CallLongMethod(motionEvent, gMotionEventClassInfo.getEventTime) *
- 1000000;
- out_event->downTime =
- env->CallLongMethod(motionEvent, gMotionEventClassInfo.getDownTime) *
- 1000000;
- out_event->flags =
- env->CallIntMethod(motionEvent, gMotionEventClassInfo.getFlags);
- out_event->metaState =
- env->CallIntMethod(motionEvent, gMotionEventClassInfo.getMetaState);
- out_event->actionButton =
- gMotionEventClassInfo.getActionButton
- ? env->CallIntMethod(motionEvent,
- gMotionEventClassInfo.getActionButton)
- : 0;
- out_event->buttonState =
- gMotionEventClassInfo.getButtonState
- ? env->CallIntMethod(motionEvent,
- gMotionEventClassInfo.getButtonState)
- : 0;
- out_event->classification =
- gMotionEventClassInfo.getClassification
- ? env->CallIntMethod(motionEvent,
- gMotionEventClassInfo.getClassification)
- : 0;
- out_event->edgeFlags =
- env->CallIntMethod(motionEvent, gMotionEventClassInfo.getEdgeFlags);
- out_event->precisionX =
- env->CallFloatMethod(motionEvent, gMotionEventClassInfo.getXPrecision);
- out_event->precisionY =
- env->CallFloatMethod(motionEvent, gMotionEventClassInfo.getYPrecision);
-
- return out_event->pointerCount * out_event->historicalCount;
-}
-
-static struct {
- jmethodID getDeviceId;
- jmethodID getSource;
- jmethodID getAction;
-
- jmethodID getEventTime;
- jmethodID getDownTime;
-
- jmethodID getFlags;
- jmethodID getMetaState;
-
- jmethodID getModifiers;
- jmethodID getRepeatCount;
- jmethodID getKeyCode;
- jmethodID getScanCode;
-} gKeyEventClassInfo;
-
-extern "C" void GameActivityKeyEvent_fromJava(JNIEnv *env, jobject keyEvent,
- GameActivityKeyEvent *out_event) {
- static bool gKeyEventClassInfoInitialized = false;
- if (!gKeyEventClassInfoInitialized) {
- int sdkVersion = GetSystemPropAsInt("ro.build.version.sdk");
- gKeyEventClassInfo = {0};
- jclass keyEventClass = env->FindClass("android/view/KeyEvent");
- gKeyEventClassInfo.getDeviceId =
- env->GetMethodID(keyEventClass, "getDeviceId", "()I");
- gKeyEventClassInfo.getSource =
- env->GetMethodID(keyEventClass, "getSource", "()I");
- gKeyEventClassInfo.getAction =
- env->GetMethodID(keyEventClass, "getAction", "()I");
- gKeyEventClassInfo.getEventTime =
- env->GetMethodID(keyEventClass, "getEventTime", "()J");
- gKeyEventClassInfo.getDownTime =
- env->GetMethodID(keyEventClass, "getDownTime", "()J");
- gKeyEventClassInfo.getFlags =
- env->GetMethodID(keyEventClass, "getFlags", "()I");
- gKeyEventClassInfo.getMetaState =
- env->GetMethodID(keyEventClass, "getMetaState", "()I");
- if (sdkVersion >= 13) {
- gKeyEventClassInfo.getModifiers =
- env->GetMethodID(keyEventClass, "getModifiers", "()I");
- }
- gKeyEventClassInfo.getRepeatCount =
- env->GetMethodID(keyEventClass, "getRepeatCount", "()I");
- gKeyEventClassInfo.getKeyCode =
- env->GetMethodID(keyEventClass, "getKeyCode", "()I");
- gKeyEventClassInfo.getScanCode =
- env->GetMethodID(keyEventClass, "getScanCode", "()I");
-
- gKeyEventClassInfoInitialized = true;
- }
-
- *out_event = {
- /*deviceId=*/env->CallIntMethod(keyEvent,
- gKeyEventClassInfo.getDeviceId),
- /*source=*/env->CallIntMethod(keyEvent, gKeyEventClassInfo.getSource),
- /*action=*/env->CallIntMethod(keyEvent, gKeyEventClassInfo.getAction),
- // TODO: introduce a millisecondsToNanoseconds helper:
- /*eventTime=*/
- env->CallLongMethod(keyEvent, gKeyEventClassInfo.getEventTime) *
- 1000000,
- /*downTime=*/
- env->CallLongMethod(keyEvent, gKeyEventClassInfo.getDownTime) * 1000000,
- /*flags=*/env->CallIntMethod(keyEvent, gKeyEventClassInfo.getFlags),
- /*metaState=*/
- env->CallIntMethod(keyEvent, gKeyEventClassInfo.getMetaState),
- /*modifiers=*/gKeyEventClassInfo.getModifiers
- ? env->CallIntMethod(keyEvent, gKeyEventClassInfo.getModifiers)
- : 0,
- /*repeatCount=*/
- env->CallIntMethod(keyEvent, gKeyEventClassInfo.getRepeatCount),
- /*keyCode=*/
- env->CallIntMethod(keyEvent, gKeyEventClassInfo.getKeyCode),
- /*scanCode=*/
- env->CallIntMethod(keyEvent, gKeyEventClassInfo.getScanCode)};
-}
-
-static bool onTouchEvent_native(JNIEnv *env, jobject javaGameActivity,
- jlong handle, jobject motionEvent) {
- if (handle == 0) return false;
- NativeCode *code = (NativeCode *)handle;
- if (code->callbacks.onTouchEvent == nullptr) return false;
-
- static GameActivityMotionEvent c_event;
- // Note the actual data is written contiguously as numPointers x historySize
- // entries.
- static GameActivityHistoricalPointerAxes historical[GAMEACTIVITY_MAX_NUM_POINTERS_IN_MOTION_EVENT * GAMEACTIVITY_MAX_NUM_HISTORICAL_IN_MOTION_EVENT];
- int historicalLen = GameActivityMotionEvent_fromJava(env, motionEvent, &c_event, historical);
- return code->callbacks.onTouchEvent(code, &c_event, historical, historicalLen);
-}
-
-static bool onKeyUp_native(JNIEnv *env, jobject javaGameActivity, jlong handle,
- jobject keyEvent) {
- if (handle == 0) return false;
- NativeCode *code = (NativeCode *)handle;
- if (code->callbacks.onKeyUp == nullptr) return false;
-
- static GameActivityKeyEvent c_event;
- GameActivityKeyEvent_fromJava(env, keyEvent, &c_event);
- return code->callbacks.onKeyUp(code, &c_event);
-}
-
-static bool onKeyDown_native(JNIEnv *env, jobject javaGameActivity,
- jlong handle, jobject keyEvent) {
- if (handle == 0) return false;
- NativeCode *code = (NativeCode *)handle;
- if (code->callbacks.onKeyDown == nullptr) return false;
-
- static GameActivityKeyEvent c_event;
- GameActivityKeyEvent_fromJava(env, keyEvent, &c_event);
- return code->callbacks.onKeyDown(code, &c_event);
-}
-
-static void onTextInput_native(JNIEnv *env, jobject activity, jlong handle,
- jobject textInputEvent) {
- if (handle == 0) return;
- NativeCode *code = (NativeCode *)handle;
- GameTextInput_processEvent(code->gameTextInput, textInputEvent);
-}
-
-static void onWindowInsetsChanged_native(JNIEnv *env, jobject activity,
- jlong handle) {
- if (handle == 0) return;
- NativeCode *code = (NativeCode *)handle;
- if (code->callbacks.onWindowInsetsChanged == nullptr) return;
- for (int type = 0; type < GAMECOMMON_INSETS_TYPE_COUNT; ++type) {
- jobject jinsets;
- // Note that waterfall insets are handled differently on the Java side.
- if (type == GAMECOMMON_INSETS_TYPE_WATERFALL) {
- jinsets = env->CallObjectMethod(
- code->javaGameActivity,
- gGameActivityClassInfo.getWaterfallInsets);
- } else {
- jint jtype = env->CallStaticIntMethod(
- gWindowInsetsCompatTypeClassInfo.clazz,
- gWindowInsetsCompatTypeClassInfo.methods[type]);
- jinsets = env->CallObjectMethod(
- code->javaGameActivity, gGameActivityClassInfo.getWindowInsets,
- jtype);
- }
- ARect &insets = code->insetsState[type];
- if (jinsets == nullptr) {
- insets.left = 0;
- insets.right = 0;
- insets.top = 0;
- insets.bottom = 0;
- } else {
- insets.left = env->GetIntField(jinsets, gInsetsClassInfo.left);
- insets.right = env->GetIntField(jinsets, gInsetsClassInfo.right);
- insets.top = env->GetIntField(jinsets, gInsetsClassInfo.top);
- insets.bottom = env->GetIntField(jinsets, gInsetsClassInfo.bottom);
- }
- }
- GameTextInput_processImeInsets(
- code->gameTextInput, &code->insetsState[GAMECOMMON_INSETS_TYPE_IME]);
- code->callbacks.onWindowInsetsChanged(code);
-}
-
-static void setInputConnection_native(JNIEnv *env, jobject activity,
- jlong handle, jobject inputConnection) {
- NativeCode *code = (NativeCode *)handle;
- GameTextInput_setInputConnection(code->gameTextInput, inputConnection);
-}
-
-static const JNINativeMethod g_methods[] = {
- {"loadNativeCode",
- "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/"
- "String;Ljava/lang/String;Landroid/content/res/AssetManager;[B)J",
- (void *)loadNativeCode_native},
- {"getDlError", "()Ljava/lang/String;", (void *)getDlError_native},
- {"unloadNativeCode", "(J)V", (void *)unloadNativeCode_native},
- {"onStartNative", "(J)V", (void *)onStart_native},
- {"onResumeNative", "(J)V", (void *)onResume_native},
- {"onSaveInstanceStateNative", "(J)[B", (void *)onSaveInstanceState_native},
- {"onPauseNative", "(J)V", (void *)onPause_native},
- {"onStopNative", "(J)V", (void *)onStop_native},
- {"onConfigurationChangedNative", "(J)V",
- (void *)onConfigurationChanged_native},
- {"onTrimMemoryNative", "(JI)V", (void *)onTrimMemory_native},
- {"onWindowFocusChangedNative", "(JZ)V",
- (void *)onWindowFocusChanged_native},
- {"onSurfaceCreatedNative", "(JLandroid/view/Surface;)V",
- (void *)onSurfaceCreated_native},
- {"onSurfaceChangedNative", "(JLandroid/view/Surface;III)V",
- (void *)onSurfaceChanged_native},
- {"onSurfaceRedrawNeededNative", "(JLandroid/view/Surface;)V",
- (void *)onSurfaceRedrawNeeded_native},
- {"onSurfaceDestroyedNative", "(J)V", (void *)onSurfaceDestroyed_native},
- {"onTouchEventNative", "(JLandroid/view/MotionEvent;)Z",
- (void *)onTouchEvent_native},
- {"onKeyDownNative", "(JLandroid/view/KeyEvent;)Z",
- (void *)onKeyDown_native},
- {"onKeyUpNative", "(JLandroid/view/KeyEvent;)Z", (void *)onKeyUp_native},
- {"onTextInputEventNative",
- "(JLcom/google/androidgamesdk/gametextinput/State;)V",
- (void *)onTextInput_native},
- {"onWindowInsetsChangedNative", "(J)V",
- (void *)onWindowInsetsChanged_native},
- {"setInputConnectionNative",
- "(JLcom/google/androidgamesdk/gametextinput/InputConnection;)V",
- (void *)setInputConnection_native},
-};
-
-static const char *const kGameActivityPathName =
- "com/google/androidgamesdk/GameActivity";
-
-static const char *const kInsetsPathName = "androidx/core/graphics/Insets";
-
-static const char *const kWindowInsetsCompatTypePathName =
- "androidx/core/view/WindowInsetsCompat$Type";
-
-#define FIND_CLASS(var, className) \
- var = env->FindClass(className); \
- LOG_FATAL_IF(!var, "Unable to find class %s", className);
-
-#define GET_METHOD_ID(var, clazz, methodName, fieldDescriptor) \
- var = env->GetMethodID(clazz, methodName, fieldDescriptor); \
- LOG_FATAL_IF(!var, "Unable to find method %s", methodName);
-
-#define GET_STATIC_METHOD_ID(var, clazz, methodName, fieldDescriptor) \
- var = env->GetStaticMethodID(clazz, methodName, fieldDescriptor); \
- LOG_FATAL_IF(!var, "Unable to find static method %s", methodName);
-
-#define GET_FIELD_ID(var, clazz, fieldName, fieldDescriptor) \
- var = env->GetFieldID(clazz, fieldName, fieldDescriptor); \
- LOG_FATAL_IF(!var, "Unable to find field %s", fieldName);
-
-static int jniRegisterNativeMethods(JNIEnv *env, const char *className,
- const JNINativeMethod *methods,
- int numMethods) {
- ALOGV("Registering %s's %d native methods...", className, numMethods);
- jclass clazz = env->FindClass(className);
- LOG_FATAL_IF(clazz == nullptr,
- "Native registration unable to find class '%s'; aborting...",
- className);
- int result = env->RegisterNatives(clazz, methods, numMethods);
- env->DeleteLocalRef(clazz);
- if (result == 0) {
- return 0;
- }
-
- // Failure to register natives is fatal. Try to report the corresponding
- // exception, otherwise abort with generic failure message.
- jthrowable thrown = env->ExceptionOccurred();
- if (thrown != NULL) {
- env->ExceptionDescribe();
- env->DeleteLocalRef(thrown);
- }
- LOG_FATAL("RegisterNatives failed for '%s'; aborting...", className);
-}
-
-extern "C" int GameActivity_register(JNIEnv *env) {
- ALOGD("GameActivity_register");
- jclass activity_class;
- FIND_CLASS(activity_class, kGameActivityPathName);
- GET_METHOD_ID(gGameActivityClassInfo.finish, activity_class, "finish",
- "()V");
- GET_METHOD_ID(gGameActivityClassInfo.setWindowFlags, activity_class,
- "setWindowFlags", "(II)V");
- GET_METHOD_ID(gGameActivityClassInfo.getWindowInsets, activity_class,
- "getWindowInsets", "(I)Landroidx/core/graphics/Insets;");
- GET_METHOD_ID(gGameActivityClassInfo.getWaterfallInsets, activity_class,
- "getWaterfallInsets", "()Landroidx/core/graphics/Insets;");
- GET_METHOD_ID(gGameActivityClassInfo.setImeEditorInfoFields, activity_class,
- "setImeEditorInfoFields", "(III)V");
- jclass insets_class;
- FIND_CLASS(insets_class, kInsetsPathName);
- GET_FIELD_ID(gInsetsClassInfo.left, insets_class, "left", "I");
- GET_FIELD_ID(gInsetsClassInfo.right, insets_class, "right", "I");
- GET_FIELD_ID(gInsetsClassInfo.top, insets_class, "top", "I");
- GET_FIELD_ID(gInsetsClassInfo.bottom, insets_class, "bottom", "I");
- jclass windowInsetsCompatType_class;
- FIND_CLASS(windowInsetsCompatType_class, kWindowInsetsCompatTypePathName);
- gWindowInsetsCompatTypeClassInfo.clazz =
- (jclass)env->NewGlobalRef(windowInsetsCompatType_class);
- // These names must match, in order, the GameCommonInsetsType enum fields
- // Note that waterfall is handled differently by the insets API, so we
- // exclude it here.
- const char *methodNames[GAMECOMMON_INSETS_TYPE_WATERFALL] = {
- "captionBar",
- "displayCutout",
- "ime",
- "mandatorySystemGestures",
- "navigationBars",
- "statusBars",
- "systemBars",
- "systemGestures",
- "tappableElement"};
- for (int i = 0; i < GAMECOMMON_INSETS_TYPE_WATERFALL; ++i) {
- GET_STATIC_METHOD_ID(gWindowInsetsCompatTypeClassInfo.methods[i],
- windowInsetsCompatType_class, methodNames[i],
- "()I");
- }
- return jniRegisterNativeMethods(env, kGameActivityPathName, g_methods,
- NELEM(g_methods));
-}
-
-// XXX: This symbol is renamed with a _C suffix and then re-exported from
-// Rust because Rust/Cargo don't give us a way to directly export symbols
-// from C/C++ code: https://github.com/rust-lang/rfcs/issues/2771
-//
-// Register this method so that GameActiviy_register does not need to be called
-// manually.
-extern "C" jlong Java_com_google_androidgamesdk_GameActivity_loadNativeCode_C(
- JNIEnv *env, jobject javaGameActivity, jstring path, jstring funcName,
- jstring internalDataDir, jstring obbDir, jstring externalDataDir,
- jobject jAssetMgr, jbyteArray savedState) {
- GameActivity_register(env);
- jlong nativeCode = loadNativeCode_native(
- env, javaGameActivity, path, funcName, internalDataDir, obbDir,
- externalDataDir, jAssetMgr, savedState);
- return nativeCode;
-}
diff --git a/android-activity/game-activity-csrc/game-activity/GameActivity.h b/android-activity/game-activity-csrc/game-activity/GameActivity.h
deleted file mode 100644
index c5abfc04..00000000
--- a/android-activity/game-activity-csrc/game-activity/GameActivity.h
+++ /dev/null
@@ -1,820 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @addtogroup GameActivity Game Activity
- * The interface to use GameActivity.
- * @{
- */
-
-/**
- * @file GameActivity.h
- */
-
-#ifndef ANDROID_GAME_SDK_GAME_ACTIVITY_H
-#define ANDROID_GAME_SDK_GAME_ACTIVITY_H
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "game-text-input/gametextinput.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * {@link GameActivityCallbacks}
- */
-struct GameActivityCallbacks;
-
-/**
- * This structure defines the native side of an android.app.GameActivity.
- * It is created by the framework, and handed to the application's native
- * code as it is being launched.
- */
-typedef struct GameActivity {
- /**
- * Pointer to the callback function table of the native application.
- * You can set the functions here to your own callbacks. The callbacks
- * pointer itself here should not be changed; it is allocated and managed
- * for you by the framework.
- */
- struct GameActivityCallbacks* callbacks;
-
- /**
- * The global handle on the process's Java VM.
- */
- JavaVM* vm;
-
- /**
- * JNI context for the main thread of the app. Note that this field
- * can ONLY be used from the main thread of the process; that is, the
- * thread that calls into the GameActivityCallbacks.
- */
- JNIEnv* env;
-
- /**
- * The GameActivity object handle.
- */
- jobject javaGameActivity;
-
- /**
- * Path to this application's internal data directory.
- */
- const char* internalDataPath;
-
- /**
- * Path to this application's external (removable/mountable) data directory.
- */
- const char* externalDataPath;
-
- /**
- * The platform's SDK version code.
- */
- int32_t sdkVersion;
-
- /**
- * This is the native instance of the application. It is not used by
- * the framework, but can be set by the application to its own instance
- * state.
- */
- void* instance;
-
- /**
- * Pointer to the Asset Manager instance for the application. The
- * application uses this to access binary assets bundled inside its own .apk
- * file.
- */
- AAssetManager* assetManager;
-
- /**
- * Available starting with Honeycomb: path to the directory containing
- * the application's OBB files (if any). If the app doesn't have any
- * OBB files, this directory may not exist.
- */
- const char* obbPath;
-} GameActivity;
-
-/**
- * The maximum number of axes supported in an Android MotionEvent.
- * See https://developer.android.com/ndk/reference/group/input.
- */
-#define GAME_ACTIVITY_POINTER_INFO_AXIS_COUNT 48
-
-/**
- * \brief Describe information about a pointer, found in a
- * GameActivityMotionEvent.
- *
- * You can read values directly from this structure, or use helper functions
- * (`GameActivityPointerAxes_getX`, `GameActivityPointerAxes_getY` and
- * `GameActivityPointerAxes_getAxisValue`).
- *
- * The X axis and Y axis are enabled by default but any other axis that you want
- * to read **must** be enabled first, using
- * `GameActivityPointerAxes_enableAxis`.
- *
- * \see GameActivityMotionEvent
- */
-typedef struct GameActivityPointerAxes {
- int32_t id;
- int32_t toolType;
- float axisValues[GAME_ACTIVITY_POINTER_INFO_AXIS_COUNT];
- float rawX;
- float rawY;
-} GameActivityPointerAxes;
-
-typedef struct GameActivityHistoricalPointerAxes {
- int64_t eventTime;
- float axisValues[GAME_ACTIVITY_POINTER_INFO_AXIS_COUNT];
-} GameActivityHistoricalPointerAxes;
-
-/** \brief Get the current X coordinate of the pointer. */
-inline float GameActivityPointerAxes_getX(
- const GameActivityPointerAxes* pointerInfo) {
- return pointerInfo->axisValues[AMOTION_EVENT_AXIS_X];
-}
-
-/** \brief Get the current Y coordinate of the pointer. */
-inline float GameActivityPointerAxes_getY(
- const GameActivityPointerAxes* pointerInfo) {
- return pointerInfo->axisValues[AMOTION_EVENT_AXIS_Y];
-}
-
-/**
- * \brief Enable the specified axis, so that its value is reported in the
- * GameActivityPointerAxes structures stored in a motion event.
- *
- * You must enable any axis that you want to read, apart from
- * `AMOTION_EVENT_AXIS_X` and `AMOTION_EVENT_AXIS_Y` that are enabled by
- * default.
- *
- * If the axis index is out of range, nothing is done.
- */
-void GameActivityPointerAxes_enableAxis(int32_t axis);
-
-/**
- * \brief Disable the specified axis. Its value won't be reported in the
- * GameActivityPointerAxes structures stored in a motion event anymore.
- *
- * Apart from X and Y, any axis that you want to read **must** be enabled first,
- * using `GameActivityPointerAxes_enableAxis`.
- *
- * If the axis index is out of range, nothing is done.
- */
-void GameActivityPointerAxes_disableAxis(int32_t axis);
-
-/**
- * \brief Enable the specified axis, so that its value is reported in the
- * GameActivityHistoricalPointerAxes structures associated with a motion event.
- *
- * You must enable any axis that you want to read (no axes are enabled by
- * default).
- *
- * If the axis index is out of range, nothing is done.
- */
-void GameActivityHistoricalPointerAxes_enableAxis(int32_t axis);
-
-/**
- * \brief Disable the specified axis. Its value won't be reported in the
- * GameActivityHistoricalPointerAxes structures associated with motion events
- * anymore.
- *
- * If the axis index is out of range, nothing is done.
- */
-void GameActivityHistoricalPointerAxes_disableAxis(int32_t axis);
-
-/**
- * \brief Get the value of the requested axis.
- *
- * Apart from X and Y, any axis that you want to read **must** be enabled first,
- * using `GameActivityPointerAxes_enableAxis`.
- *
- * Find the valid enums for the axis (`AMOTION_EVENT_AXIS_X`,
- * `AMOTION_EVENT_AXIS_Y`, `AMOTION_EVENT_AXIS_PRESSURE`...)
- * in https://developer.android.com/ndk/reference/group/input.
- *
- * @param pointerInfo The structure containing information about the pointer,
- * obtained from GameActivityMotionEvent.
- * @param axis The axis to get the value from
- * @return The value of the axis, or 0 if the axis is invalid or was not
- * enabled.
- */
-inline float GameActivityPointerAxes_getAxisValue(
- GameActivityPointerAxes* pointerInfo, int32_t axis) {
- if (axis < 0 || axis >= GAME_ACTIVITY_POINTER_INFO_AXIS_COUNT) {
- return 0;
- }
-
- return pointerInfo->axisValues[axis];
-}
-
-/**
- * The maximum number of pointers returned inside a motion event.
- */
-#if (defined GAMEACTIVITY_MAX_NUM_POINTERS_IN_MOTION_EVENT_OVERRIDE)
-#define GAMEACTIVITY_MAX_NUM_POINTERS_IN_MOTION_EVENT \
- GAMEACTIVITY_MAX_NUM_POINTERS_IN_MOTION_EVENT_OVERRIDE
-#else
-#define GAMEACTIVITY_MAX_NUM_POINTERS_IN_MOTION_EVENT 8
-#endif
-
-/**
- * The maximum number of historic samples associated with a single motion event.
- */
-#if (defined GAMEACTIVITY_MAX_NUM_HISTORICAL_IN_MOTION_EVENT_OVERRIDE)
-#define GAMEACTIVITY_MAX_NUM_HISTORICAL_IN_MOTION_EVENT \
- GAMEACTIVITY_MAX_NUM_HISTORICAL_IN_MOTION_EVENT_OVERRIDE
-#else
-#define GAMEACTIVITY_MAX_NUM_HISTORICAL_IN_MOTION_EVENT 8
-#endif
-
-/**
- * \brief Describe a motion event that happened on the GameActivity SurfaceView.
- *
- * This is 1:1 mapping to the information contained in a Java `MotionEvent`
- * (see https://developer.android.com/reference/android/view/MotionEvent).
- */
-typedef struct GameActivityMotionEvent {
- int32_t deviceId;
- int32_t source;
- int32_t action;
-
- int64_t eventTime;
- int64_t downTime;
-
- int32_t flags;
- int32_t metaState;
-
- int32_t actionButton;
- int32_t buttonState;
- int32_t classification;
- int32_t edgeFlags;
-
- uint32_t pointerCount;
- GameActivityPointerAxes
- pointers[GAMEACTIVITY_MAX_NUM_POINTERS_IN_MOTION_EVENT];
-
- float precisionX;
- float precisionY;
-
- int16_t historicalStart;
-
- // Note the actual buffer of historical data has a length of
- // pointerCount * historicalCount, since the historical axis
- // data is per-pointer.
- int16_t historicalCount;
-} GameActivityMotionEvent;
-
-/**
- * \brief Describe a key event that happened on the GameActivity SurfaceView.
- *
- * This is 1:1 mapping to the information contained in a Java `KeyEvent`
- * (see https://developer.android.com/reference/android/view/KeyEvent).
- */
-typedef struct GameActivityKeyEvent {
- int32_t deviceId;
- int32_t source;
- int32_t action;
-
- int64_t eventTime;
- int64_t downTime;
-
- int32_t flags;
- int32_t metaState;
-
- int32_t modifiers;
- int32_t repeatCount;
- int32_t keyCode;
- int32_t scanCode;
-} GameActivityKeyEvent;
-
-/**
- * A function the user should call from their callback with the data, its length
- * and the library- supplied context.
- */
-typedef void (*SaveInstanceStateRecallback)(const char* bytes, int len,
- void* context);
-
-/**
- * These are the callbacks the framework makes into a native application.
- * All of these callbacks happen on the main thread of the application.
- * By default, all callbacks are NULL; set to a pointer to your own function
- * to have it called.
- */
-typedef struct GameActivityCallbacks {
- /**
- * GameActivity has started. See Java documentation for Activity.onStart()
- * for more information.
- */
- void (*onStart)(GameActivity* activity);
-
- /**
- * GameActivity has resumed. See Java documentation for Activity.onResume()
- * for more information.
- */
- void (*onResume)(GameActivity* activity);
-
- /**
- * The framework is asking GameActivity to save its current instance state.
- * See the Java documentation for Activity.onSaveInstanceState() for more
- * information. The user should call the recallback with their data, its
- * length and the provided context; they retain ownership of the data. Note
- * that the saved state will be persisted, so it can not contain any active
- * entities (pointers to memory, file descriptors, etc).
- */
- void (*onSaveInstanceState)(GameActivity* activity,
- SaveInstanceStateRecallback recallback,
- void* context);
-
- /**
- * GameActivity has paused. See Java documentation for Activity.onPause()
- * for more information.
- */
- void (*onPause)(GameActivity* activity);
-
- /**
- * GameActivity has stopped. See Java documentation for Activity.onStop()
- * for more information.
- */
- void (*onStop)(GameActivity* activity);
-
- /**
- * GameActivity is being destroyed. See Java documentation for
- * Activity.onDestroy() for more information.
- */
- void (*onDestroy)(GameActivity* activity);
-
- /**
- * Focus has changed in this GameActivity's window. This is often used,
- * for example, to pause a game when it loses input focus.
- */
- void (*onWindowFocusChanged)(GameActivity* activity, bool hasFocus);
-
- /**
- * The drawing window for this native activity has been created. You
- * can use the given native window object to start drawing.
- */
- void (*onNativeWindowCreated)(GameActivity* activity,
- ANativeWindow* window);
-
- /**
- * The drawing window for this native activity has been resized. You should
- * retrieve the new size from the window and ensure that your rendering in
- * it now matches.
- */
- void (*onNativeWindowResized)(GameActivity* activity, ANativeWindow* window,
- int32_t newWidth, int32_t newHeight);
-
- /**
- * The drawing window for this native activity needs to be redrawn. To
- * avoid transient artifacts during screen changes (such resizing after
- * rotation), applications should not return from this function until they
- * have finished drawing their window in its current state.
- */
- void (*onNativeWindowRedrawNeeded)(GameActivity* activity,
- ANativeWindow* window);
-
- /**
- * The drawing window for this native activity is going to be destroyed.
- * You MUST ensure that you do not touch the window object after returning
- * from this function: in the common case of drawing to the window from
- * another thread, that means the implementation of this callback must
- * properly synchronize with the other thread to stop its drawing before
- * returning from here.
- */
- void (*onNativeWindowDestroyed)(GameActivity* activity,
- ANativeWindow* window);
-
- /**
- * The current device AConfiguration has changed. The new configuration can
- * be retrieved from assetManager.
- */
- void (*onConfigurationChanged)(GameActivity* activity);
-
- /**
- * The system is running low on memory. Use this callback to release
- * resources you do not need, to help the system avoid killing more
- * important processes.
- */
- void (*onTrimMemory)(GameActivity* activity, int level);
-
- /**
- * Callback called for every MotionEvent done on the GameActivity
- * SurfaceView. Ownership of `event` is maintained by the library and it is
- * only valid during the callback.
- */
- bool (*onTouchEvent)(GameActivity* activity,
- const GameActivityMotionEvent* event,
- const GameActivityHistoricalPointerAxes* historical,
- int historicalLen);
-
- /**
- * Callback called for every key down event on the GameActivity SurfaceView.
- * Ownership of `event` is maintained by the library and it is only valid
- * during the callback.
- */
- bool (*onKeyDown)(GameActivity* activity,
- const GameActivityKeyEvent* event);
-
- /**
- * Callback called for every key up event on the GameActivity SurfaceView.
- * Ownership of `event` is maintained by the library and it is only valid
- * during the callback.
- */
- bool (*onKeyUp)(GameActivity* activity, const GameActivityKeyEvent* event);
-
- /**
- * Callback called for every soft-keyboard text input event.
- * Ownership of `state` is maintained by the library and it is only valid
- * during the callback.
- */
- void (*onTextInputEvent)(GameActivity* activity,
- const GameTextInputState* state);
-
- /**
- * Callback called when WindowInsets of the main app window have changed.
- * Call GameActivity_getWindowInsets to retrieve the insets themselves.
- */
- void (*onWindowInsetsChanged)(GameActivity* activity);
-} GameActivityCallbacks;
-
-/**
- * \brief Convert a Java `MotionEvent` to a `GameActivityMotionEvent`.
- *
- * This is done automatically by the GameActivity: see `onTouchEvent` to set
- * a callback to consume the received events.
- * This function can be used if you re-implement events handling in your own
- * activity. On return, the out_event->historicalStart will be zero, and should
- * be updated to index into whatever buffer out_historical is copied.
- * On return the length of out_historical is
- * (out_event->pointerCount x out_event->historicalCount) and is in a
- * pointer-major order (i.e. all axis for a pointer are contiguous)
- * Ownership of out_event is maintained by the caller.
- */
-int GameActivityMotionEvent_fromJava(JNIEnv* env, jobject motionEvent,
- GameActivityMotionEvent* out_event,
- GameActivityHistoricalPointerAxes *out_historical);
-
-/**
- * \brief Convert a Java `KeyEvent` to a `GameActivityKeyEvent`.
- *
- * This is done automatically by the GameActivity: see `onKeyUp` and `onKeyDown`
- * to set a callback to consume the received events.
- * This function can be used if you re-implement events handling in your own
- * activity.
- * Ownership of out_event is maintained by the caller.
- */
-void GameActivityKeyEvent_fromJava(JNIEnv* env, jobject motionEvent,
- GameActivityKeyEvent* out_event);
-
-/**
- * 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.
- */
-typedef void GameActivity_createFunc(GameActivity* activity, void* savedState,
- size_t savedStateSize);
-
-/**
- * The name of the function that NativeInstance looks for when launching its
- * native code. This is the default function that is used, you can specify
- * "android.app.func_name" string meta-data in your manifest to use a different
- * function.
- */
-extern GameActivity_createFunc GameActivity_onCreate;
-
-/**
- * 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.
- */
-void GameActivity_finish(GameActivity* activity);
-
-/**
- * Flags for GameActivity_setWindowFlags,
- * as per the Java API at android.view.WindowManager.LayoutParams.
- */
-enum GameActivitySetWindowFlags {
- /**
- * 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
- * GAMEACTIVITY_FLAG_KEEP_SCREEN_ON} and/or {@link
- * GAMEACTIVITY_FLAG_SHOW_WHEN_LOCKED}
- */
- GAMEACTIVITY_FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001,
- /** Everything behind this window will be dimmed. */
- GAMEACTIVITY_FLAG_DIM_BEHIND = 0x00000002,
- /**
- * Blur everything behind this window.
- * @deprecated Blurring is no longer supported.
- */
- GAMEACTIVITY_FLAG_BLUR_BEHIND = 0x00000004,
- /**
- * 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 GAMEACTIVITY_FLAG_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 GAMEACTIVITY_FLAG_ALT_FOCUSABLE_IM} to modify this
- * behavior.
- */
- GAMEACTIVITY_FLAG_NOT_FOCUSABLE = 0x00000008,
- /** This window can never receive touch events. */
- GAMEACTIVITY_FLAG_NOT_TOUCHABLE = 0x00000010,
- /**
- * Even when this window is focusable (its
- * {@link GAMEACTIVITY_FLAG_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.
- */
- GAMEACTIVITY_FLAG_NOT_TOUCH_MODAL = 0x00000020,
- /**
- * 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.
- */
- GAMEACTIVITY_FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040,
- /**
- * As long as this window is visible to the user, keep
- * the device's screen turned on and bright.
- */
- GAMEACTIVITY_FLAG_KEEP_SCREEN_ON = 0x00000080,
- /**
- * 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.
- */
- GAMEACTIVITY_FLAG_LAYOUT_IN_SCREEN = 0x00000100,
- /** Allows the window to extend outside of the screen. */
- GAMEACTIVITY_FLAG_LAYOUT_NO_LIMITS = 0x00000200,
- /**
- * 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 {@link
- * GAMEACTIVITY_SOFT_INPUT_ADJUST_RESIZE}; the window will stay
- * fullscreen and will not resize.
- */
- GAMEACTIVITY_FLAG_FULLSCREEN = 0x00000400,
- /**
- * Override {@link GAMEACTIVITY_FLAG_FULLSCREEN} and force the
- * screen decorations (such as the status bar) to be shown.
- */
- GAMEACTIVITY_FLAG_FORCE_NOT_FULLSCREEN = 0x00000800,
- /**
- * Turn on dithering when compositing this window to
- * the screen.
- * @deprecated This flag is no longer used.
- */
- GAMEACTIVITY_FLAG_DITHER = 0x00001000,
- /**
- * Treat the content of the window as secure, preventing
- * it from appearing in screenshots or from being viewed on non-secure
- * displays.
- */
- GAMEACTIVITY_FLAG_SECURE = 0x00002000,
- /**
- * A special mode where the layout parameters are used
- * to perform scaling of the surface when it is composited to the
- * screen.
- */
- GAMEACTIVITY_FLAG_SCALED = 0x00004000,
- /**
- * 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.
- */
- GAMEACTIVITY_FLAG_IGNORE_CHEEK_PRESSES = 0x00008000,
- /**
- * A special option only for use in combination with
- * {@link GAMEACTIVITY_FLAG_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.
- */
- GAMEACTIVITY_FLAG_LAYOUT_INSET_DECOR = 0x00010000,
- /**
- * Invert the state of {@link GAMEACTIVITY_FLAG_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
- * GAMEACTIVITY_FLAG_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.
- */
- GAMEACTIVITY_FLAG_ALT_FOCUSABLE_IM = 0x00020000,
- /**
- * If you have set {@link GAMEACTIVITY_FLAG_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}.
- */
- GAMEACTIVITY_FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000,
- /**
- * 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 GAMEACTIVITY_FLAG_KEEP_SCREEN_ON} to turn screen on and display
- * windows directly before showing the key guard window. Can be used with
- * {@link GAMEACTIVITY_FLAG_DISMISS_KEYGUARD} to automatically fully
- * dismisss non-secure keyguards. This flag only applies to the top-most
- * full-screen window.
- */
- GAMEACTIVITY_FLAG_SHOW_WHEN_LOCKED = 0x00080000,
- /**
- * 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.
- */
- GAMEACTIVITY_FLAG_SHOW_WALLPAPER = 0x00100000,
- /**
- * 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.
- */
- GAMEACTIVITY_FLAG_TURN_SCREEN_ON = 0x00200000,
- /**
- * 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 GAMEACTIVITY_FLAG_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 GAMEACTIVITY_FLAG_SHOW_WHEN_LOCKED} has
- * also been set.
- */
- GAMEACTIVITY_FLAG_DISMISS_KEYGUARD = 0x00400000,
-};
-
-/**
- * Change the window flags of the given activity. Calls getWindow().setFlags()
- * of the given activity.
- * Note that some flags must be set before the window decoration is created,
- * see
- * https://developer.android.com/reference/android/view/Window#setFlags(int,%20int).
- * Note also 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.
- */
-void GameActivity_setWindowFlags(GameActivity* activity, uint32_t addFlags,
- uint32_t removeFlags);
-
-/**
- * Flags for GameActivity_showSoftInput; see the Java InputMethodManager
- * API for documentation.
- */
-enum GameActivityShowSoftInputFlags {
- /**
- * Implicit request to show the input window, not as the result
- * of a direct request by the user.
- */
- GAMEACTIVITY_SHOW_SOFT_INPUT_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.
- */
- GAMEACTIVITY_SHOW_SOFT_INPUT_FORCED = 0x0002,
-};
-
-/**
- * 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 call will take place.
- */
-void GameActivity_showSoftInput(GameActivity* activity, uint32_t flags);
-
-/**
- * Set the text entry state (see documentation of the GameTextInputState struct
- * in the Game Text Input library reference).
- *
- * Ownership of the state is maintained by the caller.
- */
-void GameActivity_setTextInputState(GameActivity* activity,
- const GameTextInputState* state);
-
-/**
- * Get the last-received text entry state (see documentation of the
- * GameTextInputState struct in the Game Text Input library reference).
- *
- */
-void GameActivity_getTextInputState(GameActivity* activity,
- GameTextInputGetStateCallback callback,
- void* context);
-
-/**
- * Get a pointer to the GameTextInput library instance.
- */
-GameTextInput* GameActivity_getTextInput(const GameActivity* activity);
-
-/**
- * Flags for GameActivity_hideSoftInput; see the Java InputMethodManager
- * API for documentation.
- */
-enum GameActivityHideSoftInputFlags {
- /**
- * The soft input window should only be hidden if it was not
- * explicitly shown by the user.
- */
- GAMEACTIVITY_HIDE_SOFT_INPUT_IMPLICIT_ONLY = 0x0001,
- /**
- * The soft input window should normally be hidden, unless it was
- * originally shown with {@link GAMEACTIVITY_SHOW_SOFT_INPUT_FORCED}.
- */
- GAMEACTIVITY_HIDE_SOFT_INPUT_NOT_ALWAYS = 0x0002,
-};
-
-/**
- * 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.
- */
-void GameActivity_hideSoftInput(GameActivity* activity, uint32_t flags);
-
-/**
- * Get the current window insets of the particular component. See
- * https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type
- * for more details.
- * You can use these insets to influence what you show on the screen.
- */
-void GameActivity_getWindowInsets(GameActivity* activity,
- GameCommonInsetsType type, ARect* insets);
-
-/**
- * Set options on how the IME behaves when it is requested for text input.
- * See
- * https://developer.android.com/reference/android/view/inputmethod/EditorInfo
- * for the meaning of inputType, actionId and imeOptions.
- *
- * Note that this function will attach the current thread to the JVM if it is
- * not already attached, so the caller must detach the thread from the JVM
- * before the thread is destroyed using DetachCurrentThread.
- */
-void GameActivity_setImeEditorInfo(GameActivity* activity, int inputType,
- int actionId, int imeOptions);
-
-#ifdef __cplusplus
-}
-#endif
-
-/** @} */
-
-#endif // ANDROID_GAME_SDK_GAME_ACTIVITY_H
diff --git a/android-activity/game-activity-csrc/game-activity/native_app_glue/android_native_app_glue.c b/android-activity/game-activity-csrc/game-activity/native_app_glue/android_native_app_glue.c
deleted file mode 100644
index 5fd3eb86..00000000
--- a/android-activity/game-activity-csrc/game-activity/native_app_glue/android_native_app_glue.c
+++ /dev/null
@@ -1,639 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "android_native_app_glue.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#define LOGI(...) \
- ((void)__android_log_print(ANDROID_LOG_INFO, "threaded_app", __VA_ARGS__))
-#define LOGE(...) \
- ((void)__android_log_print(ANDROID_LOG_ERROR, "threaded_app", __VA_ARGS__))
-#define LOGW(...) \
- ((void)__android_log_print(ANDROID_LOG_WARN, "threaded_app", __VA_ARGS__))
-#define LOGW_ONCE(...) \
- do { \
- static bool alogw_once##__FILE__##__LINE__##__ = true; \
- if (alogw_once##__FILE__##__LINE__##__) { \
- alogw_once##__FILE__##__LINE__##__ = false; \
- LOGW(__VA_ARGS__); \
- } \
- } while (0)
-
-/* For debug builds, always enable the debug traces in this library */
-#ifndef NDEBUG
-#define LOGV(...) \
- ((void)__android_log_print(ANDROID_LOG_VERBOSE, "threaded_app", \
- __VA_ARGS__))
-#else
-#define LOGV(...) ((void)0)
-#endif
-
-static void free_saved_state(struct android_app* android_app) {
- pthread_mutex_lock(&android_app->mutex);
- if (android_app->savedState != NULL) {
- free(android_app->savedState);
- android_app->savedState = NULL;
- android_app->savedStateSize = 0;
- }
- pthread_mutex_unlock(&android_app->mutex);
-}
-
-int8_t android_app_read_cmd(struct android_app* android_app) {
- int8_t cmd;
- if (read(android_app->msgread, &cmd, sizeof(cmd)) != sizeof(cmd)) {
- LOGE("No data on command pipe!");
- return -1;
- }
- if (cmd == APP_CMD_SAVE_STATE) free_saved_state(android_app);
- return cmd;
-}
-
-static void print_cur_config(struct android_app* android_app) {
- char lang[2], country[2];
- AConfiguration_getLanguage(android_app->config, lang);
- AConfiguration_getCountry(android_app->config, country);
-
- LOGV(
- "Config: mcc=%d mnc=%d lang=%c%c cnt=%c%c orien=%d touch=%d dens=%d "
- "keys=%d nav=%d keysHid=%d navHid=%d sdk=%d size=%d long=%d "
- "modetype=%d modenight=%d",
- AConfiguration_getMcc(android_app->config),
- AConfiguration_getMnc(android_app->config), lang[0], lang[1],
- country[0], country[1],
- AConfiguration_getOrientation(android_app->config),
- AConfiguration_getTouchscreen(android_app->config),
- AConfiguration_getDensity(android_app->config),
- AConfiguration_getKeyboard(android_app->config),
- AConfiguration_getNavigation(android_app->config),
- AConfiguration_getKeysHidden(android_app->config),
- AConfiguration_getNavHidden(android_app->config),
- AConfiguration_getSdkVersion(android_app->config),
- AConfiguration_getScreenSize(android_app->config),
- AConfiguration_getScreenLong(android_app->config),
- AConfiguration_getUiModeType(android_app->config),
- AConfiguration_getUiModeNight(android_app->config));
-}
-
-void android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd) {
- switch (cmd) {
- case UNUSED_APP_CMD_INPUT_CHANGED:
- LOGV("UNUSED_APP_CMD_INPUT_CHANGED");
- // Do nothing. This can be used in the future to handle AInputQueue
- // natively, like done in NativeActivity.
- break;
-
- case APP_CMD_INIT_WINDOW:
- LOGV("APP_CMD_INIT_WINDOW");
- pthread_mutex_lock(&android_app->mutex);
- android_app->window = android_app->pendingWindow;
- pthread_cond_broadcast(&android_app->cond);
- pthread_mutex_unlock(&android_app->mutex);
- break;
-
- case APP_CMD_TERM_WINDOW:
- LOGV("APP_CMD_TERM_WINDOW");
- pthread_cond_broadcast(&android_app->cond);
- break;
-
- case APP_CMD_RESUME:
- case APP_CMD_START:
- case APP_CMD_PAUSE:
- case APP_CMD_STOP:
- LOGV("activityState=%d", cmd);
- pthread_mutex_lock(&android_app->mutex);
- android_app->activityState = cmd;
- pthread_cond_broadcast(&android_app->cond);
- pthread_mutex_unlock(&android_app->mutex);
- break;
-
- case APP_CMD_CONFIG_CHANGED:
- LOGV("APP_CMD_CONFIG_CHANGED");
- AConfiguration_fromAssetManager(
- android_app->config, android_app->activity->assetManager);
- print_cur_config(android_app);
- break;
-
- case APP_CMD_DESTROY:
- LOGV("APP_CMD_DESTROY");
- android_app->destroyRequested = 1;
- break;
- }
-}
-
-void android_app_post_exec_cmd(struct android_app* android_app, int8_t cmd) {
- switch (cmd) {
- case APP_CMD_TERM_WINDOW:
- LOGV("APP_CMD_TERM_WINDOW");
- pthread_mutex_lock(&android_app->mutex);
- android_app->window = NULL;
- pthread_cond_broadcast(&android_app->cond);
- pthread_mutex_unlock(&android_app->mutex);
- break;
-
- case APP_CMD_SAVE_STATE:
- LOGV("APP_CMD_SAVE_STATE");
- pthread_mutex_lock(&android_app->mutex);
- android_app->stateSaved = 1;
- pthread_cond_broadcast(&android_app->cond);
- pthread_mutex_unlock(&android_app->mutex);
- break;
-
- case APP_CMD_RESUME:
- free_saved_state(android_app);
- break;
- }
-}
-
-void app_dummy() {}
-
-static void android_app_destroy(struct android_app* android_app) {
- LOGV("android_app_destroy!");
- free_saved_state(android_app);
- pthread_mutex_lock(&android_app->mutex);
-
- AConfiguration_delete(android_app->config);
- android_app->destroyed = 1;
- pthread_cond_broadcast(&android_app->cond);
- pthread_mutex_unlock(&android_app->mutex);
- // Can't touch android_app object after this.
-}
-
-static void process_cmd(struct android_app* app,
- struct android_poll_source* source) {
- int8_t cmd = android_app_read_cmd(app);
- android_app_pre_exec_cmd(app, cmd);
- if (app->onAppCmd != NULL) app->onAppCmd(app, cmd);
- android_app_post_exec_cmd(app, cmd);
-}
-
-// This is run on a separate thread (i.e: not the main thread).
-static void* android_app_entry(void* param) {
- struct android_app* android_app = (struct android_app*)param;
-
- LOGV("android_app_entry called");
- android_app->config = AConfiguration_new();
- LOGV("android_app = %p", android_app);
- LOGV("config = %p", android_app->config);
- LOGV("activity = %p", android_app->activity);
- LOGV("assetmanager = %p", android_app->activity->assetManager);
- AConfiguration_fromAssetManager(android_app->config,
- android_app->activity->assetManager);
-
- print_cur_config(android_app);
-
- android_app->cmdPollSource.id = LOOPER_ID_MAIN;
- android_app->cmdPollSource.app = android_app;
- android_app->cmdPollSource.process = process_cmd;
-
- ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
- ALooper_addFd(looper, android_app->msgread, LOOPER_ID_MAIN,
- ALOOPER_EVENT_INPUT, NULL, &android_app->cmdPollSource);
- android_app->looper = looper;
-
- pthread_mutex_lock(&android_app->mutex);
- android_app->running = 1;
- pthread_cond_broadcast(&android_app->cond);
- pthread_mutex_unlock(&android_app->mutex);
-
- _rust_glue_entry(android_app);
-
- android_app_destroy(android_app);
- return NULL;
-}
-
-// Codes from https://developer.android.com/reference/android/view/KeyEvent
-#define KEY_EVENT_KEYCODE_VOLUME_DOWN 25
-#define KEY_EVENT_KEYCODE_VOLUME_MUTE 164
-#define KEY_EVENT_KEYCODE_VOLUME_UP 24
-#define KEY_EVENT_KEYCODE_CAMERA 27
-#define KEY_EVENT_KEYCODE_ZOOM_IN 168
-#define KEY_EVENT_KEYCODE_ZOOM_OUT 169
-
-// Double-buffer the key event filter to avoid race condition.
-static bool default_key_filter(const GameActivityKeyEvent* event) {
- // Ignore camera, volume, etc. buttons
- return !(event->keyCode == KEY_EVENT_KEYCODE_VOLUME_DOWN ||
- event->keyCode == KEY_EVENT_KEYCODE_VOLUME_MUTE ||
- event->keyCode == KEY_EVENT_KEYCODE_VOLUME_UP ||
- event->keyCode == KEY_EVENT_KEYCODE_CAMERA ||
- event->keyCode == KEY_EVENT_KEYCODE_ZOOM_IN ||
- event->keyCode == KEY_EVENT_KEYCODE_ZOOM_OUT);
-}
-
-// See
-// https://developer.android.com/reference/android/view/InputDevice#SOURCE_TOUCHSCREEN
-#define SOURCE_TOUCHSCREEN 0x00001002
-
-static bool default_motion_filter(const GameActivityMotionEvent* event) {
- // Ignore any non-touch events.
- return event->source == SOURCE_TOUCHSCREEN;
-}
-
-// --------------------------------------------------------------------
-// Native activity interaction (called from main thread)
-// --------------------------------------------------------------------
-
-static struct android_app* android_app_create(GameActivity* activity,
- void* savedState,
- size_t savedStateSize) {
- // struct android_app* android_app = calloc(1, sizeof(struct android_app));
- struct android_app* android_app =
- (struct android_app*)malloc(sizeof(struct android_app));
- memset(android_app, 0, sizeof(struct android_app));
- android_app->activity = activity;
-
- pthread_mutex_init(&android_app->mutex, NULL);
- pthread_cond_init(&android_app->cond, NULL);
-
- if (savedState != NULL) {
- android_app->savedState = malloc(savedStateSize);
- android_app->savedStateSize = savedStateSize;
- memcpy(android_app->savedState, savedState, savedStateSize);
- }
-
- int msgpipe[2];
- if (pipe(msgpipe)) {
- LOGE("could not create pipe: %s", strerror(errno));
- return NULL;
- }
- android_app->msgread = msgpipe[0];
- android_app->msgwrite = msgpipe[1];
-
- android_app->keyEventFilter = default_key_filter;
- android_app->motionEventFilter = default_motion_filter;
-
- LOGV("Launching android_app_entry in a thread");
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- pthread_create(&android_app->thread, &attr, android_app_entry, android_app);
-
- // Wait for thread to start.
- pthread_mutex_lock(&android_app->mutex);
- while (!android_app->running) {
- pthread_cond_wait(&android_app->cond, &android_app->mutex);
- }
- pthread_mutex_unlock(&android_app->mutex);
-
- return android_app;
-}
-
-static void android_app_write_cmd(struct android_app* android_app, int8_t cmd) {
- if (write(android_app->msgwrite, &cmd, sizeof(cmd)) != sizeof(cmd)) {
- LOGE("Failure writing android_app cmd: %s", strerror(errno));
- }
-}
-
-static void android_app_set_window(struct android_app* android_app,
- ANativeWindow* window) {
- LOGV("android_app_set_window called");
- pthread_mutex_lock(&android_app->mutex);
- if (android_app->pendingWindow != NULL) {
- android_app_write_cmd(android_app, APP_CMD_TERM_WINDOW);
- }
- android_app->pendingWindow = window;
- if (window != NULL) {
- android_app_write_cmd(android_app, APP_CMD_INIT_WINDOW);
- }
- while (android_app->window != android_app->pendingWindow) {
- pthread_cond_wait(&android_app->cond, &android_app->mutex);
- }
- pthread_mutex_unlock(&android_app->mutex);
-}
-
-static void android_app_set_activity_state(struct android_app* android_app,
- int8_t cmd) {
- pthread_mutex_lock(&android_app->mutex);
- android_app_write_cmd(android_app, cmd);
- while (android_app->activityState != cmd) {
- pthread_cond_wait(&android_app->cond, &android_app->mutex);
- }
- pthread_mutex_unlock(&android_app->mutex);
-}
-
-static void android_app_free(struct android_app* android_app) {
- pthread_mutex_lock(&android_app->mutex);
- android_app_write_cmd(android_app, APP_CMD_DESTROY);
- while (!android_app->destroyed) {
- pthread_cond_wait(&android_app->cond, &android_app->mutex);
- }
- pthread_mutex_unlock(&android_app->mutex);
-
- close(android_app->msgread);
- close(android_app->msgwrite);
- pthread_cond_destroy(&android_app->cond);
- pthread_mutex_destroy(&android_app->mutex);
- free(android_app);
-}
-
-static inline struct android_app* ToApp(GameActivity* activity) {
- return (struct android_app*)activity->instance;
-}
-
-static void onDestroy(GameActivity* activity) {
- LOGV("Destroy: %p", activity);
- android_app_free(ToApp(activity));
-}
-
-static void onStart(GameActivity* activity) {
- LOGV("Start: %p", activity);
- android_app_set_activity_state(ToApp(activity), APP_CMD_START);
-}
-
-static void onResume(GameActivity* activity) {
- LOGV("Resume: %p", activity);
- android_app_set_activity_state(ToApp(activity), APP_CMD_RESUME);
-}
-
-static void onSaveInstanceState(GameActivity* activity,
- SaveInstanceStateRecallback recallback,
- void* context) {
- LOGV("SaveInstanceState: %p", activity);
-
- struct android_app* android_app = ToApp(activity);
- pthread_mutex_lock(&android_app->mutex);
- android_app->stateSaved = 0;
- android_app_write_cmd(android_app, APP_CMD_SAVE_STATE);
- while (!android_app->stateSaved) {
- pthread_cond_wait(&android_app->cond, &android_app->mutex);
- }
-
- if (android_app->savedState != NULL) {
- // Tell the Java side about our state.
- recallback((const char*)android_app->savedState,
- android_app->savedStateSize, context);
- // Now we can free it.
- free(android_app->savedState);
- android_app->savedState = NULL;
- android_app->savedStateSize = 0;
- }
-
- pthread_mutex_unlock(&android_app->mutex);
-}
-
-static void onPause(GameActivity* activity) {
- LOGV("Pause: %p", activity);
- android_app_set_activity_state(ToApp(activity), APP_CMD_PAUSE);
-}
-
-static void onStop(GameActivity* activity) {
- LOGV("Stop: %p", activity);
- android_app_set_activity_state(ToApp(activity), APP_CMD_STOP);
-}
-
-static void onConfigurationChanged(GameActivity* activity) {
- LOGV("ConfigurationChanged: %p", activity);
- android_app_write_cmd(ToApp(activity), APP_CMD_CONFIG_CHANGED);
-}
-
-static void onTrimMemory(GameActivity* activity, int level) {
- LOGV("TrimMemory: %p %d", activity, level);
- android_app_write_cmd(ToApp(activity), APP_CMD_LOW_MEMORY);
-}
-
-static void onWindowFocusChanged(GameActivity* activity, bool focused) {
- LOGV("WindowFocusChanged: %p -- %d", activity, focused);
- android_app_write_cmd(ToApp(activity),
- focused ? APP_CMD_GAINED_FOCUS : APP_CMD_LOST_FOCUS);
-}
-
-static void onNativeWindowCreated(GameActivity* activity,
- ANativeWindow* window) {
- LOGV("NativeWindowCreated: %p -- %p", activity, window);
- android_app_set_window(ToApp(activity), window);
-}
-
-static void onNativeWindowDestroyed(GameActivity* activity,
- ANativeWindow* window) {
- LOGV("NativeWindowDestroyed: %p -- %p", activity, window);
- android_app_set_window(ToApp(activity), NULL);
-}
-
-static void onNativeWindowRedrawNeeded(GameActivity* activity,
- ANativeWindow* window) {
- LOGV("NativeWindowRedrawNeeded: %p -- %p", activity, window);
- android_app_write_cmd(ToApp(activity), APP_CMD_WINDOW_REDRAW_NEEDED);
-}
-
-static void onNativeWindowResized(GameActivity* activity, ANativeWindow* window,
- int32_t width, int32_t height) {
- LOGV("NativeWindowResized: %p -- %p ( %d x %d )", activity, window, width,
- height);
- android_app_write_cmd(ToApp(activity), APP_CMD_WINDOW_RESIZED);
-}
-
-void android_app_set_motion_event_filter(struct android_app* app,
- android_motion_event_filter filter) {
- pthread_mutex_lock(&app->mutex);
- app->motionEventFilter = filter;
- pthread_mutex_unlock(&app->mutex);
-}
-
-bool android_app_input_available_wake_up(struct android_app* app) {
- pthread_mutex_lock(&app->mutex);
- // TODO: use atomic ops for this
- bool available = app->inputAvailableWakeUp;
- app->inputAvailableWakeUp = false;
- pthread_mutex_unlock(&app->mutex);
- return available;
-}
-
-// NB: should be called with the android_app->mutex held already
-static void notifyInput(struct android_app* android_app) {
- // Don't spam the mainloop with wake ups if we've already sent one
- if (android_app->inputSwapPending) {
- return;
- }
-
- if (android_app->looper != NULL) {
- LOGV("Input Notify: %p", android_app);
- // for the app thread to know why it received the wake() up
- android_app->inputAvailableWakeUp = true;
- android_app->inputSwapPending = true;
- ALooper_wake(android_app->looper);
- }
-}
-
-static bool onTouchEvent(GameActivity* activity,
- const GameActivityMotionEvent* event,
- const GameActivityHistoricalPointerAxes* historical,
- int historicalLen) {
- struct android_app* android_app = ToApp(activity);
- pthread_mutex_lock(&android_app->mutex);
-
- if (android_app->motionEventFilter != NULL &&
- !android_app->motionEventFilter(event)) {
- pthread_mutex_unlock(&android_app->mutex);
- return false;
- }
-
- struct android_input_buffer* inputBuffer =
- &android_app->inputBuffers[android_app->currentInputBuffer];
-
- // Add to the list of active motion events
- if (inputBuffer->motionEventsCount <
- NATIVE_APP_GLUE_MAX_NUM_MOTION_EVENTS) {
- int new_ix = inputBuffer->motionEventsCount;
- memcpy(&inputBuffer->motionEvents[new_ix], event,
- sizeof(GameActivityMotionEvent));
- ++inputBuffer->motionEventsCount;
-
- if (inputBuffer->historicalSamplesCount + historicalLen <=
- NATIVE_APP_GLUE_MAX_HISTORICAL_POINTER_SAMPLES) {
-
- int start_ix = inputBuffer->historicalSamplesCount;
- memcpy(&inputBuffer->historicalAxisSamples[start_ix], historical,
- sizeof(historical[0]) * historicalLen);
- inputBuffer->historicalSamplesCount += event->historicalCount;
-
- inputBuffer->motionEvents[new_ix].historicalStart = start_ix;
- inputBuffer->motionEvents[new_ix].historicalCount = historicalLen;
- } else {
- inputBuffer->motionEvents[new_ix].historicalCount = 0;
- }
-
- notifyInput(android_app);
- } else {
- LOGW_ONCE("Motion event will be dropped because the number of unconsumed motion"
- " events exceeded NATIVE_APP_GLUE_MAX_NUM_MOTION_EVENTS (%d). Consider setting"
- " NATIVE_APP_GLUE_MAX_NUM_MOTION_EVENTS_OVERRIDE to a larger value",
- NATIVE_APP_GLUE_MAX_NUM_MOTION_EVENTS);
- }
-
- pthread_mutex_unlock(&android_app->mutex);
- return true;
-}
-
-struct android_input_buffer* android_app_swap_input_buffers(
- struct android_app* android_app) {
- pthread_mutex_lock(&android_app->mutex);
-
- struct android_input_buffer* inputBuffer =
- &android_app->inputBuffers[android_app->currentInputBuffer];
-
- if (inputBuffer->motionEventsCount == 0 &&
- inputBuffer->keyEventsCount == 0) {
- inputBuffer = NULL;
- } else {
- android_app->currentInputBuffer =
- (android_app->currentInputBuffer + 1) %
- NATIVE_APP_GLUE_MAX_INPUT_BUFFERS;
- }
-
- android_app->inputSwapPending = false;
- android_app->inputAvailableWakeUp = false;
-
- pthread_mutex_unlock(&android_app->mutex);
-
- return inputBuffer;
-}
-
-void android_app_clear_motion_events(struct android_input_buffer* inputBuffer) {
- inputBuffer->motionEventsCount = 0;
-}
-
-void android_app_set_key_event_filter(struct android_app* app,
- android_key_event_filter filter) {
- pthread_mutex_lock(&app->mutex);
- app->keyEventFilter = filter;
- pthread_mutex_unlock(&app->mutex);
-}
-
-static bool onKey(GameActivity* activity, const GameActivityKeyEvent* event) {
- struct android_app* android_app = ToApp(activity);
- pthread_mutex_lock(&android_app->mutex);
-
- if (android_app->keyEventFilter != NULL &&
- !android_app->keyEventFilter(event)) {
- pthread_mutex_unlock(&android_app->mutex);
- return false;
- }
-
- struct android_input_buffer* inputBuffer =
- &android_app->inputBuffers[android_app->currentInputBuffer];
-
- // Add to the list of active key down events
- if (inputBuffer->keyEventsCount < NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS) {
- int new_ix = inputBuffer->keyEventsCount;
- memcpy(&inputBuffer->keyEvents[new_ix], event,
- sizeof(GameActivityKeyEvent));
- ++inputBuffer->keyEventsCount;
-
- notifyInput(android_app);
- } else {
- LOGW_ONCE("Key event will be dropped because the number of unconsumed key events exceeded"
- " NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS (%d). Consider setting"
- " NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS_OVERRIDE to a larger value",
- NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS);
- }
-
- pthread_mutex_unlock(&android_app->mutex);
- return true;
-}
-
-void android_app_clear_key_events(struct android_input_buffer* inputBuffer) {
- inputBuffer->keyEventsCount = 0;
-}
-
-static void onTextInputEvent(GameActivity* activity,
- const GameTextInputState* state) {
- struct android_app* android_app = ToApp(activity);
- pthread_mutex_lock(&android_app->mutex);
-
- android_app->textInputState = 1;
- pthread_mutex_unlock(&android_app->mutex);
-}
-
-static void onWindowInsetsChanged(GameActivity* activity) {
- LOGV("WindowInsetsChanged: %p", activity);
- android_app_write_cmd(ToApp(activity), APP_CMD_WINDOW_INSETS_CHANGED);
-}
-
-JNIEXPORT
-void GameActivity_onCreate_C(GameActivity* activity, void* savedState,
- size_t savedStateSize) {
- LOGV("Creating: %p", activity);
- activity->callbacks->onDestroy = onDestroy;
- activity->callbacks->onStart = onStart;
- activity->callbacks->onResume = onResume;
- activity->callbacks->onSaveInstanceState = onSaveInstanceState;
- activity->callbacks->onPause = onPause;
- activity->callbacks->onStop = onStop;
- activity->callbacks->onTouchEvent = onTouchEvent;
- activity->callbacks->onKeyDown = onKey;
- activity->callbacks->onKeyUp = onKey;
- activity->callbacks->onTextInputEvent = onTextInputEvent;
- activity->callbacks->onConfigurationChanged = onConfigurationChanged;
- activity->callbacks->onTrimMemory = onTrimMemory;
- activity->callbacks->onWindowFocusChanged = onWindowFocusChanged;
- activity->callbacks->onNativeWindowCreated = onNativeWindowCreated;
- activity->callbacks->onNativeWindowDestroyed = onNativeWindowDestroyed;
- activity->callbacks->onNativeWindowRedrawNeeded =
- onNativeWindowRedrawNeeded;
- activity->callbacks->onNativeWindowResized = onNativeWindowResized;
- activity->callbacks->onWindowInsetsChanged = onWindowInsetsChanged;
- LOGV("Callbacks set: %p", activity->callbacks);
-
- activity->instance =
- android_app_create(activity, savedState, savedStateSize);
-}
diff --git a/android-activity/game-activity-csrc/game-activity/native_app_glue/android_native_app_glue.h b/android-activity/game-activity-csrc/game-activity/native_app_glue/android_native_app_glue.h
deleted file mode 100644
index 96968e38..00000000
--- a/android-activity/game-activity-csrc/game-activity/native_app_glue/android_native_app_glue.h
+++ /dev/null
@@ -1,541 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-/**
- * @addtogroup android_native_app_glue Native App Glue library
- * The glue library to interface your game loop with GameActivity.
- * @{
- */
-
-#include
-#include
-#include
-#include
-#include
-
-#include "game-activity/GameActivity.h"
-
-#if (defined NATIVE_APP_GLUE_MAX_NUM_MOTION_EVENTS_OVERRIDE)
-#define NATIVE_APP_GLUE_MAX_NUM_MOTION_EVENTS \
- NATIVE_APP_GLUE_MAX_NUM_MOTION_EVENTS_OVERRIDE
-#else
-#define NATIVE_APP_GLUE_MAX_NUM_MOTION_EVENTS 16
-#endif
-
-#if (defined NATIVE_APP_GLUE_MAX_HISTORICAL_POINTER_SAMPLES_OVERRIDE)
-#define NATIVE_APP_GLUE_MAX_HISTORICAL_POINTER_SAMPLES \
- NATIVE_APP_GLUE_MAX_HISTORICAL_POINTER_SAMPLES_OVERRIDE
-#else
-#define NATIVE_APP_GLUE_MAX_HISTORICAL_POINTER_SAMPLES 64
-#endif
-
-#if (defined NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS_OVERRIDE)
-#define NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS \
- NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS_OVERRIDE
-#else
-#define NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS 4
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * The GameActivity interface provided by
- * is based on a set of application-provided callbacks that will be called
- * by the Activity's main thread when certain events occur.
- *
- * This means that each one of this callbacks _should_ _not_ block, or they
- * risk having the system force-close the application. This programming
- * model is direct, lightweight, but constraining.
- *
- * The 'android_native_app_glue' static library is used to provide a different
- * execution model where the application can implement its own main event
- * loop in a different thread instead. Here's how it works:
- *
- * 1/ The application must provide a function named "android_main()" that
- * will be called when the activity is created, in a new thread that is
- * distinct from the activity's main thread.
- *
- * 2/ android_main() receives a pointer to a valid "android_app" structure
- * that contains references to other important objects, e.g. the
- * GameActivity obejct instance the application is running in.
- *
- * 3/ the "android_app" object holds an ALooper instance that already
- * listens to activity lifecycle events (e.g. "pause", "resume").
- * See APP_CMD_XXX declarations below.
- *
- * This corresponds to an ALooper identifier returned by
- * ALooper_pollOnce with value LOOPER_ID_MAIN.
- *
- * Your application can use the same ALooper to listen to additional
- * file-descriptors. They can either be callback based, or with return
- * identifiers starting with LOOPER_ID_USER.
- *
- * 4/ Whenever you receive a LOOPER_ID_MAIN event,
- * the returned data will point to an android_poll_source structure. You
- * can call the process() function on it, and fill in android_app->onAppCmd
- * to be called for your own processing of the event.
- *
- * Alternatively, you can call the low-level functions to read and process
- * the data directly... look at the process_cmd() and process_input()
- * implementations in the glue to see how to do this.
- *
- * See the sample named "native-activity" that comes with the NDK with a
- * full usage example. Also look at the documentation of GameActivity.
- */
-
-struct android_app;
-
-/**
- * Data associated with an ALooper fd that will be returned as the "outData"
- * when that source has data ready.
- */
-struct android_poll_source {
- /**
- * The identifier of this source. May be LOOPER_ID_MAIN or
- * LOOPER_ID_INPUT.
- */
- int32_t id;
-
- /** The android_app this ident is associated with. */
- struct android_app* app;
-
- /**
- * Function to call to perform the standard processing of data from
- * this source.
- */
- void (*process)(struct android_app* app,
- struct android_poll_source* source);
-};
-
-struct android_input_buffer {
- /**
- * Pointer to a read-only array of pointers to GameActivityMotionEvent.
- * Only the first motionEventsCount events are valid.
- */
- GameActivityMotionEvent motionEvents[NATIVE_APP_GLUE_MAX_NUM_MOTION_EVENTS];
-
- /**
- * The number of valid motion events in `motionEvents`.
- */
- uint64_t motionEventsCount;
-
- /**
- * Pointer to a read-only array of pointers to GameActivityHistoricalPointerAxes.
- *
- * Only the first historicalSamplesCount samples are valid.
- * Refer to event->historicalStart, event->pointerCount and event->historicalCount
- * to access the specific samples that relate to an event.
- *
- * Each slice of samples for one event has a length of
- * (event->pointerCount and event->historicalCount) and is in pointer-major
- * order so the historic samples for each pointer are contiguous.
- * E.g. you would access historic sample index 3 for pointer 2 of an event with:
- *
- * historicalAxisSamples[event->historicalStart + (event->historicalCount * 2) + 3];
- */
- GameActivityHistoricalPointerAxes historicalAxisSamples[NATIVE_APP_GLUE_MAX_HISTORICAL_POINTER_SAMPLES];
-
- /**
- * The number of valid historical samples in `historicalAxisSamples`.
- */
- uint64_t historicalSamplesCount;
-
- /**
- * Pointer to a read-only array of pointers to GameActivityKeyEvent.
- * Only the first keyEventsCount events are valid.
- */
- GameActivityKeyEvent keyEvents[NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS];
-
- /**
- * The number of valid "Key" events in `keyEvents`.
- */
- uint64_t keyEventsCount;
-};
-
-/**
- * Function pointer declaration for the filtering of key events.
- * A function with this signature should be passed to
- * android_app_set_key_event_filter and return false for any events that should
- * not be handled by android_native_app_glue. These events will be handled by
- * the system instead.
- */
-typedef bool (*android_key_event_filter)(const GameActivityKeyEvent*);
-
-/**
- * Function pointer definition for the filtering of motion events.
- * A function with this signature should be passed to
- * android_app_set_motion_event_filter and return false for any events that
- * should not be handled by android_native_app_glue. These events will be
- * handled by the system instead.
- */
-typedef bool (*android_motion_event_filter)(const GameActivityMotionEvent*);
-
-/**
- * This is the interface for the standard glue code of a threaded
- * application. In this model, the application's code is running
- * in its own thread separate from the main thread of the process.
- * It is not required that this thread be associated with the Java
- * VM, although it will need to be in order to make JNI calls any
- * Java objects.
- */
-struct android_app {
- /**
- * An optional pointer to application-defined state.
- */
- void* userData;
-
- /**
- * A required callback for processing main app commands (`APP_CMD_*`).
- * This is called each frame if there are app commands that need processing.
- */
- void (*onAppCmd)(struct android_app* app, int32_t cmd);
-
- /** The GameActivity object instance that this app is running in. */
- GameActivity* activity;
-
- /** The current configuration the app is running in. */
- AConfiguration* config;
-
- /**
- * The last activity saved state, as provided at creation time.
- * It is NULL if there was no state. You can use this as you need; the
- * memory will remain around until you call android_app_exec_cmd() for
- * APP_CMD_RESUME, at which point it will be freed and savedState set to
- * NULL. These variables should only be changed when processing a
- * APP_CMD_SAVE_STATE, at which point they will be initialized to NULL and
- * you can malloc your state and place the information here. In that case
- * the memory will be freed for you later.
- */
- void* savedState;
-
- /**
- * The size of the activity saved state. It is 0 if `savedState` is NULL.
- */
- size_t savedStateSize;
-
- /** The ALooper associated with the app's thread. */
- ALooper* looper;
-
- /** When non-NULL, this is the window surface that the app can draw in. */
- ANativeWindow* window;
-
- /**
- * Current content rectangle of the window; this is the area where the
- * window's content should be placed to be seen by the user.
- */
- ARect contentRect;
-
- /**
- * Current state of the app's activity. May be either APP_CMD_START,
- * APP_CMD_RESUME, APP_CMD_PAUSE, or APP_CMD_STOP.
- */
- int activityState;
-
- /**
- * This is non-zero when the application's GameActivity is being
- * destroyed and waiting for the app thread to complete.
- */
- int destroyRequested;
-
-#define NATIVE_APP_GLUE_MAX_INPUT_BUFFERS 2
-
- /**
- * This is used for buffering input from GameActivity. Once ready, the
- * application thread switches the buffers and processes what was
- * accumulated.
- */
- struct android_input_buffer inputBuffers[NATIVE_APP_GLUE_MAX_INPUT_BUFFERS];
-
- int currentInputBuffer;
-
- /**
- * 0 if no text input event is outstanding, 1 if it is.
- * Use `GameActivity_getTextInputState` to get information
- * about the text entered by the user.
- */
- int textInputState;
-
- // Below are "private" implementation of the glue code.
- /** @cond INTERNAL */
-
- pthread_mutex_t mutex;
- pthread_cond_t cond;
-
- int msgread;
- int msgwrite;
-
- pthread_t thread;
-
- struct android_poll_source cmdPollSource;
-
- int running;
- int stateSaved;
- int destroyed;
- int redrawNeeded;
- ANativeWindow* pendingWindow;
- ARect pendingContentRect;
-
- android_key_event_filter keyEventFilter;
- android_motion_event_filter motionEventFilter;
-
- // When new input is received we set both of these flags and use the looper to
- // wake up the application mainloop.
- //
- // To avoid spamming the mainloop with wake ups from lots of input though we
- // don't sent a wake up if the inputSwapPending flag is already set. (i.e.
- // we already expect input to be processed in a finite amount of time due to
- // our previous wake up)
- //
- // When a wake up is received then we will check this flag (clearing it
- // at the same time). If it was set then an InputAvailable event is sent to
- // the application - which should lead to all input being processed within
- // a finite amount of time.
- //
- // The next time android_app_swap_input_buffers is called, both flags will be
- // cleared.
- //
- // NB: both of these should only be read with the app mutex held
- bool inputAvailableWakeUp;
- bool inputSwapPending;
-
- /** @endcond */
-};
-
-/**
- * Looper ID of commands coming from the app's main thread, an AInputQueue or
- * user-defined sources.
- */
-enum NativeAppGlueLooperId {
- /**
- * Looper data ID of commands coming from the app's main thread, which
- * is returned as an identifier from ALooper_pollOnce(). The data for this
- * identifier is a pointer to an android_poll_source structure.
- * These can be retrieved and processed with android_app_read_cmd()
- * and android_app_exec_cmd().
- */
- LOOPER_ID_MAIN = 1,
-
- /**
- * Unused. Reserved for future use when usage of AInputQueue will be
- * supported.
- */
- LOOPER_ID_INPUT = 2,
-
- /**
- * Start of user-defined ALooper identifiers.
- */
- LOOPER_ID_USER = 3,
-};
-
-/**
- * Commands passed from the application's main Java thread to the game's thread.
- */
-enum NativeAppGlueAppCmd {
- /**
- * Unused. Reserved for future use when usage of AInputQueue will be
- * supported.
- */
- UNUSED_APP_CMD_INPUT_CHANGED,
-
- /**
- * Command from main thread: a new ANativeWindow is ready for use. Upon
- * receiving this command, android_app->window will contain the new window
- * surface.
- */
- APP_CMD_INIT_WINDOW,
-
- /**
- * Command from main thread: the existing ANativeWindow needs to be
- * terminated. Upon receiving this command, android_app->window still
- * contains the existing window; after calling android_app_exec_cmd
- * it will be set to NULL.
- */
- APP_CMD_TERM_WINDOW,
-
- /**
- * Command from main thread: the current ANativeWindow has been resized.
- * Please redraw with its new size.
- */
- APP_CMD_WINDOW_RESIZED,
-
- /**
- * Command from main thread: the system needs that the current ANativeWindow
- * be redrawn. You should redraw the window before handing this to
- * android_app_exec_cmd() in order to avoid transient drawing glitches.
- */
- APP_CMD_WINDOW_REDRAW_NEEDED,
-
- /**
- * Command from main thread: the content area of the window has changed,
- * such as from the soft input window being shown or hidden. You can
- * find the new content rect in android_app::contentRect.
- */
- APP_CMD_CONTENT_RECT_CHANGED,
-
- /**
- * Command from main thread: the app's activity window has gained
- * input focus.
- */
- APP_CMD_GAINED_FOCUS,
-
- /**
- * Command from main thread: the app's activity window has lost
- * input focus.
- */
- APP_CMD_LOST_FOCUS,
-
- /**
- * Command from main thread: the current device configuration has changed.
- */
- APP_CMD_CONFIG_CHANGED,
-
- /**
- * Command from main thread: the system is running low on memory.
- * Try to reduce your memory use.
- */
- APP_CMD_LOW_MEMORY,
-
- /**
- * Command from main thread: the app's activity has been started.
- */
- APP_CMD_START,
-
- /**
- * Command from main thread: the app's activity has been resumed.
- */
- APP_CMD_RESUME,
-
- /**
- * Command from main thread: the app should generate a new saved state
- * for itself, to restore from later if needed. If you have saved state,
- * allocate it with malloc and place it in android_app.savedState with
- * the size in android_app.savedStateSize. The will be freed for you
- * later.
- */
- APP_CMD_SAVE_STATE,
-
- /**
- * Command from main thread: the app's activity has been paused.
- */
- APP_CMD_PAUSE,
-
- /**
- * Command from main thread: the app's activity has been stopped.
- */
- APP_CMD_STOP,
-
- /**
- * Command from main thread: the app's activity is being destroyed,
- * and waiting for the app thread to clean up and exit before proceeding.
- */
- APP_CMD_DESTROY,
-
- /**
- * Command from main thread: the app's insets have changed.
- */
- APP_CMD_WINDOW_INSETS_CHANGED,
-
-};
-
-/**
- * Call when ALooper_pollAll() returns LOOPER_ID_MAIN, reading the next
- * app command message.
- */
-int8_t android_app_read_cmd(struct android_app* android_app);
-
-/**
- * Call with the command returned by android_app_read_cmd() to do the
- * initial pre-processing of the given command. You can perform your own
- * actions for the command after calling this function.
- */
-void android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd);
-
-/**
- * Call with the command returned by android_app_read_cmd() to do the
- * final post-processing of the given command. You must have done your own
- * actions for the command before calling this function.
- */
-void android_app_post_exec_cmd(struct android_app* android_app, int8_t cmd);
-
-/**
- * Call this before processing input events to get the events buffer.
- * The function returns NULL if there are no events to process.
- */
-struct android_input_buffer* android_app_swap_input_buffers(
- struct android_app* android_app);
-
-/**
- * Clear the array of motion events that were waiting to be handled, and release
- * each of them.
- *
- * This method should be called after you have processed the motion events in
- * your game loop. You should handle events at each iteration of your game loop.
- */
-void android_app_clear_motion_events(struct android_input_buffer* inputBuffer);
-
-/**
- * Clear the array of key events that were waiting to be handled, and release
- * each of them.
- *
- * This method should be called after you have processed the key up events in
- * your game loop. You should handle events at each iteration of your game loop.
- */
-void android_app_clear_key_events(struct android_input_buffer* inputBuffer);
-
-/**
- * This is a springboard into the Rust glue layer that wraps calling the
- * main entry for the app itself.
- */
-extern void _rust_glue_entry(struct android_app* app);
-
-/**
- * Set the filter to use when processing key events.
- * Any events for which the filter returns false will be ignored by
- * android_native_app_glue. If filter is set to NULL, no filtering is done.
- *
- * The default key filter will filter out volume and camera button presses.
- */
-void android_app_set_key_event_filter(struct android_app* app,
- android_key_event_filter filter);
-
-/**
- * Set the filter to use when processing touch and motion events.
- * Any events for which the filter returns false will be ignored by
- * android_native_app_glue. If filter is set to NULL, no filtering is done.
- *
- * Note that the default motion event filter will only allow touchscreen events
- * through, in order to mimic NativeActivity's behaviour, so for controller
- * events to be passed to the app, set the filter to NULL.
- */
-void android_app_set_motion_event_filter(struct android_app* app,
- android_motion_event_filter filter);
-
-/**
- * Determines if a looper wake up was due to new input becoming available
- */
-bool android_app_input_available_wake_up(struct android_app* app);
-
-void GameActivity_onCreate_C(GameActivity* activity, void* savedState,
- size_t savedStateSize);
-#ifdef __cplusplus
-}
-#endif
-
-/** @} */
diff --git a/android-activity/game-activity-csrc/game-text-input/gamecommon.h b/android-activity/game-activity-csrc/game-text-input/gamecommon.h
deleted file mode 100644
index 38bffff2..00000000
--- a/android-activity/game-activity-csrc/game-text-input/gamecommon.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @defgroup game_common Game Common
- * Common structures and functions used within AGDK
- * @{
- */
-
-#pragma once
-
-/**
- * The type of a component for which to retrieve insets. See
- * https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type
- */
-typedef enum GameCommonInsetsType {
- GAMECOMMON_INSETS_TYPE_CAPTION_BAR = 0,
- GAMECOMMON_INSETS_TYPE_DISPLAY_CUTOUT,
- GAMECOMMON_INSETS_TYPE_IME,
- GAMECOMMON_INSETS_TYPE_MANDATORY_SYSTEM_GESTURES,
- GAMECOMMON_INSETS_TYPE_NAVIGATION_BARS,
- GAMECOMMON_INSETS_TYPE_STATUS_BARS,
- GAMECOMMON_INSETS_TYPE_SYSTEM_BARS,
- GAMECOMMON_INSETS_TYPE_SYSTEM_GESTURES,
- GAMECOMMON_INSETS_TYPE_TAPABLE_ELEMENT,
- GAMECOMMON_INSETS_TYPE_WATERFALL,
- GAMECOMMON_INSETS_TYPE_COUNT
-} GameCommonInsetsType;
diff --git a/android-activity/game-activity-csrc/game-text-input/gametextinput.cpp b/android-activity/game-activity-csrc/game-text-input/gametextinput.cpp
deleted file mode 100644
index 6a399439..00000000
--- a/android-activity/game-activity-csrc/game-text-input/gametextinput.cpp
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "game-text-input/gametextinput.h"
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#define LOG_TAG "GameTextInput"
-
-static constexpr int32_t DEFAULT_MAX_STRING_SIZE = 1 << 16;
-
-// Cache of field ids in the Java GameTextInputState class
-struct StateClassInfo {
- jfieldID text;
- jfieldID selectionStart;
- jfieldID selectionEnd;
- jfieldID composingRegionStart;
- jfieldID composingRegionEnd;
-};
-
-// Main GameTextInput object.
-struct GameTextInput {
- public:
- GameTextInput(JNIEnv *env, uint32_t max_string_size);
- ~GameTextInput();
- void setState(const GameTextInputState &state);
- const GameTextInputState &getState() const { return currentState_; }
- void setInputConnection(jobject inputConnection);
- void processEvent(jobject textInputEvent);
- void showIme(uint32_t flags);
- void hideIme(uint32_t flags);
- void setEventCallback(GameTextInputEventCallback callback, void *context);
- jobject stateToJava(const GameTextInputState &state) const;
- void stateFromJava(jobject textInputEvent,
- GameTextInputGetStateCallback callback,
- void *context) const;
- void setImeInsetsCallback(GameTextInputImeInsetsCallback callback,
- void *context);
- void processImeInsets(const ARect *insets);
- const ARect &getImeInsets() const { return currentInsets_; }
-
- private:
- // Copy string and set other fields
- void setStateInner(const GameTextInputState &state);
- static void processCallback(void *context, const GameTextInputState *state);
- JNIEnv *env_ = nullptr;
- // Cached at initialization from
- // com/google/androidgamesdk/gametextinput/State.
- jclass stateJavaClass_ = nullptr;
- // The latest text input update.
- GameTextInputState currentState_ = {};
- // An instance of gametextinput.InputConnection.
- jclass inputConnectionClass_ = nullptr;
- jobject inputConnection_ = nullptr;
- jmethodID inputConnectionSetStateMethod_;
- jmethodID setSoftKeyboardActiveMethod_;
- void (*eventCallback_)(void *context,
- const struct GameTextInputState *state) = nullptr;
- void *eventCallbackContext_ = nullptr;
- void (*insetsCallback_)(void *context,
- const struct ARect *insets) = nullptr;
- ARect currentInsets_ = {};
- void *insetsCallbackContext_ = nullptr;
- StateClassInfo stateClassInfo_ = {};
- // Constant-sized buffer used to store state text.
- std::vector stateStringBuffer_;
-};
-
-std::unique_ptr s_gameTextInput;
-
-extern "C" {
-
-///////////////////////////////////////////////////////////
-/// GameTextInputState C Functions
-///////////////////////////////////////////////////////////
-
-// Convert to a Java structure.
-jobject currentState_toJava(const GameTextInput *gameTextInput,
- const GameTextInputState *state) {
- if (state == nullptr) return NULL;
- return gameTextInput->stateToJava(*state);
-}
-
-// Convert from Java structure.
-void currentState_fromJava(const GameTextInput *gameTextInput,
- jobject textInputEvent,
- GameTextInputGetStateCallback callback,
- void *context) {
- gameTextInput->stateFromJava(textInputEvent, callback, context);
-}
-
-///////////////////////////////////////////////////////////
-/// GameTextInput C Functions
-///////////////////////////////////////////////////////////
-
-struct GameTextInput *GameTextInput_init(JNIEnv *env,
- uint32_t max_string_size) {
- if (s_gameTextInput.get() != nullptr) {
- __android_log_print(ANDROID_LOG_WARN, LOG_TAG,
- "Warning: called GameTextInput_init twice without "
- "calling GameTextInput_destroy");
- return s_gameTextInput.get();
- }
- // Don't use make_unique, for C++11 compatibility
- s_gameTextInput =
- std::unique_ptr(new GameTextInput(env, max_string_size));
- return s_gameTextInput.get();
-}
-
-void GameTextInput_destroy(GameTextInput *input) {
- if (input == nullptr || s_gameTextInput.get() == nullptr) return;
- s_gameTextInput.reset();
-}
-
-void GameTextInput_setState(GameTextInput *input,
- const GameTextInputState *state) {
- if (state == nullptr) return;
- input->setState(*state);
-}
-
-void GameTextInput_getState(GameTextInput *input,
- GameTextInputGetStateCallback callback,
- void *context) {
- callback(context, &input->getState());
-}
-
-void GameTextInput_setInputConnection(GameTextInput *input,
- jobject inputConnection) {
- input->setInputConnection(inputConnection);
-}
-
-void GameTextInput_processEvent(GameTextInput *input, jobject textInputEvent) {
- input->processEvent(textInputEvent);
-}
-
-void GameTextInput_processImeInsets(GameTextInput *input, const ARect *insets) {
- input->processImeInsets(insets);
-}
-
-void GameTextInput_showIme(struct GameTextInput *input, uint32_t flags) {
- input->showIme(flags);
-}
-
-void GameTextInput_hideIme(struct GameTextInput *input, uint32_t flags) {
- input->hideIme(flags);
-}
-
-void GameTextInput_setEventCallback(struct GameTextInput *input,
- GameTextInputEventCallback callback,
- void *context) {
- input->setEventCallback(callback, context);
-}
-
-void GameTextInput_setImeInsetsCallback(struct GameTextInput *input,
- GameTextInputImeInsetsCallback callback,
- void *context) {
- input->setImeInsetsCallback(callback, context);
-}
-
-void GameTextInput_getImeInsets(const GameTextInput *input, ARect *insets) {
- *insets = input->getImeInsets();
-}
-
-} // extern "C"
-
-///////////////////////////////////////////////////////////
-/// GameTextInput C++ class Implementation
-///////////////////////////////////////////////////////////
-
-GameTextInput::GameTextInput(JNIEnv *env, uint32_t max_string_size)
- : env_(env),
- stateStringBuffer_(max_string_size == 0 ? DEFAULT_MAX_STRING_SIZE
- : max_string_size) {
- stateJavaClass_ = (jclass)env_->NewGlobalRef(
- env_->FindClass("com/google/androidgamesdk/gametextinput/State"));
- inputConnectionClass_ = (jclass)env_->NewGlobalRef(env_->FindClass(
- "com/google/androidgamesdk/gametextinput/InputConnection"));
- inputConnectionSetStateMethod_ =
- env_->GetMethodID(inputConnectionClass_, "setState",
- "(Lcom/google/androidgamesdk/gametextinput/State;)V");
- setSoftKeyboardActiveMethod_ = env_->GetMethodID(
- inputConnectionClass_, "setSoftKeyboardActive", "(ZI)V");
-
- stateClassInfo_.text =
- env_->GetFieldID(stateJavaClass_, "text", "Ljava/lang/String;");
- stateClassInfo_.selectionStart =
- env_->GetFieldID(stateJavaClass_, "selectionStart", "I");
- stateClassInfo_.selectionEnd =
- env_->GetFieldID(stateJavaClass_, "selectionEnd", "I");
- stateClassInfo_.composingRegionStart =
- env_->GetFieldID(stateJavaClass_, "composingRegionStart", "I");
- stateClassInfo_.composingRegionEnd =
- env_->GetFieldID(stateJavaClass_, "composingRegionEnd", "I");
-}
-
-GameTextInput::~GameTextInput() {
- if (stateJavaClass_ != NULL) {
- env_->DeleteGlobalRef(stateJavaClass_);
- stateJavaClass_ = NULL;
- }
- if (inputConnectionClass_ != NULL) {
- env_->DeleteGlobalRef(inputConnectionClass_);
- inputConnectionClass_ = NULL;
- }
- if (inputConnection_ != NULL) {
- env_->DeleteGlobalRef(inputConnection_);
- inputConnection_ = NULL;
- }
-}
-
-void GameTextInput::setState(const GameTextInputState &state) {
- if (inputConnection_ == nullptr) return;
- jobject jstate = stateToJava(state);
- env_->CallVoidMethod(inputConnection_, inputConnectionSetStateMethod_,
- jstate);
- env_->DeleteLocalRef(jstate);
- setStateInner(state);
-}
-
-void GameTextInput::setStateInner(const GameTextInputState &state) {
- // Check if we're setting using our own string (other parts may be
- // different)
- if (state.text_UTF8 == currentState_.text_UTF8) {
- currentState_ = state;
- return;
- }
- // Otherwise, copy across the string.
- auto bytes_needed =
- std::min(static_cast(state.text_length + 1),
- static_cast(stateStringBuffer_.size()));
- currentState_.text_UTF8 = stateStringBuffer_.data();
- std::copy(state.text_UTF8, state.text_UTF8 + bytes_needed - 1,
- stateStringBuffer_.data());
- currentState_.text_length = state.text_length;
- currentState_.selection = state.selection;
- currentState_.composingRegion = state.composingRegion;
- stateStringBuffer_[bytes_needed - 1] = 0;
-}
-
-void GameTextInput::setInputConnection(jobject inputConnection) {
- if (inputConnection_ != NULL) {
- env_->DeleteGlobalRef(inputConnection_);
- }
- inputConnection_ = env_->NewGlobalRef(inputConnection);
-}
-
-/*static*/ void GameTextInput::processCallback(
- void *context, const GameTextInputState *state) {
- auto thiz = static_cast(context);
- if (state != nullptr) thiz->setStateInner(*state);
-}
-
-void GameTextInput::processEvent(jobject textInputEvent) {
- stateFromJava(textInputEvent, processCallback, this);
- if (eventCallback_) {
- eventCallback_(eventCallbackContext_, ¤tState_);
- }
-}
-
-void GameTextInput::showIme(uint32_t flags) {
- if (inputConnection_ == nullptr) return;
- env_->CallVoidMethod(inputConnection_, setSoftKeyboardActiveMethod_, true,
- flags);
-}
-
-void GameTextInput::setEventCallback(GameTextInputEventCallback callback,
- void *context) {
- eventCallback_ = callback;
- eventCallbackContext_ = context;
-}
-
-void GameTextInput::setImeInsetsCallback(
- GameTextInputImeInsetsCallback callback, void *context) {
- insetsCallback_ = callback;
- insetsCallbackContext_ = context;
-}
-
-void GameTextInput::processImeInsets(const ARect *insets) {
- currentInsets_ = *insets;
- if (insetsCallback_) {
- insetsCallback_(insetsCallbackContext_, ¤tInsets_);
- }
-}
-
-void GameTextInput::hideIme(uint32_t flags) {
- if (inputConnection_ == nullptr) return;
- env_->CallVoidMethod(inputConnection_, setSoftKeyboardActiveMethod_, false,
- flags);
-}
-
-jobject GameTextInput::stateToJava(const GameTextInputState &state) const {
- static jmethodID constructor = nullptr;
- if (constructor == nullptr) {
- constructor = env_->GetMethodID(stateJavaClass_, "",
- "(Ljava/lang/String;IIII)V");
- if (constructor == nullptr) {
- __android_log_print(ANDROID_LOG_ERROR, LOG_TAG,
- "Can't find gametextinput.State constructor");
- return nullptr;
- }
- }
- const char *text = state.text_UTF8;
- if (text == nullptr) {
- static char empty_string[] = "";
- text = empty_string;
- }
- // Note that this expects 'modified' UTF-8 which is not the same as UTF-8
- // https://en.wikipedia.org/wiki/UTF-8#Modified_UTF-8
- jstring jtext = env_->NewStringUTF(text);
- jobject jobj =
- env_->NewObject(stateJavaClass_, constructor, jtext,
- state.selection.start, state.selection.end,
- state.composingRegion.start, state.composingRegion.end);
- env_->DeleteLocalRef(jtext);
- return jobj;
-}
-
-void GameTextInput::stateFromJava(jobject textInputEvent,
- GameTextInputGetStateCallback callback,
- void *context) const {
- jstring text =
- (jstring)env_->GetObjectField(textInputEvent, stateClassInfo_.text);
- // Note this is 'modified' UTF-8, not true UTF-8. It has no NULLs in it,
- // except at the end. It's actually not specified whether the value returned
- // by GetStringUTFChars includes a null at the end, but it *seems to* on
- // Android.
- const char *text_chars = env_->GetStringUTFChars(text, NULL);
- int text_len = env_->GetStringUTFLength(
- text); // Length in bytes, *not* including the null.
- int selectionStart =
- env_->GetIntField(textInputEvent, stateClassInfo_.selectionStart);
- int selectionEnd =
- env_->GetIntField(textInputEvent, stateClassInfo_.selectionEnd);
- int composingRegionStart =
- env_->GetIntField(textInputEvent, stateClassInfo_.composingRegionStart);
- int composingRegionEnd =
- env_->GetIntField(textInputEvent, stateClassInfo_.composingRegionEnd);
- GameTextInputState state{text_chars,
- text_len,
- {selectionStart, selectionEnd},
- {composingRegionStart, composingRegionEnd}};
- callback(context, &state);
- env_->ReleaseStringUTFChars(text, text_chars);
- env_->DeleteLocalRef(text);
-}
diff --git a/android-activity/game-activity-csrc/game-text-input/gametextinput.h b/android-activity/game-activity-csrc/game-text-input/gametextinput.h
deleted file mode 100644
index a85265ee..00000000
--- a/android-activity/game-activity-csrc/game-text-input/gametextinput.h
+++ /dev/null
@@ -1,290 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @defgroup game_text_input Game Text Input
- * The interface to use GameTextInput.
- * @{
- */
-
-#pragma once
-
-#include
-#include
-#include
-
-#include "gamecommon.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * This struct holds a span within a region of text from start (inclusive) to
- * end (exclusive). An empty span or cursor position is specified with
- * start==end. An undefined span is specified with start = end = SPAN_UNDEFINED.
- */
-typedef struct GameTextInputSpan {
- /** The start of the region (inclusive). */
- int32_t start;
- /** The end of the region (exclusive). */
- int32_t end;
-} GameTextInputSpan;
-
-/**
- * Values with special meaning in a GameTextInputSpan.
- */
-enum GameTextInputSpanFlag { SPAN_UNDEFINED = -1 };
-
-/**
- * This struct holds the state of an editable section of text.
- * The text can have a selection and a composing region defined on it.
- * A composing region is used by IMEs that allow input using multiple steps to
- * compose a glyph or word. Use functions GameTextInput_getState and
- * GameTextInput_setState to read and modify the state that an IME is editing.
- */
-typedef struct GameTextInputState {
- /**
- * Text owned by the state, as a modified UTF-8 string. Null-terminated.
- * https://en.wikipedia.org/wiki/UTF-8#Modified_UTF-8
- */
- const char *text_UTF8;
- /**
- * Length in bytes of text_UTF8, *not* including the null at end.
- */
- int32_t text_length;
- /**
- * A selection defined on the text.
- */
- GameTextInputSpan selection;
- /**
- * A composing region defined on the text.
- */
- GameTextInputSpan composingRegion;
-} GameTextInputState;
-
-/**
- * A callback called by GameTextInput_getState.
- * @param context User-defined context.
- * @param state State, owned by the library, that will be valid for the duration
- * of the callback.
- */
-typedef void (*GameTextInputGetStateCallback)(
- void *context, const struct GameTextInputState *state);
-
-/**
- * Opaque handle to the GameTextInput API.
- */
-typedef struct GameTextInput GameTextInput;
-
-/**
- * Initialize the GameTextInput library.
- * If called twice without GameTextInput_destroy being called, the same pointer
- * will be returned and a warning will be issued.
- * @param env A JNI env valid on the calling thread.
- * @param max_string_size The maximum length of a string that can be edited. If
- * zero, the maximum defaults to 65536 bytes. A buffer of this size is allocated
- * at initialization.
- * @return A handle to the library.
- */
-GameTextInput *GameTextInput_init(JNIEnv *env, uint32_t max_string_size);
-
-/**
- * When using GameTextInput, you need to create a gametextinput.InputConnection
- * on the Java side and pass it using this function to the library, unless using
- * GameActivity in which case this will be done for you. See the GameActivity
- * source code or GameTextInput samples for examples of usage.
- * @param input A valid GameTextInput library handle.
- * @param inputConnection A gametextinput.InputConnection object.
- */
-void GameTextInput_setInputConnection(GameTextInput *input,
- jobject inputConnection);
-
-/**
- * Unless using GameActivity, it is required to call this function from your
- * Java gametextinput.Listener.stateChanged method to convert eventState and
- * trigger any event callbacks. When using GameActivity, this does not need to
- * be called as event processing is handled by the Activity.
- * @param input A valid GameTextInput library handle.
- * @param eventState A Java gametextinput.State object.
- */
-void GameTextInput_processEvent(GameTextInput *input, jobject eventState);
-
-/**
- * Free any resources owned by the GameTextInput library.
- * Any subsequent calls to the library will fail until GameTextInput_init is
- * called again.
- * @param input A valid GameTextInput library handle.
- */
-void GameTextInput_destroy(GameTextInput *input);
-
-/**
- * Flags to be passed to GameTextInput_showIme.
- */
-enum ShowImeFlags {
- SHOW_IME_UNDEFINED = 0, // Default value.
- SHOW_IMPLICIT =
- 1, // Indicates that the user has forced the input method open so it
- // should not be closed until they explicitly do so.
- SHOW_FORCED = 2 // Indicates that this is an implicit request to show the
- // input window, not as the result of a direct request by
- // the user. The window may not be shown in this case.
-};
-
-/**
- * Show the IME. Calls InputMethodManager.showSoftInput().
- * @param input A valid GameTextInput library handle.
- * @param flags Defined in ShowImeFlags above. For more information see:
- * https://developer.android.com/reference/android/view/inputmethod/InputMethodManager
- */
-void GameTextInput_showIme(GameTextInput *input, uint32_t flags);
-
-/**
- * Flags to be passed to GameTextInput_hideIme.
- */
-enum HideImeFlags {
- HIDE_IME_UNDEFINED = 0, // Default value.
- HIDE_IMPLICIT_ONLY =
- 1, // Indicates that the soft input window should only be hidden if it
- // was not explicitly shown by the user.
- HIDE_NOT_ALWAYS =
- 2, // Indicates that the soft input window should normally be hidden,
- // unless it was originally shown with SHOW_FORCED.
-};
-
-/**
- * Show the IME. Calls InputMethodManager.hideSoftInputFromWindow().
- * @param input A valid GameTextInput library handle.
- * @param flags Defined in HideImeFlags above. For more information see:
- * https://developer.android.com/reference/android/view/inputmethod/InputMethodManager
- */
-void GameTextInput_hideIme(GameTextInput *input, uint32_t flags);
-
-/**
- * Call a callback with the current GameTextInput state, which may have been
- * modified by changes in the IME and calls to GameTextInput_setState. We use a
- * callback rather than returning the state in order to simplify ownership of
- * text_UTF8 strings. These strings are only valid during the calling of the
- * callback.
- * @param input A valid GameTextInput library handle.
- * @param callback A function that will be called with valid state.
- * @param context Context used by the callback.
- */
-void GameTextInput_getState(GameTextInput *input,
- GameTextInputGetStateCallback callback,
- void *context);
-
-/**
- * Set the current GameTextInput state. This state is reflected to any active
- * IME.
- * @param input A valid GameTextInput library handle.
- * @param state The state to set. Ownership is maintained by the caller and must
- * remain valid for the duration of the call.
- */
-void GameTextInput_setState(GameTextInput *input,
- const GameTextInputState *state);
-
-/**
- * Type of the callback needed by GameTextInput_setEventCallback that will be
- * called every time the IME state changes.
- * @param context User-defined context set in GameTextInput_setEventCallback.
- * @param current_state Current IME state, owned by the library and valid during
- * the callback.
- */
-typedef void (*GameTextInputEventCallback)(
- void *context, const GameTextInputState *current_state);
-
-/**
- * Optionally set a callback to be called whenever the IME state changes.
- * Not necessary if you are using GameActivity, which handles these callbacks
- * for you.
- * @param input A valid GameTextInput library handle.
- * @param callback Called by the library when the IME state changes.
- * @param context Context passed as first argument to the callback.
- */
-void GameTextInput_setEventCallback(GameTextInput *input,
- GameTextInputEventCallback callback,
- void *context);
-
-/**
- * Type of the callback needed by GameTextInput_setImeInsetsCallback that will
- * be called every time the IME window insets change.
- * @param context User-defined context set in
- * GameTextInput_setImeWIndowInsetsCallback.
- * @param current_insets Current IME insets, owned by the library and valid
- * during the callback.
- */
-typedef void (*GameTextInputImeInsetsCallback)(void *context,
- const ARect *current_insets);
-
-/**
- * Optionally set a callback to be called whenever the IME insets change.
- * Not necessary if you are using GameActivity, which handles these callbacks
- * for you.
- * @param input A valid GameTextInput library handle.
- * @param callback Called by the library when the IME insets change.
- * @param context Context passed as first argument to the callback.
- */
-void GameTextInput_setImeInsetsCallback(GameTextInput *input,
- GameTextInputImeInsetsCallback callback,
- void *context);
-
-/**
- * Get the current window insets for the IME.
- * @param input A valid GameTextInput library handle.
- * @param insets Filled with the current insets by this function.
- */
-void GameTextInput_getImeInsets(const GameTextInput *input, ARect *insets);
-
-/**
- * Unless using GameActivity, it is required to call this function from your
- * Java gametextinput.Listener.onImeInsetsChanged method to
- * trigger any event callbacks. When using GameActivity, this does not need to
- * be called as insets processing is handled by the Activity.
- * @param input A valid GameTextInput library handle.
- * @param eventState A Java gametextinput.State object.
- */
-void GameTextInput_processImeInsets(GameTextInput *input, const ARect *insets);
-
-/**
- * Convert a GameTextInputState struct to a Java gametextinput.State object.
- * Don't forget to delete the returned Java local ref when you're done.
- * @param input A valid GameTextInput library handle.
- * @param state Input state to convert.
- * @return A Java object of class gametextinput.State. The caller is required to
- * delete this local reference.
- */
-jobject GameTextInputState_toJava(const GameTextInput *input,
- const GameTextInputState *state);
-
-/**
- * Convert from a Java gametextinput.State object into a C GameTextInputState
- * struct.
- * @param input A valid GameTextInput library handle.
- * @param state A Java gametextinput.State object.
- * @param callback A function called with the C struct, valid for the duration
- * of the call.
- * @param context Context passed to the callback.
- */
-void GameTextInputState_fromJava(const GameTextInput *input, jobject state,
- GameTextInputGetStateCallback callback,
- void *context);
-
-#ifdef __cplusplus
-}
-#endif
-
-/** @} */
diff --git a/android-activity/generate-bindings.sh b/android-activity/generate-bindings.sh
old mode 100644
new mode 100755
index 530eeaea..8c1a4e97
--- a/android-activity/generate-bindings.sh
+++ b/android-activity/generate-bindings.sh
@@ -1,5 +1,8 @@
#!/bin/sh
+# First install bindgen-cli via `cargo install bindgen-cli`
+
+SDK_DIR="${ANDROID_GAMES_SDK:-android-games-sdk}"
if test -z "${ANDROID_NDK_ROOT}"; then
export ANDROID_NDK_ROOT=${ANDROID_NDK_HOME}
fi
@@ -12,6 +15,7 @@ while read ARCH && read TARGET ; do
# --module-raw-line 'use '
bindgen game-activity-ffi.h -o src/game_activity/ffi_$ARCH.rs \
+ --rust-target '1.73.0' \
--blocklist-item 'JNI\w+' \
--blocklist-item 'C?_?JNIEnv' \
--blocklist-item '_?JavaVM' \
@@ -34,7 +38,9 @@ while read ARCH && read TARGET ; do
--blocklist-function 'GameActivity_onCreate_C' \
--newtype-enum '\w+_(result|status)_t' \
-- \
- -Igame-activity-csrc \
+ "-I$SDK_DIR/game-activity/prefab-src/modules/game-activity/include" \
+ "-I$SDK_DIR/game-text-input/prefab-src/modules/game-text-input/include" \
+ "-I$SDK_DIR/include" \
--sysroot="$SYSROOT" --target=$TARGET
done << EOF
diff --git a/android-activity/src/config.rs b/android-activity/src/config.rs
index 7d818ecf..ab1bf1e6 100644
--- a/android-activity/src/config.rs
+++ b/android-activity/src/config.rs
@@ -6,13 +6,14 @@ use ndk::configuration::{
ScreenSize, Touchscreen, UiModeNight, UiModeType,
};
-/// A (cheaply clonable) reference to this application's [`ndk::configuration::Configuration`]
+/// A runtime-replacable reference to [`ndk::configuration::Configuration`].
///
-/// This provides a thread-safe way to access the latest configuration state for
-/// an application without deeply copying the large [`ndk::configuration::Configuration`] struct.
+/// # Warning
///
-/// If the application is notified of configuration changes then those changes
-/// will become visible via pre-existing configuration references.
+/// The value held by this reference **will change** with every [`super::MainEvent::ConfigChanged`]
+/// event that is raised. You should **not** [`Clone`] this type to compare it against a
+/// "new" [`super::AndroidApp::config()`] when that event is raised, since both point to the same
+/// internal [`ndk::configuration::Configuration`] and will be identical.
#[derive(Clone)]
pub struct ConfigurationRef {
config: Arc>,
@@ -28,8 +29,6 @@ impl PartialEq for ConfigurationRef {
}
}
impl Eq for ConfigurationRef {}
-unsafe impl Send for ConfigurationRef {}
-unsafe impl Sync for ConfigurationRef {}
impl fmt::Debug for ConfigurationRef {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
diff --git a/android-activity/src/error.rs b/android-activity/src/error.rs
new file mode 100644
index 00000000..7193f5a1
--- /dev/null
+++ b/android-activity/src/error.rs
@@ -0,0 +1,58 @@
+use thiserror::Error;
+
+#[derive(Error, Debug)]
+pub enum AppError {
+ #[error("Operation only supported from the android_main() thread: {0}")]
+ NonMainThread(String),
+
+ #[error("Java VM or JNI error, including Java exceptions")]
+ JavaError(String),
+
+ #[error("Input unavailable")]
+ InputUnavailable,
+}
+
+pub type Result = std::result::Result;
+
+// XXX: we don't want to expose jni-rs in the public API
+// so we have an internal error type that we can generally
+// use in the backends and then we can strip the error
+// in the frontend of the API.
+//
+// This way we avoid exposing a public trait implementation for
+// `From`
+#[derive(Error, Debug)]
+pub(crate) enum InternalAppError {
+ #[error("A JNI error")]
+ JniError(jni::errors::JniError),
+ #[error("A Java Exception was thrown via a JNI method call")]
+ JniException(String),
+ #[error("A Java VM error")]
+ JvmError(jni::errors::Error),
+ #[error("Input unavailable")]
+ InputUnavailable,
+}
+
+pub(crate) type InternalResult = std::result::Result;
+
+impl From for InternalAppError {
+ fn from(value: jni::errors::Error) -> Self {
+ InternalAppError::JvmError(value)
+ }
+}
+impl From for InternalAppError {
+ fn from(value: jni::errors::JniError) -> Self {
+ InternalAppError::JniError(value)
+ }
+}
+
+impl From for AppError {
+ fn from(value: InternalAppError) -> Self {
+ match value {
+ InternalAppError::JniError(err) => AppError::JavaError(err.to_string()),
+ InternalAppError::JniException(msg) => AppError::JavaError(msg),
+ InternalAppError::JvmError(err) => AppError::JavaError(err.to_string()),
+ InternalAppError::InputUnavailable => AppError::InputUnavailable,
+ }
+ }
+}
diff --git a/android-activity/src/game_activity/ffi.rs b/android-activity/src/game_activity/ffi.rs
index 3196865b..51063ff6 100644
--- a/android-activity/src/game_activity/ffi.rs
+++ b/android-activity/src/game_activity/ffi.rs
@@ -13,20 +13,17 @@
#![allow(dead_code)]
use jni_sys::*;
-use libc::{pthread_cond_t, pthread_mutex_t, pthread_t, size_t};
+use libc::{pthread_cond_t, pthread_mutex_t, pthread_t};
use ndk_sys::{AAssetManager, AConfiguration, ALooper, ALooper_callbackFunc, ANativeWindow, ARect};
-#[cfg(all(
- any(target_os = "android", feature = "test"),
- any(target_arch = "arm", target_arch = "armv7")
-))]
+#[cfg(all(any(target_os = "android"), target_arch = "arm"))]
include!("ffi_arm.rs");
-#[cfg(all(any(target_os = "android", feature = "test"), target_arch = "aarch64"))]
+#[cfg(all(any(target_os = "android"), target_arch = "aarch64"))]
include!("ffi_aarch64.rs");
-#[cfg(all(any(target_os = "android", feature = "test"), target_arch = "x86"))]
+#[cfg(all(any(target_os = "android"), target_arch = "x86"))]
include!("ffi_i686.rs");
-#[cfg(all(any(target_os = "android", feature = "test"), target_arch = "x86_64"))]
+#[cfg(all(any(target_os = "android"), target_arch = "x86_64"))]
include!("ffi_x86_64.rs");
diff --git a/android-activity/src/game_activity/ffi_aarch64.rs b/android-activity/src/game_activity/ffi_aarch64.rs
index 20a66d0c..461f3775 100644
--- a/android-activity/src/game_activity/ffi_aarch64.rs
+++ b/android-activity/src/game_activity/ffi_aarch64.rs
@@ -1,5 +1,15 @@
-/* automatically generated by rust-bindgen 0.59.2 */
+/* automatically generated by rust-bindgen 0.71.1 */
+#[doc = r" If Bindgen could only determine the size and alignment of a"]
+#[doc = r" type, it is represented like this."]
+#[derive(PartialEq, Copy, Clone, Debug, Hash)]
+#[repr(C)]
+pub struct __BindgenOpaqueArray(pub [T; N]);
+impl Default for __BindgenOpaqueArray {
+ fn default() -> Self {
+ Self([::default(); N])
+ }
+}
pub const __BIONIC__: u32 = 1;
pub const __WORDSIZE: u32 = 64;
pub const __bos_level: u32 = 0;
@@ -21,10 +31,15 @@ pub const __ANDROID_API_O_MR1__: u32 = 27;
pub const __ANDROID_API_P__: u32 = 28;
pub const __ANDROID_API_Q__: u32 = 29;
pub const __ANDROID_API_R__: u32 = 30;
-pub const __NDK_MAJOR__: u32 = 21;
+pub const __ANDROID_API_S__: u32 = 31;
+pub const __ANDROID_API_T__: u32 = 33;
+pub const __ANDROID_API_U__: u32 = 34;
+pub const __ANDROID_API_V__: u32 = 35;
+pub const __ANDROID_NDK__: u32 = 1;
+pub const __NDK_MAJOR__: u32 = 26;
pub const __NDK_MINOR__: u32 = 1;
pub const __NDK_BETA__: u32 = 0;
-pub const __NDK_BUILD__: u32 = 6352462;
+pub const __NDK_BUILD__: u32 = 10909125;
pub const __NDK_CANARY__: u32 = 0;
pub const WCHAR_MIN: u8 = 0u8;
pub const INT8_MIN: i32 = -128;
@@ -58,170 +73,230 @@ pub const WINT_MIN: u32 = 0;
pub const __BITS_PER_LONG: u32 = 64;
pub const __FD_SETSIZE: u32 = 1024;
pub const AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT: u32 = 8;
-pub const __PRI_64_prefix: &[u8; 2usize] = b"l\0";
-pub const __PRI_PTR_prefix: &[u8; 2usize] = b"l\0";
-pub const __PRI_FAST_prefix: &[u8; 2usize] = b"l\0";
-pub const PRId8: &[u8; 2usize] = b"d\0";
-pub const PRId16: &[u8; 2usize] = b"d\0";
-pub const PRId32: &[u8; 2usize] = b"d\0";
-pub const PRId64: &[u8; 3usize] = b"ld\0";
-pub const PRIdLEAST8: &[u8; 2usize] = b"d\0";
-pub const PRIdLEAST16: &[u8; 2usize] = b"d\0";
-pub const PRIdLEAST32: &[u8; 2usize] = b"d\0";
-pub const PRIdLEAST64: &[u8; 3usize] = b"ld\0";
-pub const PRIdFAST8: &[u8; 2usize] = b"d\0";
-pub const PRIdFAST16: &[u8; 3usize] = b"ld\0";
-pub const PRIdFAST32: &[u8; 3usize] = b"ld\0";
-pub const PRIdFAST64: &[u8; 3usize] = b"ld\0";
-pub const PRIdMAX: &[u8; 3usize] = b"jd\0";
-pub const PRIdPTR: &[u8; 3usize] = b"ld\0";
-pub const PRIi8: &[u8; 2usize] = b"i\0";
-pub const PRIi16: &[u8; 2usize] = b"i\0";
-pub const PRIi32: &[u8; 2usize] = b"i\0";
-pub const PRIi64: &[u8; 3usize] = b"li\0";
-pub const PRIiLEAST8: &[u8; 2usize] = b"i\0";
-pub const PRIiLEAST16: &[u8; 2usize] = b"i\0";
-pub const PRIiLEAST32: &[u8; 2usize] = b"i\0";
-pub const PRIiLEAST64: &[u8; 3usize] = b"li\0";
-pub const PRIiFAST8: &[u8; 2usize] = b"i\0";
-pub const PRIiFAST16: &[u8; 3usize] = b"li\0";
-pub const PRIiFAST32: &[u8; 3usize] = b"li\0";
-pub const PRIiFAST64: &[u8; 3usize] = b"li\0";
-pub const PRIiMAX: &[u8; 3usize] = b"ji\0";
-pub const PRIiPTR: &[u8; 3usize] = b"li\0";
-pub const PRIo8: &[u8; 2usize] = b"o\0";
-pub const PRIo16: &[u8; 2usize] = b"o\0";
-pub const PRIo32: &[u8; 2usize] = b"o\0";
-pub const PRIo64: &[u8; 3usize] = b"lo\0";
-pub const PRIoLEAST8: &[u8; 2usize] = b"o\0";
-pub const PRIoLEAST16: &[u8; 2usize] = b"o\0";
-pub const PRIoLEAST32: &[u8; 2usize] = b"o\0";
-pub const PRIoLEAST64: &[u8; 3usize] = b"lo\0";
-pub const PRIoFAST8: &[u8; 2usize] = b"o\0";
-pub const PRIoFAST16: &[u8; 3usize] = b"lo\0";
-pub const PRIoFAST32: &[u8; 3usize] = b"lo\0";
-pub const PRIoFAST64: &[u8; 3usize] = b"lo\0";
-pub const PRIoMAX: &[u8; 3usize] = b"jo\0";
-pub const PRIoPTR: &[u8; 3usize] = b"lo\0";
-pub const PRIu8: &[u8; 2usize] = b"u\0";
-pub const PRIu16: &[u8; 2usize] = b"u\0";
-pub const PRIu32: &[u8; 2usize] = b"u\0";
-pub const PRIu64: &[u8; 3usize] = b"lu\0";
-pub const PRIuLEAST8: &[u8; 2usize] = b"u\0";
-pub const PRIuLEAST16: &[u8; 2usize] = b"u\0";
-pub const PRIuLEAST32: &[u8; 2usize] = b"u\0";
-pub const PRIuLEAST64: &[u8; 3usize] = b"lu\0";
-pub const PRIuFAST8: &[u8; 2usize] = b"u\0";
-pub const PRIuFAST16: &[u8; 3usize] = b"lu\0";
-pub const PRIuFAST32: &[u8; 3usize] = b"lu\0";
-pub const PRIuFAST64: &[u8; 3usize] = b"lu\0";
-pub const PRIuMAX: &[u8; 3usize] = b"ju\0";
-pub const PRIuPTR: &[u8; 3usize] = b"lu\0";
-pub const PRIx8: &[u8; 2usize] = b"x\0";
-pub const PRIx16: &[u8; 2usize] = b"x\0";
-pub const PRIx32: &[u8; 2usize] = b"x\0";
-pub const PRIx64: &[u8; 3usize] = b"lx\0";
-pub const PRIxLEAST8: &[u8; 2usize] = b"x\0";
-pub const PRIxLEAST16: &[u8; 2usize] = b"x\0";
-pub const PRIxLEAST32: &[u8; 2usize] = b"x\0";
-pub const PRIxLEAST64: &[u8; 3usize] = b"lx\0";
-pub const PRIxFAST8: &[u8; 2usize] = b"x\0";
-pub const PRIxFAST16: &[u8; 3usize] = b"lx\0";
-pub const PRIxFAST32: &[u8; 3usize] = b"lx\0";
-pub const PRIxFAST64: &[u8; 3usize] = b"lx\0";
-pub const PRIxMAX: &[u8; 3usize] = b"jx\0";
-pub const PRIxPTR: &[u8; 3usize] = b"lx\0";
-pub const PRIX8: &[u8; 2usize] = b"X\0";
-pub const PRIX16: &[u8; 2usize] = b"X\0";
-pub const PRIX32: &[u8; 2usize] = b"X\0";
-pub const PRIX64: &[u8; 3usize] = b"lX\0";
-pub const PRIXLEAST8: &[u8; 2usize] = b"X\0";
-pub const PRIXLEAST16: &[u8; 2usize] = b"X\0";
-pub const PRIXLEAST32: &[u8; 2usize] = b"X\0";
-pub const PRIXLEAST64: &[u8; 3usize] = b"lX\0";
-pub const PRIXFAST8: &[u8; 2usize] = b"X\0";
-pub const PRIXFAST16: &[u8; 3usize] = b"lX\0";
-pub const PRIXFAST32: &[u8; 3usize] = b"lX\0";
-pub const PRIXFAST64: &[u8; 3usize] = b"lX\0";
-pub const PRIXMAX: &[u8; 3usize] = b"jX\0";
-pub const PRIXPTR: &[u8; 3usize] = b"lX\0";
-pub const SCNd8: &[u8; 4usize] = b"hhd\0";
-pub const SCNd16: &[u8; 3usize] = b"hd\0";
-pub const SCNd32: &[u8; 2usize] = b"d\0";
-pub const SCNd64: &[u8; 3usize] = b"ld\0";
-pub const SCNdLEAST8: &[u8; 4usize] = b"hhd\0";
-pub const SCNdLEAST16: &[u8; 3usize] = b"hd\0";
-pub const SCNdLEAST32: &[u8; 2usize] = b"d\0";
-pub const SCNdLEAST64: &[u8; 3usize] = b"ld\0";
-pub const SCNdFAST8: &[u8; 4usize] = b"hhd\0";
-pub const SCNdFAST16: &[u8; 3usize] = b"ld\0";
-pub const SCNdFAST32: &[u8; 3usize] = b"ld\0";
-pub const SCNdFAST64: &[u8; 3usize] = b"ld\0";
-pub const SCNdMAX: &[u8; 3usize] = b"jd\0";
-pub const SCNdPTR: &[u8; 3usize] = b"ld\0";
-pub const SCNi8: &[u8; 4usize] = b"hhi\0";
-pub const SCNi16: &[u8; 3usize] = b"hi\0";
-pub const SCNi32: &[u8; 2usize] = b"i\0";
-pub const SCNi64: &[u8; 3usize] = b"li\0";
-pub const SCNiLEAST8: &[u8; 4usize] = b"hhi\0";
-pub const SCNiLEAST16: &[u8; 3usize] = b"hi\0";
-pub const SCNiLEAST32: &[u8; 2usize] = b"i\0";
-pub const SCNiLEAST64: &[u8; 3usize] = b"li\0";
-pub const SCNiFAST8: &[u8; 4usize] = b"hhi\0";
-pub const SCNiFAST16: &[u8; 3usize] = b"li\0";
-pub const SCNiFAST32: &[u8; 3usize] = b"li\0";
-pub const SCNiFAST64: &[u8; 3usize] = b"li\0";
-pub const SCNiMAX: &[u8; 3usize] = b"ji\0";
-pub const SCNiPTR: &[u8; 3usize] = b"li\0";
-pub const SCNo8: &[u8; 4usize] = b"hho\0";
-pub const SCNo16: &[u8; 3usize] = b"ho\0";
-pub const SCNo32: &[u8; 2usize] = b"o\0";
-pub const SCNo64: &[u8; 3usize] = b"lo\0";
-pub const SCNoLEAST8: &[u8; 4usize] = b"hho\0";
-pub const SCNoLEAST16: &[u8; 3usize] = b"ho\0";
-pub const SCNoLEAST32: &[u8; 2usize] = b"o\0";
-pub const SCNoLEAST64: &[u8; 3usize] = b"lo\0";
-pub const SCNoFAST8: &[u8; 4usize] = b"hho\0";
-pub const SCNoFAST16: &[u8; 3usize] = b"lo\0";
-pub const SCNoFAST32: &[u8; 3usize] = b"lo\0";
-pub const SCNoFAST64: &[u8; 3usize] = b"lo\0";
-pub const SCNoMAX: &[u8; 3usize] = b"jo\0";
-pub const SCNoPTR: &[u8; 3usize] = b"lo\0";
-pub const SCNu8: &[u8; 4usize] = b"hhu\0";
-pub const SCNu16: &[u8; 3usize] = b"hu\0";
-pub const SCNu32: &[u8; 2usize] = b"u\0";
-pub const SCNu64: &[u8; 3usize] = b"lu\0";
-pub const SCNuLEAST8: &[u8; 4usize] = b"hhu\0";
-pub const SCNuLEAST16: &[u8; 3usize] = b"hu\0";
-pub const SCNuLEAST32: &[u8; 2usize] = b"u\0";
-pub const SCNuLEAST64: &[u8; 3usize] = b"lu\0";
-pub const SCNuFAST8: &[u8; 4usize] = b"hhu\0";
-pub const SCNuFAST16: &[u8; 3usize] = b"lu\0";
-pub const SCNuFAST32: &[u8; 3usize] = b"lu\0";
-pub const SCNuFAST64: &[u8; 3usize] = b"lu\0";
-pub const SCNuMAX: &[u8; 3usize] = b"ju\0";
-pub const SCNuPTR: &[u8; 3usize] = b"lu\0";
-pub const SCNx8: &[u8; 4usize] = b"hhx\0";
-pub const SCNx16: &[u8; 3usize] = b"hx\0";
-pub const SCNx32: &[u8; 2usize] = b"x\0";
-pub const SCNx64: &[u8; 3usize] = b"lx\0";
-pub const SCNxLEAST8: &[u8; 4usize] = b"hhx\0";
-pub const SCNxLEAST16: &[u8; 3usize] = b"hx\0";
-pub const SCNxLEAST32: &[u8; 2usize] = b"x\0";
-pub const SCNxLEAST64: &[u8; 3usize] = b"lx\0";
-pub const SCNxFAST8: &[u8; 4usize] = b"hhx\0";
-pub const SCNxFAST16: &[u8; 3usize] = b"lx\0";
-pub const SCNxFAST32: &[u8; 3usize] = b"lx\0";
-pub const SCNxFAST64: &[u8; 3usize] = b"lx\0";
-pub const SCNxMAX: &[u8; 3usize] = b"jx\0";
-pub const SCNxPTR: &[u8; 3usize] = b"lx\0";
-pub const __GNUC_VA_LIST: u32 = 1;
+pub const __bool_true_false_are_defined: u32 = 1;
pub const true_: u32 = 1;
pub const false_: u32 = 0;
-pub const __bool_true_false_are_defined: u32 = 1;
+pub const __PRI_64_prefix: &[u8; 2] = b"l\0";
+pub const __PRI_PTR_prefix: &[u8; 2] = b"l\0";
+pub const __PRI_FAST_prefix: &[u8; 2] = b"l\0";
+pub const PRId8: &[u8; 2] = b"d\0";
+pub const PRId16: &[u8; 2] = b"d\0";
+pub const PRId32: &[u8; 2] = b"d\0";
+pub const PRId64: &[u8; 3] = b"ld\0";
+pub const PRIdLEAST8: &[u8; 2] = b"d\0";
+pub const PRIdLEAST16: &[u8; 2] = b"d\0";
+pub const PRIdLEAST32: &[u8; 2] = b"d\0";
+pub const PRIdLEAST64: &[u8; 3] = b"ld\0";
+pub const PRIdFAST8: &[u8; 2] = b"d\0";
+pub const PRIdFAST16: &[u8; 3] = b"ld\0";
+pub const PRIdFAST32: &[u8; 3] = b"ld\0";
+pub const PRIdFAST64: &[u8; 3] = b"ld\0";
+pub const PRIdMAX: &[u8; 3] = b"jd\0";
+pub const PRIdPTR: &[u8; 3] = b"ld\0";
+pub const PRIi8: &[u8; 2] = b"i\0";
+pub const PRIi16: &[u8; 2] = b"i\0";
+pub const PRIi32: &[u8; 2] = b"i\0";
+pub const PRIi64: &[u8; 3] = b"li\0";
+pub const PRIiLEAST8: &[u8; 2] = b"i\0";
+pub const PRIiLEAST16: &[u8; 2] = b"i\0";
+pub const PRIiLEAST32: &[u8; 2] = b"i\0";
+pub const PRIiLEAST64: &[u8; 3] = b"li\0";
+pub const PRIiFAST8: &[u8; 2] = b"i\0";
+pub const PRIiFAST16: &[u8; 3] = b"li\0";
+pub const PRIiFAST32: &[u8; 3] = b"li\0";
+pub const PRIiFAST64: &[u8; 3] = b"li\0";
+pub const PRIiMAX: &[u8; 3] = b"ji\0";
+pub const PRIiPTR: &[u8; 3] = b"li\0";
+pub const PRIb8: &[u8; 2] = b"b\0";
+pub const PRIb16: &[u8; 2] = b"b\0";
+pub const PRIb32: &[u8; 2] = b"b\0";
+pub const PRIb64: &[u8; 3] = b"lb\0";
+pub const PRIbLEAST8: &[u8; 2] = b"b\0";
+pub const PRIbLEAST16: &[u8; 2] = b"b\0";
+pub const PRIbLEAST32: &[u8; 2] = b"b\0";
+pub const PRIbLEAST64: &[u8; 3] = b"lb\0";
+pub const PRIbFAST8: &[u8; 2] = b"b\0";
+pub const PRIbFAST16: &[u8; 3] = b"lb\0";
+pub const PRIbFAST32: &[u8; 3] = b"lb\0";
+pub const PRIbFAST64: &[u8; 3] = b"lb\0";
+pub const PRIbMAX: &[u8; 3] = b"jb\0";
+pub const PRIbPTR: &[u8; 3] = b"lb\0";
+pub const PRIB8: &[u8; 2] = b"B\0";
+pub const PRIB16: &[u8; 2] = b"B\0";
+pub const PRIB32: &[u8; 2] = b"B\0";
+pub const PRIB64: &[u8; 3] = b"lB\0";
+pub const PRIBLEAST8: &[u8; 2] = b"B\0";
+pub const PRIBLEAST16: &[u8; 2] = b"B\0";
+pub const PRIBLEAST32: &[u8; 2] = b"B\0";
+pub const PRIBLEAST64: &[u8; 3] = b"lB\0";
+pub const PRIBFAST8: &[u8; 2] = b"B\0";
+pub const PRIBFAST16: &[u8; 3] = b"lB\0";
+pub const PRIBFAST32: &[u8; 3] = b"lB\0";
+pub const PRIBFAST64: &[u8; 3] = b"lB\0";
+pub const PRIBMAX: &[u8; 3] = b"jB\0";
+pub const PRIBPTR: &[u8; 3] = b"lB\0";
+pub const PRIo8: &[u8; 2] = b"o\0";
+pub const PRIo16: &[u8; 2] = b"o\0";
+pub const PRIo32: &[u8; 2] = b"o\0";
+pub const PRIo64: &[u8; 3] = b"lo\0";
+pub const PRIoLEAST8: &[u8; 2] = b"o\0";
+pub const PRIoLEAST16: &[u8; 2] = b"o\0";
+pub const PRIoLEAST32: &[u8; 2] = b"o\0";
+pub const PRIoLEAST64: &[u8; 3] = b"lo\0";
+pub const PRIoFAST8: &[u8; 2] = b"o\0";
+pub const PRIoFAST16: &[u8; 3] = b"lo\0";
+pub const PRIoFAST32: &[u8; 3] = b"lo\0";
+pub const PRIoFAST64: &[u8; 3] = b"lo\0";
+pub const PRIoMAX: &[u8; 3] = b"jo\0";
+pub const PRIoPTR: &[u8; 3] = b"lo\0";
+pub const PRIu8: &[u8; 2] = b"u\0";
+pub const PRIu16: &[u8; 2] = b"u\0";
+pub const PRIu32: &[u8; 2] = b"u\0";
+pub const PRIu64: &[u8; 3] = b"lu\0";
+pub const PRIuLEAST8: &[u8; 2] = b"u\0";
+pub const PRIuLEAST16: &[u8; 2] = b"u\0";
+pub const PRIuLEAST32: &[u8; 2] = b"u\0";
+pub const PRIuLEAST64: &[u8; 3] = b"lu\0";
+pub const PRIuFAST8: &[u8; 2] = b"u\0";
+pub const PRIuFAST16: &[u8; 3] = b"lu\0";
+pub const PRIuFAST32: &[u8; 3] = b"lu\0";
+pub const PRIuFAST64: &[u8; 3] = b"lu\0";
+pub const PRIuMAX: &[u8; 3] = b"ju\0";
+pub const PRIuPTR: &[u8; 3] = b"lu\0";
+pub const PRIx8: &[u8; 2] = b"x\0";
+pub const PRIx16: &[u8; 2] = b"x\0";
+pub const PRIx32: &[u8; 2] = b"x\0";
+pub const PRIx64: &[u8; 3] = b"lx\0";
+pub const PRIxLEAST8: &[u8; 2] = b"x\0";
+pub const PRIxLEAST16: &[u8; 2] = b"x\0";
+pub const PRIxLEAST32: &[u8; 2] = b"x\0";
+pub const PRIxLEAST64: &[u8; 3] = b"lx\0";
+pub const PRIxFAST8: &[u8; 2] = b"x\0";
+pub const PRIxFAST16: &[u8; 3] = b"lx\0";
+pub const PRIxFAST32: &[u8; 3] = b"lx\0";
+pub const PRIxFAST64: &[u8; 3] = b"lx\0";
+pub const PRIxMAX: &[u8; 3] = b"jx\0";
+pub const PRIxPTR: &[u8; 3] = b"lx\0";
+pub const PRIX8: &[u8; 2] = b"X\0";
+pub const PRIX16: &[u8; 2] = b"X\0";
+pub const PRIX32: &[u8; 2] = b"X\0";
+pub const PRIX64: &[u8; 3] = b"lX\0";
+pub const PRIXLEAST8: &[u8; 2] = b"X\0";
+pub const PRIXLEAST16: &[u8; 2] = b"X\0";
+pub const PRIXLEAST32: &[u8; 2] = b"X\0";
+pub const PRIXLEAST64: &[u8; 3] = b"lX\0";
+pub const PRIXFAST8: &[u8; 2] = b"X\0";
+pub const PRIXFAST16: &[u8; 3] = b"lX\0";
+pub const PRIXFAST32: &[u8; 3] = b"lX\0";
+pub const PRIXFAST64: &[u8; 3] = b"lX\0";
+pub const PRIXMAX: &[u8; 3] = b"jX\0";
+pub const PRIXPTR: &[u8; 3] = b"lX\0";
+pub const SCNd8: &[u8; 4] = b"hhd\0";
+pub const SCNd16: &[u8; 3] = b"hd\0";
+pub const SCNd32: &[u8; 2] = b"d\0";
+pub const SCNd64: &[u8; 3] = b"ld\0";
+pub const SCNdLEAST8: &[u8; 4] = b"hhd\0";
+pub const SCNdLEAST16: &[u8; 3] = b"hd\0";
+pub const SCNdLEAST32: &[u8; 2] = b"d\0";
+pub const SCNdLEAST64: &[u8; 3] = b"ld\0";
+pub const SCNdFAST8: &[u8; 4] = b"hhd\0";
+pub const SCNdFAST16: &[u8; 3] = b"ld\0";
+pub const SCNdFAST32: &[u8; 3] = b"ld\0";
+pub const SCNdFAST64: &[u8; 3] = b"ld\0";
+pub const SCNdMAX: &[u8; 3] = b"jd\0";
+pub const SCNdPTR: &[u8; 3] = b"ld\0";
+pub const SCNi8: &[u8; 4] = b"hhi\0";
+pub const SCNi16: &[u8; 3] = b"hi\0";
+pub const SCNi32: &[u8; 2] = b"i\0";
+pub const SCNi64: &[u8; 3] = b"li\0";
+pub const SCNiLEAST8: &[u8; 4] = b"hhi\0";
+pub const SCNiLEAST16: &[u8; 3] = b"hi\0";
+pub const SCNiLEAST32: &[u8; 2] = b"i\0";
+pub const SCNiLEAST64: &[u8; 3] = b"li\0";
+pub const SCNiFAST8: &[u8; 4] = b"hhi\0";
+pub const SCNiFAST16: &[u8; 3] = b"li\0";
+pub const SCNiFAST32: &[u8; 3] = b"li\0";
+pub const SCNiFAST64: &[u8; 3] = b"li\0";
+pub const SCNiMAX: &[u8; 3] = b"ji\0";
+pub const SCNiPTR: &[u8; 3] = b"li\0";
+pub const SCNb8: &[u8; 4] = b"hhb\0";
+pub const SCNb16: &[u8; 3] = b"hb\0";
+pub const SCNb32: &[u8; 2] = b"b\0";
+pub const SCNb64: &[u8; 3] = b"lb\0";
+pub const SCNbLEAST8: &[u8; 4] = b"hhb\0";
+pub const SCNbLEAST16: &[u8; 3] = b"hb\0";
+pub const SCNbLEAST32: &[u8; 2] = b"b\0";
+pub const SCNbLEAST64: &[u8; 3] = b"lb\0";
+pub const SCNbFAST8: &[u8; 4] = b"hhb\0";
+pub const SCNbFAST16: &[u8; 3] = b"lb\0";
+pub const SCNbFAST32: &[u8; 3] = b"lb\0";
+pub const SCNbFAST64: &[u8; 3] = b"lb\0";
+pub const SCNbMAX: &[u8; 3] = b"jb\0";
+pub const SCNbPTR: &[u8; 3] = b"lb\0";
+pub const SCNB8: &[u8; 4] = b"hhB\0";
+pub const SCNB16: &[u8; 3] = b"hB\0";
+pub const SCNB32: &[u8; 2] = b"B\0";
+pub const SCNB64: &[u8; 3] = b"lB\0";
+pub const SCNBLEAST8: &[u8; 4] = b"hhB\0";
+pub const SCNBLEAST16: &[u8; 3] = b"hB\0";
+pub const SCNBLEAST32: &[u8; 2] = b"B\0";
+pub const SCNBLEAST64: &[u8; 3] = b"lB\0";
+pub const SCNBFAST8: &[u8; 4] = b"hhB\0";
+pub const SCNBFAST16: &[u8; 3] = b"lB\0";
+pub const SCNBFAST32: &[u8; 3] = b"lB\0";
+pub const SCNBFAST64: &[u8; 3] = b"lB\0";
+pub const SCNBMAX: &[u8; 3] = b"jB\0";
+pub const SCNBPTR: &[u8; 3] = b"lB\0";
+pub const SCNo8: &[u8; 4] = b"hho\0";
+pub const SCNo16: &[u8; 3] = b"ho\0";
+pub const SCNo32: &[u8; 2] = b"o\0";
+pub const SCNo64: &[u8; 3] = b"lo\0";
+pub const SCNoLEAST8: &[u8; 4] = b"hho\0";
+pub const SCNoLEAST16: &[u8; 3] = b"ho\0";
+pub const SCNoLEAST32: &[u8; 2] = b"o\0";
+pub const SCNoLEAST64: &[u8; 3] = b"lo\0";
+pub const SCNoFAST8: &[u8; 4] = b"hho\0";
+pub const SCNoFAST16: &[u8; 3] = b"lo\0";
+pub const SCNoFAST32: &[u8; 3] = b"lo\0";
+pub const SCNoFAST64: &[u8; 3] = b"lo\0";
+pub const SCNoMAX: &[u8; 3] = b"jo\0";
+pub const SCNoPTR: &[u8; 3] = b"lo\0";
+pub const SCNu8: &[u8; 4] = b"hhu\0";
+pub const SCNu16: &[u8; 3] = b"hu\0";
+pub const SCNu32: &[u8; 2] = b"u\0";
+pub const SCNu64: &[u8; 3] = b"lu\0";
+pub const SCNuLEAST8: &[u8; 4] = b"hhu\0";
+pub const SCNuLEAST16: &[u8; 3] = b"hu\0";
+pub const SCNuLEAST32: &[u8; 2] = b"u\0";
+pub const SCNuLEAST64: &[u8; 3] = b"lu\0";
+pub const SCNuFAST8: &[u8; 4] = b"hhu\0";
+pub const SCNuFAST16: &[u8; 3] = b"lu\0";
+pub const SCNuFAST32: &[u8; 3] = b"lu\0";
+pub const SCNuFAST64: &[u8; 3] = b"lu\0";
+pub const SCNuMAX: &[u8; 3] = b"ju\0";
+pub const SCNuPTR: &[u8; 3] = b"lu\0";
+pub const SCNx8: &[u8; 4] = b"hhx\0";
+pub const SCNx16: &[u8; 3] = b"hx\0";
+pub const SCNx32: &[u8; 2] = b"x\0";
+pub const SCNx64: &[u8; 3] = b"lx\0";
+pub const SCNxLEAST8: &[u8; 4] = b"hhx\0";
+pub const SCNxLEAST16: &[u8; 3] = b"hx\0";
+pub const SCNxLEAST32: &[u8; 2] = b"x\0";
+pub const SCNxLEAST64: &[u8; 3] = b"lx\0";
+pub const SCNxFAST8: &[u8; 4] = b"hhx\0";
+pub const SCNxFAST16: &[u8; 3] = b"lx\0";
+pub const SCNxFAST32: &[u8; 3] = b"lx\0";
+pub const SCNxFAST64: &[u8; 3] = b"lx\0";
+pub const SCNxMAX: &[u8; 3] = b"jx\0";
+pub const SCNxPTR: &[u8; 3] = b"lx\0";
pub const GAME_ACTIVITY_POINTER_INFO_AXIS_COUNT: u32 = 48;
pub const GAMEACTIVITY_MAX_NUM_POINTERS_IN_MOTION_EVENT: u32 = 8;
-pub const GAMEACTIVITY_MAX_NUM_HISTORICAL_IN_MOTION_EVENT: u32 = 8;
+pub const GAMETEXTINPUT_MAJOR_VERSION: u32 = 4;
+pub const GAMETEXTINPUT_MINOR_VERSION: u32 = 0;
+pub const GAMETEXTINPUT_BUGFIX_VERSION: u32 = 0;
+pub const GAMEACTIVITY_MAJOR_VERSION: u32 = 4;
+pub const GAMEACTIVITY_MINOR_VERSION: u32 = 0;
+pub const GAMEACTIVITY_BUGFIX_VERSION: u32 = 0;
pub const POLLIN: u32 = 1;
pub const POLLPRI: u32 = 2;
pub const POLLOUT: u32 = 4;
@@ -239,6 +314,10 @@ pub const FPSIMD_MAGIC: u32 = 1179680769;
pub const ESR_MAGIC: u32 = 1163088385;
pub const EXTRA_MAGIC: u32 = 1163416577;
pub const SVE_MAGIC: u32 = 1398162689;
+pub const SVE_SIG_FLAG_SM: u32 = 1;
+pub const TPIDR2_MAGIC: u32 = 1414547714;
+pub const ZA_MAGIC: u32 = 1412850501;
+pub const ZT_MAGIC: u32 = 1515474433;
pub const __SVE_VQ_BYTES: u32 = 16;
pub const __SVE_VQ_MIN: u32 = 1;
pub const __SVE_VQ_MAX: u32 = 512;
@@ -254,6 +333,8 @@ pub const SVE_VL_MIN: u32 = 16;
pub const SVE_VL_MAX: u32 = 8192;
pub const SVE_NUM_ZREGS: u32 = 32;
pub const SVE_NUM_PREGS: u32 = 16;
+pub const ZT_SIG_REG_SIZE: u32 = 512;
+pub const ZT_SIG_REG_BYTES: u32 = 64;
pub const NR_OPEN: u32 = 1024;
pub const NGROUPS_MAX: u32 = 65536;
pub const ARG_MAX: u32 = 131072;
@@ -471,6 +552,8 @@ pub const __SIGRTMAX: u32 = 64;
pub const SA_NOCLDSTOP: u32 = 1;
pub const SA_NOCLDWAIT: u32 = 2;
pub const SA_SIGINFO: u32 = 4;
+pub const SA_UNSUPPORTED: u32 = 1024;
+pub const SA_EXPOSE_TAGBITS: u32 = 2048;
pub const SA_ONSTACK: u32 = 134217728;
pub const SA_RESTART: u32 = 268435456;
pub const SA_NODEFER: u32 = 1073741824;
@@ -526,7 +609,9 @@ pub const SEGV_PKUERR: u32 = 4;
pub const SEGV_ACCADI: u32 = 5;
pub const SEGV_ADIDERR: u32 = 6;
pub const SEGV_ADIPERR: u32 = 7;
-pub const NSIGSEGV: u32 = 7;
+pub const SEGV_MTEAERR: u32 = 8;
+pub const SEGV_MTESERR: u32 = 9;
+pub const NSIGSEGV: u32 = 9;
pub const BUS_ADRALN: u32 = 1;
pub const BUS_ADRERR: u32 = 2;
pub const BUS_OBJERR: u32 = 3;
@@ -538,7 +623,9 @@ pub const TRAP_TRACE: u32 = 2;
pub const TRAP_BRANCH: u32 = 3;
pub const TRAP_HWBKPT: u32 = 4;
pub const TRAP_UNK: u32 = 5;
-pub const NSIGTRAP: u32 = 5;
+pub const TRAP_PERF: u32 = 6;
+pub const NSIGTRAP: u32 = 6;
+pub const TRAP_PERF_FLAG_ASYNC: u32 = 1;
pub const CLD_EXITED: u32 = 1;
pub const CLD_KILLED: u32 = 2;
pub const CLD_DUMPED: u32 = 3;
@@ -554,7 +641,8 @@ pub const POLL_PRI: u32 = 5;
pub const POLL_HUP: u32 = 6;
pub const NSIGPOLL: u32 = 6;
pub const SYS_SECCOMP: u32 = 1;
-pub const NSIGSYS: u32 = 1;
+pub const SYS_USER_DISPATCH: u32 = 2;
+pub const NSIGSYS: u32 = 2;
pub const EMT_TAGOVF: u32 = 1;
pub const NSIGEMT: u32 = 1;
pub const SIGEV_SIGNAL: u32 = 0;
@@ -593,6 +681,9 @@ pub const TIMER_ABSTIME: u32 = 1;
pub const FD_SETSIZE: u32 = 1024;
pub const CLOCKS_PER_SEC: u32 = 1000000;
pub const TIME_UTC: u32 = 1;
+pub const TIME_MONOTONIC: u32 = 2;
+pub const TIME_ACTIVE: u32 = 3;
+pub const TIME_THREAD_ACTIVE: u32 = 4;
pub const CSIGNAL: u32 = 255;
pub const CLONE_VM: u32 = 256;
pub const CLONE_FS: u32 = 512;
@@ -618,6 +709,12 @@ pub const CLONE_NEWUSER: u32 = 268435456;
pub const CLONE_NEWPID: u32 = 536870912;
pub const CLONE_NEWNET: u32 = 1073741824;
pub const CLONE_IO: u32 = 2147483648;
+pub const CLONE_CLEAR_SIGHAND: u64 = 4294967296;
+pub const CLONE_INTO_CGROUP: u64 = 8589934592;
+pub const CLONE_NEWTIME: u32 = 128;
+pub const CLONE_ARGS_SIZE_VER0: u32 = 64;
+pub const CLONE_ARGS_SIZE_VER1: u32 = 80;
+pub const CLONE_ARGS_SIZE_VER2: u32 = 88;
pub const SCHED_NORMAL: u32 = 0;
pub const SCHED_FIFO: u32 = 1;
pub const SCHED_RR: u32 = 2;
@@ -649,9 +746,6 @@ pub const PTHREAD_PROCESS_PRIVATE: u32 = 0;
pub const PTHREAD_PROCESS_SHARED: u32 = 1;
pub const PTHREAD_SCOPE_SYSTEM: u32 = 0;
pub const PTHREAD_SCOPE_PROCESS: u32 = 1;
-pub const NATIVE_APP_GLUE_MAX_NUM_MOTION_EVENTS: u32 = 16;
-pub const NATIVE_APP_GLUE_MAX_HISTORICAL_POINTER_SAMPLES: u32 = 64;
-pub const NATIVE_APP_GLUE_MAX_NUM_KEY_EVENTS: u32 = 4;
pub const NATIVE_APP_GLUE_MAX_INPUT_BUFFERS: u32 = 2;
extern "C" {
pub fn android_get_application_target_sdk_version() -> ::std::os::raw::c_int;
@@ -670,39 +764,27 @@ pub struct max_align_t {
}
#[test]
fn bindgen_test_layout_max_align_t() {
+ const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit();
+ let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::(),
32usize,
- concat!("Size of: ", stringify!(max_align_t))
+ "Size of max_align_t"
);
assert_eq!(
::std::mem::align_of::(),
16usize,
- concat!("Alignment of ", stringify!(max_align_t))
+ "Alignment of max_align_t"
);
assert_eq!(
- unsafe {
- &(*(::std::ptr::null::())).__clang_max_align_nonce1 as *const _ as usize
- },
+ unsafe { ::std::ptr::addr_of!((*ptr).__clang_max_align_nonce1) as usize - ptr as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(max_align_t),
- "::",
- stringify!(__clang_max_align_nonce1)
- )
+ "Offset of field: max_align_t::__clang_max_align_nonce1"
);
assert_eq!(
- unsafe {
- &(*(::std::ptr::null::())).__clang_max_align_nonce2 as *const _ as usize
- },
+ unsafe { ::std::ptr::addr_of!((*ptr).__clang_max_align_nonce2) as usize - ptr as usize },
16usize,
- concat!(
- "Offset of field: ",
- stringify!(max_align_t),
- "::",
- stringify!(__clang_max_align_nonce2)
- )
+ "Offset of field: max_align_t::__clang_max_align_nonce2"
);
}
pub type __int8_t = ::std::os::raw::c_schar;
@@ -748,25 +830,22 @@ pub struct __kernel_fd_set {
}
#[test]
fn bindgen_test_layout___kernel_fd_set() {
+ const UNINIT: ::std::mem::MaybeUninit<__kernel_fd_set> = ::std::mem::MaybeUninit::uninit();
+ let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<__kernel_fd_set>(),
128usize,
- concat!("Size of: ", stringify!(__kernel_fd_set))
+ "Size of __kernel_fd_set"
);
assert_eq!(
::std::mem::align_of::<__kernel_fd_set>(),
8usize,
- concat!("Alignment of ", stringify!(__kernel_fd_set))
+ "Alignment of __kernel_fd_set"
);
assert_eq!(
- unsafe { &(*(::std::ptr::null::<__kernel_fd_set>())).fds_bits as *const _ as usize },
+ unsafe { ::std::ptr::addr_of!((*ptr).fds_bits) as usize - ptr as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(__kernel_fd_set),
- "::",
- stringify!(fds_bits)
- )
+ "Offset of field: __kernel_fd_set::fds_bits"
);
}
pub type __kernel_sighandler_t =
@@ -798,29 +877,27 @@ pub struct __kernel_fsid_t {
}
#[test]
fn bindgen_test_layout___kernel_fsid_t() {
+ const UNINIT: ::std::mem::MaybeUninit<__kernel_fsid_t> = ::std::mem::MaybeUninit::uninit();
+ let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::<__kernel_fsid_t>(),
8usize,
- concat!("Size of: ", stringify!(__kernel_fsid_t))
+ "Size of __kernel_fsid_t"
);
assert_eq!(
::std::mem::align_of::<__kernel_fsid_t>(),
4usize,
- concat!("Alignment of ", stringify!(__kernel_fsid_t))
+ "Alignment of __kernel_fsid_t"
);
assert_eq!(
- unsafe { &(*(::std::ptr::null::<__kernel_fsid_t>())).val as *const _ as usize },
+ unsafe { ::std::ptr::addr_of!((*ptr).val) as usize - ptr as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(__kernel_fsid_t),
- "::",
- stringify!(val)
- )
+ "Offset of field: __kernel_fsid_t::val"
);
}
pub type __kernel_off_t = __kernel_long_t;
pub type __kernel_loff_t = ::std::os::raw::c_longlong;
+pub type __kernel_old_time_t = __kernel_long_t;
pub type __kernel_time_t = __kernel_long_t;
pub type __kernel_time64_t = ::std::os::raw::c_longlong;
pub type __kernel_clock_t = __kernel_long_t;
@@ -878,8 +955,7 @@ pub type loff_t = off_t;
pub type off64_t = loff_t;
pub type __socklen_t = u32;
pub type socklen_t = __socklen_t;
-pub type __va_list = [u64; 4usize];
-pub type ssize_t = __kernel_ssize_t;
+pub type __va_list = __BindgenOpaqueArray;
pub type uint_t = ::std::os::raw::c_uint;
pub type uint = ::std::os::raw::c_uint;
pub type u_char = ::std::os::raw::c_uchar;
@@ -890,483 +966,622 @@ pub type u_int32_t = u32;
pub type u_int16_t = u16;
pub type u_int8_t = u8;
pub type u_int64_t = u64;
-pub const AASSET_MODE_UNKNOWN: ::std::os::raw::c_uint = 0;
-pub const AASSET_MODE_RANDOM: ::std::os::raw::c_uint = 1;
-pub const AASSET_MODE_STREAMING: ::std::os::raw::c_uint = 2;
-pub const AASSET_MODE_BUFFER: ::std::os::raw::c_uint = 3;
+pub const AASSET_MODE_UNKNOWN: _bindgen_ty_1 = 0;
+pub const AASSET_MODE_RANDOM: _bindgen_ty_1 = 1;
+pub const AASSET_MODE_STREAMING: _bindgen_ty_1 = 2;
+pub const AASSET_MODE_BUFFER: _bindgen_ty_1 = 3;
pub type _bindgen_ty_1 = ::std::os::raw::c_uint;
-pub const AKEYCODE_UNKNOWN: ::std::os::raw::c_uint = 0;
-pub const AKEYCODE_SOFT_LEFT: ::std::os::raw::c_uint = 1;
-pub const AKEYCODE_SOFT_RIGHT: ::std::os::raw::c_uint = 2;
-pub const AKEYCODE_HOME: ::std::os::raw::c_uint = 3;
-pub const AKEYCODE_BACK: ::std::os::raw::c_uint = 4;
-pub const AKEYCODE_CALL: ::std::os::raw::c_uint = 5;
-pub const AKEYCODE_ENDCALL: ::std::os::raw::c_uint = 6;
-pub const AKEYCODE_0: ::std::os::raw::c_uint = 7;
-pub const AKEYCODE_1: ::std::os::raw::c_uint = 8;
-pub const AKEYCODE_2: ::std::os::raw::c_uint = 9;
-pub const AKEYCODE_3: ::std::os::raw::c_uint = 10;
-pub const AKEYCODE_4: ::std::os::raw::c_uint = 11;
-pub const AKEYCODE_5: ::std::os::raw::c_uint = 12;
-pub const AKEYCODE_6: ::std::os::raw::c_uint = 13;
-pub const AKEYCODE_7: ::std::os::raw::c_uint = 14;
-pub const AKEYCODE_8: ::std::os::raw::c_uint = 15;
-pub const AKEYCODE_9: ::std::os::raw::c_uint = 16;
-pub const AKEYCODE_STAR: ::std::os::raw::c_uint = 17;
-pub const AKEYCODE_POUND: ::std::os::raw::c_uint = 18;
-pub const AKEYCODE_DPAD_UP: ::std::os::raw::c_uint = 19;
-pub const AKEYCODE_DPAD_DOWN: ::std::os::raw::c_uint = 20;
-pub const AKEYCODE_DPAD_LEFT: ::std::os::raw::c_uint = 21;
-pub const AKEYCODE_DPAD_RIGHT: ::std::os::raw::c_uint = 22;
-pub const AKEYCODE_DPAD_CENTER: ::std::os::raw::c_uint = 23;
-pub const AKEYCODE_VOLUME_UP: ::std::os::raw::c_uint = 24;
-pub const AKEYCODE_VOLUME_DOWN: ::std::os::raw::c_uint = 25;
-pub const AKEYCODE_POWER: ::std::os::raw::c_uint = 26;
-pub const AKEYCODE_CAMERA: ::std::os::raw::c_uint = 27;
-pub const AKEYCODE_CLEAR: ::std::os::raw::c_uint = 28;
-pub const AKEYCODE_A: ::std::os::raw::c_uint = 29;
-pub const AKEYCODE_B: ::std::os::raw::c_uint = 30;
-pub const AKEYCODE_C: ::std::os::raw::c_uint = 31;
-pub const AKEYCODE_D: ::std::os::raw::c_uint = 32;
-pub const AKEYCODE_E: ::std::os::raw::c_uint = 33;
-pub const AKEYCODE_F: ::std::os::raw::c_uint = 34;
-pub const AKEYCODE_G: ::std::os::raw::c_uint = 35;
-pub const AKEYCODE_H: ::std::os::raw::c_uint = 36;
-pub const AKEYCODE_I: ::std::os::raw::c_uint = 37;
-pub const AKEYCODE_J: ::std::os::raw::c_uint = 38;
-pub const AKEYCODE_K: ::std::os::raw::c_uint = 39;
-pub const AKEYCODE_L: ::std::os::raw::c_uint = 40;
-pub const AKEYCODE_M: ::std::os::raw::c_uint = 41;
-pub const AKEYCODE_N: ::std::os::raw::c_uint = 42;
-pub const AKEYCODE_O: ::std::os::raw::c_uint = 43;
-pub const AKEYCODE_P: ::std::os::raw::c_uint = 44;
-pub const AKEYCODE_Q: ::std::os::raw::c_uint = 45;
-pub const AKEYCODE_R: ::std::os::raw::c_uint = 46;
-pub const AKEYCODE_S: ::std::os::raw::c_uint = 47;
-pub const AKEYCODE_T: ::std::os::raw::c_uint = 48;
-pub const AKEYCODE_U: ::std::os::raw::c_uint = 49;
-pub const AKEYCODE_V: ::std::os::raw::c_uint = 50;
-pub const AKEYCODE_W: ::std::os::raw::c_uint = 51;
-pub const AKEYCODE_X: ::std::os::raw::c_uint = 52;
-pub const AKEYCODE_Y: ::std::os::raw::c_uint = 53;
-pub const AKEYCODE_Z: ::std::os::raw::c_uint = 54;
-pub const AKEYCODE_COMMA: ::std::os::raw::c_uint = 55;
-pub const AKEYCODE_PERIOD: ::std::os::raw::c_uint = 56;
-pub const AKEYCODE_ALT_LEFT: ::std::os::raw::c_uint = 57;
-pub const AKEYCODE_ALT_RIGHT: ::std::os::raw::c_uint = 58;
-pub const AKEYCODE_SHIFT_LEFT: ::std::os::raw::c_uint = 59;
-pub const AKEYCODE_SHIFT_RIGHT: ::std::os::raw::c_uint = 60;
-pub const AKEYCODE_TAB: ::std::os::raw::c_uint = 61;
-pub const AKEYCODE_SPACE: ::std::os::raw::c_uint = 62;
-pub const AKEYCODE_SYM: ::std::os::raw::c_uint = 63;
-pub const AKEYCODE_EXPLORER: ::std::os::raw::c_uint = 64;
-pub const AKEYCODE_ENVELOPE: ::std::os::raw::c_uint = 65;
-pub const AKEYCODE_ENTER: ::std::os::raw::c_uint = 66;
-pub const AKEYCODE_DEL: ::std::os::raw::c_uint = 67;
-pub const AKEYCODE_GRAVE: ::std::os::raw::c_uint = 68;
-pub const AKEYCODE_MINUS: ::std::os::raw::c_uint = 69;
-pub const AKEYCODE_EQUALS: ::std::os::raw::c_uint = 70;
-pub const AKEYCODE_LEFT_BRACKET: ::std::os::raw::c_uint = 71;
-pub const AKEYCODE_RIGHT_BRACKET: ::std::os::raw::c_uint = 72;
-pub const AKEYCODE_BACKSLASH: ::std::os::raw::c_uint = 73;
-pub const AKEYCODE_SEMICOLON: ::std::os::raw::c_uint = 74;
-pub const AKEYCODE_APOSTROPHE: ::std::os::raw::c_uint = 75;
-pub const AKEYCODE_SLASH: ::std::os::raw::c_uint = 76;
-pub const AKEYCODE_AT: ::std::os::raw::c_uint = 77;
-pub const AKEYCODE_NUM: ::std::os::raw::c_uint = 78;
-pub const AKEYCODE_HEADSETHOOK: ::std::os::raw::c_uint = 79;
-pub const AKEYCODE_FOCUS: ::std::os::raw::c_uint = 80;
-pub const AKEYCODE_PLUS: ::std::os::raw::c_uint = 81;
-pub const AKEYCODE_MENU: ::std::os::raw::c_uint = 82;
-pub const AKEYCODE_NOTIFICATION: ::std::os::raw::c_uint = 83;
-pub const AKEYCODE_SEARCH: ::std::os::raw::c_uint = 84;
-pub const AKEYCODE_MEDIA_PLAY_PAUSE: ::std::os::raw::c_uint = 85;
-pub const AKEYCODE_MEDIA_STOP: ::std::os::raw::c_uint = 86;
-pub const AKEYCODE_MEDIA_NEXT: ::std::os::raw::c_uint = 87;
-pub const AKEYCODE_MEDIA_PREVIOUS: ::std::os::raw::c_uint = 88;
-pub const AKEYCODE_MEDIA_REWIND: ::std::os::raw::c_uint = 89;
-pub const AKEYCODE_MEDIA_FAST_FORWARD: ::std::os::raw::c_uint = 90;
-pub const AKEYCODE_MUTE: ::std::os::raw::c_uint = 91;
-pub const AKEYCODE_PAGE_UP: ::std::os::raw::c_uint = 92;
-pub const AKEYCODE_PAGE_DOWN: ::std::os::raw::c_uint = 93;
-pub const AKEYCODE_PICTSYMBOLS: ::std::os::raw::c_uint = 94;
-pub const AKEYCODE_SWITCH_CHARSET: ::std::os::raw::c_uint = 95;
-pub const AKEYCODE_BUTTON_A: ::std::os::raw::c_uint = 96;
-pub const AKEYCODE_BUTTON_B: ::std::os::raw::c_uint = 97;
-pub const AKEYCODE_BUTTON_C: ::std::os::raw::c_uint = 98;
-pub const AKEYCODE_BUTTON_X: ::std::os::raw::c_uint = 99;
-pub const AKEYCODE_BUTTON_Y: ::std::os::raw::c_uint = 100;
-pub const AKEYCODE_BUTTON_Z: ::std::os::raw::c_uint = 101;
-pub const AKEYCODE_BUTTON_L1: ::std::os::raw::c_uint = 102;
-pub const AKEYCODE_BUTTON_R1: ::std::os::raw::c_uint = 103;
-pub const AKEYCODE_BUTTON_L2: ::std::os::raw::c_uint = 104;
-pub const AKEYCODE_BUTTON_R2: ::std::os::raw::c_uint = 105;
-pub const AKEYCODE_BUTTON_THUMBL: ::std::os::raw::c_uint = 106;
-pub const AKEYCODE_BUTTON_THUMBR: ::std::os::raw::c_uint = 107;
-pub const AKEYCODE_BUTTON_START: ::std::os::raw::c_uint = 108;
-pub const AKEYCODE_BUTTON_SELECT: ::std::os::raw::c_uint = 109;
-pub const AKEYCODE_BUTTON_MODE: ::std::os::raw::c_uint = 110;
-pub const AKEYCODE_ESCAPE: ::std::os::raw::c_uint = 111;
-pub const AKEYCODE_FORWARD_DEL: ::std::os::raw::c_uint = 112;
-pub const AKEYCODE_CTRL_LEFT: ::std::os::raw::c_uint = 113;
-pub const AKEYCODE_CTRL_RIGHT: ::std::os::raw::c_uint = 114;
-pub const AKEYCODE_CAPS_LOCK: ::std::os::raw::c_uint = 115;
-pub const AKEYCODE_SCROLL_LOCK: ::std::os::raw::c_uint = 116;
-pub const AKEYCODE_META_LEFT: ::std::os::raw::c_uint = 117;
-pub const AKEYCODE_META_RIGHT: ::std::os::raw::c_uint = 118;
-pub const AKEYCODE_FUNCTION: ::std::os::raw::c_uint = 119;
-pub const AKEYCODE_SYSRQ: ::std::os::raw::c_uint = 120;
-pub const AKEYCODE_BREAK: ::std::os::raw::c_uint = 121;
-pub const AKEYCODE_MOVE_HOME: ::std::os::raw::c_uint = 122;
-pub const AKEYCODE_MOVE_END: ::std::os::raw::c_uint = 123;
-pub const AKEYCODE_INSERT: ::std::os::raw::c_uint = 124;
-pub const AKEYCODE_FORWARD: ::std::os::raw::c_uint = 125;
-pub const AKEYCODE_MEDIA_PLAY: ::std::os::raw::c_uint = 126;
-pub const AKEYCODE_MEDIA_PAUSE: ::std::os::raw::c_uint = 127;
-pub const AKEYCODE_MEDIA_CLOSE: ::std::os::raw::c_uint = 128;
-pub const AKEYCODE_MEDIA_EJECT: ::std::os::raw::c_uint = 129;
-pub const AKEYCODE_MEDIA_RECORD: ::std::os::raw::c_uint = 130;
-pub const AKEYCODE_F1: ::std::os::raw::c_uint = 131;
-pub const AKEYCODE_F2: ::std::os::raw::c_uint = 132;
-pub const AKEYCODE_F3: ::std::os::raw::c_uint = 133;
-pub const AKEYCODE_F4: ::std::os::raw::c_uint = 134;
-pub const AKEYCODE_F5: ::std::os::raw::c_uint = 135;
-pub const AKEYCODE_F6: ::std::os::raw::c_uint = 136;
-pub const AKEYCODE_F7: ::std::os::raw::c_uint = 137;
-pub const AKEYCODE_F8: ::std::os::raw::c_uint = 138;
-pub const AKEYCODE_F9: ::std::os::raw::c_uint = 139;
-pub const AKEYCODE_F10: ::std::os::raw::c_uint = 140;
-pub const AKEYCODE_F11: ::std::os::raw::c_uint = 141;
-pub const AKEYCODE_F12: ::std::os::raw::c_uint = 142;
-pub const AKEYCODE_NUM_LOCK: ::std::os::raw::c_uint = 143;
-pub const AKEYCODE_NUMPAD_0: ::std::os::raw::c_uint = 144;
-pub const AKEYCODE_NUMPAD_1: ::std::os::raw::c_uint = 145;
-pub const AKEYCODE_NUMPAD_2: ::std::os::raw::c_uint = 146;
-pub const AKEYCODE_NUMPAD_3: ::std::os::raw::c_uint = 147;
-pub const AKEYCODE_NUMPAD_4: ::std::os::raw::c_uint = 148;
-pub const AKEYCODE_NUMPAD_5: ::std::os::raw::c_uint = 149;
-pub const AKEYCODE_NUMPAD_6: ::std::os::raw::c_uint = 150;
-pub const AKEYCODE_NUMPAD_7: ::std::os::raw::c_uint = 151;
-pub const AKEYCODE_NUMPAD_8: ::std::os::raw::c_uint = 152;
-pub const AKEYCODE_NUMPAD_9: ::std::os::raw::c_uint = 153;
-pub const AKEYCODE_NUMPAD_DIVIDE: ::std::os::raw::c_uint = 154;
-pub const AKEYCODE_NUMPAD_MULTIPLY: ::std::os::raw::c_uint = 155;
-pub const AKEYCODE_NUMPAD_SUBTRACT: ::std::os::raw::c_uint = 156;
-pub const AKEYCODE_NUMPAD_ADD: ::std::os::raw::c_uint = 157;
-pub const AKEYCODE_NUMPAD_DOT: ::std::os::raw::c_uint = 158;
-pub const AKEYCODE_NUMPAD_COMMA: ::std::os::raw::c_uint = 159;
-pub const AKEYCODE_NUMPAD_ENTER: ::std::os::raw::c_uint = 160;
-pub const AKEYCODE_NUMPAD_EQUALS: ::std::os::raw::c_uint = 161;
-pub const AKEYCODE_NUMPAD_LEFT_PAREN: ::std::os::raw::c_uint = 162;
-pub const AKEYCODE_NUMPAD_RIGHT_PAREN: ::std::os::raw::c_uint = 163;
-pub const AKEYCODE_VOLUME_MUTE: ::std::os::raw::c_uint = 164;
-pub const AKEYCODE_INFO: ::std::os::raw::c_uint = 165;
-pub const AKEYCODE_CHANNEL_UP: ::std::os::raw::c_uint = 166;
-pub const AKEYCODE_CHANNEL_DOWN: ::std::os::raw::c_uint = 167;
-pub const AKEYCODE_ZOOM_IN: ::std::os::raw::c_uint = 168;
-pub const AKEYCODE_ZOOM_OUT: ::std::os::raw::c_uint = 169;
-pub const AKEYCODE_TV: ::std::os::raw::c_uint = 170;
-pub const AKEYCODE_WINDOW: ::std::os::raw::c_uint = 171;
-pub const AKEYCODE_GUIDE: ::std::os::raw::c_uint = 172;
-pub const AKEYCODE_DVR: ::std::os::raw::c_uint = 173;
-pub const AKEYCODE_BOOKMARK: ::std::os::raw::c_uint = 174;
-pub const AKEYCODE_CAPTIONS: ::std::os::raw::c_uint = 175;
-pub const AKEYCODE_SETTINGS: ::std::os::raw::c_uint = 176;
-pub const AKEYCODE_TV_POWER: ::std::os::raw::c_uint = 177;
-pub const AKEYCODE_TV_INPUT: ::std::os::raw::c_uint = 178;
-pub const AKEYCODE_STB_POWER: ::std::os::raw::c_uint = 179;
-pub const AKEYCODE_STB_INPUT: ::std::os::raw::c_uint = 180;
-pub const AKEYCODE_AVR_POWER: ::std::os::raw::c_uint = 181;
-pub const AKEYCODE_AVR_INPUT: ::std::os::raw::c_uint = 182;
-pub const AKEYCODE_PROG_RED: ::std::os::raw::c_uint = 183;
-pub const AKEYCODE_PROG_GREEN: ::std::os::raw::c_uint = 184;
-pub const AKEYCODE_PROG_YELLOW: ::std::os::raw::c_uint = 185;
-pub const AKEYCODE_PROG_BLUE: ::std::os::raw::c_uint = 186;
-pub const AKEYCODE_APP_SWITCH: ::std::os::raw::c_uint = 187;
-pub const AKEYCODE_BUTTON_1: ::std::os::raw::c_uint = 188;
-pub const AKEYCODE_BUTTON_2: ::std::os::raw::c_uint = 189;
-pub const AKEYCODE_BUTTON_3: ::std::os::raw::c_uint = 190;
-pub const AKEYCODE_BUTTON_4: ::std::os::raw::c_uint = 191;
-pub const AKEYCODE_BUTTON_5: ::std::os::raw::c_uint = 192;
-pub const AKEYCODE_BUTTON_6: ::std::os::raw::c_uint = 193;
-pub const AKEYCODE_BUTTON_7: ::std::os::raw::c_uint = 194;
-pub const AKEYCODE_BUTTON_8: ::std::os::raw::c_uint = 195;
-pub const AKEYCODE_BUTTON_9: ::std::os::raw::c_uint = 196;
-pub const AKEYCODE_BUTTON_10: ::std::os::raw::c_uint = 197;
-pub const AKEYCODE_BUTTON_11: ::std::os::raw::c_uint = 198;
-pub const AKEYCODE_BUTTON_12: ::std::os::raw::c_uint = 199;
-pub const AKEYCODE_BUTTON_13: ::std::os::raw::c_uint = 200;
-pub const AKEYCODE_BUTTON_14: ::std::os::raw::c_uint = 201;
-pub const AKEYCODE_BUTTON_15: ::std::os::raw::c_uint = 202;
-pub const AKEYCODE_BUTTON_16: ::std::os::raw::c_uint = 203;
-pub const AKEYCODE_LANGUAGE_SWITCH: ::std::os::raw::c_uint = 204;
-pub const AKEYCODE_MANNER_MODE: ::std::os::raw::c_uint = 205;
-pub const AKEYCODE_3D_MODE: ::std::os::raw::c_uint = 206;
-pub const AKEYCODE_CONTACTS: ::std::os::raw::c_uint = 207;
-pub const AKEYCODE_CALENDAR: ::std::os::raw::c_uint = 208;
-pub const AKEYCODE_MUSIC: ::std::os::raw::c_uint = 209;
-pub const AKEYCODE_CALCULATOR: ::std::os::raw::c_uint = 210;
-pub const AKEYCODE_ZENKAKU_HANKAKU: ::std::os::raw::c_uint = 211;
-pub const AKEYCODE_EISU: ::std::os::raw::c_uint = 212;
-pub const AKEYCODE_MUHENKAN: ::std::os::raw::c_uint = 213;
-pub const AKEYCODE_HENKAN: ::std::os::raw::c_uint = 214;
-pub const AKEYCODE_KATAKANA_HIRAGANA: ::std::os::raw::c_uint = 215;
-pub const AKEYCODE_YEN: ::std::os::raw::c_uint = 216;
-pub const AKEYCODE_RO: ::std::os::raw::c_uint = 217;
-pub const AKEYCODE_KANA: ::std::os::raw::c_uint = 218;
-pub const AKEYCODE_ASSIST: ::std::os::raw::c_uint = 219;
-pub const AKEYCODE_BRIGHTNESS_DOWN: ::std::os::raw::c_uint = 220;
-pub const AKEYCODE_BRIGHTNESS_UP: ::std::os::raw::c_uint = 221;
-pub const AKEYCODE_MEDIA_AUDIO_TRACK: ::std::os::raw::c_uint = 222;
-pub const AKEYCODE_SLEEP: ::std::os::raw::c_uint = 223;
-pub const AKEYCODE_WAKEUP: ::std::os::raw::c_uint = 224;
-pub const AKEYCODE_PAIRING: ::std::os::raw::c_uint = 225;
-pub const AKEYCODE_MEDIA_TOP_MENU: ::std::os::raw::c_uint = 226;
-pub const AKEYCODE_11: ::std::os::raw::c_uint = 227;
-pub const AKEYCODE_12: ::std::os::raw::c_uint = 228;
-pub const AKEYCODE_LAST_CHANNEL: ::std::os::raw::c_uint = 229;
-pub const AKEYCODE_TV_DATA_SERVICE: ::std::os::raw::c_uint = 230;
-pub const AKEYCODE_VOICE_ASSIST: ::std::os::raw::c_uint = 231;
-pub const AKEYCODE_TV_RADIO_SERVICE: ::std::os::raw::c_uint = 232;
-pub const AKEYCODE_TV_TELETEXT: ::std::os::raw::c_uint = 233;
-pub const AKEYCODE_TV_NUMBER_ENTRY: ::std::os::raw::c_uint = 234;
-pub const AKEYCODE_TV_TERRESTRIAL_ANALOG: ::std::os::raw::c_uint = 235;
-pub const AKEYCODE_TV_TERRESTRIAL_DIGITAL: ::std::os::raw::c_uint = 236;
-pub const AKEYCODE_TV_SATELLITE: ::std::os::raw::c_uint = 237;
-pub const AKEYCODE_TV_SATELLITE_BS: ::std::os::raw::c_uint = 238;
-pub const AKEYCODE_TV_SATELLITE_CS: ::std::os::raw::c_uint = 239;
-pub const AKEYCODE_TV_SATELLITE_SERVICE: ::std::os::raw::c_uint = 240;
-pub const AKEYCODE_TV_NETWORK: ::std::os::raw::c_uint = 241;
-pub const AKEYCODE_TV_ANTENNA_CABLE: ::std::os::raw::c_uint = 242;
-pub const AKEYCODE_TV_INPUT_HDMI_1: ::std::os::raw::c_uint = 243;
-pub const AKEYCODE_TV_INPUT_HDMI_2: ::std::os::raw::c_uint = 244;
-pub const AKEYCODE_TV_INPUT_HDMI_3: ::std::os::raw::c_uint = 245;
-pub const AKEYCODE_TV_INPUT_HDMI_4: ::std::os::raw::c_uint = 246;
-pub const AKEYCODE_TV_INPUT_COMPOSITE_1: ::std::os::raw::c_uint = 247;
-pub const AKEYCODE_TV_INPUT_COMPOSITE_2: ::std::os::raw::c_uint = 248;
-pub const AKEYCODE_TV_INPUT_COMPONENT_1: ::std::os::raw::c_uint = 249;
-pub const AKEYCODE_TV_INPUT_COMPONENT_2: ::std::os::raw::c_uint = 250;
-pub const AKEYCODE_TV_INPUT_VGA_1: ::std::os::raw::c_uint = 251;
-pub const AKEYCODE_TV_AUDIO_DESCRIPTION: ::std::os::raw::c_uint = 252;
-pub const AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP: ::std::os::raw::c_uint = 253;
-pub const AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN: ::std::os::raw::c_uint = 254;
-pub const AKEYCODE_TV_ZOOM_MODE: ::std::os::raw::c_uint = 255;
-pub const AKEYCODE_TV_CONTENTS_MENU: ::std::os::raw::c_uint = 256;
-pub const AKEYCODE_TV_MEDIA_CONTEXT_MENU: ::std::os::raw::c_uint = 257;
-pub const AKEYCODE_TV_TIMER_PROGRAMMING: ::std::os::raw::c_uint = 258;
-pub const AKEYCODE_HELP: ::std::os::raw::c_uint = 259;
-pub const AKEYCODE_NAVIGATE_PREVIOUS: ::std::os::raw::c_uint = 260;
-pub const AKEYCODE_NAVIGATE_NEXT: ::std::os::raw::c_uint = 261;
-pub const AKEYCODE_NAVIGATE_IN: ::std::os::raw::c_uint = 262;
-pub const AKEYCODE_NAVIGATE_OUT: ::std::os::raw::c_uint = 263;
-pub const AKEYCODE_STEM_PRIMARY: ::std::os::raw::c_uint = 264;
-pub const AKEYCODE_STEM_1: ::std::os::raw::c_uint = 265;
-pub const AKEYCODE_STEM_2: ::std::os::raw::c_uint = 266;
-pub const AKEYCODE_STEM_3: ::std::os::raw::c_uint = 267;
-pub const AKEYCODE_DPAD_UP_LEFT: ::std::os::raw::c_uint = 268;
-pub const AKEYCODE_DPAD_DOWN_LEFT: ::std::os::raw::c_uint = 269;
-pub const AKEYCODE_DPAD_UP_RIGHT: ::std::os::raw::c_uint = 270;
-pub const AKEYCODE_DPAD_DOWN_RIGHT: ::std::os::raw::c_uint = 271;
-pub const AKEYCODE_MEDIA_SKIP_FORWARD: ::std::os::raw::c_uint = 272;
-pub const AKEYCODE_MEDIA_SKIP_BACKWARD: ::std::os::raw::c_uint = 273;
-pub const AKEYCODE_MEDIA_STEP_FORWARD: ::std::os::raw::c_uint = 274;
-pub const AKEYCODE_MEDIA_STEP_BACKWARD: ::std::os::raw::c_uint = 275;
-pub const AKEYCODE_SOFT_SLEEP: ::std::os::raw::c_uint = 276;
-pub const AKEYCODE_CUT: ::std::os::raw::c_uint = 277;
-pub const AKEYCODE_COPY: ::std::os::raw::c_uint = 278;
-pub const AKEYCODE_PASTE: ::std::os::raw::c_uint = 279;
-pub const AKEYCODE_SYSTEM_NAVIGATION_UP: ::std::os::raw::c_uint = 280;
-pub const AKEYCODE_SYSTEM_NAVIGATION_DOWN: ::std::os::raw::c_uint = 281;
-pub const AKEYCODE_SYSTEM_NAVIGATION_LEFT: ::std::os::raw::c_uint = 282;
-pub const AKEYCODE_SYSTEM_NAVIGATION_RIGHT: ::std::os::raw::c_uint = 283;
-pub const AKEYCODE_ALL_APPS: ::std::os::raw::c_uint = 284;
-pub const AKEYCODE_REFRESH: ::std::os::raw::c_uint = 285;
-pub const AKEYCODE_THUMBS_UP: ::std::os::raw::c_uint = 286;
-pub const AKEYCODE_THUMBS_DOWN: ::std::os::raw::c_uint = 287;
-pub const AKEYCODE_PROFILE_SWITCH: ::std::os::raw::c_uint = 288;
+pub const AKEYCODE_UNKNOWN: _bindgen_ty_2 = 0;
+pub const AKEYCODE_SOFT_LEFT: _bindgen_ty_2 = 1;
+pub const AKEYCODE_SOFT_RIGHT: _bindgen_ty_2 = 2;
+pub const AKEYCODE_HOME: _bindgen_ty_2 = 3;
+pub const AKEYCODE_BACK: _bindgen_ty_2 = 4;
+pub const AKEYCODE_CALL: _bindgen_ty_2 = 5;
+pub const AKEYCODE_ENDCALL: _bindgen_ty_2 = 6;
+pub const AKEYCODE_0: _bindgen_ty_2 = 7;
+pub const AKEYCODE_1: _bindgen_ty_2 = 8;
+pub const AKEYCODE_2: _bindgen_ty_2 = 9;
+pub const AKEYCODE_3: _bindgen_ty_2 = 10;
+pub const AKEYCODE_4: _bindgen_ty_2 = 11;
+pub const AKEYCODE_5: _bindgen_ty_2 = 12;
+pub const AKEYCODE_6: _bindgen_ty_2 = 13;
+pub const AKEYCODE_7: _bindgen_ty_2 = 14;
+pub const AKEYCODE_8: _bindgen_ty_2 = 15;
+pub const AKEYCODE_9: _bindgen_ty_2 = 16;
+pub const AKEYCODE_STAR: _bindgen_ty_2 = 17;
+pub const AKEYCODE_POUND: _bindgen_ty_2 = 18;
+pub const AKEYCODE_DPAD_UP: _bindgen_ty_2 = 19;
+pub const AKEYCODE_DPAD_DOWN: _bindgen_ty_2 = 20;
+pub const AKEYCODE_DPAD_LEFT: _bindgen_ty_2 = 21;
+pub const AKEYCODE_DPAD_RIGHT: _bindgen_ty_2 = 22;
+pub const AKEYCODE_DPAD_CENTER: _bindgen_ty_2 = 23;
+pub const AKEYCODE_VOLUME_UP: _bindgen_ty_2 = 24;
+pub const AKEYCODE_VOLUME_DOWN: _bindgen_ty_2 = 25;
+pub const AKEYCODE_POWER: _bindgen_ty_2 = 26;
+pub const AKEYCODE_CAMERA: _bindgen_ty_2 = 27;
+pub const AKEYCODE_CLEAR: _bindgen_ty_2 = 28;
+pub const AKEYCODE_A: _bindgen_ty_2 = 29;
+pub const AKEYCODE_B: _bindgen_ty_2 = 30;
+pub const AKEYCODE_C: _bindgen_ty_2 = 31;
+pub const AKEYCODE_D: _bindgen_ty_2 = 32;
+pub const AKEYCODE_E: _bindgen_ty_2 = 33;
+pub const AKEYCODE_F: _bindgen_ty_2 = 34;
+pub const AKEYCODE_G: _bindgen_ty_2 = 35;
+pub const AKEYCODE_H: _bindgen_ty_2 = 36;
+pub const AKEYCODE_I: _bindgen_ty_2 = 37;
+pub const AKEYCODE_J: _bindgen_ty_2 = 38;
+pub const AKEYCODE_K: _bindgen_ty_2 = 39;
+pub const AKEYCODE_L: _bindgen_ty_2 = 40;
+pub const AKEYCODE_M: _bindgen_ty_2 = 41;
+pub const AKEYCODE_N: _bindgen_ty_2 = 42;
+pub const AKEYCODE_O: _bindgen_ty_2 = 43;
+pub const AKEYCODE_P: _bindgen_ty_2 = 44;
+pub const AKEYCODE_Q: _bindgen_ty_2 = 45;
+pub const AKEYCODE_R: _bindgen_ty_2 = 46;
+pub const AKEYCODE_S: _bindgen_ty_2 = 47;
+pub const AKEYCODE_T: _bindgen_ty_2 = 48;
+pub const AKEYCODE_U: _bindgen_ty_2 = 49;
+pub const AKEYCODE_V: _bindgen_ty_2 = 50;
+pub const AKEYCODE_W: _bindgen_ty_2 = 51;
+pub const AKEYCODE_X: _bindgen_ty_2 = 52;
+pub const AKEYCODE_Y: _bindgen_ty_2 = 53;
+pub const AKEYCODE_Z: _bindgen_ty_2 = 54;
+pub const AKEYCODE_COMMA: _bindgen_ty_2 = 55;
+pub const AKEYCODE_PERIOD: _bindgen_ty_2 = 56;
+pub const AKEYCODE_ALT_LEFT: _bindgen_ty_2 = 57;
+pub const AKEYCODE_ALT_RIGHT: _bindgen_ty_2 = 58;
+pub const AKEYCODE_SHIFT_LEFT: _bindgen_ty_2 = 59;
+pub const AKEYCODE_SHIFT_RIGHT: _bindgen_ty_2 = 60;
+pub const AKEYCODE_TAB: _bindgen_ty_2 = 61;
+pub const AKEYCODE_SPACE: _bindgen_ty_2 = 62;
+pub const AKEYCODE_SYM: _bindgen_ty_2 = 63;
+pub const AKEYCODE_EXPLORER: _bindgen_ty_2 = 64;
+pub const AKEYCODE_ENVELOPE: _bindgen_ty_2 = 65;
+pub const AKEYCODE_ENTER: _bindgen_ty_2 = 66;
+pub const AKEYCODE_DEL: _bindgen_ty_2 = 67;
+pub const AKEYCODE_GRAVE: _bindgen_ty_2 = 68;
+pub const AKEYCODE_MINUS: _bindgen_ty_2 = 69;
+pub const AKEYCODE_EQUALS: _bindgen_ty_2 = 70;
+pub const AKEYCODE_LEFT_BRACKET: _bindgen_ty_2 = 71;
+pub const AKEYCODE_RIGHT_BRACKET: _bindgen_ty_2 = 72;
+pub const AKEYCODE_BACKSLASH: _bindgen_ty_2 = 73;
+pub const AKEYCODE_SEMICOLON: _bindgen_ty_2 = 74;
+pub const AKEYCODE_APOSTROPHE: _bindgen_ty_2 = 75;
+pub const AKEYCODE_SLASH: _bindgen_ty_2 = 76;
+pub const AKEYCODE_AT: _bindgen_ty_2 = 77;
+pub const AKEYCODE_NUM: _bindgen_ty_2 = 78;
+pub const AKEYCODE_HEADSETHOOK: _bindgen_ty_2 = 79;
+pub const AKEYCODE_FOCUS: _bindgen_ty_2 = 80;
+pub const AKEYCODE_PLUS: _bindgen_ty_2 = 81;
+pub const AKEYCODE_MENU: _bindgen_ty_2 = 82;
+pub const AKEYCODE_NOTIFICATION: _bindgen_ty_2 = 83;
+pub const AKEYCODE_SEARCH: _bindgen_ty_2 = 84;
+pub const AKEYCODE_MEDIA_PLAY_PAUSE: _bindgen_ty_2 = 85;
+pub const AKEYCODE_MEDIA_STOP: _bindgen_ty_2 = 86;
+pub const AKEYCODE_MEDIA_NEXT: _bindgen_ty_2 = 87;
+pub const AKEYCODE_MEDIA_PREVIOUS: _bindgen_ty_2 = 88;
+pub const AKEYCODE_MEDIA_REWIND: _bindgen_ty_2 = 89;
+pub const AKEYCODE_MEDIA_FAST_FORWARD: _bindgen_ty_2 = 90;
+pub const AKEYCODE_MUTE: _bindgen_ty_2 = 91;
+pub const AKEYCODE_PAGE_UP: _bindgen_ty_2 = 92;
+pub const AKEYCODE_PAGE_DOWN: _bindgen_ty_2 = 93;
+pub const AKEYCODE_PICTSYMBOLS: _bindgen_ty_2 = 94;
+pub const AKEYCODE_SWITCH_CHARSET: _bindgen_ty_2 = 95;
+pub const AKEYCODE_BUTTON_A: _bindgen_ty_2 = 96;
+pub const AKEYCODE_BUTTON_B: _bindgen_ty_2 = 97;
+pub const AKEYCODE_BUTTON_C: _bindgen_ty_2 = 98;
+pub const AKEYCODE_BUTTON_X: _bindgen_ty_2 = 99;
+pub const AKEYCODE_BUTTON_Y: _bindgen_ty_2 = 100;
+pub const AKEYCODE_BUTTON_Z: _bindgen_ty_2 = 101;
+pub const AKEYCODE_BUTTON_L1: _bindgen_ty_2 = 102;
+pub const AKEYCODE_BUTTON_R1: _bindgen_ty_2 = 103;
+pub const AKEYCODE_BUTTON_L2: _bindgen_ty_2 = 104;
+pub const AKEYCODE_BUTTON_R2: _bindgen_ty_2 = 105;
+pub const AKEYCODE_BUTTON_THUMBL: _bindgen_ty_2 = 106;
+pub const AKEYCODE_BUTTON_THUMBR: _bindgen_ty_2 = 107;
+pub const AKEYCODE_BUTTON_START: _bindgen_ty_2 = 108;
+pub const AKEYCODE_BUTTON_SELECT: _bindgen_ty_2 = 109;
+pub const AKEYCODE_BUTTON_MODE: _bindgen_ty_2 = 110;
+pub const AKEYCODE_ESCAPE: _bindgen_ty_2 = 111;
+pub const AKEYCODE_FORWARD_DEL: _bindgen_ty_2 = 112;
+pub const AKEYCODE_CTRL_LEFT: _bindgen_ty_2 = 113;
+pub const AKEYCODE_CTRL_RIGHT: _bindgen_ty_2 = 114;
+pub const AKEYCODE_CAPS_LOCK: _bindgen_ty_2 = 115;
+pub const AKEYCODE_SCROLL_LOCK: _bindgen_ty_2 = 116;
+pub const AKEYCODE_META_LEFT: _bindgen_ty_2 = 117;
+pub const AKEYCODE_META_RIGHT: _bindgen_ty_2 = 118;
+pub const AKEYCODE_FUNCTION: _bindgen_ty_2 = 119;
+pub const AKEYCODE_SYSRQ: _bindgen_ty_2 = 120;
+pub const AKEYCODE_BREAK: _bindgen_ty_2 = 121;
+pub const AKEYCODE_MOVE_HOME: _bindgen_ty_2 = 122;
+pub const AKEYCODE_MOVE_END: _bindgen_ty_2 = 123;
+pub const AKEYCODE_INSERT: _bindgen_ty_2 = 124;
+pub const AKEYCODE_FORWARD: _bindgen_ty_2 = 125;
+pub const AKEYCODE_MEDIA_PLAY: _bindgen_ty_2 = 126;
+pub const AKEYCODE_MEDIA_PAUSE: _bindgen_ty_2 = 127;
+pub const AKEYCODE_MEDIA_CLOSE: _bindgen_ty_2 = 128;
+pub const AKEYCODE_MEDIA_EJECT: _bindgen_ty_2 = 129;
+pub const AKEYCODE_MEDIA_RECORD: _bindgen_ty_2 = 130;
+pub const AKEYCODE_F1: _bindgen_ty_2 = 131;
+pub const AKEYCODE_F2: _bindgen_ty_2 = 132;
+pub const AKEYCODE_F3: _bindgen_ty_2 = 133;
+pub const AKEYCODE_F4: _bindgen_ty_2 = 134;
+pub const AKEYCODE_F5: _bindgen_ty_2 = 135;
+pub const AKEYCODE_F6: _bindgen_ty_2 = 136;
+pub const AKEYCODE_F7: _bindgen_ty_2 = 137;
+pub const AKEYCODE_F8: _bindgen_ty_2 = 138;
+pub const AKEYCODE_F9: _bindgen_ty_2 = 139;
+pub const AKEYCODE_F10: _bindgen_ty_2 = 140;
+pub const AKEYCODE_F11: _bindgen_ty_2 = 141;
+pub const AKEYCODE_F12: _bindgen_ty_2 = 142;
+pub const AKEYCODE_NUM_LOCK: _bindgen_ty_2 = 143;
+pub const AKEYCODE_NUMPAD_0: _bindgen_ty_2 = 144;
+pub const AKEYCODE_NUMPAD_1: _bindgen_ty_2 = 145;
+pub const AKEYCODE_NUMPAD_2: _bindgen_ty_2 = 146;
+pub const AKEYCODE_NUMPAD_3: _bindgen_ty_2 = 147;
+pub const AKEYCODE_NUMPAD_4: _bindgen_ty_2 = 148;
+pub const AKEYCODE_NUMPAD_5: _bindgen_ty_2 = 149;
+pub const AKEYCODE_NUMPAD_6: _bindgen_ty_2 = 150;
+pub const AKEYCODE_NUMPAD_7: _bindgen_ty_2 = 151;
+pub const AKEYCODE_NUMPAD_8: _bindgen_ty_2 = 152;
+pub const AKEYCODE_NUMPAD_9: _bindgen_ty_2 = 153;
+pub const AKEYCODE_NUMPAD_DIVIDE: _bindgen_ty_2 = 154;
+pub const AKEYCODE_NUMPAD_MULTIPLY: _bindgen_ty_2 = 155;
+pub const AKEYCODE_NUMPAD_SUBTRACT: _bindgen_ty_2 = 156;
+pub const AKEYCODE_NUMPAD_ADD: _bindgen_ty_2 = 157;
+pub const AKEYCODE_NUMPAD_DOT: _bindgen_ty_2 = 158;
+pub const AKEYCODE_NUMPAD_COMMA: _bindgen_ty_2 = 159;
+pub const AKEYCODE_NUMPAD_ENTER: _bindgen_ty_2 = 160;
+pub const AKEYCODE_NUMPAD_EQUALS: _bindgen_ty_2 = 161;
+pub const AKEYCODE_NUMPAD_LEFT_PAREN: _bindgen_ty_2 = 162;
+pub const AKEYCODE_NUMPAD_RIGHT_PAREN: _bindgen_ty_2 = 163;
+pub const AKEYCODE_VOLUME_MUTE: _bindgen_ty_2 = 164;
+pub const AKEYCODE_INFO: _bindgen_ty_2 = 165;
+pub const AKEYCODE_CHANNEL_UP: _bindgen_ty_2 = 166;
+pub const AKEYCODE_CHANNEL_DOWN: _bindgen_ty_2 = 167;
+pub const AKEYCODE_ZOOM_IN: _bindgen_ty_2 = 168;
+pub const AKEYCODE_ZOOM_OUT: _bindgen_ty_2 = 169;
+pub const AKEYCODE_TV: _bindgen_ty_2 = 170;
+pub const AKEYCODE_WINDOW: _bindgen_ty_2 = 171;
+pub const AKEYCODE_GUIDE: _bindgen_ty_2 = 172;
+pub const AKEYCODE_DVR: _bindgen_ty_2 = 173;
+pub const AKEYCODE_BOOKMARK: _bindgen_ty_2 = 174;
+pub const AKEYCODE_CAPTIONS: _bindgen_ty_2 = 175;
+pub const AKEYCODE_SETTINGS: _bindgen_ty_2 = 176;
+pub const AKEYCODE_TV_POWER: _bindgen_ty_2 = 177;
+pub const AKEYCODE_TV_INPUT: _bindgen_ty_2 = 178;
+pub const AKEYCODE_STB_POWER: _bindgen_ty_2 = 179;
+pub const AKEYCODE_STB_INPUT: _bindgen_ty_2 = 180;
+pub const AKEYCODE_AVR_POWER: _bindgen_ty_2 = 181;
+pub const AKEYCODE_AVR_INPUT: _bindgen_ty_2 = 182;
+pub const AKEYCODE_PROG_RED: _bindgen_ty_2 = 183;
+pub const AKEYCODE_PROG_GREEN: _bindgen_ty_2 = 184;
+pub const AKEYCODE_PROG_YELLOW: _bindgen_ty_2 = 185;
+pub const AKEYCODE_PROG_BLUE: _bindgen_ty_2 = 186;
+pub const AKEYCODE_APP_SWITCH: _bindgen_ty_2 = 187;
+pub const AKEYCODE_BUTTON_1: _bindgen_ty_2 = 188;
+pub const AKEYCODE_BUTTON_2: _bindgen_ty_2 = 189;
+pub const AKEYCODE_BUTTON_3: _bindgen_ty_2 = 190;
+pub const AKEYCODE_BUTTON_4: _bindgen_ty_2 = 191;
+pub const AKEYCODE_BUTTON_5: _bindgen_ty_2 = 192;
+pub const AKEYCODE_BUTTON_6: _bindgen_ty_2 = 193;
+pub const AKEYCODE_BUTTON_7: _bindgen_ty_2 = 194;
+pub const AKEYCODE_BUTTON_8: _bindgen_ty_2 = 195;
+pub const AKEYCODE_BUTTON_9: _bindgen_ty_2 = 196;
+pub const AKEYCODE_BUTTON_10: _bindgen_ty_2 = 197;
+pub const AKEYCODE_BUTTON_11: _bindgen_ty_2 = 198;
+pub const AKEYCODE_BUTTON_12: _bindgen_ty_2 = 199;
+pub const AKEYCODE_BUTTON_13: _bindgen_ty_2 = 200;
+pub const AKEYCODE_BUTTON_14: _bindgen_ty_2 = 201;
+pub const AKEYCODE_BUTTON_15: _bindgen_ty_2 = 202;
+pub const AKEYCODE_BUTTON_16: _bindgen_ty_2 = 203;
+pub const AKEYCODE_LANGUAGE_SWITCH: _bindgen_ty_2 = 204;
+pub const AKEYCODE_MANNER_MODE: _bindgen_ty_2 = 205;
+pub const AKEYCODE_3D_MODE: _bindgen_ty_2 = 206;
+pub const AKEYCODE_CONTACTS: _bindgen_ty_2 = 207;
+pub const AKEYCODE_CALENDAR: _bindgen_ty_2 = 208;
+pub const AKEYCODE_MUSIC: _bindgen_ty_2 = 209;
+pub const AKEYCODE_CALCULATOR: _bindgen_ty_2 = 210;
+pub const AKEYCODE_ZENKAKU_HANKAKU: _bindgen_ty_2 = 211;
+pub const AKEYCODE_EISU: _bindgen_ty_2 = 212;
+pub const AKEYCODE_MUHENKAN: _bindgen_ty_2 = 213;
+pub const AKEYCODE_HENKAN: _bindgen_ty_2 = 214;
+pub const AKEYCODE_KATAKANA_HIRAGANA: _bindgen_ty_2 = 215;
+pub const AKEYCODE_YEN: _bindgen_ty_2 = 216;
+pub const AKEYCODE_RO: _bindgen_ty_2 = 217;
+pub const AKEYCODE_KANA: _bindgen_ty_2 = 218;
+pub const AKEYCODE_ASSIST: _bindgen_ty_2 = 219;
+pub const AKEYCODE_BRIGHTNESS_DOWN: _bindgen_ty_2 = 220;
+pub const AKEYCODE_BRIGHTNESS_UP: _bindgen_ty_2 = 221;
+pub const AKEYCODE_MEDIA_AUDIO_TRACK: _bindgen_ty_2 = 222;
+pub const AKEYCODE_SLEEP: _bindgen_ty_2 = 223;
+pub const AKEYCODE_WAKEUP: _bindgen_ty_2 = 224;
+pub const AKEYCODE_PAIRING: _bindgen_ty_2 = 225;
+pub const AKEYCODE_MEDIA_TOP_MENU: _bindgen_ty_2 = 226;
+pub const AKEYCODE_11: _bindgen_ty_2 = 227;
+pub const AKEYCODE_12: _bindgen_ty_2 = 228;
+pub const AKEYCODE_LAST_CHANNEL: _bindgen_ty_2 = 229;
+pub const AKEYCODE_TV_DATA_SERVICE: _bindgen_ty_2 = 230;
+pub const AKEYCODE_VOICE_ASSIST: _bindgen_ty_2 = 231;
+pub const AKEYCODE_TV_RADIO_SERVICE: _bindgen_ty_2 = 232;
+pub const AKEYCODE_TV_TELETEXT: _bindgen_ty_2 = 233;
+pub const AKEYCODE_TV_NUMBER_ENTRY: _bindgen_ty_2 = 234;
+pub const AKEYCODE_TV_TERRESTRIAL_ANALOG: _bindgen_ty_2 = 235;
+pub const AKEYCODE_TV_TERRESTRIAL_DIGITAL: _bindgen_ty_2 = 236;
+pub const AKEYCODE_TV_SATELLITE: _bindgen_ty_2 = 237;
+pub const AKEYCODE_TV_SATELLITE_BS: _bindgen_ty_2 = 238;
+pub const AKEYCODE_TV_SATELLITE_CS: _bindgen_ty_2 = 239;
+pub const AKEYCODE_TV_SATELLITE_SERVICE: _bindgen_ty_2 = 240;
+pub const AKEYCODE_TV_NETWORK: _bindgen_ty_2 = 241;
+pub const AKEYCODE_TV_ANTENNA_CABLE: _bindgen_ty_2 = 242;
+pub const AKEYCODE_TV_INPUT_HDMI_1: _bindgen_ty_2 = 243;
+pub const AKEYCODE_TV_INPUT_HDMI_2: _bindgen_ty_2 = 244;
+pub const AKEYCODE_TV_INPUT_HDMI_3: _bindgen_ty_2 = 245;
+pub const AKEYCODE_TV_INPUT_HDMI_4: _bindgen_ty_2 = 246;
+pub const AKEYCODE_TV_INPUT_COMPOSITE_1: _bindgen_ty_2 = 247;
+pub const AKEYCODE_TV_INPUT_COMPOSITE_2: _bindgen_ty_2 = 248;
+pub const AKEYCODE_TV_INPUT_COMPONENT_1: _bindgen_ty_2 = 249;
+pub const AKEYCODE_TV_INPUT_COMPONENT_2: _bindgen_ty_2 = 250;
+pub const AKEYCODE_TV_INPUT_VGA_1: _bindgen_ty_2 = 251;
+pub const AKEYCODE_TV_AUDIO_DESCRIPTION: _bindgen_ty_2 = 252;
+pub const AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP: _bindgen_ty_2 = 253;
+pub const AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN: _bindgen_ty_2 = 254;
+pub const AKEYCODE_TV_ZOOM_MODE: _bindgen_ty_2 = 255;
+pub const AKEYCODE_TV_CONTENTS_MENU: _bindgen_ty_2 = 256;
+pub const AKEYCODE_TV_MEDIA_CONTEXT_MENU: _bindgen_ty_2 = 257;
+pub const AKEYCODE_TV_TIMER_PROGRAMMING: _bindgen_ty_2 = 258;
+pub const AKEYCODE_HELP: _bindgen_ty_2 = 259;
+pub const AKEYCODE_NAVIGATE_PREVIOUS: _bindgen_ty_2 = 260;
+pub const AKEYCODE_NAVIGATE_NEXT: _bindgen_ty_2 = 261;
+pub const AKEYCODE_NAVIGATE_IN: _bindgen_ty_2 = 262;
+pub const AKEYCODE_NAVIGATE_OUT: _bindgen_ty_2 = 263;
+pub const AKEYCODE_STEM_PRIMARY: _bindgen_ty_2 = 264;
+pub const AKEYCODE_STEM_1: _bindgen_ty_2 = 265;
+pub const AKEYCODE_STEM_2: _bindgen_ty_2 = 266;
+pub const AKEYCODE_STEM_3: _bindgen_ty_2 = 267;
+pub const AKEYCODE_DPAD_UP_LEFT: _bindgen_ty_2 = 268;
+pub const AKEYCODE_DPAD_DOWN_LEFT: _bindgen_ty_2 = 269;
+pub const AKEYCODE_DPAD_UP_RIGHT: _bindgen_ty_2 = 270;
+pub const AKEYCODE_DPAD_DOWN_RIGHT: _bindgen_ty_2 = 271;
+pub const AKEYCODE_MEDIA_SKIP_FORWARD: _bindgen_ty_2 = 272;
+pub const AKEYCODE_MEDIA_SKIP_BACKWARD: _bindgen_ty_2 = 273;
+pub const AKEYCODE_MEDIA_STEP_FORWARD: _bindgen_ty_2 = 274;
+pub const AKEYCODE_MEDIA_STEP_BACKWARD: _bindgen_ty_2 = 275;
+pub const AKEYCODE_SOFT_SLEEP: _bindgen_ty_2 = 276;
+pub const AKEYCODE_CUT: _bindgen_ty_2 = 277;
+pub const AKEYCODE_COPY: _bindgen_ty_2 = 278;
+pub const AKEYCODE_PASTE: _bindgen_ty_2 = 279;
+pub const AKEYCODE_SYSTEM_NAVIGATION_UP: _bindgen_ty_2 = 280;
+pub const AKEYCODE_SYSTEM_NAVIGATION_DOWN: _bindgen_ty_2 = 281;
+pub const AKEYCODE_SYSTEM_NAVIGATION_LEFT: _bindgen_ty_2 = 282;
+pub const AKEYCODE_SYSTEM_NAVIGATION_RIGHT: _bindgen_ty_2 = 283;
+pub const AKEYCODE_ALL_APPS: _bindgen_ty_2 = 284;
+pub const AKEYCODE_REFRESH: _bindgen_ty_2 = 285;
+pub const AKEYCODE_THUMBS_UP: _bindgen_ty_2 = 286;
+pub const AKEYCODE_THUMBS_DOWN: _bindgen_ty_2 = 287;
+pub const AKEYCODE_PROFILE_SWITCH: _bindgen_ty_2 = 288;
+pub const AKEYCODE_VIDEO_APP_1: _bindgen_ty_2 = 289;
+pub const AKEYCODE_VIDEO_APP_2: _bindgen_ty_2 = 290;
+pub const AKEYCODE_VIDEO_APP_3: _bindgen_ty_2 = 291;
+pub const AKEYCODE_VIDEO_APP_4: _bindgen_ty_2 = 292;
+pub const AKEYCODE_VIDEO_APP_5: _bindgen_ty_2 = 293;
+pub const AKEYCODE_VIDEO_APP_6: _bindgen_ty_2 = 294;
+pub const AKEYCODE_VIDEO_APP_7: _bindgen_ty_2 = 295;
+pub const AKEYCODE_VIDEO_APP_8: _bindgen_ty_2 = 296;
+pub const AKEYCODE_FEATURED_APP_1: _bindgen_ty_2 = 297;
+pub const AKEYCODE_FEATURED_APP_2: _bindgen_ty_2 = 298;
+pub const AKEYCODE_FEATURED_APP_3: _bindgen_ty_2 = 299;
+pub const AKEYCODE_FEATURED_APP_4: _bindgen_ty_2 = 300;
+pub const AKEYCODE_DEMO_APP_1: _bindgen_ty_2 = 301;
+pub const AKEYCODE_DEMO_APP_2: _bindgen_ty_2 = 302;
+pub const AKEYCODE_DEMO_APP_3: _bindgen_ty_2 = 303;
+pub const AKEYCODE_DEMO_APP_4: _bindgen_ty_2 = 304;
pub type _bindgen_ty_2 = ::std::os::raw::c_uint;
-pub const ALOOPER_PREPARE_ALLOW_NON_CALLBACKS: ::std::os::raw::c_uint = 1;
+pub const ALOOPER_PREPARE_ALLOW_NON_CALLBACKS: _bindgen_ty_3 = 1;
pub type _bindgen_ty_3 = ::std::os::raw::c_uint;
-pub const ALOOPER_POLL_WAKE: ::std::os::raw::c_int = -1;
-pub const ALOOPER_POLL_CALLBACK: ::std::os::raw::c_int = -2;
-pub const ALOOPER_POLL_TIMEOUT: ::std::os::raw::c_int = -3;
-pub const ALOOPER_POLL_ERROR: ::std::os::raw::c_int = -4;
+pub const ALOOPER_POLL_WAKE: _bindgen_ty_4 = -1;
+pub const ALOOPER_POLL_CALLBACK: _bindgen_ty_4 = -2;
+pub const ALOOPER_POLL_TIMEOUT: _bindgen_ty_4 = -3;
+pub const ALOOPER_POLL_ERROR: _bindgen_ty_4 = -4;
pub type _bindgen_ty_4 = ::std::os::raw::c_int;
-pub const ALOOPER_EVENT_INPUT: ::std::os::raw::c_uint = 1;
-pub const ALOOPER_EVENT_OUTPUT: ::std::os::raw::c_uint = 2;
-pub const ALOOPER_EVENT_ERROR: ::std::os::raw::c_uint = 4;
-pub const ALOOPER_EVENT_HANGUP: ::std::os::raw::c_uint = 8;
-pub const ALOOPER_EVENT_INVALID: ::std::os::raw::c_uint = 16;
+pub const ALOOPER_EVENT_INPUT: _bindgen_ty_5 = 1;
+pub const ALOOPER_EVENT_OUTPUT: _bindgen_ty_5 = 2;
+pub const ALOOPER_EVENT_ERROR: _bindgen_ty_5 = 4;
+pub const ALOOPER_EVENT_HANGUP: _bindgen_ty_5 = 8;
+pub const ALOOPER_EVENT_INVALID: _bindgen_ty_5 = 16;
pub type _bindgen_ty_5 = ::std::os::raw::c_uint;
-pub const AKEY_STATE_UNKNOWN: ::std::os::raw::c_int = -1;
-pub const AKEY_STATE_UP: ::std::os::raw::c_int = 0;
-pub const AKEY_STATE_DOWN: ::std::os::raw::c_int = 1;
-pub const AKEY_STATE_VIRTUAL: ::std::os::raw::c_int = 2;
+pub type __gnuc_va_list = __BindgenOpaqueArray;
+pub type va_list = __BindgenOpaqueArray;
+#[repr(C)]
+pub struct JavaVMAttachArgs {
+ pub version: jint,
+ pub name: *const ::std::os::raw::c_char,
+ pub group: jobject,
+}
+#[test]
+fn bindgen_test_layout_JavaVMAttachArgs() {
+ const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit();
+ let ptr = UNINIT.as_ptr();
+ assert_eq!(
+ ::std::mem::size_of::(),
+ 24usize,
+ "Size of JavaVMAttachArgs"
+ );
+ assert_eq!(
+ ::std::mem::align_of::(),
+ 8usize,
+ "Alignment of JavaVMAttachArgs"
+ );
+ assert_eq!(
+ unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize },
+ 0usize,
+ "Offset of field: JavaVMAttachArgs::version"
+ );
+ assert_eq!(
+ unsafe { ::std::ptr::addr_of!((*ptr).name) as usize - ptr as usize },
+ 8usize,
+ "Offset of field: JavaVMAttachArgs::name"
+ );
+ assert_eq!(
+ unsafe { ::std::ptr::addr_of!((*ptr).group) as usize - ptr as usize },
+ 16usize,
+ "Offset of field: JavaVMAttachArgs::group"
+ );
+}
+#[repr(C)]
+#[derive(Debug, Copy, Clone)]
+pub struct JavaVMOption {
+ pub optionString: *const ::std::os::raw::c_char,
+ pub extraInfo: *mut ::std::os::raw::c_void,
+}
+#[test]
+fn bindgen_test_layout_JavaVMOption() {
+ const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit();
+ let ptr = UNINIT.as_ptr();
+ assert_eq!(
+ ::std::mem::size_of::(),
+ 16usize,
+ "Size of JavaVMOption"
+ );
+ assert_eq!(
+ ::std::mem::align_of::(),
+ 8usize,
+ "Alignment of JavaVMOption"
+ );
+ assert_eq!(
+ unsafe { ::std::ptr::addr_of!((*ptr).optionString) as usize - ptr as usize },
+ 0usize,
+ "Offset of field: JavaVMOption::optionString"
+ );
+ assert_eq!(
+ unsafe { ::std::ptr::addr_of!((*ptr).extraInfo) as usize - ptr as usize },
+ 8usize,
+ "Offset of field: JavaVMOption::extraInfo"
+ );
+}
+#[repr(C)]
+pub struct JavaVMInitArgs {
+ pub version: jint,
+ pub nOptions: jint,
+ pub options: *mut JavaVMOption,
+ pub ignoreUnrecognized: jboolean,
+}
+#[test]
+fn bindgen_test_layout_JavaVMInitArgs() {
+ const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit();
+ let ptr = UNINIT.as_ptr();
+ assert_eq!(
+ ::std::mem::size_of::(),
+ 24usize,
+ "Size of JavaVMInitArgs"
+ );
+ assert_eq!(
+ ::std::mem::align_of::(),
+ 8usize,
+ "Alignment of JavaVMInitArgs"
+ );
+ assert_eq!(
+ unsafe { ::std::ptr::addr_of!((*ptr).version) as usize - ptr as usize },
+ 0usize,
+ "Offset of field: JavaVMInitArgs::version"
+ );
+ assert_eq!(
+ unsafe { ::std::ptr::addr_of!((*ptr).nOptions) as usize - ptr as usize },
+ 4usize,
+ "Offset of field: JavaVMInitArgs::nOptions"
+ );
+ assert_eq!(
+ unsafe { ::std::ptr::addr_of!((*ptr).options) as usize - ptr as usize },
+ 8usize,
+ "Offset of field: JavaVMInitArgs::options"
+ );
+ assert_eq!(
+ unsafe { ::std::ptr::addr_of!((*ptr).ignoreUnrecognized) as usize - ptr as usize },
+ 16usize,
+ "Offset of field: JavaVMInitArgs::ignoreUnrecognized"
+ );
+}
+pub const AKEY_STATE_UNKNOWN: _bindgen_ty_6 = -1;
+pub const AKEY_STATE_UP: _bindgen_ty_6 = 0;
+pub const AKEY_STATE_DOWN: _bindgen_ty_6 = 1;
+pub const AKEY_STATE_VIRTUAL: _bindgen_ty_6 = 2;
pub type _bindgen_ty_6 = ::std::os::raw::c_int;
-pub const AMETA_NONE: ::std::os::raw::c_uint = 0;
-pub const AMETA_ALT_ON: ::std::os::raw::c_uint = 2;
-pub const AMETA_ALT_LEFT_ON: ::std::os::raw::c_uint = 16;
-pub const AMETA_ALT_RIGHT_ON: ::std::os::raw::c_uint = 32;
-pub const AMETA_SHIFT_ON: ::std::os::raw::c_uint = 1;
-pub const AMETA_SHIFT_LEFT_ON: ::std::os::raw::c_uint = 64;
-pub const AMETA_SHIFT_RIGHT_ON: ::std::os::raw::c_uint = 128;
-pub const AMETA_SYM_ON: ::std::os::raw::c_uint = 4;
-pub const AMETA_FUNCTION_ON: ::std::os::raw::c_uint = 8;
-pub const AMETA_CTRL_ON: ::std::os::raw::c_uint = 4096;
-pub const AMETA_CTRL_LEFT_ON: ::std::os::raw::c_uint = 8192;
-pub const AMETA_CTRL_RIGHT_ON: ::std::os::raw::c_uint = 16384;
-pub const AMETA_META_ON: ::std::os::raw::c_uint = 65536;
-pub const AMETA_META_LEFT_ON: ::std::os::raw::c_uint = 131072;
-pub const AMETA_META_RIGHT_ON: ::std::os::raw::c_uint = 262144;
-pub const AMETA_CAPS_LOCK_ON: ::std::os::raw::c_uint = 1048576;
-pub const AMETA_NUM_LOCK_ON: ::std::os::raw::c_uint = 2097152;
-pub const AMETA_SCROLL_LOCK_ON: ::std::os::raw::c_uint = 4194304;
+pub const AMETA_NONE: _bindgen_ty_7 = 0;
+pub const AMETA_ALT_ON: _bindgen_ty_7 = 2;
+pub const AMETA_ALT_LEFT_ON: _bindgen_ty_7 = 16;
+pub const AMETA_ALT_RIGHT_ON: _bindgen_ty_7 = 32;
+pub const AMETA_SHIFT_ON: _bindgen_ty_7 = 1;
+pub const AMETA_SHIFT_LEFT_ON: _bindgen_ty_7 = 64;
+pub const AMETA_SHIFT_RIGHT_ON: _bindgen_ty_7 = 128;
+pub const AMETA_SYM_ON: _bindgen_ty_7 = 4;
+pub const AMETA_FUNCTION_ON: _bindgen_ty_7 = 8;
+pub const AMETA_CTRL_ON: _bindgen_ty_7 = 4096;
+pub const AMETA_CTRL_LEFT_ON: _bindgen_ty_7 = 8192;
+pub const AMETA_CTRL_RIGHT_ON: _bindgen_ty_7 = 16384;
+pub const AMETA_META_ON: _bindgen_ty_7 = 65536;
+pub const AMETA_META_LEFT_ON: _bindgen_ty_7 = 131072;
+pub const AMETA_META_RIGHT_ON: _bindgen_ty_7 = 262144;
+pub const AMETA_CAPS_LOCK_ON: _bindgen_ty_7 = 1048576;
+pub const AMETA_NUM_LOCK_ON: _bindgen_ty_7 = 2097152;
+pub const AMETA_SCROLL_LOCK_ON: _bindgen_ty_7 = 4194304;
pub type _bindgen_ty_7 = ::std::os::raw::c_uint;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct AInputEvent {
_unused: [u8; 0],
}
-pub const AINPUT_EVENT_TYPE_KEY: ::std::os::raw::c_uint = 1;
-pub const AINPUT_EVENT_TYPE_MOTION: ::std::os::raw::c_uint = 2;
+pub const AINPUT_EVENT_TYPE_KEY: _bindgen_ty_8 = 1;
+pub const AINPUT_EVENT_TYPE_MOTION: _bindgen_ty_8 = 2;
+pub const AINPUT_EVENT_TYPE_FOCUS: _bindgen_ty_8 = 3;
+pub const AINPUT_EVENT_TYPE_CAPTURE: _bindgen_ty_8 = 4;
+pub const AINPUT_EVENT_TYPE_DRAG: _bindgen_ty_8 = 5;
+pub const AINPUT_EVENT_TYPE_TOUCH_MODE: _bindgen_ty_8 = 6;
pub type _bindgen_ty_8 = ::std::os::raw::c_uint;
-pub const AKEY_EVENT_ACTION_DOWN: ::std::os::raw::c_uint = 0;
-pub const AKEY_EVENT_ACTION_UP: ::std::os::raw::c_uint = 1;
-pub const AKEY_EVENT_ACTION_MULTIPLE: ::std::os::raw::c_uint = 2;
+pub const AKEY_EVENT_ACTION_DOWN: _bindgen_ty_9 = 0;
+pub const AKEY_EVENT_ACTION_UP: _bindgen_ty_9 = 1;
+pub const AKEY_EVENT_ACTION_MULTIPLE: _bindgen_ty_9 = 2;
pub type _bindgen_ty_9 = ::std::os::raw::c_uint;
-pub const AKEY_EVENT_FLAG_WOKE_HERE: ::std::os::raw::c_uint = 1;
-pub const AKEY_EVENT_FLAG_SOFT_KEYBOARD: ::std::os::raw::c_uint = 2;
-pub const AKEY_EVENT_FLAG_KEEP_TOUCH_MODE: ::std::os::raw::c_uint = 4;
-pub const AKEY_EVENT_FLAG_FROM_SYSTEM: ::std::os::raw::c_uint = 8;
-pub const AKEY_EVENT_FLAG_EDITOR_ACTION: ::std::os::raw::c_uint = 16;
-pub const AKEY_EVENT_FLAG_CANCELED: ::std::os::raw::c_uint = 32;
-pub const AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY: ::std::os::raw::c_uint = 64;
-pub const AKEY_EVENT_FLAG_LONG_PRESS: ::std::os::raw::c_uint = 128;
-pub const AKEY_EVENT_FLAG_CANCELED_LONG_PRESS: ::std::os::raw::c_uint = 256;
-pub const AKEY_EVENT_FLAG_TRACKING: ::std::os::raw::c_uint = 512;
-pub const AKEY_EVENT_FLAG_FALLBACK: ::std::os::raw::c_uint = 1024;
+pub const AKEY_EVENT_FLAG_WOKE_HERE: _bindgen_ty_10 = 1;
+pub const AKEY_EVENT_FLAG_SOFT_KEYBOARD: _bindgen_ty_10 = 2;
+pub const AKEY_EVENT_FLAG_KEEP_TOUCH_MODE: _bindgen_ty_10 = 4;
+pub const AKEY_EVENT_FLAG_FROM_SYSTEM: _bindgen_ty_10 = 8;
+pub const AKEY_EVENT_FLAG_EDITOR_ACTION: _bindgen_ty_10 = 16;
+pub const AKEY_EVENT_FLAG_CANCELED: _bindgen_ty_10 = 32;
+pub const AKEY_EVENT_FLAG_VIRTUAL_HARD_KEY: _bindgen_ty_10 = 64;
+pub const AKEY_EVENT_FLAG_LONG_PRESS: _bindgen_ty_10 = 128;
+pub const AKEY_EVENT_FLAG_CANCELED_LONG_PRESS: _bindgen_ty_10 = 256;
+pub const AKEY_EVENT_FLAG_TRACKING: _bindgen_ty_10 = 512;
+pub const AKEY_EVENT_FLAG_FALLBACK: _bindgen_ty_10 = 1024;
pub type _bindgen_ty_10 = ::std::os::raw::c_uint;
-pub const AMOTION_EVENT_ACTION_MASK: ::std::os::raw::c_uint = 255;
-pub const AMOTION_EVENT_ACTION_POINTER_INDEX_MASK: ::std::os::raw::c_uint = 65280;
-pub const AMOTION_EVENT_ACTION_DOWN: ::std::os::raw::c_uint = 0;
-pub const AMOTION_EVENT_ACTION_UP: ::std::os::raw::c_uint = 1;
-pub const AMOTION_EVENT_ACTION_MOVE: ::std::os::raw::c_uint = 2;
-pub const AMOTION_EVENT_ACTION_CANCEL: ::std::os::raw::c_uint = 3;
-pub const AMOTION_EVENT_ACTION_OUTSIDE: ::std::os::raw::c_uint = 4;
-pub const AMOTION_EVENT_ACTION_POINTER_DOWN: ::std::os::raw::c_uint = 5;
-pub const AMOTION_EVENT_ACTION_POINTER_UP: ::std::os::raw::c_uint = 6;
-pub const AMOTION_EVENT_ACTION_HOVER_MOVE: ::std::os::raw::c_uint = 7;
-pub const AMOTION_EVENT_ACTION_SCROLL: ::std::os::raw::c_uint = 8;
-pub const AMOTION_EVENT_ACTION_HOVER_ENTER: ::std::os::raw::c_uint = 9;
-pub const AMOTION_EVENT_ACTION_HOVER_EXIT: ::std::os::raw::c_uint = 10;
-pub const AMOTION_EVENT_ACTION_BUTTON_PRESS: ::std::os::raw::c_uint = 11;
-pub const AMOTION_EVENT_ACTION_BUTTON_RELEASE: ::std::os::raw::c_uint = 12;
+pub const AMOTION_EVENT_ACTION_MASK: _bindgen_ty_11 = 255;
+pub const AMOTION_EVENT_ACTION_POINTER_INDEX_MASK: _bindgen_ty_11 = 65280;
+pub const AMOTION_EVENT_ACTION_DOWN: _bindgen_ty_11 = 0;
+pub const AMOTION_EVENT_ACTION_UP: _bindgen_ty_11 = 1;
+pub const AMOTION_EVENT_ACTION_MOVE: _bindgen_ty_11 = 2;
+pub const AMOTION_EVENT_ACTION_CANCEL: _bindgen_ty_11 = 3;
+pub const AMOTION_EVENT_ACTION_OUTSIDE: _bindgen_ty_11 = 4;
+pub const AMOTION_EVENT_ACTION_POINTER_DOWN: _bindgen_ty_11 = 5;
+pub const AMOTION_EVENT_ACTION_POINTER_UP: _bindgen_ty_11 = 6;
+pub const AMOTION_EVENT_ACTION_HOVER_MOVE: _bindgen_ty_11 = 7;
+pub const AMOTION_EVENT_ACTION_SCROLL: _bindgen_ty_11 = 8;
+pub const AMOTION_EVENT_ACTION_HOVER_ENTER: _bindgen_ty_11 = 9;
+pub const AMOTION_EVENT_ACTION_HOVER_EXIT: _bindgen_ty_11 = 10;
+pub const AMOTION_EVENT_ACTION_BUTTON_PRESS: _bindgen_ty_11 = 11;
+pub const AMOTION_EVENT_ACTION_BUTTON_RELEASE: _bindgen_ty_11 = 12;
pub type _bindgen_ty_11 = ::std::os::raw::c_uint;
-pub const AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED: ::std::os::raw::c_uint = 1;
+pub const AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED: _bindgen_ty_12 = 1;
pub type _bindgen_ty_12 = ::std::os::raw::c_uint;
-pub const AMOTION_EVENT_EDGE_FLAG_NONE: ::std::os::raw::c_uint = 0;
-pub const AMOTION_EVENT_EDGE_FLAG_TOP: ::std::os::raw::c_uint = 1;
-pub const AMOTION_EVENT_EDGE_FLAG_BOTTOM: ::std::os::raw::c_uint = 2;
-pub const AMOTION_EVENT_EDGE_FLAG_LEFT: ::std::os::raw::c_uint = 4;
-pub const AMOTION_EVENT_EDGE_FLAG_RIGHT: ::std::os::raw::c_uint = 8;
+pub const AMOTION_EVENT_EDGE_FLAG_NONE: _bindgen_ty_13 = 0;
+pub const AMOTION_EVENT_EDGE_FLAG_TOP: _bindgen_ty_13 = 1;
+pub const AMOTION_EVENT_EDGE_FLAG_BOTTOM: _bindgen_ty_13 = 2;
+pub const AMOTION_EVENT_EDGE_FLAG_LEFT: _bindgen_ty_13 = 4;
+pub const AMOTION_EVENT_EDGE_FLAG_RIGHT: _bindgen_ty_13 = 8;
pub type _bindgen_ty_13 = ::std::os::raw::c_uint;
-pub const AMOTION_EVENT_AXIS_X: ::std::os::raw::c_uint = 0;
-pub const AMOTION_EVENT_AXIS_Y: ::std::os::raw::c_uint = 1;
-pub const AMOTION_EVENT_AXIS_PRESSURE: ::std::os::raw::c_uint = 2;
-pub const AMOTION_EVENT_AXIS_SIZE: ::std::os::raw::c_uint = 3;
-pub const AMOTION_EVENT_AXIS_TOUCH_MAJOR: ::std::os::raw::c_uint = 4;
-pub const AMOTION_EVENT_AXIS_TOUCH_MINOR: ::std::os::raw::c_uint = 5;
-pub const AMOTION_EVENT_AXIS_TOOL_MAJOR: ::std::os::raw::c_uint = 6;
-pub const AMOTION_EVENT_AXIS_TOOL_MINOR: ::std::os::raw::c_uint = 7;
-pub const AMOTION_EVENT_AXIS_ORIENTATION: ::std::os::raw::c_uint = 8;
-pub const AMOTION_EVENT_AXIS_VSCROLL: ::std::os::raw::c_uint = 9;
-pub const AMOTION_EVENT_AXIS_HSCROLL: ::std::os::raw::c_uint = 10;
-pub const AMOTION_EVENT_AXIS_Z: ::std::os::raw::c_uint = 11;
-pub const AMOTION_EVENT_AXIS_RX: ::std::os::raw::c_uint = 12;
-pub const AMOTION_EVENT_AXIS_RY: ::std::os::raw::c_uint = 13;
-pub const AMOTION_EVENT_AXIS_RZ: ::std::os::raw::c_uint = 14;
-pub const AMOTION_EVENT_AXIS_HAT_X: ::std::os::raw::c_uint = 15;
-pub const AMOTION_EVENT_AXIS_HAT_Y: ::std::os::raw::c_uint = 16;
-pub const AMOTION_EVENT_AXIS_LTRIGGER: ::std::os::raw::c_uint = 17;
-pub const AMOTION_EVENT_AXIS_RTRIGGER: ::std::os::raw::c_uint = 18;
-pub const AMOTION_EVENT_AXIS_THROTTLE: ::std::os::raw::c_uint = 19;
-pub const AMOTION_EVENT_AXIS_RUDDER: ::std::os::raw::c_uint = 20;
-pub const AMOTION_EVENT_AXIS_WHEEL: ::std::os::raw::c_uint = 21;
-pub const AMOTION_EVENT_AXIS_GAS: ::std::os::raw::c_uint = 22;
-pub const AMOTION_EVENT_AXIS_BRAKE: ::std::os::raw::c_uint = 23;
-pub const AMOTION_EVENT_AXIS_DISTANCE: ::std::os::raw::c_uint = 24;
-pub const AMOTION_EVENT_AXIS_TILT: ::std::os::raw::c_uint = 25;
-pub const AMOTION_EVENT_AXIS_SCROLL: ::std::os::raw::c_uint = 26;
-pub const AMOTION_EVENT_AXIS_RELATIVE_X: ::std::os::raw::c_uint = 27;
-pub const AMOTION_EVENT_AXIS_RELATIVE_Y: ::std::os::raw::c_uint = 28;
-pub const AMOTION_EVENT_AXIS_GENERIC_1: ::std::os::raw::c_uint = 32;
-pub const AMOTION_EVENT_AXIS_GENERIC_2: ::std::os::raw::c_uint = 33;
-pub const AMOTION_EVENT_AXIS_GENERIC_3: ::std::os::raw::c_uint = 34;
-pub const AMOTION_EVENT_AXIS_GENERIC_4: ::std::os::raw::c_uint = 35;
-pub const AMOTION_EVENT_AXIS_GENERIC_5: ::std::os::raw::c_uint = 36;
-pub const AMOTION_EVENT_AXIS_GENERIC_6: ::std::os::raw::c_uint = 37;
-pub const AMOTION_EVENT_AXIS_GENERIC_7: ::std::os::raw::c_uint = 38;
-pub const AMOTION_EVENT_AXIS_GENERIC_8: ::std::os::raw::c_uint = 39;
-pub const AMOTION_EVENT_AXIS_GENERIC_9: ::std::os::raw::c_uint = 40;
-pub const AMOTION_EVENT_AXIS_GENERIC_10: ::std::os::raw::c_uint = 41;
-pub const AMOTION_EVENT_AXIS_GENERIC_11: ::std::os::raw::c_uint = 42;
-pub const AMOTION_EVENT_AXIS_GENERIC_12: ::std::os::raw::c_uint = 43;
-pub const AMOTION_EVENT_AXIS_GENERIC_13: ::std::os::raw::c_uint = 44;
-pub const AMOTION_EVENT_AXIS_GENERIC_14: ::std::os::raw::c_uint = 45;
-pub const AMOTION_EVENT_AXIS_GENERIC_15: ::std::os::raw::c_uint = 46;
-pub const AMOTION_EVENT_AXIS_GENERIC_16: ::std::os::raw::c_uint = 47;
+pub const AMOTION_EVENT_AXIS_X: _bindgen_ty_14 = 0;
+pub const AMOTION_EVENT_AXIS_Y: _bindgen_ty_14 = 1;
+pub const AMOTION_EVENT_AXIS_PRESSURE: _bindgen_ty_14 = 2;
+pub const AMOTION_EVENT_AXIS_SIZE: _bindgen_ty_14 = 3;
+pub const AMOTION_EVENT_AXIS_TOUCH_MAJOR: _bindgen_ty_14 = 4;
+pub const AMOTION_EVENT_AXIS_TOUCH_MINOR: _bindgen_ty_14 = 5;
+pub const AMOTION_EVENT_AXIS_TOOL_MAJOR: _bindgen_ty_14 = 6;
+pub const AMOTION_EVENT_AXIS_TOOL_MINOR: _bindgen_ty_14 = 7;
+pub const AMOTION_EVENT_AXIS_ORIENTATION: _bindgen_ty_14 = 8;
+pub const AMOTION_EVENT_AXIS_VSCROLL: _bindgen_ty_14 = 9;
+pub const AMOTION_EVENT_AXIS_HSCROLL: _bindgen_ty_14 = 10;
+pub const AMOTION_EVENT_AXIS_Z: _bindgen_ty_14 = 11;
+pub const AMOTION_EVENT_AXIS_RX: _bindgen_ty_14 = 12;
+pub const AMOTION_EVENT_AXIS_RY: _bindgen_ty_14 = 13;
+pub const AMOTION_EVENT_AXIS_RZ: _bindgen_ty_14 = 14;
+pub const AMOTION_EVENT_AXIS_HAT_X: _bindgen_ty_14 = 15;
+pub const AMOTION_EVENT_AXIS_HAT_Y: _bindgen_ty_14 = 16;
+pub const AMOTION_EVENT_AXIS_LTRIGGER: _bindgen_ty_14 = 17;
+pub const AMOTION_EVENT_AXIS_RTRIGGER: _bindgen_ty_14 = 18;
+pub const AMOTION_EVENT_AXIS_THROTTLE: _bindgen_ty_14 = 19;
+pub const AMOTION_EVENT_AXIS_RUDDER: _bindgen_ty_14 = 20;
+pub const AMOTION_EVENT_AXIS_WHEEL: _bindgen_ty_14 = 21;
+pub const AMOTION_EVENT_AXIS_GAS: _bindgen_ty_14 = 22;
+pub const AMOTION_EVENT_AXIS_BRAKE: _bindgen_ty_14 = 23;
+pub const AMOTION_EVENT_AXIS_DISTANCE: _bindgen_ty_14 = 24;
+pub const AMOTION_EVENT_AXIS_TILT: _bindgen_ty_14 = 25;
+pub const AMOTION_EVENT_AXIS_SCROLL: _bindgen_ty_14 = 26;
+pub const AMOTION_EVENT_AXIS_RELATIVE_X: _bindgen_ty_14 = 27;
+pub const AMOTION_EVENT_AXIS_RELATIVE_Y: _bindgen_ty_14 = 28;
+pub const AMOTION_EVENT_AXIS_GENERIC_1: _bindgen_ty_14 = 32;
+pub const AMOTION_EVENT_AXIS_GENERIC_2: _bindgen_ty_14 = 33;
+pub const AMOTION_EVENT_AXIS_GENERIC_3: _bindgen_ty_14 = 34;
+pub const AMOTION_EVENT_AXIS_GENERIC_4: _bindgen_ty_14 = 35;
+pub const AMOTION_EVENT_AXIS_GENERIC_5: _bindgen_ty_14 = 36;
+pub const AMOTION_EVENT_AXIS_GENERIC_6: _bindgen_ty_14 = 37;
+pub const AMOTION_EVENT_AXIS_GENERIC_7: _bindgen_ty_14 = 38;
+pub const AMOTION_EVENT_AXIS_GENERIC_8: _bindgen_ty_14 = 39;
+pub const AMOTION_EVENT_AXIS_GENERIC_9: _bindgen_ty_14 = 40;
+pub const AMOTION_EVENT_AXIS_GENERIC_10: _bindgen_ty_14 = 41;
+pub const AMOTION_EVENT_AXIS_GENERIC_11: _bindgen_ty_14 = 42;
+pub const AMOTION_EVENT_AXIS_GENERIC_12: _bindgen_ty_14 = 43;
+pub const AMOTION_EVENT_AXIS_GENERIC_13: _bindgen_ty_14 = 44;
+pub const AMOTION_EVENT_AXIS_GENERIC_14: _bindgen_ty_14 = 45;
+pub const AMOTION_EVENT_AXIS_GENERIC_15: _bindgen_ty_14 = 46;
+pub const AMOTION_EVENT_AXIS_GENERIC_16: _bindgen_ty_14 = 47;
pub type _bindgen_ty_14 = ::std::os::raw::c_uint;
-pub const AMOTION_EVENT_BUTTON_PRIMARY: ::std::os::raw::c_uint = 1;
-pub const AMOTION_EVENT_BUTTON_SECONDARY: ::std::os::raw::c_uint = 2;
-pub const AMOTION_EVENT_BUTTON_TERTIARY: ::std::os::raw::c_uint = 4;
-pub const AMOTION_EVENT_BUTTON_BACK: ::std::os::raw::c_uint = 8;
-pub const AMOTION_EVENT_BUTTON_FORWARD: ::std::os::raw::c_uint = 16;
-pub const AMOTION_EVENT_BUTTON_STYLUS_PRIMARY: ::std::os::raw::c_uint = 32;
-pub const AMOTION_EVENT_BUTTON_STYLUS_SECONDARY: ::std::os::raw::c_uint = 64;
+pub const AMOTION_EVENT_BUTTON_PRIMARY: _bindgen_ty_15 = 1;
+pub const AMOTION_EVENT_BUTTON_SECONDARY: _bindgen_ty_15 = 2;
+pub const AMOTION_EVENT_BUTTON_TERTIARY: _bindgen_ty_15 = 4;
+pub const AMOTION_EVENT_BUTTON_BACK: _bindgen_ty_15 = 8;
+pub const AMOTION_EVENT_BUTTON_FORWARD: _bindgen_ty_15 = 16;
+pub const AMOTION_EVENT_BUTTON_STYLUS_PRIMARY: _bindgen_ty_15 = 32;
+pub const AMOTION_EVENT_BUTTON_STYLUS_SECONDARY: _bindgen_ty_15 = 64;
pub type _bindgen_ty_15 = ::std::os::raw::c_uint;
-pub const AMOTION_EVENT_TOOL_TYPE_UNKNOWN: ::std::os::raw::c_uint = 0;
-pub const AMOTION_EVENT_TOOL_TYPE_FINGER: ::std::os::raw::c_uint = 1;
-pub const AMOTION_EVENT_TOOL_TYPE_STYLUS: ::std::os::raw::c_uint = 2;
-pub const AMOTION_EVENT_TOOL_TYPE_MOUSE: ::std::os::raw::c_uint = 3;
-pub const AMOTION_EVENT_TOOL_TYPE_ERASER: ::std::os::raw::c_uint = 4;
+pub const AMOTION_EVENT_TOOL_TYPE_UNKNOWN: _bindgen_ty_16 = 0;
+pub const AMOTION_EVENT_TOOL_TYPE_FINGER: _bindgen_ty_16 = 1;
+pub const AMOTION_EVENT_TOOL_TYPE_STYLUS: _bindgen_ty_16 = 2;
+pub const AMOTION_EVENT_TOOL_TYPE_MOUSE: _bindgen_ty_16 = 3;
+pub const AMOTION_EVENT_TOOL_TYPE_ERASER: _bindgen_ty_16 = 4;
+pub const AMOTION_EVENT_TOOL_TYPE_PALM: _bindgen_ty_16 = 5;
pub type _bindgen_ty_16 = ::std::os::raw::c_uint;
-pub const AINPUT_SOURCE_CLASS_MASK: ::std::os::raw::c_uint = 255;
-pub const AINPUT_SOURCE_CLASS_NONE: ::std::os::raw::c_uint = 0;
-pub const AINPUT_SOURCE_CLASS_BUTTON: ::std::os::raw::c_uint = 1;
-pub const AINPUT_SOURCE_CLASS_POINTER: ::std::os::raw::c_uint = 2;
-pub const AINPUT_SOURCE_CLASS_NAVIGATION: ::std::os::raw::c_uint = 4;
-pub const AINPUT_SOURCE_CLASS_POSITION: ::std::os::raw::c_uint = 8;
-pub const AINPUT_SOURCE_CLASS_JOYSTICK: ::std::os::raw::c_uint = 16;
+pub const AMotionClassification_AMOTION_EVENT_CLASSIFICATION_NONE: AMotionClassification = 0;
+pub const AMotionClassification_AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE:
+ AMotionClassification = 1;
+pub const AMotionClassification_AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS: AMotionClassification = 2;
+pub type AMotionClassification = u32;
+pub const AINPUT_SOURCE_CLASS_MASK: _bindgen_ty_17 = 255;
+pub const AINPUT_SOURCE_CLASS_NONE: _bindgen_ty_17 = 0;
+pub const AINPUT_SOURCE_CLASS_BUTTON: _bindgen_ty_17 = 1;
+pub const AINPUT_SOURCE_CLASS_POINTER: _bindgen_ty_17 = 2;
+pub const AINPUT_SOURCE_CLASS_NAVIGATION: _bindgen_ty_17 = 4;
+pub const AINPUT_SOURCE_CLASS_POSITION: _bindgen_ty_17 = 8;
+pub const AINPUT_SOURCE_CLASS_JOYSTICK: _bindgen_ty_17 = 16;
pub type _bindgen_ty_17 = ::std::os::raw::c_uint;
-pub const AINPUT_SOURCE_UNKNOWN: ::std::os::raw::c_uint = 0;
-pub const AINPUT_SOURCE_KEYBOARD: ::std::os::raw::c_uint = 257;
-pub const AINPUT_SOURCE_DPAD: ::std::os::raw::c_uint = 513;
-pub const AINPUT_SOURCE_GAMEPAD: ::std::os::raw::c_uint = 1025;
-pub const AINPUT_SOURCE_TOUCHSCREEN: ::std::os::raw::c_uint = 4098;
-pub const AINPUT_SOURCE_MOUSE: ::std::os::raw::c_uint = 8194;
-pub const AINPUT_SOURCE_STYLUS: ::std::os::raw::c_uint = 16386;
-pub const AINPUT_SOURCE_BLUETOOTH_STYLUS: ::std::os::raw::c_uint = 49154;
-pub const AINPUT_SOURCE_TRACKBALL: ::std::os::raw::c_uint = 65540;
-pub const AINPUT_SOURCE_MOUSE_RELATIVE: ::std::os::raw::c_uint = 131076;
-pub const AINPUT_SOURCE_TOUCHPAD: ::std::os::raw::c_uint = 1048584;
-pub const AINPUT_SOURCE_TOUCH_NAVIGATION: ::std::os::raw::c_uint = 2097152;
-pub const AINPUT_SOURCE_JOYSTICK: ::std::os::raw::c_uint = 16777232;
-pub const AINPUT_SOURCE_ROTARY_ENCODER: ::std::os::raw::c_uint = 4194304;
-pub const AINPUT_SOURCE_ANY: ::std::os::raw::c_uint = 4294967040;
+pub const AINPUT_SOURCE_UNKNOWN: _bindgen_ty_18 = 0;
+pub const AINPUT_SOURCE_KEYBOARD: _bindgen_ty_18 = 257;
+pub const AINPUT_SOURCE_DPAD: _bindgen_ty_18 = 513;
+pub const AINPUT_SOURCE_GAMEPAD: _bindgen_ty_18 = 1025;
+pub const AINPUT_SOURCE_TOUCHSCREEN: _bindgen_ty_18 = 4098;
+pub const AINPUT_SOURCE_MOUSE: _bindgen_ty_18 = 8194;
+pub const AINPUT_SOURCE_STYLUS: _bindgen_ty_18 = 16386;
+pub const AINPUT_SOURCE_BLUETOOTH_STYLUS: _bindgen_ty_18 = 49154;
+pub const AINPUT_SOURCE_TRACKBALL: _bindgen_ty_18 = 65540;
+pub const AINPUT_SOURCE_MOUSE_RELATIVE: _bindgen_ty_18 = 131076;
+pub const AINPUT_SOURCE_TOUCHPAD: _bindgen_ty_18 = 1048584;
+pub const AINPUT_SOURCE_TOUCH_NAVIGATION: _bindgen_ty_18 = 2097152;
+pub const AINPUT_SOURCE_JOYSTICK: _bindgen_ty_18 = 16777232;
+pub const AINPUT_SOURCE_HDMI: _bindgen_ty_18 = 33554433;
+pub const AINPUT_SOURCE_SENSOR: _bindgen_ty_18 = 67108864;
+pub const AINPUT_SOURCE_ROTARY_ENCODER: _bindgen_ty_18 = 4194304;
+pub const AINPUT_SOURCE_ANY: _bindgen_ty_18 = 4294967040;
pub type _bindgen_ty_18 = ::std::os::raw::c_uint;
-pub const AINPUT_KEYBOARD_TYPE_NONE: ::std::os::raw::c_uint = 0;
-pub const AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC: ::std::os::raw::c_uint = 1;
-pub const AINPUT_KEYBOARD_TYPE_ALPHABETIC: ::std::os::raw::c_uint = 2;
+pub const AINPUT_KEYBOARD_TYPE_NONE: _bindgen_ty_19 = 0;
+pub const AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC: _bindgen_ty_19 = 1;
+pub const AINPUT_KEYBOARD_TYPE_ALPHABETIC: _bindgen_ty_19 = 2;
pub type _bindgen_ty_19 = ::std::os::raw::c_uint;
-pub const AINPUT_MOTION_RANGE_X: ::std::os::raw::c_uint = 0;
-pub const AINPUT_MOTION_RANGE_Y: ::std::os::raw::c_uint = 1;
-pub const AINPUT_MOTION_RANGE_PRESSURE: ::std::os::raw::c_uint = 2;
-pub const AINPUT_MOTION_RANGE_SIZE: ::std::os::raw::c_uint = 3;
-pub const AINPUT_MOTION_RANGE_TOUCH_MAJOR: ::std::os::raw::c_uint = 4;
-pub const AINPUT_MOTION_RANGE_TOUCH_MINOR: ::std::os::raw::c_uint = 5;
-pub const AINPUT_MOTION_RANGE_TOOL_MAJOR: ::std::os::raw::c_uint = 6;
-pub const AINPUT_MOTION_RANGE_TOOL_MINOR: ::std::os::raw::c_uint = 7;
-pub const AINPUT_MOTION_RANGE_ORIENTATION: ::std::os::raw::c_uint = 8;
+pub const AINPUT_MOTION_RANGE_X: _bindgen_ty_20 = 0;
+pub const AINPUT_MOTION_RANGE_Y: _bindgen_ty_20 = 1;
+pub const AINPUT_MOTION_RANGE_PRESSURE: _bindgen_ty_20 = 2;
+pub const AINPUT_MOTION_RANGE_SIZE: _bindgen_ty_20 = 3;
+pub const AINPUT_MOTION_RANGE_TOUCH_MAJOR: _bindgen_ty_20 = 4;
+pub const AINPUT_MOTION_RANGE_TOUCH_MINOR: _bindgen_ty_20 = 5;
+pub const AINPUT_MOTION_RANGE_TOOL_MAJOR: _bindgen_ty_20 = 6;
+pub const AINPUT_MOTION_RANGE_TOOL_MINOR: _bindgen_ty_20 = 7;
+pub const AINPUT_MOTION_RANGE_ORIENTATION: _bindgen_ty_20 = 8;
pub type _bindgen_ty_20 = ::std::os::raw::c_uint;
extern "C" {
pub fn AInputEvent_getType(event: *const AInputEvent) -> i32;
@@ -1377,6 +1592,9 @@ extern "C" {
extern "C" {
pub fn AInputEvent_getSource(event: *const AInputEvent) -> i32;
}
+extern "C" {
+ pub fn AInputEvent_release(event: *const AInputEvent);
+}
extern "C" {
pub fn AKeyEvent_getAction(key_event: *const AInputEvent) -> i32;
}
@@ -1401,6 +1619,9 @@ extern "C" {
extern "C" {
pub fn AKeyEvent_getEventTime(key_event: *const AInputEvent) -> i64;
}
+extern "C" {
+ pub fn AKeyEvent_fromJava(env: *mut JNIEnv, keyEvent: jobject) -> *const AInputEvent;
+}
extern "C" {
pub fn AMotionEvent_getAction(motion_event: *const AInputEvent) -> i32;
}
@@ -1435,168 +1656,169 @@ extern "C" {
pub fn AMotionEvent_getYPrecision(motion_event: *const AInputEvent) -> f32;
}
extern "C" {
- pub fn AMotionEvent_getPointerCount(motion_event: *const AInputEvent) -> size_t;
+ pub fn AMotionEvent_getPointerCount(motion_event: *const AInputEvent) -> usize;
}
extern "C" {
- pub fn AMotionEvent_getPointerId(
- motion_event: *const AInputEvent,
- pointer_index: size_t,
- ) -> i32;
+ pub fn AMotionEvent_getPointerId(motion_event: *const AInputEvent, pointer_index: usize)
+ -> i32;
}
extern "C" {
- pub fn AMotionEvent_getToolType(motion_event: *const AInputEvent, pointer_index: size_t)
- -> i32;
+ pub fn AMotionEvent_getToolType(motion_event: *const AInputEvent, pointer_index: usize) -> i32;
}
extern "C" {
- pub fn AMotionEvent_getRawX(motion_event: *const AInputEvent, pointer_index: size_t) -> f32;
+ pub fn AMotionEvent_getRawX(motion_event: *const AInputEvent, pointer_index: usize) -> f32;
}
extern "C" {
- pub fn AMotionEvent_getRawY(motion_event: *const AInputEvent, pointer_index: size_t) -> f32;
+ pub fn AMotionEvent_getRawY(motion_event: *const AInputEvent, pointer_index: usize) -> f32;
}
extern "C" {
- pub fn AMotionEvent_getX(motion_event: *const AInputEvent, pointer_index: size_t) -> f32;
+ pub fn AMotionEvent_getX(motion_event: *const AInputEvent, pointer_index: usize) -> f32;
}
extern "C" {
- pub fn AMotionEvent_getY(motion_event: *const AInputEvent, pointer_index: size_t) -> f32;
+ pub fn AMotionEvent_getY(motion_event: *const AInputEvent, pointer_index: usize) -> f32;
}
extern "C" {
- pub fn AMotionEvent_getPressure(motion_event: *const AInputEvent, pointer_index: size_t)
- -> f32;
+ pub fn AMotionEvent_getPressure(motion_event: *const AInputEvent, pointer_index: usize) -> f32;
}
extern "C" {
- pub fn AMotionEvent_getSize(motion_event: *const AInputEvent, pointer_index: size_t) -> f32;
+ pub fn AMotionEvent_getSize(motion_event: *const AInputEvent, pointer_index: usize) -> f32;
}
extern "C" {
pub fn AMotionEvent_getTouchMajor(
motion_event: *const AInputEvent,
- pointer_index: size_t,
+ pointer_index: usize,
) -> f32;
}
extern "C" {
pub fn AMotionEvent_getTouchMinor(
motion_event: *const AInputEvent,
- pointer_index: size_t,
+ pointer_index: usize,
) -> f32;
}
extern "C" {
- pub fn AMotionEvent_getToolMajor(
- motion_event: *const AInputEvent,
- pointer_index: size_t,
- ) -> f32;
+ pub fn AMotionEvent_getToolMajor(motion_event: *const AInputEvent, pointer_index: usize)
+ -> f32;
}
extern "C" {
- pub fn AMotionEvent_getToolMinor(
- motion_event: *const AInputEvent,
- pointer_index: size_t,
- ) -> f32;
+ pub fn AMotionEvent_getToolMinor(motion_event: *const AInputEvent, pointer_index: usize)
+ -> f32;
}
extern "C" {
pub fn AMotionEvent_getOrientation(
motion_event: *const AInputEvent,
- pointer_index: size_t,
+ pointer_index: usize,
) -> f32;
}
extern "C" {
pub fn AMotionEvent_getAxisValue(
motion_event: *const AInputEvent,
axis: i32,
- pointer_index: size_t,
+ pointer_index: usize,
) -> f32;
}
extern "C" {
- pub fn AMotionEvent_getHistorySize(motion_event: *const AInputEvent) -> size_t;
+ pub fn AMotionEvent_getHistorySize(motion_event: *const AInputEvent) -> usize;
}
extern "C" {
pub fn AMotionEvent_getHistoricalEventTime(
motion_event: *const AInputEvent,
- history_index: size_t,
+ history_index: usize,
) -> i64;
}
extern "C" {
pub fn AMotionEvent_getHistoricalRawX(
motion_event: *const AInputEvent,
- pointer_index: size_t,
- history_index: size_t,
+ pointer_index: usize,
+ history_index: usize,
) -> f32;
}
extern "C" {
pub fn AMotionEvent_getHistoricalRawY(
motion_event: *const AInputEvent,
- pointer_index: size_t,
- history_index: size_t,
+ pointer_index: usize,
+ history_index: usize,
) -> f32;
}
extern "C" {
pub fn AMotionEvent_getHistoricalX(
motion_event: *const AInputEvent,
- pointer_index: size_t,
- history_index: size_t,
+ pointer_index: usize,
+ history_index: usize,
) -> f32;
}
extern "C" {
pub fn AMotionEvent_getHistoricalY(
motion_event: *const AInputEvent,
- pointer_index: size_t,
- history_index: size_t,
+ pointer_index: usize,
+ history_index: usize,
) -> f32;
}
extern "C" {
pub fn AMotionEvent_getHistoricalPressure(
motion_event: *const AInputEvent,
- pointer_index: size_t,
- history_index: size_t,
+ pointer_index: usize,
+ history_index: usize,
) -> f32;
}
extern "C" {
pub fn AMotionEvent_getHistoricalSize(
motion_event: *const AInputEvent,
- pointer_index: size_t,
- history_index: size_t,
+ pointer_index: usize,
+ history_index: usize,
) -> f32;
}
extern "C" {
pub fn AMotionEvent_getHistoricalTouchMajor(
motion_event: *const AInputEvent,
- pointer_index: size_t,
- history_index: size_t,
+ pointer_index: usize,
+ history_index: usize,
) -> f32;
}
extern "C" {
pub fn AMotionEvent_getHistoricalTouchMinor(
motion_event: *const AInputEvent,
- pointer_index: size_t,
- history_index: size_t,
+ pointer_index: usize,
+ history_index: usize,
) -> f32;
}
extern "C" {
pub fn AMotionEvent_getHistoricalToolMajor(
motion_event: *const AInputEvent,
- pointer_index: size_t,
- history_index: size_t,
+ pointer_index: usize,
+ history_index: usize,
) -> f32;
}
extern "C" {
pub fn AMotionEvent_getHistoricalToolMinor(
motion_event: *const AInputEvent,
- pointer_index: size_t,
- history_index: size_t,
+ pointer_index: usize,
+ history_index: usize,
) -> f32;
}
extern "C" {
pub fn AMotionEvent_getHistoricalOrientation(
motion_event: *const AInputEvent,
- pointer_index: size_t,
- history_index: size_t,
+ pointer_index: usize,
+ history_index: usize,
) -> f32;
}
extern "C" {
pub fn AMotionEvent_getHistoricalAxisValue(
motion_event: *const AInputEvent,
axis: i32,
- pointer_index: size_t,
- history_index: size_t,
+ pointer_index: usize,
+ history_index: usize,
) -> f32;
}
+extern "C" {
+ pub fn AMotionEvent_getActionButton(motion_event: *const AInputEvent) -> i32;
+}
+extern "C" {
+ pub fn AMotionEvent_getClassification(motion_event: *const AInputEvent) -> i32;
+}
+extern "C" {
+ pub fn AMotionEvent_fromJava(env: *mut JNIEnv, motionEvent: jobject) -> *const AInputEvent;
+}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct AInputQueue {
@@ -1630,6 +1852,9 @@ extern "C" {
handled: ::std::os::raw::c_int,
);
}
+extern "C" {
+ pub fn AInputQueue_fromJava(env: *mut JNIEnv, inputQueue: jobject) -> *mut AInputQueue;
+}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct imaxdiv_t {
@@ -1638,35 +1863,27 @@ pub struct imaxdiv_t {
}
#[test]
fn bindgen_test_layout_imaxdiv_t() {
+ const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit();
+ let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::(),
16usize,
- concat!("Size of: ", stringify!(imaxdiv_t))
+ "Size of imaxdiv_t"
);
assert_eq!(
::std::mem::align_of::(),
8usize,
- concat!("Alignment of ", stringify!(imaxdiv_t))
+ "Alignment of imaxdiv_t"
);
assert_eq!(
- unsafe { &(*(::std::ptr::null::())).quot as *const _ as usize },
+ unsafe { ::std::ptr::addr_of!((*ptr).quot) as usize - ptr as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(imaxdiv_t),
- "::",
- stringify!(quot)
- )
+ "Offset of field: imaxdiv_t::quot"
);
assert_eq!(
- unsafe { &(*(::std::ptr::null::())).rem as *const _ as usize },
+ unsafe { ::std::ptr::addr_of!((*ptr).rem) as usize - ptr as usize },
8usize,
- concat!(
- "Offset of field: ",
- stringify!(imaxdiv_t),
- "::",
- stringify!(rem)
- )
+ "Offset of field: imaxdiv_t::rem"
);
}
extern "C" {
@@ -1704,11 +1921,52 @@ extern "C" {
) -> uintmax_t;
}
pub const ADataSpace_ADATASPACE_UNKNOWN: ADataSpace = 0;
+pub const ADataSpace_STANDARD_MASK: ADataSpace = 4128768;
+pub const ADataSpace_STANDARD_UNSPECIFIED: ADataSpace = 0;
+pub const ADataSpace_STANDARD_BT709: ADataSpace = 65536;
+pub const ADataSpace_STANDARD_BT601_625: ADataSpace = 131072;
+pub const ADataSpace_STANDARD_BT601_625_UNADJUSTED: ADataSpace = 196608;
+pub const ADataSpace_STANDARD_BT601_525: ADataSpace = 262144;
+pub const ADataSpace_STANDARD_BT601_525_UNADJUSTED: ADataSpace = 327680;
+pub const ADataSpace_STANDARD_BT2020: ADataSpace = 393216;
+pub const ADataSpace_STANDARD_BT2020_CONSTANT_LUMINANCE: ADataSpace = 458752;
+pub const ADataSpace_STANDARD_BT470M: ADataSpace = 524288;
+pub const ADataSpace_STANDARD_FILM: ADataSpace = 589824;
+pub const ADataSpace_STANDARD_DCI_P3: ADataSpace = 655360;
+pub const ADataSpace_STANDARD_ADOBE_RGB: ADataSpace = 720896;
+pub const ADataSpace_TRANSFER_MASK: ADataSpace = 130023424;
+pub const ADataSpace_TRANSFER_UNSPECIFIED: ADataSpace = 0;
+pub const ADataSpace_TRANSFER_LINEAR: ADataSpace = 4194304;
+pub const ADataSpace_TRANSFER_SRGB: ADataSpace = 8388608;
+pub const ADataSpace_TRANSFER_SMPTE_170M: ADataSpace = 12582912;
+pub const ADataSpace_TRANSFER_GAMMA2_2: ADataSpace = 16777216;
+pub const ADataSpace_TRANSFER_GAMMA2_6: ADataSpace = 20971520;
+pub const ADataSpace_TRANSFER_GAMMA2_8: ADataSpace = 25165824;
+pub const ADataSpace_TRANSFER_ST2084: ADataSpace = 29360128;
+pub const ADataSpace_TRANSFER_HLG: ADataSpace = 33554432;
+pub const ADataSpace_RANGE_MASK: ADataSpace = 939524096;
+pub const ADataSpace_RANGE_UNSPECIFIED: ADataSpace = 0;
+pub const ADataSpace_RANGE_FULL: ADataSpace = 134217728;
+pub const ADataSpace_RANGE_LIMITED: ADataSpace = 268435456;
+pub const ADataSpace_RANGE_EXTENDED: ADataSpace = 402653184;
pub const ADataSpace_ADATASPACE_SCRGB_LINEAR: ADataSpace = 406913024;
pub const ADataSpace_ADATASPACE_SRGB: ADataSpace = 142671872;
pub const ADataSpace_ADATASPACE_SCRGB: ADataSpace = 411107328;
pub const ADataSpace_ADATASPACE_DISPLAY_P3: ADataSpace = 143261696;
pub const ADataSpace_ADATASPACE_BT2020_PQ: ADataSpace = 163971072;
+pub const ADataSpace_ADATASPACE_BT2020_ITU_PQ: ADataSpace = 298188800;
+pub const ADataSpace_ADATASPACE_ADOBE_RGB: ADataSpace = 151715840;
+pub const ADataSpace_ADATASPACE_JFIF: ADataSpace = 146931712;
+pub const ADataSpace_ADATASPACE_BT601_625: ADataSpace = 281149440;
+pub const ADataSpace_ADATASPACE_BT601_525: ADataSpace = 281280512;
+pub const ADataSpace_ADATASPACE_BT2020: ADataSpace = 147193856;
+pub const ADataSpace_ADATASPACE_BT709: ADataSpace = 281083904;
+pub const ADataSpace_ADATASPACE_DCI_P3: ADataSpace = 155844608;
+pub const ADataSpace_ADATASPACE_SRGB_LINEAR: ADataSpace = 138477568;
+pub const ADataSpace_ADATASPACE_BT2020_HLG: ADataSpace = 168165376;
+pub const ADataSpace_ADATASPACE_BT2020_ITU_HLG: ADataSpace = 302383104;
+pub const ADataSpace_DEPTH: ADataSpace = 4096;
+pub const ADataSpace_DYNAMIC_DEPTH: ADataSpace = 4098;
pub type ADataSpace = ::std::os::raw::c_uint;
pub const AHardwareBuffer_Format_AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM: AHardwareBuffer_Format = 1;
pub const AHardwareBuffer_Format_AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM: AHardwareBuffer_Format = 2;
@@ -1728,6 +1986,12 @@ pub const AHardwareBuffer_Format_AHARDWAREBUFFER_FORMAT_D32_FLOAT_S8_UINT: AHard
52;
pub const AHardwareBuffer_Format_AHARDWAREBUFFER_FORMAT_S8_UINT: AHardwareBuffer_Format = 53;
pub const AHardwareBuffer_Format_AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420: AHardwareBuffer_Format = 35;
+pub const AHardwareBuffer_Format_AHARDWAREBUFFER_FORMAT_YCbCr_P010: AHardwareBuffer_Format = 54;
+pub const AHardwareBuffer_Format_AHARDWAREBUFFER_FORMAT_R8_UNORM: AHardwareBuffer_Format = 56;
+pub const AHardwareBuffer_Format_AHARDWAREBUFFER_FORMAT_R16_UINT: AHardwareBuffer_Format = 57;
+pub const AHardwareBuffer_Format_AHARDWAREBUFFER_FORMAT_R16G16_UINT: AHardwareBuffer_Format = 58;
+pub const AHardwareBuffer_Format_AHARDWAREBUFFER_FORMAT_R10G10B10A10_UNORM: AHardwareBuffer_Format =
+ 59;
pub type AHardwareBuffer_Format = ::std::os::raw::c_uint;
pub const AHardwareBuffer_UsageFlags_AHARDWAREBUFFER_USAGE_CPU_READ_NEVER:
AHardwareBuffer_UsageFlags = 0;
@@ -1765,6 +2029,8 @@ pub const AHardwareBuffer_UsageFlags_AHARDWAREBUFFER_USAGE_GPU_CUBE_MAP:
AHardwareBuffer_UsageFlags = 33554432;
pub const AHardwareBuffer_UsageFlags_AHARDWAREBUFFER_USAGE_GPU_MIPMAP_COMPLETE:
AHardwareBuffer_UsageFlags = 67108864;
+pub const AHardwareBuffer_UsageFlags_AHARDWAREBUFFER_USAGE_FRONT_BUFFER:
+ AHardwareBuffer_UsageFlags = 4294967296;
pub const AHardwareBuffer_UsageFlags_AHARDWAREBUFFER_USAGE_VENDOR_0: AHardwareBuffer_UsageFlags =
268435456;
pub const AHardwareBuffer_UsageFlags_AHARDWAREBUFFER_USAGE_VENDOR_1: AHardwareBuffer_UsageFlags =
@@ -1820,95 +2086,57 @@ pub struct AHardwareBuffer_Desc {
}
#[test]
fn bindgen_test_layout_AHardwareBuffer_Desc() {
+ const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit();
+ let ptr = UNINIT.as_ptr();
assert_eq!(
::std::mem::size_of::(),
40usize,
- concat!("Size of: ", stringify!(AHardwareBuffer_Desc))
+ "Size of AHardwareBuffer_Desc"
);
assert_eq!(
::std::mem::align_of::(),
8usize,
- concat!("Alignment of ", stringify!(AHardwareBuffer_Desc))
+ "Alignment of AHardwareBuffer_Desc"
);
assert_eq!(
- unsafe { &(*(::std::ptr::null::())).width as *const _ as usize },
+ unsafe { ::std::ptr::addr_of!((*ptr).width) as usize - ptr as usize },
0usize,
- concat!(
- "Offset of field: ",
- stringify!(AHardwareBuffer_Desc),
- "::",
- stringify!(width)
- )
+ "Offset of field: AHardwareBuffer_Desc::width"
);
assert_eq!(
- unsafe { &(*(::std::ptr::null::())).height as *const _ as usize },
+ unsafe { ::std::ptr::addr_of!((*ptr).height) as usize - ptr as usize },
4usize,
- concat!(
- "Offset of field: ",
- stringify!(AHardwareBuffer_Desc),
- "::",
- stringify!(height)
- )
+ "Offset of field: AHardwareBuffer_Desc::height"
);
assert_eq!(
- unsafe { &(*(::std::ptr::null::())).layers as *const _ as usize },
+ unsafe { ::std::ptr::addr_of!((*ptr).layers) as usize - ptr as usize },
8usize,
- concat!(
- "Offset of field: ",
- stringify!(AHardwareBuffer_Desc),
- "::",
- stringify!(layers)
- )
+ "Offset of field: AHardwareBuffer_Desc::layers"
);
assert_eq!(
- unsafe { &(*(::std::ptr::null::())).format as *const _ as usize },
+ unsafe { ::std::ptr::addr_of!((*ptr).format) as usize - ptr as usize },
12usize,
- concat!(
- "Offset of field: ",
- stringify!(AHardwareBuffer_Desc),
- "::",
- stringify!(format)
- )
+ "Offset of field: AHardwareBuffer_Desc::format"
);
assert_eq!(
- unsafe { &(*(::std::ptr::null::