core/hid: Documment some files
This commit is contained in:
parent
e0da5c1bbc
commit
72e5920240
4 changed files with 265 additions and 52 deletions
|
@ -45,7 +45,7 @@ struct DeviceStatus {
|
|||
KeyboardModifierValues keyboard_moddifier_values{};
|
||||
MouseButtonValues mouse_button_values{};
|
||||
|
||||
// Data for Nintendo devices
|
||||
// Data for HID serices
|
||||
KeyboardKey keyboard_state{};
|
||||
KeyboardModifier keyboard_moddifier_state{};
|
||||
MouseButton mouse_button_state{};
|
||||
|
@ -65,58 +65,108 @@ struct InterfaceUpdateCallback {
|
|||
class EmulatedDevices {
|
||||
public:
|
||||
/**
|
||||
* TODO: Write description
|
||||
*
|
||||
* @param npad_id_type
|
||||
* Contains all input data related to external devices that aren't necesarily a controller
|
||||
* like keyboard and mouse
|
||||
*/
|
||||
explicit EmulatedDevices();
|
||||
EmulatedDevices();
|
||||
~EmulatedDevices();
|
||||
|
||||
YUZU_NON_COPYABLE(EmulatedDevices);
|
||||
YUZU_NON_MOVEABLE(EmulatedDevices);
|
||||
|
||||
void ReloadFromSettings();
|
||||
void ReloadInput();
|
||||
/// Removes all callbacks created from input devices
|
||||
void UnloadInput();
|
||||
|
||||
/// Sets the emulated console into configuring mode. Locking all HID service events from being
|
||||
/// moddified
|
||||
void EnableConfiguration();
|
||||
|
||||
/// Returns the emulated console to the normal behaivour
|
||||
void DisableConfiguration();
|
||||
|
||||
/// Returns true if the emulated device is on configuring mode
|
||||
bool IsConfiguring() const;
|
||||
|
||||
/// Reload all input devices
|
||||
void ReloadInput();
|
||||
|
||||
/// Overrides current mapped devices with the stored configuration and reloads all input devices
|
||||
void ReloadFromSettings();
|
||||
|
||||
/// Saves the current mapped configuration
|
||||
void SaveCurrentConfig();
|
||||
|
||||
/// Reverts any mapped changes made that weren't saved
|
||||
void RestoreConfig();
|
||||
|
||||
std::vector<Common::ParamPackage> GetMappedDevices() const;
|
||||
|
||||
/// Returns the current mapped motion device
|
||||
Common::ParamPackage GetMouseButtonParam(std::size_t index) const;
|
||||
|
||||
void SetButtonParam(std::size_t index, Common::ParamPackage param);
|
||||
/**
|
||||
* Updates the current mapped mouse button device
|
||||
* @param ParamPackage with controller data to be mapped
|
||||
*/
|
||||
void SetMouseButtonParam(std::size_t index, Common::ParamPackage param);
|
||||
|
||||
/// Returns the latest status of button input from the keyboard with parameters
|
||||
KeyboardValues GetKeyboardValues() const;
|
||||
|
||||
/// Returns the latest status of button input from the keyboard modifiers with parameters
|
||||
KeyboardModifierValues GetKeyboardModdifierValues() const;
|
||||
|
||||
/// Returns the latest status of button input from the mouse with parameters
|
||||
MouseButtonValues GetMouseButtonsValues() const;
|
||||
|
||||
/// Returns the latest status of button input from the keyboard
|
||||
KeyboardKey GetKeyboard() const;
|
||||
|
||||
/// Returns the latest status of button input from the keyboard modifiers
|
||||
KeyboardModifier GetKeyboardModifier() const;
|
||||
|
||||
/// Returns the latest status of button input from the mouse
|
||||
MouseButton GetMouseButtons() const;
|
||||
|
||||
/// Returns the latest mouse coordinates
|
||||
MousePosition GetMousePosition() const;
|
||||
|
||||
/**
|
||||
* Adds a callback to the list of events
|
||||
* @param ConsoleUpdateCallback that will be triggered
|
||||
* @return an unique key corresponding to the callback index in the list
|
||||
*/
|
||||
int SetCallback(InterfaceUpdateCallback update_callback);
|
||||
|
||||
/**
|
||||
* Removes a callback from the list stopping any future events to this object
|
||||
* @param Key corresponding to the callback index in the list
|
||||
*/
|
||||
void DeleteCallback(int key);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Sets the status of a button. Applies toggle properties to the output.
|
||||
*
|
||||
* @param A CallbackStatus and a button index number
|
||||
* Updates the touch status of the console
|
||||
* @param callback: A CallbackStatus containing the key status
|
||||
* @param index: key ID to be updated
|
||||
*/
|
||||
void SetKeyboardButton(Input::CallbackStatus callback, std::size_t index);
|
||||
|
||||
/**
|
||||
* Updates the touch status of the console
|
||||
* @param callback: A CallbackStatus containing the modifier key status
|
||||
* @param index: modifier key ID to be updated
|
||||
*/
|
||||
void SetKeyboardModifier(Input::CallbackStatus callback, std::size_t index);
|
||||
|
||||
/**
|
||||
* Updates the touch status of the console
|
||||
* @param callback: A CallbackStatus containing the button status
|
||||
* @param index: Button ID of the to be updated
|
||||
*/
|
||||
void SetMouseButton(Input::CallbackStatus callback, std::size_t index);
|
||||
|
||||
/**
|
||||
* Triggers a callback that something has changed
|
||||
*
|
||||
* @param Input type of the trigger
|
||||
* Triggers a callback that something has changed on the device status
|
||||
* @param Input type of the event to trigger
|
||||
*/
|
||||
void TriggerOnChange(DeviceTriggerType type);
|
||||
|
||||
|
@ -131,6 +181,8 @@ private:
|
|||
mutable std::mutex mutex;
|
||||
std::unordered_map<int, InterfaceUpdateCallback> callback_list;
|
||||
int last_callback_key = 0;
|
||||
|
||||
// Stores the current status of all external device input
|
||||
DeviceStatus device_status;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue