mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 00:32:49 +00:00
(Dinput) get rid of memsets
This commit is contained in:
parent
b4be553ccc
commit
aa4f84b037
@ -193,12 +193,14 @@ static void *dinput_init(const char *joypad_driver)
|
||||
|
||||
static void dinput_poll(void *data)
|
||||
{
|
||||
unsigned i;
|
||||
struct dinput_input *di = (struct dinput_input*)data;
|
||||
|
||||
if (!di)
|
||||
return;
|
||||
|
||||
memset(di->state, 0, sizeof(di->state));
|
||||
for (i = 0; i < 256; i++)
|
||||
di->state[i] = 0;
|
||||
if (di->keyboard)
|
||||
{
|
||||
if (FAILED(IDirectInputDevice8_GetDeviceState(
|
||||
@ -207,7 +209,10 @@ static void dinput_poll(void *data)
|
||||
IDirectInputDevice8_Acquire(di->keyboard);
|
||||
if (FAILED(IDirectInputDevice8_GetDeviceState(
|
||||
di->keyboard, sizeof(di->state), di->state)))
|
||||
memset(di->state, 0, sizeof(di->state));
|
||||
{
|
||||
for (i = 0; i < 256; i++)
|
||||
di->state[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,7 +224,11 @@ static void dinput_poll(void *data)
|
||||
point.x = 0;
|
||||
point.y = 0;
|
||||
|
||||
memset(&mouse_state, 0, sizeof(mouse_state));
|
||||
mouse_state.lX = 0;
|
||||
mouse_state.lY = 0;
|
||||
mouse_state.lZ = 0;
|
||||
for (i = 0; i < 8; i++)
|
||||
mouse_state.rgbButtons[i] = 0;
|
||||
|
||||
if (FAILED(IDirectInputDevice8_GetDeviceState(
|
||||
di->mouse, sizeof(mouse_state), &mouse_state)))
|
||||
@ -227,7 +236,13 @@ static void dinput_poll(void *data)
|
||||
IDirectInputDevice8_Acquire(di->mouse);
|
||||
if (FAILED(IDirectInputDevice8_GetDeviceState(
|
||||
di->mouse, sizeof(mouse_state), &mouse_state)))
|
||||
memset(&mouse_state, 0, sizeof(mouse_state));
|
||||
{
|
||||
mouse_state.lX = 0;
|
||||
mouse_state.lY = 0;
|
||||
mouse_state.lZ = 0;
|
||||
for (i = 0; i < 8; i++)
|
||||
mouse_state.rgbButtons[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
di->mouse_rel_x = mouse_state.lX;
|
||||
|
@ -195,14 +195,12 @@ static BOOL CALLBACK enum_axes_cb(
|
||||
DIPROPRANGE range;
|
||||
LPDIRECTINPUTDEVICE8 joypad = (LPDIRECTINPUTDEVICE8)p;
|
||||
|
||||
memset(&range, 0, sizeof(range));
|
||||
|
||||
range.diph.dwSize = sizeof(DIPROPRANGE);
|
||||
range.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
||||
range.diph.dwHow = DIPH_BYID;
|
||||
range.diph.dwObj = inst->dwType;
|
||||
range.lMin = -0x7fff;
|
||||
range.lMax = 0x7fff;
|
||||
range.diph.dwSize = sizeof(DIPROPRANGE);
|
||||
range.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
||||
range.diph.dwHow = DIPH_BYID;
|
||||
range.diph.dwObj = inst->dwType;
|
||||
range.lMin = -0x7fff;
|
||||
range.lMax = 0x7fff;
|
||||
|
||||
IDirectInputDevice8_SetProperty(joypad, DIPROP_RANGE, &range.diph);
|
||||
|
||||
@ -570,14 +568,52 @@ static void dinput_joypad_poll(void)
|
||||
unsigned i;
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
{
|
||||
unsigned j;
|
||||
HRESULT ret;
|
||||
struct dinput_joypad_data *pad = &g_pads[i];
|
||||
bool polled = g_xinput_pad_indexes[i] < 0;
|
||||
struct dinput_joypad_data *pad = &g_pads[i];
|
||||
bool polled = g_xinput_pad_indexes[i] < 0;
|
||||
|
||||
if (!pad || !pad->joypad || !polled)
|
||||
continue;
|
||||
|
||||
memset(&pad->joy_state, 0, sizeof(pad->joy_state));
|
||||
pad->joy_state.lX = 0;
|
||||
pad->joy_state.lY = 0;
|
||||
pad->joy_state.lRx = 0;
|
||||
pad->joy_state.lRy = 0;
|
||||
pad->joy_state.lRz = 0;
|
||||
pad->joy_state.rglSlider[0] = 0;
|
||||
pad->joy_state.rglSlider[1] = 0;
|
||||
pad->joy_state.rgdwPOV[0] = 0;
|
||||
pad->joy_state.rgdwPOV[1] = 0;
|
||||
pad->joy_state.rgdwPOV[2] = 0;
|
||||
pad->joy_state.rgdwPOV[3] = 0;
|
||||
for (j = 0; j < 128; j++)
|
||||
pad->joy_state.rgbButtons[j] = 0;
|
||||
|
||||
pad->joy_state.lVX = 0;
|
||||
pad->joy_state.lVY = 0;
|
||||
pad->joy_state.lVZ = 0;
|
||||
pad->joy_state.lVRx = 0;
|
||||
pad->joy_state.lVRy = 0;
|
||||
pad->joy_state.lVRz = 0;
|
||||
pad->joy_state.rglVSlider[0] = 0;
|
||||
pad->joy_state.rglVSlider[1] = 0;
|
||||
pad->joy_state.lAX = 0;
|
||||
pad->joy_state.lAY = 0;
|
||||
pad->joy_state.lAZ = 0;
|
||||
pad->joy_state.lARx = 0;
|
||||
pad->joy_state.lARy = 0;
|
||||
pad->joy_state.lARz = 0;
|
||||
pad->joy_state.rglASlider[0] = 0;
|
||||
pad->joy_state.rglASlider[1] = 0;
|
||||
pad->joy_state.lFX = 0;
|
||||
pad->joy_state.lFY = 0;
|
||||
pad->joy_state.lFZ = 0;
|
||||
pad->joy_state.lFRx = 0;
|
||||
pad->joy_state.lFRy = 0;
|
||||
pad->joy_state.lFRz = 0;
|
||||
pad->joy_state.rglFSlider[0] = 0;
|
||||
pad->joy_state.rglFSlider[1] = 0;
|
||||
|
||||
/* If this fails, something *really* bad must have happened. */
|
||||
if (FAILED(IDirectInputDevice8_Poll(pad->joypad)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user