Merge pull request #4082 from zhaowenlan1779/port-yuzu-906
Port "input_common: minor changes" from yuzu
This commit is contained in:
commit
f201484c63
|
@ -5,6 +5,7 @@
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <utility>
|
||||||
#include "input_common/keyboard.h"
|
#include "input_common/keyboard.h"
|
||||||
|
|
||||||
namespace InputCommon {
|
namespace InputCommon {
|
||||||
|
@ -12,9 +13,9 @@ namespace InputCommon {
|
||||||
class KeyButton final : public Input::ButtonDevice {
|
class KeyButton final : public Input::ButtonDevice {
|
||||||
public:
|
public:
|
||||||
explicit KeyButton(std::shared_ptr<KeyButtonList> key_button_list_)
|
explicit KeyButton(std::shared_ptr<KeyButtonList> key_button_list_)
|
||||||
: key_button_list(key_button_list_) {}
|
: key_button_list(std::move(key_button_list_)) {}
|
||||||
|
|
||||||
~KeyButton();
|
~KeyButton() override;
|
||||||
|
|
||||||
bool GetStatus() const override {
|
bool GetStatus() const override {
|
||||||
return status.load();
|
return status.load();
|
||||||
|
|
|
@ -133,7 +133,7 @@ public:
|
||||||
device = std::make_shared<MotionEmuDevice>(update_millisecond, sensitivity, tilt_clamp);
|
device = std::make_shared<MotionEmuDevice>(update_millisecond, sensitivity, tilt_clamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<Math::Vec3<float>, Math::Vec3<float>> GetStatus() const {
|
std::tuple<Math::Vec3<float>, Math::Vec3<float>> GetStatus() const override {
|
||||||
return device->GetStatus();
|
return device->GetStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ private:
|
||||||
class SDLButton final : public Input::ButtonDevice {
|
class SDLButton final : public Input::ButtonDevice {
|
||||||
public:
|
public:
|
||||||
explicit SDLButton(std::shared_ptr<SDLJoystick> joystick_, int button_)
|
explicit SDLButton(std::shared_ptr<SDLJoystick> joystick_, int button_)
|
||||||
: joystick(joystick_), button(button_) {}
|
: joystick(std::move(joystick_)), button(button_) {}
|
||||||
|
|
||||||
bool GetStatus() const override {
|
bool GetStatus() const override {
|
||||||
return joystick->GetButton(button);
|
return joystick->GetButton(button);
|
||||||
|
@ -96,7 +96,7 @@ private:
|
||||||
class SDLDirectionButton final : public Input::ButtonDevice {
|
class SDLDirectionButton final : public Input::ButtonDevice {
|
||||||
public:
|
public:
|
||||||
explicit SDLDirectionButton(std::shared_ptr<SDLJoystick> joystick_, int hat_, Uint8 direction_)
|
explicit SDLDirectionButton(std::shared_ptr<SDLJoystick> joystick_, int hat_, Uint8 direction_)
|
||||||
: joystick(joystick_), hat(hat_), direction(direction_) {}
|
: joystick(std::move(joystick_)), hat(hat_), direction(direction_) {}
|
||||||
|
|
||||||
bool GetStatus() const override {
|
bool GetStatus() const override {
|
||||||
return joystick->GetHatDirection(hat, direction);
|
return joystick->GetHatDirection(hat, direction);
|
||||||
|
@ -112,7 +112,7 @@ class SDLAxisButton final : public Input::ButtonDevice {
|
||||||
public:
|
public:
|
||||||
explicit SDLAxisButton(std::shared_ptr<SDLJoystick> joystick_, int axis_, float threshold_,
|
explicit SDLAxisButton(std::shared_ptr<SDLJoystick> joystick_, int axis_, float threshold_,
|
||||||
bool trigger_if_greater_)
|
bool trigger_if_greater_)
|
||||||
: joystick(joystick_), axis(axis_), threshold(threshold_),
|
: joystick(std::move(joystick_)), axis(axis_), threshold(threshold_),
|
||||||
trigger_if_greater(trigger_if_greater_) {}
|
trigger_if_greater(trigger_if_greater_) {}
|
||||||
|
|
||||||
bool GetStatus() const override {
|
bool GetStatus() const override {
|
||||||
|
@ -132,7 +132,7 @@ private:
|
||||||
class SDLAnalog final : public Input::AnalogDevice {
|
class SDLAnalog final : public Input::AnalogDevice {
|
||||||
public:
|
public:
|
||||||
SDLAnalog(std::shared_ptr<SDLJoystick> joystick_, int axis_x_, int axis_y_)
|
SDLAnalog(std::shared_ptr<SDLJoystick> joystick_, int axis_x_, int axis_y_)
|
||||||
: joystick(joystick_), axis_x(axis_x_), axis_y(axis_y_) {}
|
: joystick(std::move(joystick_)), axis_x(axis_x_), axis_y(axis_y_) {}
|
||||||
|
|
||||||
std::tuple<float, float> GetStatus() const override {
|
std::tuple<float, float> GetStatus() const override {
|
||||||
return joystick->GetAnalog(axis_x, axis_y);
|
return joystick->GetAnalog(axis_x, axis_y);
|
||||||
|
@ -314,10 +314,6 @@ namespace Polling {
|
||||||
|
|
||||||
class SDLPoller : public InputCommon::Polling::DevicePoller {
|
class SDLPoller : public InputCommon::Polling::DevicePoller {
|
||||||
public:
|
public:
|
||||||
SDLPoller() = default;
|
|
||||||
|
|
||||||
~SDLPoller() = default;
|
|
||||||
|
|
||||||
void Start() override {
|
void Start() override {
|
||||||
// SDL joysticks must be opened, otherwise they don't generate events
|
// SDL joysticks must be opened, otherwise they don't generate events
|
||||||
SDL_JoystickUpdate();
|
SDL_JoystickUpdate();
|
||||||
|
@ -341,10 +337,6 @@ private:
|
||||||
|
|
||||||
class SDLButtonPoller final : public SDLPoller {
|
class SDLButtonPoller final : public SDLPoller {
|
||||||
public:
|
public:
|
||||||
SDLButtonPoller() = default;
|
|
||||||
|
|
||||||
~SDLButtonPoller() = default;
|
|
||||||
|
|
||||||
Common::ParamPackage GetNextInput() override {
|
Common::ParamPackage GetNextInput() override {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
|
@ -364,10 +356,6 @@ public:
|
||||||
|
|
||||||
class SDLAnalogPoller final : public SDLPoller {
|
class SDLAnalogPoller final : public SDLPoller {
|
||||||
public:
|
public:
|
||||||
SDLAnalogPoller() = default;
|
|
||||||
|
|
||||||
~SDLAnalogPoller() = default;
|
|
||||||
|
|
||||||
void Start() override {
|
void Start() override {
|
||||||
SDLPoller::Start();
|
SDLPoller::Start();
|
||||||
|
|
||||||
|
|
Reference in New Issue