(Apple) Input cleanups

This commit is contained in:
twinaphex 2015-02-11 02:16:33 +01:00
parent 639fc61f60
commit 8fca12257a

View File

@ -247,14 +247,13 @@ static void apple_input_poll(void *data)
return; return;
for (i = 0; i < apple->touch_count; i++) for (i = 0; i < apple->touch_count; i++)
{ input_translate_coord_viewport(
input_translate_coord_viewport(apple->touches[i].screen_x, apple->touches[i].screen_x,
apple->touches[i].screen_y, apple->touches[i].screen_y,
&apple->touches[i].fixed_x, &apple->touches[i].fixed_x,
&apple->touches[i].fixed_y, &apple->touches[i].fixed_y,
&apple->touches[i].full_x, &apple->touches[i].full_x,
&apple->touches[i].full_y); &apple->touches[i].full_y);
}
if (apple->joypad) if (apple->joypad)
apple->joypad->poll(); apple->joypad->poll();
@ -293,8 +292,14 @@ static int16_t apple_pointer_state(apple_input_data_t *apple,
{ {
const apple_touch_data_t *touch = (const apple_touch_data_t *) const apple_touch_data_t *touch = (const apple_touch_data_t *)
&apple->touches[idx]; &apple->touches[idx];
int16_t x = want_full ? touch->full_x : touch->fixed_x; int16_t x = touch->fixed_x;
int16_t y = want_full ? touch->full_y : touch->fixed_y; int16_t y = touch->fixed_y;
if (want_full)
{
x = touch->full_x;
y = touch->full_y;
}
switch (id) switch (id)
{ {
@ -310,6 +315,12 @@ static int16_t apple_pointer_state(apple_input_data_t *apple,
return 0; return 0;
} }
static int16_t apple_keyboard_state(apple_input_data_t *apple, unsigned id)
{
unsigned bit = input_keymaps_translate_rk_to_keysym((enum retro_key)id);
return (id < RETROK_LAST) && apple->key_state[bit];
}
static int16_t apple_input_state(void *data, static int16_t apple_input_state(void *data,
const struct retro_keybind **binds, unsigned port, const struct retro_keybind **binds, unsigned port,
unsigned device, unsigned idx, unsigned id) unsigned device, unsigned idx, unsigned id)
@ -328,10 +339,7 @@ static int16_t apple_input_state(void *data,
return input_joypad_analog(apple->joypad, port, return input_joypad_analog(apple->joypad, port,
idx, id, binds[port]); idx, id, binds[port]);
case RETRO_DEVICE_KEYBOARD: case RETRO_DEVICE_KEYBOARD:
{ return apple_keyboard_state(apple, id);
unsigned bit = input_keymaps_translate_rk_to_keysym((enum retro_key)id);
return (id < RETROK_LAST) && apple->key_state[bit];
}
case RETRO_DEVICE_MOUSE: case RETRO_DEVICE_MOUSE:
return apple_mouse_state(apple, id); return apple_mouse_state(apple, id);
case RETRO_DEVICE_POINTER: case RETRO_DEVICE_POINTER: