mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-23 11:18:25 +00:00
(hid_joypad.c) Prevent null pointer dereferences
This commit is contained in:
parent
7197be5a0d
commit
ce2fbbdbe2
@ -18,7 +18,7 @@
|
||||
#include "../input_hid_driver.h"
|
||||
#include "../input_driver.h"
|
||||
|
||||
static const hid_driver_t *generic_hid;
|
||||
static const hid_driver_t *generic_hid = NULL;
|
||||
|
||||
static bool hid_joypad_init(void *data)
|
||||
{
|
||||
@ -33,7 +33,9 @@ static bool hid_joypad_init(void *data)
|
||||
|
||||
static bool hid_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
if (generic_hid && generic_hid->query_pad)
|
||||
return generic_hid->query_pad((void*)hid_driver_get_data(), pad);
|
||||
return false;
|
||||
}
|
||||
|
||||
static void hid_joypad_free(void)
|
||||
@ -49,28 +51,37 @@ static void hid_joypad_free(void)
|
||||
|
||||
static bool hid_joypad_button(unsigned port, uint16_t joykey)
|
||||
{
|
||||
if (generic_hid && generic_hid->button)
|
||||
return generic_hid->button((void*)hid_driver_get_data(), port, joykey);
|
||||
return false;
|
||||
}
|
||||
|
||||
static uint64_t hid_joypad_get_buttons(unsigned port)
|
||||
{
|
||||
if (generic_hid && generic_hid->get_buttons)
|
||||
return generic_hid->get_buttons((void*)hid_driver_get_data(), port);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t hid_joypad_axis(unsigned port, uint32_t joyaxis)
|
||||
{
|
||||
if (generic_hid && generic_hid->axis)
|
||||
return generic_hid->axis((void*)hid_driver_get_data(), port, joyaxis);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void hid_joypad_poll(void)
|
||||
{
|
||||
if (generic_hid && generic_hid->poll)
|
||||
generic_hid->poll((void*)hid_driver_get_data());
|
||||
}
|
||||
|
||||
static bool hid_joypad_rumble(unsigned pad,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
if (generic_hid && generic_hid->set_rumble)
|
||||
return generic_hid->set_rumble((void*)hid_driver_get_data(), pad, effect, strength);
|
||||
return false;
|
||||
}
|
||||
|
||||
static const char *hid_joypad_name(unsigned pad)
|
||||
|
Loading…
Reference in New Issue
Block a user