(Android) Input - cleanups

This commit is contained in:
twinaphex 2014-06-11 08:23:00 +02:00
parent 4d29cff96f
commit e0111e9ade
1 changed files with 34 additions and 54 deletions

View File

@ -200,12 +200,10 @@ enum
typedef struct android_input typedef struct android_input
{ {
//jmethodID onBackPressed;
unsigned pads_connected; unsigned pads_connected;
int state_device_ids[MAX_PADS]; int state_device_ids[MAX_PADS];
uint8_t pad_state[MAX_PADS][(LAST_KEYCODE + 7) / 8]; uint8_t pad_state[MAX_PADS][(LAST_KEYCODE + 7) / 8];
uint64_t keycode_lut[LAST_KEYCODE];
int16_t analog_state[MAX_PADS][MAX_AXIS]; int16_t analog_state[MAX_PADS][MAX_AXIS];
sensor_t accelerometer_state; sensor_t accelerometer_state;
struct input_pointer pointer[MAX_TOUCH]; struct input_pointer pointer[MAX_TOUCH];
@ -299,29 +297,8 @@ static void *android_input_init(void)
return NULL; return NULL;
android->pads_connected = 0; android->pads_connected = 0;
android->joypad = input_joypad_init_driver(g_settings.input.joypad_driver); android->joypad = input_joypad_init_driver(g_settings.input.joypad_driver);
#if 0
JNIEnv *env;
jclass class;
env = jni_thread_getenv();
if (!env)
goto retobj;
GET_OBJECT_CLASS(env, class, android_app->activity->clazz);
if (!class)
goto retobj;
GET_METHOD_ID(env, android->onBackPressed, class, "onBackPressed", "()V");
if (!android->onBackPressed)
{
RARCH_ERR("Could not set onBackPressed JNI function pointer.\n");
goto retobj;
}
#endif
return android; return android;
} }
@ -332,18 +309,22 @@ static unsigned zeus_port;
static int android_input_poll_event_type_motion(android_input_t *android, AInputEvent *event, static int android_input_poll_event_type_motion(android_input_t *android, AInputEvent *event,
float *x, float *y, int port, int source) float *x, float *y, int port, int source)
{ {
int getaction, action;
size_t motion_pointer;
bool keyup;
if (source & ~(AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_MOUSE)) if (source & ~(AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_MOUSE))
{
return 1; return 1;
}
else getaction = AMotionEvent_getAction(event);
{ action = getaction & AMOTION_EVENT_ACTION_MASK;
int getaction = AMotionEvent_getAction(event); motion_pointer = getaction >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
int action = getaction & AMOTION_EVENT_ACTION_MASK; keyup = (
size_t motion_pointer = getaction >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; action == AMOTION_EVENT_ACTION_UP ||
bool keyup = (action == AMOTION_EVENT_ACTION_UP || action == AMOTION_EVENT_ACTION_CANCEL ||
action == AMOTION_EVENT_ACTION_CANCEL || action == AMOTION_EVENT_ACTION_POINTER_UP) || action == AMOTION_EVENT_ACTION_POINTER_UP) ||
(source == AINPUT_SOURCE_MOUSE && action != AMOTION_EVENT_ACTION_DOWN); (source == AINPUT_SOURCE_MOUSE &&
action != AMOTION_EVENT_ACTION_DOWN);
if (keyup && motion_pointer < MAX_TOUCH) if (keyup && motion_pointer < MAX_TOUCH)
{ {
@ -368,7 +349,6 @@ static int android_input_poll_event_type_motion(android_input_t *android, AInput
android->pointer_count = max(android->pointer_count, motion_pointer + 1); android->pointer_count = max(android->pointer_count, motion_pointer + 1);
} }
} }
}
return 0; return 0;
} }
@ -385,7 +365,7 @@ static void android_input_poll_event_type_key(android_input_t *android, struct a
else if (action == AKEY_EVENT_ACTION_DOWN) else if (action == AKEY_EVENT_ACTION_DOWN)
set_bit(android->pad_state[port], keycode); set_bit(android->pad_state[port], keycode);
if ((keycode == AKEYCODE_VOLUME_UP || keycode == AKEYCODE_VOLUME_DOWN))// && android->keycode_lut[keycode] == 0) if ((keycode == AKEYCODE_VOLUME_UP || keycode == AKEYCODE_VOLUME_DOWN))
*handled = 0; *handled = 0;
} }