From 8ac1bb3b042150837cf80880b6743c792a5648dd Mon Sep 17 00:00:00 2001 From: Daniel Stuart Baxter Date: Sun, 31 May 2015 15:09:39 -0500 Subject: [PATCH] Review Changes 13 - const reference, public member documentation, enum class --- src/input_common/input_common.cpp | 4 ++-- src/input_common/input_common.h | 24 +++++++++++++++++------- src/input_common/sdl_input/sdl_input.h | 13 +++++++++++-- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/input_common/input_common.cpp b/src/input_common/input_common.cpp index d5096d8b2..b8a8407ab 100644 --- a/src/input_common/input_common.cpp +++ b/src/input_common/input_common.cpp @@ -32,11 +32,11 @@ static void InputCallback(u64 userdata, int cycles_late) { CoreTiming::ScheduleEvent(frame_ticks - cycles_late, input_event); } -std::string InputBase::GetDeviceName() const { +const std::string& InputBase::GetDeviceName() const { return device_name; } -Service::HID::PadState InputBase::GetPadState() const { +const Service::HID::PadState& InputBase::GetPadState() const { return controller.pad_state; } diff --git a/src/input_common/input_common.h b/src/input_common/input_common.h index 230b3c8ec..ea8f40a7c 100644 --- a/src/input_common/input_common.h +++ b/src/input_common/input_common.h @@ -10,7 +10,7 @@ namespace InputCommon { /// Enum defining available backends -enum InputBackends { +enum class InputBackends { NONE, SDL2 }; @@ -30,14 +30,21 @@ public: virtual void Poll() = 0; /// Shuts down all backend related data - virtual void Shutdown() = 0; + virtual void Shutdown() = 0; - /// Returns internal name of currently selected device. Expose this to the UI - std::string GetDeviceName() const; + /** + * Returns internal name of currently selected device. Expose this to the UI + * @returns A string of the device name, e.g. "SDL::PS3 Controller" + */ + const std::string& GetDeviceName() const; - /// Returns internal pad state - Service::HID::PadState GetPadState() const; + /** + * Returns internal pad state + * @returns PadState structure from the HID service + */ + const Service::HID::PadState& GetPadState() const; + /// Current input system activation status bool activated; protected: @@ -48,7 +55,10 @@ protected: ControllerState controller; }; -/// Initialize the user input system +/** + * Initializes the user input system + * @param backend Enumeration of the backend to use + */ void Init(InputBackends backend); /// Deactive the user input system diff --git a/src/input_common/sdl_input/sdl_input.h b/src/input_common/sdl_input/sdl_input.h index b05670833..050db1d7e 100644 --- a/src/input_common/sdl_input/sdl_input.h +++ b/src/input_common/sdl_input/sdl_input.h @@ -33,10 +33,19 @@ public: /// Sets up keymaps from input configuration void SetupKeyMaps(); - /// Sets analog deadzones + /** + * Sets analog deadzones + * @param range Value SDL assigns for analog input + * Applicable values (-32768 to 32767) + */ void SetDeadZone(int range); - /// Checks if analog input is within the dead zone + /** + * Checks if analog input is within the dead zone + * @param range Value SDL assigns for analog input + * Applicable values (-32768 to 32767) + * @return True if outside dead zone, false otherwise + */ bool CheckDeadZone(int range) const; private: