mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-14 18:57:07 -07:00
Add chiaki_controller_state_or()
This commit is contained in:
parent
bf17d81d25
commit
5c1611b52e
3 changed files with 18 additions and 2 deletions
|
@ -223,8 +223,7 @@ void StreamSession::SendFeedbackState()
|
|||
}
|
||||
#endif
|
||||
|
||||
state.buttons |= keyboard_state.buttons;
|
||||
|
||||
chiaki_controller_state_or(&state, &state, &keyboard_state);
|
||||
chiaki_session_set_controller_state(&session, &state);
|
||||
}
|
||||
|
||||
|
|
|
@ -85,6 +85,8 @@ static inline bool chiaki_controller_state_equals(ChiakiControllerState *a, Chia
|
|||
&& a->right_y == b->right_y;
|
||||
}
|
||||
|
||||
CHIAKI_EXPORT void chiaki_controller_state_or(ChiakiControllerState *out, ChiakiControllerState *a, ChiakiControllerState *b);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -25,3 +25,18 @@ CHIAKI_EXPORT void chiaki_controller_state_set_idle(ChiakiControllerState *state
|
|||
state->right_x = 0;
|
||||
state->right_y = 0;
|
||||
}
|
||||
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define ABS(a) ((a) > 0 ? (a) : -(a))
|
||||
#define MAX_ABS(a, b) (ABS(a) > ABS(b) ? (a) : (b))
|
||||
|
||||
CHIAKI_EXPORT void chiaki_controller_state_or(ChiakiControllerState *out, ChiakiControllerState *a, ChiakiControllerState *b)
|
||||
{
|
||||
out->buttons = a->buttons | b->buttons;
|
||||
out->l2_state = MAX(a->l2_state, b->l2_state);
|
||||
out->r2_state = MAX(a->r2_state, b->r2_state);
|
||||
out->left_x = MAX_ABS(a->left_x, b->left_x);
|
||||
out->left_y = MAX_ABS(a->left_y, b->left_y);
|
||||
out->right_x = MAX_ABS(a->right_x, b->right_x);
|
||||
out->right_y = MAX_ABS(a->right_y, b->right_y);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue