Rewrite set_rumble function

This commit is contained in:
twinaphex 2020-08-29 23:33:13 +02:00
parent 0d9b2eef4f
commit b48b751a3c
2 changed files with 14 additions and 21 deletions

View File

@ -177,6 +177,10 @@ struct android_app
unsigned width, height; unsigned width, height;
bool changed; bool changed;
} content_rect; } content_rect;
uint16_t rumble_last_strength_strong[MAX_USERS];
uint16_t rumble_last_strength_weak[MAX_USERS];
uint16_t rumble_last_strength[MAX_USERS];
int id[MAX_USERS];
}; };
enum enum

View File

@ -141,9 +141,6 @@ typedef struct state_device
{ {
int id; int id;
int port; int port;
uint16_t rumble_last_strength_strong;
uint16_t rumble_last_strength_weak;
uint16_t rumble_last_strength;
char name[256]; char name[256];
} state_device_t; } state_device_t;
@ -1203,7 +1200,8 @@ static void handle_hotplug(android_input_t *android,
vendorId, vendorId,
productId); productId);
android->pad_states[android->pads_connected].id = id; android->pad_states[android->pads_connected].id =
g_android->id[android->pads_connected] = id;
android->pad_states[android->pads_connected].port = *port; android->pad_states[android->pads_connected].port = *port;
strlcpy(android->pad_states[*port].name, name_buf, strlcpy(android->pad_states[*port].name, name_buf,
@ -1673,28 +1671,19 @@ static bool android_input_set_rumble(void *data, unsigned port,
&last_strength, &last_strength,
-1, -1,
effect); effect);
return true;
} }
else else
{ {
android_input_t *android = (android_input_t*)data; android_input_set_rumble_internal(
state_device_t *state = android ? &android->pad_states[port] : NULL; strength,
&g_android->rumble_last_strength_strong[port],
if (state) &g_android->rumble_last_strength_weak[port],
{ &g_android->rumble_last_strength[port],
android_input_set_rumble_internal( g_android->id[port],
strength, effect);
&state->rumble_last_strength_strong,
&state->rumble_last_strength_weak,
&state->rumble_last_strength,
state->id,
effect);
return true;
}
} }
return false; return true;
} }
input_driver_t input_android = { input_driver_t input_android = {