mirror of
https://github.com/libretro/RetroArch
synced 2025-04-16 08:43:10 +00:00
(Xinput) This variable doesn't need to be set at every button call
This commit is contained in:
parent
02876aecae
commit
e0672e46a5
@ -129,7 +129,8 @@ typedef uint32_t (__stdcall *XInputSetState_t)(uint32_t, XINPUT_VIBRATION*);
|
|||||||
static XInputSetState_t g_XInputSetState;
|
static XInputSetState_t g_XInputSetState;
|
||||||
|
|
||||||
/* Guide button may or may not be available */
|
/* Guide button may or may not be available */
|
||||||
static bool g_xinput_guide_button_supported;
|
static bool g_xinput_guide_button_supported = false;
|
||||||
|
static unsigned g_xinput_num_buttons = 0;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -229,7 +230,7 @@ static bool xinput_joypad_init(void *data)
|
|||||||
#if defined(HAVE_DYNAMIC) && !defined(__WINRT__)
|
#if defined(HAVE_DYNAMIC) && !defined(__WINRT__)
|
||||||
if (!g_xinput_dll)
|
if (!g_xinput_dll)
|
||||||
if (!load_xinput_dll())
|
if (!load_xinput_dll())
|
||||||
return false;
|
goto error;
|
||||||
|
|
||||||
/* If we get here then an xinput DLL is correctly loaded.
|
/* If we get here then an xinput DLL is correctly loaded.
|
||||||
* First try to load ordinal 100 (XInputGetStateEx).
|
* First try to load ordinal 100 (XInputGetStateEx).
|
||||||
@ -264,7 +265,7 @@ static bool xinput_joypad_init(void *data)
|
|||||||
dylib_close(g_xinput_dll);
|
dylib_close(g_xinput_dll);
|
||||||
#endif
|
#endif
|
||||||
/* DLL was loaded but did not contain the correct function. */
|
/* DLL was loaded but did not contain the correct function. */
|
||||||
return false;
|
goto error;
|
||||||
}
|
}
|
||||||
RARCH_WARN("[XInput]: No guide button support.\n");
|
RARCH_WARN("[XInput]: No guide button support.\n");
|
||||||
}
|
}
|
||||||
@ -281,7 +282,7 @@ static bool xinput_joypad_init(void *data)
|
|||||||
#if defined(HAVE_DYNAMIC) && !defined(__WINRT__)
|
#if defined(HAVE_DYNAMIC) && !defined(__WINRT__)
|
||||||
dylib_close(g_xinput_dll);
|
dylib_close(g_xinput_dll);
|
||||||
#endif
|
#endif
|
||||||
return false; /* DLL was loaded but did not contain the correct function. */
|
goto error; /* DLL was loaded but did not contain the correct function. */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Zero out the states. */
|
/* Zero out the states. */
|
||||||
@ -301,9 +302,9 @@ static bool xinput_joypad_init(void *data)
|
|||||||
(!g_xinput_states[2].connected) &&
|
(!g_xinput_states[2].connected) &&
|
||||||
(!g_xinput_states[3].connected))
|
(!g_xinput_states[3].connected))
|
||||||
#ifdef __WINRT__
|
#ifdef __WINRT__
|
||||||
return true;
|
goto succeeded;
|
||||||
#else
|
#else
|
||||||
return false;
|
goto error;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RARCH_LOG("[XInput]: Pads connected: %d\n",
|
RARCH_LOG("[XInput]: Pads connected: %d\n",
|
||||||
@ -320,7 +321,7 @@ static bool xinput_joypad_init(void *data)
|
|||||||
if (!dinput_joypad.init(data))
|
if (!dinput_joypad.init(data))
|
||||||
{
|
{
|
||||||
g_xinput_block_pads = false;
|
g_xinput_block_pads = false;
|
||||||
return false;
|
goto error;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -355,7 +356,17 @@ static bool xinput_joypad_init(void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __WINRT__
|
||||||
|
succeeded:
|
||||||
|
#endif
|
||||||
|
/* non-hat button. */
|
||||||
|
g_xinput_num_buttons = g_xinput_guide_button_supported ? 11 : 10;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
error:
|
||||||
|
/* non-hat button. */
|
||||||
|
g_xinput_num_buttons = g_xinput_guide_button_supported ? 11 : 10;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool xinput_joypad_query_pad(unsigned pad)
|
static bool xinput_joypad_query_pad(unsigned pad)
|
||||||
@ -413,7 +424,6 @@ static const uint16_t button_index_to_bitmap_code[] = {
|
|||||||
static bool xinput_joypad_button(unsigned port_num, uint16_t joykey)
|
static bool xinput_joypad_button(unsigned port_num, uint16_t joykey)
|
||||||
{
|
{
|
||||||
uint16_t btn_word = 0;
|
uint16_t btn_word = 0;
|
||||||
unsigned num_buttons = 0;
|
|
||||||
unsigned hat_dir = 0;
|
unsigned hat_dir = 0;
|
||||||
int xuser = pad_index_to_xuser_index(port_num);
|
int xuser = pad_index_to_xuser_index(port_num);
|
||||||
|
|
||||||
@ -445,10 +455,7 @@ static bool xinput_joypad_button(unsigned port_num, uint16_t joykey)
|
|||||||
return false; /* hat requested and no hat button down. */
|
return false; /* hat requested and no hat button down. */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* non-hat button. */
|
if (joykey < g_xinput_num_buttons)
|
||||||
num_buttons = g_xinput_guide_button_supported ? 11 : 10;
|
|
||||||
|
|
||||||
if (joykey < num_buttons)
|
|
||||||
return btn_word & button_index_to_bitmap_code[joykey];
|
return btn_word & button_index_to_bitmap_code[joykey];
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user