Review Changes 13 - const reference, public member documentation, enum class

This commit is contained in:
Daniel Stuart Baxter 2015-05-31 15:09:39 -05:00
parent 1be629b345
commit 8ac1bb3b04
3 changed files with 30 additions and 11 deletions

View File

@ -32,11 +32,11 @@ static void InputCallback(u64 userdata, int cycles_late) {
CoreTiming::ScheduleEvent(frame_ticks - cycles_late, input_event); CoreTiming::ScheduleEvent(frame_ticks - cycles_late, input_event);
} }
std::string InputBase::GetDeviceName() const { const std::string& InputBase::GetDeviceName() const {
return device_name; return device_name;
} }
Service::HID::PadState InputBase::GetPadState() const { const Service::HID::PadState& InputBase::GetPadState() const {
return controller.pad_state; return controller.pad_state;
} }

View File

@ -10,7 +10,7 @@
namespace InputCommon { namespace InputCommon {
/// Enum defining available backends /// Enum defining available backends
enum InputBackends { enum class InputBackends {
NONE, NONE,
SDL2 SDL2
}; };
@ -32,12 +32,19 @@ public:
/// Shuts down all backend related data /// 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; bool activated;
protected: protected:
@ -48,7 +55,10 @@ protected:
ControllerState controller; ControllerState controller;
}; };
/// Initialize the user input system /**
* Initializes the user input system
* @param backend Enumeration of the backend to use
*/
void Init(InputBackends backend); void Init(InputBackends backend);
/// Deactive the user input system /// Deactive the user input system

View File

@ -33,10 +33,19 @@ public:
/// Sets up keymaps from input configuration /// Sets up keymaps from input configuration
void SetupKeyMaps(); 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); 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; bool CheckDeadZone(int range) const;
private: private: