mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 18:40:49 +00:00
(Android) Code reformatting to stay within 80-char limit
This commit is contained in:
parent
51637bc69e
commit
cb09818d71
@ -90,7 +90,8 @@ typedef struct android_input
|
|||||||
|
|
||||||
|
|
||||||
void (*engine_handle_dpad)(android_input_t *android, AInputEvent*, int, int);
|
void (*engine_handle_dpad)(android_input_t *android, AInputEvent*, int, int);
|
||||||
static bool android_input_set_sensor_state(void *data, unsigned port, enum retro_sensor_action action, unsigned event_rate);
|
static bool android_input_set_sensor_state(void *data, unsigned port,
|
||||||
|
enum retro_sensor_action action, unsigned event_rate);
|
||||||
|
|
||||||
extern float AMotionEvent_getAxisValue(const AInputEvent* motion_event,
|
extern float AMotionEvent_getAxisValue(const AInputEvent* motion_event,
|
||||||
int32_t axis, size_t pointer_index);
|
int32_t axis, size_t pointer_index);
|
||||||
@ -114,9 +115,11 @@ static inline void set_bit(uint8_t *buf, unsigned bit)
|
|||||||
buf[bit >> 3] |= 1 << (bit & 7);
|
buf[bit >> 3] |= 1 << (bit & 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void engine_handle_dpad_default(android_input_t *android, AInputEvent *event, int port, int source)
|
static void engine_handle_dpad_default(android_input_t *android,
|
||||||
|
AInputEvent *event, int port, int source)
|
||||||
{
|
{
|
||||||
size_t motion_pointer = AMotionEvent_getAction(event) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
|
size_t motion_pointer = AMotionEvent_getAction(event) >>
|
||||||
|
AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
|
||||||
float x = AMotionEvent_getX(event, motion_pointer);
|
float x = AMotionEvent_getX(event, motion_pointer);
|
||||||
float y = AMotionEvent_getY(event, motion_pointer);
|
float y = AMotionEvent_getY(event, motion_pointer);
|
||||||
|
|
||||||
@ -124,9 +127,11 @@ static void engine_handle_dpad_default(android_input_t *android, AInputEvent *ev
|
|||||||
android->analog_state[port][1] = (int16_t)(y * 32767.0f);
|
android->analog_state[port][1] = (int16_t)(y * 32767.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void engine_handle_dpad_getaxisvalue(android_input_t *android, AInputEvent *event, int port, int source)
|
static void engine_handle_dpad_getaxisvalue(android_input_t *android,
|
||||||
|
AInputEvent *event, int port, int source)
|
||||||
{
|
{
|
||||||
size_t motion_pointer = AMotionEvent_getAction(event) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
|
size_t motion_pointer = AMotionEvent_getAction(event) >>
|
||||||
|
AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
|
||||||
float x = AMotionEvent_getAxisValue(event, AXIS_X, motion_pointer);
|
float x = AMotionEvent_getAxisValue(event, AXIS_X, motion_pointer);
|
||||||
float y = AMotionEvent_getAxisValue(event, AXIS_Y, motion_pointer);
|
float y = AMotionEvent_getAxisValue(event, AXIS_Y, motion_pointer);
|
||||||
float z = AMotionEvent_getAxisValue(event, AXIS_Z, motion_pointer);
|
float z = AMotionEvent_getAxisValue(event, AXIS_Z, motion_pointer);
|
||||||
@ -141,7 +146,9 @@ static void engine_handle_dpad_getaxisvalue(android_input_t *android, AInputEven
|
|||||||
android->hat_state[port][0] = (int)hatx;
|
android->hat_state[port][0] = (int)hatx;
|
||||||
android->hat_state[port][1] = (int)haty;
|
android->hat_state[port][1] = (int)haty;
|
||||||
|
|
||||||
// XXX: this could be a loop instead, but do we really want to loop through every axis?
|
/* XXX: this could be a loop instead, but do we really want to
|
||||||
|
* loop through every axis?
|
||||||
|
*/
|
||||||
android->analog_state[port][0] = (int16_t)(x * 32767.0f);
|
android->analog_state[port][0] = (int16_t)(x * 32767.0f);
|
||||||
android->analog_state[port][1] = (int16_t)(y * 32767.0f);
|
android->analog_state[port][1] = (int16_t)(y * 32767.0f);
|
||||||
android->analog_state[port][2] = (int16_t)(z * 32767.0f);
|
android->analog_state[port][2] = (int16_t)(z * 32767.0f);
|
||||||
@ -169,7 +176,8 @@ static void *android_input_init(void)
|
|||||||
static int zeus_id = -1;
|
static int zeus_id = -1;
|
||||||
static int zeus_second_id = -1;
|
static int zeus_second_id = -1;
|
||||||
|
|
||||||
static inline int android_input_poll_event_type_motion(android_input_t *android, AInputEvent *event,
|
static inline int android_input_poll_event_type_motion(
|
||||||
|
android_input_t *android, AInputEvent *event,
|
||||||
int port, int source)
|
int port, int source)
|
||||||
{
|
{
|
||||||
int getaction, action;
|
int getaction, action;
|
||||||
@ -207,23 +215,32 @@ static inline int android_input_poll_event_type_motion(android_input_t *android,
|
|||||||
y = AMotionEvent_getY(event, motion_pointer);
|
y = AMotionEvent_getY(event, motion_pointer);
|
||||||
|
|
||||||
input_translate_coord_viewport(x, y,
|
input_translate_coord_viewport(x, y,
|
||||||
&android->pointer[motion_pointer].x, &android->pointer[motion_pointer].y,
|
&android->pointer[motion_pointer].x,
|
||||||
&android->pointer[motion_pointer].full_x, &android->pointer[motion_pointer].full_y);
|
&android->pointer[motion_pointer].y,
|
||||||
|
&android->pointer[motion_pointer].full_x,
|
||||||
|
&android->pointer[motion_pointer].full_y);
|
||||||
|
|
||||||
android->pointer_count = max(android->pointer_count, motion_pointer + 1);
|
android->pointer_count = max(
|
||||||
|
android->pointer_count,
|
||||||
|
motion_pointer + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void android_input_poll_event_type_key(android_input_t *android, struct android_app *android_app,
|
static inline void android_input_poll_event_type_key(
|
||||||
AInputEvent *event, int port, int keycode, int source, int type_event, int *handled)
|
android_input_t *android, struct android_app *android_app,
|
||||||
|
AInputEvent *event, int port, int keycode, int source,
|
||||||
|
int type_event, int *handled)
|
||||||
{
|
{
|
||||||
int action = AKeyEvent_getAction(event);
|
int action = AKeyEvent_getAction(event);
|
||||||
|
|
||||||
// some controllers send both the up and down events at once when the button is released for "special" buttons, like menu buttons
|
/* some controllers send both the up and down events at once
|
||||||
// work around that by only using down events for meta keys (which get cleared every poll anyway)
|
* when the button is released for "special" buttons, like menu buttons
|
||||||
|
* work around that by only using down events for meta keys (which get
|
||||||
|
* cleared every poll anyway)
|
||||||
|
*/
|
||||||
if (action == AKEY_EVENT_ACTION_UP)
|
if (action == AKEY_EVENT_ACTION_UP)
|
||||||
clear_bit(android->pad_state[port], keycode);
|
clear_bit(android->pad_state[port], keycode);
|
||||||
else if (action == AKEY_EVENT_ACTION_DOWN)
|
else if (action == AKEY_EVENT_ACTION_DOWN)
|
||||||
@ -233,11 +250,13 @@ static inline void android_input_poll_event_type_key(android_input_t *android, s
|
|||||||
*handled = 0;
|
*handled = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int android_input_get_id_port(android_input_t *android, int id, int source)
|
static int android_input_get_id_port(android_input_t *android, int id,
|
||||||
|
int source)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
if (source & (AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD))
|
if (source & (AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_MOUSE |
|
||||||
return 0; // touch overlay is always player 1
|
AINPUT_SOURCE_TOUCHPAD))
|
||||||
|
return 0; /* touch overlay is always player 1 */
|
||||||
|
|
||||||
for (i = 0; i < android->pads_connected; i++)
|
for (i = 0; i < android->pads_connected; i++)
|
||||||
if (android->pad_states[i].id == id)
|
if (android->pad_states[i].id == id)
|
||||||
@ -262,7 +281,8 @@ static bool android_input_lookup_name(char *buf, size_t size, int id)
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
method = NULL;
|
method = NULL;
|
||||||
GET_STATIC_METHOD_ID(env, method, class, "getDevice", "(I)Landroid/view/InputDevice;");
|
GET_STATIC_METHOD_ID(env, method, class, "getDevice",
|
||||||
|
"(I)Landroid/view/InputDevice;");
|
||||||
if (!method)
|
if (!method)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -300,10 +320,9 @@ error:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Returns the index inside android->pad_state */
|
||||||
* Returns the index inside android->pad_states
|
static int android_input_get_id_index_from_name(android_input_t *android,
|
||||||
*/
|
const char *name)
|
||||||
static int android_input_get_id_index_from_name(android_input_t *android, const char *name)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < android->pads_connected; i++)
|
for (i = 0; i < android->pads_connected; i++)
|
||||||
@ -315,7 +334,8 @@ static int android_input_get_id_index_from_name(android_input_t *android, const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_hotplug(android_input_t *android, struct android_app *android_app, unsigned *port, unsigned id,
|
static void handle_hotplug(android_input_t *android,
|
||||||
|
struct android_app *android_app, unsigned *port, unsigned id,
|
||||||
int source)
|
int source)
|
||||||
{
|
{
|
||||||
char device_name[256], name_buf[256];
|
char device_name[256], name_buf[256];
|
||||||
@ -332,8 +352,9 @@ static void handle_hotplug(android_input_t *android, struct android_app *android
|
|||||||
|
|
||||||
android_input_lookup_name(device_name, sizeof(device_name), id);
|
android_input_lookup_name(device_name, sizeof(device_name), id);
|
||||||
|
|
||||||
//FIXME: Ugly hack, see other FIXME note below.
|
/* FIXME: Ugly hack, see other FIXME note below. */
|
||||||
if (strstr(device_name, "keypad-game-zeus") || strstr(device_name, "keypad-zeus"))
|
if (strstr(device_name, "keypad-game-zeus") ||
|
||||||
|
strstr(device_name, "keypad-zeus"))
|
||||||
{
|
{
|
||||||
if (zeus_id < 0)
|
if (zeus_id < 0)
|
||||||
{
|
{
|
||||||
@ -347,7 +368,8 @@ static void handle_hotplug(android_input_t *android, struct android_app *android
|
|||||||
}
|
}
|
||||||
strlcpy(name_buf, "Xperia Play", sizeof(name_buf));
|
strlcpy(name_buf, "Xperia Play", sizeof(name_buf));
|
||||||
}
|
}
|
||||||
else if (strstr(device_name, "iControlPad-")) // followed by a 4 (hex) char HW id
|
/* followed by a 4 (hex) char HW id */
|
||||||
|
else if (strstr(device_name, "iControlPad-"))
|
||||||
strlcpy(name_buf, "iControlPad HID Joystick profile", sizeof(name_buf));
|
strlcpy(name_buf, "iControlPad HID Joystick profile", sizeof(name_buf));
|
||||||
else if (strstr(device_name, "TTT THT Arcade console 2P USB Play"))
|
else if (strstr(device_name, "TTT THT Arcade console 2P USB Play"))
|
||||||
{
|
{
|
||||||
@ -388,8 +410,11 @@ static void handle_hotplug(android_input_t *android, struct android_app *android
|
|||||||
}
|
}
|
||||||
else if (strstr(device_name, "WiseGroup"))
|
else if (strstr(device_name, "WiseGroup"))
|
||||||
{
|
{
|
||||||
if (strstr(device_name, "TigerGame") || strstr(device_name, "Game Controller Adapter")
|
if (
|
||||||
|| strstr(device_name, "JC-PS102U") || strstr(device_name, "Dual USB Joypad"))
|
strstr(device_name, "TigerGame") ||
|
||||||
|
strstr(device_name, "Game Controller Adapter") ||
|
||||||
|
strstr(device_name, "JC-PS102U") ||
|
||||||
|
strstr(device_name, "Dual USB Joypad"))
|
||||||
{
|
{
|
||||||
if (strstr(device_name, "WiseGroup"))
|
if (strstr(device_name, "WiseGroup"))
|
||||||
strlcpy(name_buf, "PlayStation2 WiseGroup", sizeof(name_buf));
|
strlcpy(name_buf, "PlayStation2 WiseGroup", sizeof(name_buf));
|
||||||
@ -399,10 +424,16 @@ static void handle_hotplug(android_input_t *android, struct android_app *android
|
|||||||
strlcpy(name_buf, "PlayStation2 Generic", sizeof(name_buf));
|
strlcpy(name_buf, "PlayStation2 Generic", sizeof(name_buf));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strstr(device_name, "PLAYSTATION(R)3") || strstr(device_name, "Dualshock3")
|
else if (
|
||||||
|| strstr(device_name, "Sixaxis") || strstr(device_name, "Gasia,Co") ||
|
strstr(device_name, "PLAYSTATION(R)3") ||
|
||||||
(strstr(device_name, "Gamepad 0") || strstr(device_name, "Gamepad 1") ||
|
strstr(device_name, "Dualshock3") ||
|
||||||
strstr(device_name, "Gamepad 2") || strstr(device_name, "Gamepad 3")))
|
strstr(device_name, "Sixaxis") ||
|
||||||
|
strstr(device_name, "Gasia,Co") ||
|
||||||
|
(strstr(device_name, "Gamepad 0") ||
|
||||||
|
strstr(device_name, "Gamepad 1") ||
|
||||||
|
strstr(device_name, "Gamepad 2") ||
|
||||||
|
strstr(device_name, "Gamepad 3"))
|
||||||
|
)
|
||||||
strlcpy(name_buf, "PlayStation3", sizeof(name_buf));
|
strlcpy(name_buf, "PlayStation3", sizeof(name_buf));
|
||||||
else if (strstr(device_name, "MOGA"))
|
else if (strstr(device_name, "MOGA"))
|
||||||
strlcpy(name_buf, "Moga IME", sizeof(name_buf));
|
strlcpy(name_buf, "Moga IME", sizeof(name_buf));
|
||||||
@ -418,7 +449,9 @@ static void handle_hotplug(android_input_t *android, struct android_app *android
|
|||||||
strlcpy(name_buf, "JXD S5110B", sizeof(name_buf));
|
strlcpy(name_buf, "JXD S5110B", sizeof(name_buf));
|
||||||
else if (strstr(device_name, "tincore_adc_joystick"))
|
else if (strstr(device_name, "tincore_adc_joystick"))
|
||||||
strlcpy(name_buf, "JXD S5110B (Skelrom)", sizeof(name_buf));
|
strlcpy(name_buf, "JXD S5110B (Skelrom)", sizeof(name_buf));
|
||||||
else if (strstr(device_name, "keypad-zeus") || (strstr(device_name, "keypad-game-zeus")))
|
else if (strstr(device_name, "keypad-zeus") ||
|
||||||
|
(strstr(device_name, "keypad-game-zeus"))
|
||||||
|
)
|
||||||
strlcpy(name_buf, "Xperia Play", sizeof(name_buf));
|
strlcpy(name_buf, "Xperia Play", sizeof(name_buf));
|
||||||
else if (strstr(device_name, "USB Gamepad"))
|
else if (strstr(device_name, "USB Gamepad"))
|
||||||
strlcpy(name_buf, "Thrust Predator", sizeof(name_buf));
|
strlcpy(name_buf, "Thrust Predator", sizeof(name_buf));
|
||||||
@ -426,13 +459,20 @@ static void handle_hotplug(android_input_t *android, struct android_app *android
|
|||||||
strlcpy(name_buf, "JXD S7800B", sizeof(name_buf));
|
strlcpy(name_buf, "JXD S7800B", sizeof(name_buf));
|
||||||
else if (strstr(device_name, "2Axes 11Keys Game Pad"))
|
else if (strstr(device_name, "2Axes 11Keys Game Pad"))
|
||||||
strlcpy(name_buf, "Tomee NES USB", sizeof(name_buf));
|
strlcpy(name_buf, "Tomee NES USB", sizeof(name_buf));
|
||||||
else if (strstr(device_name, "rk29-keypad") || strstr(device_name, "GAMEMID"))
|
else if (
|
||||||
|
strstr(device_name, "rk29-keypad") ||
|
||||||
|
strstr(device_name, "GAMEMID")
|
||||||
|
)
|
||||||
strlcpy(name_buf, "GameMID", sizeof(name_buf));
|
strlcpy(name_buf, "GameMID", sizeof(name_buf));
|
||||||
else if (strstr(device_name, "USB Gamepad"))
|
else if (strstr(device_name, "USB Gamepad"))
|
||||||
strlcpy(name_buf, "Defender Game Racer Classic", sizeof(name_buf));
|
strlcpy(name_buf, "Defender Game Racer Classic", sizeof(name_buf));
|
||||||
else if (strstr(device_name, "NVIDIA Controller"))
|
else if (strstr(device_name, "NVIDIA Controller"))
|
||||||
{
|
{
|
||||||
*port = 0; // Shield is always player 1. FIXME: This is kinda ugly. We really need to find a way to detect useless input devices like gpio-keys in a general way.
|
/* Shield is always player 1. FIXME: This is kinda ugly.
|
||||||
|
* We really need to find a way to detect useless input devices
|
||||||
|
* like gpio-keys in a general way.
|
||||||
|
*/
|
||||||
|
*port = 0;
|
||||||
strlcpy(name_buf, "NVIDIA Shield", sizeof(name_buf));
|
strlcpy(name_buf, "NVIDIA Shield", sizeof(name_buf));
|
||||||
}
|
}
|
||||||
else if (device_name[0] != '\0')
|
else if (device_name[0] != '\0')
|
||||||
@ -450,7 +490,8 @@ static void handle_hotplug(android_input_t *android, struct android_app *android
|
|||||||
|
|
||||||
if (name_buf[0] != '\0')
|
if (name_buf[0] != '\0')
|
||||||
{
|
{
|
||||||
strlcpy(g_settings.input.device_names[*port], name_buf, sizeof(g_settings.input.device_names[*port]));
|
strlcpy(g_settings.input.device_names[*port],
|
||||||
|
name_buf, sizeof(g_settings.input.device_names[*port]));
|
||||||
input_config_autoconfigure_joypad(*port, name_buf, android_joypad.ident);
|
input_config_autoconfigure_joypad(*port, name_buf, android_joypad.ident);
|
||||||
RARCH_LOG("Port %d: %s.\n", *port, name_buf);
|
RARCH_LOG("Port %d: %s.\n", *port, name_buf);
|
||||||
}
|
}
|
||||||
@ -468,67 +509,69 @@ static int android_input_get_id(android_input_t *android, AInputEvent *event)
|
|||||||
{
|
{
|
||||||
int id = AInputEvent_getDeviceId(event);
|
int id = AInputEvent_getDeviceId(event);
|
||||||
|
|
||||||
// Needs to be cleaned up
|
/* Needs to be cleaned up */
|
||||||
if (id == zeus_second_id)
|
if (id == zeus_second_id)
|
||||||
id = zeus_id;
|
id = zeus_id;
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle all events. If our activity is in pause state, block until we're unpaused.
|
/* Handle all events. If our activity is in pause state,
|
||||||
|
* block until we're unpaused.
|
||||||
|
*/
|
||||||
static void android_input_poll(void *data)
|
static void android_input_poll(void *data)
|
||||||
{
|
{
|
||||||
int ident;
|
int ident;
|
||||||
struct android_app *android_app = (struct android_app*)g_android;
|
struct android_app *android_app = (struct android_app*)g_android;
|
||||||
android_input_t *android = (android_input_t*)data;
|
android_input_t *android = (android_input_t*)data;
|
||||||
|
|
||||||
while ((ident = ALooper_pollAll((input_key_pressed_func(RARCH_PAUSE_TOGGLE)) ? -1 : 0,
|
while ((ident = ALooper_pollAll((input_key_pressed_func(RARCH_PAUSE_TOGGLE))
|
||||||
|
? -1 : 0,
|
||||||
NULL, NULL, NULL)) >= 0)
|
NULL, NULL, NULL)) >= 0)
|
||||||
{
|
{
|
||||||
if (ident == LOOPER_ID_INPUT)
|
if (ident == LOOPER_ID_INPUT)
|
||||||
{
|
{
|
||||||
AInputEvent *event = NULL;
|
AInputEvent *event = NULL;
|
||||||
|
|
||||||
// Read all pending events.
|
/* Read all pending events. */
|
||||||
while (AInputQueue_hasEvents(android_app->inputQueue))
|
while (AInputQueue_hasEvents(android_app->inputQueue))
|
||||||
{
|
{
|
||||||
while (AInputQueue_getEvent(android_app->inputQueue, &event) >= 0)
|
while (AInputQueue_getEvent(android_app->inputQueue, &event) >= 0)
|
||||||
{
|
{
|
||||||
int32_t handled = 1;
|
int32_t handled = 1;
|
||||||
int source, id, type_event, port;
|
int predispatched = AInputQueue_preDispatchEvent(android_app->inputQueue, event);
|
||||||
int predispatched;
|
int source = AInputEvent_getSource(event);
|
||||||
|
int type_event = AInputEvent_getType(event);
|
||||||
predispatched = AInputQueue_preDispatchEvent(android_app->inputQueue, event);
|
int id = android_input_get_id(android, event);
|
||||||
|
int port = android_input_get_id_port(android, id, source);
|
||||||
source = AInputEvent_getSource(event);
|
|
||||||
id = android_input_get_id(android, event);
|
|
||||||
|
|
||||||
port = android_input_get_id_port(android, id, source);
|
|
||||||
|
|
||||||
if (port < 0)
|
if (port < 0)
|
||||||
handle_hotplug(android, android_app, &android->pads_connected, id, source);
|
handle_hotplug(android, android_app,
|
||||||
|
&android->pads_connected, id, source);
|
||||||
type_event = AInputEvent_getType(event);
|
|
||||||
|
|
||||||
if (type_event == AINPUT_EVENT_TYPE_MOTION)
|
if (type_event == AINPUT_EVENT_TYPE_MOTION)
|
||||||
{
|
{
|
||||||
if (android_input_poll_event_type_motion(android, event, port, source))
|
if (android_input_poll_event_type_motion(android, event,
|
||||||
|
port, source))
|
||||||
engine_handle_dpad(android, event, port, source);
|
engine_handle_dpad(android, event, port, source);
|
||||||
}
|
}
|
||||||
else if (type_event == AINPUT_EVENT_TYPE_KEY)
|
else if (type_event == AINPUT_EVENT_TYPE_KEY)
|
||||||
{
|
{
|
||||||
int keycode = AKeyEvent_getKeyCode(event);
|
int keycode = AKeyEvent_getKeyCode(event);
|
||||||
android_input_poll_event_type_key(android, android_app, event, port, keycode, source, type_event, &handled);
|
android_input_poll_event_type_key(android, android_app,
|
||||||
|
event, port, keycode, source, type_event, &handled);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!predispatched)
|
if (!predispatched)
|
||||||
AInputQueue_finishEvent(android_app->inputQueue, event, handled);
|
AInputQueue_finishEvent(android_app->inputQueue, event,
|
||||||
|
handled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ident == LOOPER_ID_USER)
|
else if (ident == LOOPER_ID_USER)
|
||||||
{
|
{
|
||||||
if ((android_app->sensor_state_mask & (1ULL << RETRO_SENSOR_ACCELEROMETER_ENABLE))
|
if ((android_app->sensor_state_mask & (1ULL <<
|
||||||
|
RETRO_SENSOR_ACCELEROMETER_ENABLE))
|
||||||
&& android_app->accelerometerSensor)
|
&& android_app->accelerometerSensor)
|
||||||
{
|
{
|
||||||
ASensorEvent event;
|
ASensorEvent event;
|
||||||
@ -545,7 +588,9 @@ static void android_input_poll(void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t android_input_state(void *data, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned index, unsigned id)
|
static int16_t android_input_state(void *data,
|
||||||
|
const struct retro_keybind **binds, unsigned port, unsigned device,
|
||||||
|
unsigned index, unsigned id)
|
||||||
{
|
{
|
||||||
android_input_t *android = (android_input_t*)data;
|
android_input_t *android = (android_input_t*)data;
|
||||||
|
|
||||||
@ -554,7 +599,8 @@ static int16_t android_input_state(void *data, const struct retro_keybind **bind
|
|||||||
case RETRO_DEVICE_JOYPAD:
|
case RETRO_DEVICE_JOYPAD:
|
||||||
return input_joypad_pressed(android->joypad, port, binds[port], id);
|
return input_joypad_pressed(android->joypad, port, binds[port], id);
|
||||||
case RETRO_DEVICE_ANALOG:
|
case RETRO_DEVICE_ANALOG:
|
||||||
return input_joypad_analog(android->joypad, port, index, id, binds[port]);
|
return input_joypad_analog(android->joypad, port, index, id,
|
||||||
|
binds[port]);
|
||||||
case RETRO_DEVICE_POINTER:
|
case RETRO_DEVICE_POINTER:
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
@ -563,7 +609,9 @@ static int16_t android_input_state(void *data, const struct retro_keybind **bind
|
|||||||
case RETRO_DEVICE_ID_POINTER_Y:
|
case RETRO_DEVICE_ID_POINTER_Y:
|
||||||
return android->pointer[index].y;
|
return android->pointer[index].y;
|
||||||
case RETRO_DEVICE_ID_POINTER_PRESSED:
|
case RETRO_DEVICE_ID_POINTER_PRESSED:
|
||||||
return (index < android->pointer_count) && (android->pointer[index].x != -0x8000) && (android->pointer[index].y != -0x8000);
|
return (index < android->pointer_count) &&
|
||||||
|
(android->pointer[index].x != -0x8000) &&
|
||||||
|
(android->pointer[index].y != -0x8000);
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -576,7 +624,9 @@ static int16_t android_input_state(void *data, const struct retro_keybind **bind
|
|||||||
case RETRO_DEVICE_ID_POINTER_Y:
|
case RETRO_DEVICE_ID_POINTER_Y:
|
||||||
return android->pointer[index].full_y;
|
return android->pointer[index].full_y;
|
||||||
case RETRO_DEVICE_ID_POINTER_PRESSED:
|
case RETRO_DEVICE_ID_POINTER_PRESSED:
|
||||||
return (index < android->pointer_count) && (android->pointer[index].full_x != -0x8000) && (android->pointer[index].full_y != -0x8000);
|
return (index < android->pointer_count) &&
|
||||||
|
(android->pointer[index].full_x != -0x8000) &&
|
||||||
|
(android->pointer[index].full_y != -0x8000);
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -591,8 +641,9 @@ static bool android_input_key_pressed(void *data, int key)
|
|||||||
android_input_t *android = (android_input_t*)data;
|
android_input_t *android = (android_input_t*)data;
|
||||||
if (!android)
|
if (!android)
|
||||||
return false;
|
return false;
|
||||||
return ((g_extern.lifecycle_state | driver.overlay_state.buttons) & (1ULL << key))
|
return ((g_extern.lifecycle_state | driver.overlay_state.buttons)
|
||||||
|| input_joypad_pressed(android->joypad, 0, g_settings.input.binds[0], key);
|
& (1ULL << key)) || input_joypad_pressed(android->joypad,
|
||||||
|
0, g_settings.input.binds[0], key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_input_free_input(void *data)
|
static void android_input_free_input(void *data)
|
||||||
@ -602,7 +653,8 @@ static void android_input_free_input(void *data)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (android->sensorManager)
|
if (android->sensorManager)
|
||||||
ASensorManager_destroyEventQueue(android->sensorManager, android->sensorEventQueue);
|
ASensorManager_destroyEventQueue(android->sensorManager,
|
||||||
|
android->sensorEventQueue);
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
}
|
}
|
||||||
@ -624,13 +676,16 @@ static void android_input_enable_sensor_manager(void *data)
|
|||||||
struct android_app *android_app = (struct android_app*)g_android;
|
struct android_app *android_app = (struct android_app*)g_android;
|
||||||
|
|
||||||
android->sensorManager = ASensorManager_getInstance();
|
android->sensorManager = ASensorManager_getInstance();
|
||||||
android_app->accelerometerSensor = ASensorManager_getDefaultSensor(android->sensorManager,
|
android_app->accelerometerSensor =
|
||||||
|
ASensorManager_getDefaultSensor(android->sensorManager,
|
||||||
ASENSOR_TYPE_ACCELEROMETER);
|
ASENSOR_TYPE_ACCELEROMETER);
|
||||||
android->sensorEventQueue = ASensorManager_createEventQueue(android->sensorManager,
|
android->sensorEventQueue =
|
||||||
|
ASensorManager_createEventQueue(android->sensorManager,
|
||||||
android_app->looper, LOOPER_ID_USER, NULL, NULL);
|
android_app->looper, LOOPER_ID_USER, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool android_input_set_sensor_state(void *data, unsigned port, enum retro_sensor_action action, unsigned event_rate)
|
static bool android_input_set_sensor_state(void *data, unsigned port,
|
||||||
|
enum retro_sensor_action action, unsigned event_rate)
|
||||||
{
|
{
|
||||||
android_input_t *android = (android_input_t*)data;
|
android_input_t *android = (android_input_t*)data;
|
||||||
struct android_app *android_app = (struct android_app*)g_android;
|
struct android_app *android_app = (struct android_app*)g_android;
|
||||||
@ -651,7 +706,8 @@ static bool android_input_set_sensor_state(void *data, unsigned port, enum retro
|
|||||||
// events per second (in us).
|
// events per second (in us).
|
||||||
if (android_app->accelerometerSensor)
|
if (android_app->accelerometerSensor)
|
||||||
ASensorEventQueue_setEventRate(android->sensorEventQueue,
|
ASensorEventQueue_setEventRate(android->sensorEventQueue,
|
||||||
android_app->accelerometerSensor, (1000L / event_rate) * 1000);
|
android_app->accelerometerSensor, (1000L / event_rate)
|
||||||
|
* 1000);
|
||||||
|
|
||||||
android_app->sensor_state_mask &= ~(1ULL << RETRO_SENSOR_ACCELEROMETER_DISABLE);
|
android_app->sensor_state_mask &= ~(1ULL << RETRO_SENSOR_ACCELEROMETER_DISABLE);
|
||||||
android_app->sensor_state_mask |= (1ULL << RETRO_SENSOR_ACCELEROMETER_ENABLE);
|
android_app->sensor_state_mask |= (1ULL << RETRO_SENSOR_ACCELEROMETER_ENABLE);
|
||||||
@ -672,7 +728,8 @@ static bool android_input_set_sensor_state(void *data, unsigned port, enum retro
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float android_input_get_sensor_input(void *data, unsigned port, unsigned id)
|
static float android_input_get_sensor_input(void *data,
|
||||||
|
unsigned port,unsigned id)
|
||||||
{
|
{
|
||||||
android_input_t *android = (android_input_t*)data;
|
android_input_t *android = (android_input_t*)data;
|
||||||
|
|
||||||
@ -722,8 +779,12 @@ static bool android_joypad_init(void)
|
|||||||
|
|
||||||
for (autoconf_pad = 0; autoconf_pad < MAX_PLAYERS; autoconf_pad++)
|
for (autoconf_pad = 0; autoconf_pad < MAX_PLAYERS; autoconf_pad++)
|
||||||
{
|
{
|
||||||
strlcpy(g_settings.input.device_names[autoconf_pad], android_joypad_name(autoconf_pad), sizeof(g_settings.input.device_names[autoconf_pad]));
|
strlcpy(g_settings.input.device_names[autoconf_pad],
|
||||||
input_config_autoconfigure_joypad(autoconf_pad, android_joypad_name(autoconf_pad), android_joypad.ident);
|
android_joypad_name(autoconf_pad),
|
||||||
|
sizeof(g_settings.input.device_names[autoconf_pad]));
|
||||||
|
input_config_autoconfigure_joypad(autoconf_pad,
|
||||||
|
android_joypad_name(autoconf_pad),
|
||||||
|
android_joypad.ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
engine_handle_dpad = engine_handle_dpad_default;
|
engine_handle_dpad = engine_handle_dpad_default;
|
||||||
@ -733,7 +794,8 @@ static bool android_joypad_init(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((p_AMotionEvent_getAxisValue = dlsym(RTLD_DEFAULT, "AMotionEvent_getAxisValue")))
|
if ((p_AMotionEvent_getAxisValue = dlsym(RTLD_DEFAULT,
|
||||||
|
"AMotionEvent_getAxisValue")))
|
||||||
{
|
{
|
||||||
RARCH_LOG("Set engine_handle_dpad to 'Get Axis Value' (for reading extra analog sticks)");
|
RARCH_LOG("Set engine_handle_dpad to 'Get Axis Value' (for reading extra analog sticks)");
|
||||||
engine_handle_dpad = engine_handle_dpad_getaxisvalue;
|
engine_handle_dpad = engine_handle_dpad_getaxisvalue;
|
||||||
@ -764,7 +826,8 @@ static bool android_joypad_button(unsigned port_num, uint16_t joykey)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return joykey < LAST_KEYCODE && get_bit(android->pad_state[port_num], joykey);
|
return joykey < LAST_KEYCODE && get_bit(android->pad_state[port_num],
|
||||||
|
joykey);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t android_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
static int16_t android_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user