mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-09 02:48:54 +00:00
Simplify cocoa_input
This commit is contained in:
parent
afd6a2bec5
commit
c3f5c499f3
@ -291,7 +291,9 @@ static int16_t cocoa_input_state(void *data,
|
||||
switch (device)
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
return apple_input_is_pressed(port, binds[port], id) ||
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
return apple_key_state[rarch_keysym_lut[binds[id].key]];
|
||||
return
|
||||
input_joypad_pressed(apple->joypad, joypad_info, port, binds[port], id)
|
||||
#ifdef HAVE_MFI
|
||||
|| input_joypad_pressed(apple->sec_joypad, joypad_info, port, binds[port], id)
|
||||
@ -308,7 +310,7 @@ static int16_t cocoa_input_state(void *data,
|
||||
idx, id, binds[port]);
|
||||
return ret;
|
||||
case RETRO_DEVICE_KEYBOARD:
|
||||
return apple_keyboard_state(id);
|
||||
return (id < RETROK_LAST) && apple_key_state[rarch_keysym_lut[(enum retro_key)id]];
|
||||
case RETRO_DEVICE_MOUSE:
|
||||
return cocoa_mouse_state(apple, id);
|
||||
case RARCH_DEVICE_MOUSE_SCREEN:
|
||||
@ -328,6 +330,7 @@ static bool cocoa_input_meta_key_pressed(void *data, int key)
|
||||
|
||||
static void cocoa_input_free(void *data)
|
||||
{
|
||||
unsigned i;
|
||||
cocoa_input_data_t *apple = (cocoa_input_data_t*)data;
|
||||
|
||||
if (!apple || !data)
|
||||
@ -339,7 +342,9 @@ static void cocoa_input_free(void *data)
|
||||
if (apple->sec_joypad)
|
||||
apple->sec_joypad->destroy();
|
||||
|
||||
apple_keyboard_free();
|
||||
for (i = 0; i < MAX_KEYS; i++)
|
||||
apple_key_state[i] = 0;
|
||||
|
||||
free(apple);
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ static const unsigned char MAC_NATIVE_TO_HID[128] = {
|
||||
#define HIDKEY(X) (X < 128) ? MAC_NATIVE_TO_HID[X] : 0
|
||||
#endif
|
||||
|
||||
static uint32_t apple_key_state[MAX_KEYS];
|
||||
uint32_t apple_key_state[MAX_KEYS];
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
static bool handle_small_keyboard(unsigned* code, bool down)
|
||||
@ -306,24 +306,6 @@ void apple_input_keyboard_event(bool down,
|
||||
character, (enum retro_mod)mod, device);
|
||||
}
|
||||
|
||||
int16_t apple_input_is_pressed(unsigned port_num,
|
||||
const struct retro_keybind *binds, unsigned id)
|
||||
{
|
||||
if (id < RARCH_BIND_LIST_END)
|
||||
{
|
||||
const struct retro_keybind *bind = &binds[id];
|
||||
unsigned bit = rarch_keysym_lut[bind->key];
|
||||
return apple_key_state[bit];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int16_t apple_keyboard_state(unsigned id)
|
||||
{
|
||||
unsigned bit = rarch_keysym_lut[(enum retro_key)id];
|
||||
return (id < RETROK_LAST) && apple_key_state[bit];
|
||||
}
|
||||
|
||||
int32_t apple_keyboard_find_any_key(void)
|
||||
{
|
||||
unsigned i;
|
||||
@ -334,10 +316,3 @@ int32_t apple_keyboard_find_any_key(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void apple_keyboard_free(void)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < MAX_KEYS; i++)
|
||||
apple_key_state[i] = 0;
|
||||
}
|
||||
|
@ -170,14 +170,9 @@ RETRO_BEGIN_DECLS
|
||||
void apple_input_keyboard_event(bool down,
|
||||
unsigned code, uint32_t character, uint32_t mod, unsigned device);
|
||||
|
||||
int16_t apple_input_is_pressed(unsigned port_num,
|
||||
const struct retro_keybind *binds, unsigned id);
|
||||
|
||||
int16_t apple_keyboard_state(unsigned id);
|
||||
|
||||
int32_t apple_keyboard_find_any_key(void);
|
||||
|
||||
void apple_keyboard_free(void);
|
||||
extern uint32_t apple_key_state[MAX_KEYS];
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user