(HID) Cleanups

This commit is contained in:
Twinaphex 2015-04-01 23:16:43 +02:00
parent 4ec9a7542c
commit 05db495f63
3 changed files with 9 additions and 53 deletions

View File

@ -424,9 +424,11 @@ static int apple_hid_manager_set_device_matching(apple_hid_t *hid)
return 0; return 0;
} }
static void *apple_hid_init(void) static bool apple_hid_init(void *data)
{ {
apple_hid_t *hid_apple = (apple_hid_t*)calloc(1, sizeof(*hid_apple)); apple_hid_t *hid_apple = (apple_hid_t*)data;
hid_apple = (apple_hid_t*)calloc(1, sizeof(*hid_apple));
if (!hid_apple) if (!hid_apple)
goto error; goto error;
@ -437,12 +439,12 @@ static void *apple_hid_init(void)
hid_apple->slots = (joypad_connection_t*)pad_connection_init(MAX_USERS); hid_apple->slots = (joypad_connection_t*)pad_connection_init(MAX_USERS);
return hid_apple; return true;
error: error:
if (hid_apple) if (hid_apple)
free(hid_apple); free(hid_apple);
return NULL; return false;
} }
static void apple_hid_free(void *data) static void apple_hid_free(void *data)

View File

@ -103,39 +103,6 @@ const char* config_get_hid_driver_options(void)
return options; return options;
} }
/**
* input_hid_init_driver:
* @ident : identifier of driver to initialize.
*
* Initialize a HID driver of name @ident.
*
* If ident points to NULL or a zero-length string,
* equivalent to calling input_hid_init_first().
*
* Returns: HID driver if found, otherwise NULL.
**/
const hid_driver_t *input_hid_init_driver(const char *ident)
{
unsigned i;
driver_t *driver = driver_get_ptr();
if (!ident || !*ident)
return input_hid_init_first(driver->hid_data);
for (i = 0; hid_drivers[i]; i++)
{
if (strcmp(ident, hid_drivers[i]->ident) == 0
&& hid_drivers[i]->init())
{
RARCH_LOG("Found HID driver: \"%s\".\n",
hid_drivers[i]->ident);
return hid_drivers[i];
}
}
return input_hid_init_first(driver->hid_data);
}
/** /**
* input_hid_init_first: * input_hid_init_first:
* *
@ -149,9 +116,9 @@ const hid_driver_t *input_hid_init_first(void *data)
for (i = 0; hid_drivers[i]; i++) for (i = 0; hid_drivers[i]; i++)
{ {
data = hid_drivers[i]->init(); bool ret = hid_drivers[i]->init(data);
if (data) if (ret)
{ {
RARCH_LOG("Found HID driver: \"%s\".\n", RARCH_LOG("Found HID driver: \"%s\".\n",
hid_drivers[i]->ident); hid_drivers[i]->ident);

View File

@ -30,7 +30,7 @@ typedef struct hid_driver hid_driver_t;
struct hid_driver struct hid_driver
{ {
void *(*init)(void); bool (*init)(void *);
bool (*query_pad)(void *, unsigned); bool (*query_pad)(void *, unsigned);
void (*free)(void *); void (*free)(void *);
bool (*button)(void *, unsigned, uint16_t); bool (*button)(void *, unsigned, uint16_t);
@ -72,19 +72,6 @@ const char *hid_driver_find_ident(int index);
**/ **/
const char* config_get_hid_driver_options(void); const char* config_get_hid_driver_options(void);
/**
* input_hid_init_driver:
* @ident : identifier of driver to initialize.
*
* Initialize a HID driver of name @ident.
*
* If ident points to NULL or a zero-length string,
* equivalent to calling input_hid_init_first().
*
* Returns: HID driver if found, otherwise NULL.
**/
const hid_driver_t *input_hid_init_driver(const char *ident);
/** /**
* input_hid_init_first: * input_hid_init_first:
* *