InputManager: Export a few functions

This commit is contained in:
Connor McLaughlin
2022-09-22 23:11:38 +10:00
parent d25a9a22e3
commit 583b8cd955
2 changed files with 74 additions and 43 deletions

View File

@ -91,6 +91,14 @@ using InputButtonEventHandler = std::function<void(s32 value)>;
/// Callback types for a normalized event. Usually used for pads.
using InputAxisEventHandler = std::function<void(float value)>;
/// ------------------------------------------------------------------------
/// Event Handler Type
/// ------------------------------------------------------------------------
/// This class acts as an adapter to convert from normalized values to
/// binary values when the callback is a binary/button handler. That way
/// you don't need to convert float->bool in your callbacks.
using InputEventHandler = std::variant<InputAxisEventHandler, InputButtonEventHandler>;
/// Input monitoring for external access.
struct InputInterceptHook
{
@ -226,6 +234,16 @@ bool HasAnyBindingsForKey(InputBindingKey key);
/// Can be safely called on another thread.
bool HasAnyBindingsForSource(InputBindingKey key);
/// Parses a string binding into its components. Use with external AddBinding().
bool ParseBindingAndGetSource(const std::string_view& binding, InputBindingKey* key, InputSource** source);
/// Externally adds a fixed binding. Be sure to call *after* ReloadBindings() otherwise it will be lost.
void AddBinding(const std::string_view& binding, const InputEventHandler& handler);
/// Adds an external vibration binding.
void AddVibrationBinding(u32 pad_index, const InputBindingKey* motor_0_binding, InputSource* motor_0_source,
const InputBindingKey* motor_1_binding, InputSource* motor_1_source);
/// Updates internal state for any binds for this key, and fires callbacks as needed.
/// Returns true if anything was bound to this key, otherwise false.
bool InvokeEvents(InputBindingKey key, float value, GenericInputBinding generic_key);