forked from ShuriZma/suyu
1
0
Fork 0

input_engine: std::move engine name where applicable

We can allow the name to be moved into, allowing allocations to be
avoided.
This commit is contained in:
Lioncash 2021-12-13 09:05:23 -05:00
parent 9a104e2b60
commit 2b92d22bda
15 changed files with 29 additions and 29 deletions

View File

@ -69,7 +69,7 @@ private:
libusb_device_handle* handle{}; libusb_device_handle* handle{};
}; };
GCAdapter::GCAdapter(const std::string& input_engine_) : InputEngine(input_engine_) { GCAdapter::GCAdapter(std::string input_engine_) : InputEngine(std::move(input_engine_)) {
if (usb_adapter_handle) { if (usb_adapter_handle) {
return; return;
} }

View File

@ -22,10 +22,10 @@ namespace InputCommon {
class LibUSBContext; class LibUSBContext;
class LibUSBDeviceHandle; class LibUSBDeviceHandle;
class GCAdapter : public InputCommon::InputEngine { class GCAdapter : public InputEngine {
public: public:
explicit GCAdapter(const std::string& input_engine_); explicit GCAdapter(std::string input_engine_);
~GCAdapter(); ~GCAdapter() override;
Common::Input::VibrationError SetRumble( Common::Input::VibrationError SetRumble(
const PadIdentifier& identifier, const Common::Input::VibrationStatus vibration) override; const PadIdentifier& identifier, const Common::Input::VibrationStatus vibration) override;

View File

@ -24,7 +24,7 @@ constexpr PadIdentifier keyboard_modifier_identifier = {
.pad = 1, .pad = 1,
}; };
Keyboard::Keyboard(const std::string& input_engine_) : InputEngine(input_engine_) { Keyboard::Keyboard(std::string input_engine_) : InputEngine(std::move(input_engine_)) {
// Keyboard is broken into 3 diferent sets: // Keyboard is broken into 3 diferent sets:
// key: Unfiltered intended for controllers. // key: Unfiltered intended for controllers.
// keyboard_key: Allows only Settings::NativeKeyboard::Keys intended for keyboard emulation. // keyboard_key: Allows only Settings::NativeKeyboard::Keys intended for keyboard emulation.

View File

@ -12,9 +12,9 @@ namespace InputCommon {
* A button device factory representing a keyboard. It receives keyboard events and forward them * A button device factory representing a keyboard. It receives keyboard events and forward them
* to all button devices it created. * to all button devices it created.
*/ */
class Keyboard final : public InputCommon::InputEngine { class Keyboard final : public InputEngine {
public: public:
explicit Keyboard(const std::string& input_engine_); explicit Keyboard(std::string input_engine_);
/** /**
* Sets the status of all buttons bound with the key to pressed * Sets the status of all buttons bound with the key to pressed

View File

@ -24,7 +24,7 @@ constexpr PadIdentifier identifier = {
.pad = 0, .pad = 0,
}; };
Mouse::Mouse(const std::string& input_engine_) : InputEngine(input_engine_) { Mouse::Mouse(std::string input_engine_) : InputEngine(std::move(input_engine_)) {
PreSetController(identifier); PreSetController(identifier);
PreSetAxis(identifier, mouse_axis_x); PreSetAxis(identifier, mouse_axis_x);
PreSetAxis(identifier, mouse_axis_y); PreSetAxis(identifier, mouse_axis_y);

View File

@ -27,9 +27,9 @@ enum class MouseButton {
* A button device factory representing a keyboard. It receives keyboard events and forward them * A button device factory representing a keyboard. It receives keyboard events and forward them
* to all button devices it created. * to all button devices it created.
*/ */
class Mouse final : public InputCommon::InputEngine { class Mouse final : public InputEngine {
public: public:
explicit Mouse(const std::string& input_engine_); explicit Mouse(std::string input_engine_);
/** /**
* Signals that mouse has moved. * Signals that mouse has moved.

View File

@ -387,7 +387,7 @@ void SDLDriver::CloseJoysticks() {
joystick_map.clear(); joystick_map.clear();
} }
SDLDriver::SDLDriver(const std::string& input_engine_) : InputEngine(input_engine_) { SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_engine_)) {
if (!Settings::values.enable_raw_input) { if (!Settings::values.enable_raw_input) {
// Disable raw input. When enabled this setting causes SDL to die when a web applet opens // Disable raw input. When enabled this setting causes SDL to die when a web applet opens
SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT, "0"); SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT, "0");

View File

@ -19,19 +19,19 @@ using SDL_GameController = struct _SDL_GameController;
using SDL_Joystick = struct _SDL_Joystick; using SDL_Joystick = struct _SDL_Joystick;
using SDL_JoystickID = s32; using SDL_JoystickID = s32;
namespace InputCommon {
class SDLJoystick;
using ButtonBindings = using ButtonBindings =
std::array<std::pair<Settings::NativeButton::Values, SDL_GameControllerButton>, 17>; std::array<std::pair<Settings::NativeButton::Values, SDL_GameControllerButton>, 17>;
using ZButtonBindings = using ZButtonBindings =
std::array<std::pair<Settings::NativeButton::Values, SDL_GameControllerAxis>, 2>; std::array<std::pair<Settings::NativeButton::Values, SDL_GameControllerAxis>, 2>;
namespace InputCommon { class SDLDriver : public InputEngine {
class SDLJoystick;
class SDLDriver : public InputCommon::InputEngine {
public: public:
/// Initializes and registers SDL device factories /// Initializes and registers SDL device factories
SDLDriver(const std::string& input_engine_); explicit SDLDriver(std::string input_engine_);
/// Unregisters SDL device factories and shut them down. /// Unregisters SDL device factories and shut them down.
~SDLDriver() override; ~SDLDriver() override;

View File

@ -47,7 +47,7 @@ constexpr std::array<std::pair<std::string_view, TasButton>, 20> text_to_tas_but
{"KEY_ZR", TasButton::TRIGGER_ZR}, {"KEY_ZR", TasButton::TRIGGER_ZR},
}; };
Tas::Tas(const std::string& input_engine_) : InputCommon::InputEngine(input_engine_) { Tas::Tas(std::string input_engine_) : InputEngine(std::move(input_engine_)) {
for (size_t player_index = 0; player_index < PLAYER_NUMBER; player_index++) { for (size_t player_index = 0; player_index < PLAYER_NUMBER; player_index++) {
PadIdentifier identifier{ PadIdentifier identifier{
.guid = Common::UUID{}, .guid = Common::UUID{},

View File

@ -81,10 +81,10 @@ enum class TasState {
Stopped, Stopped,
}; };
class Tas final : public InputCommon::InputEngine { class Tas final : public InputEngine {
public: public:
explicit Tas(const std::string& input_engine_); explicit Tas(std::string input_engine_);
~Tas(); ~Tas() override;
/** /**
* Changes the input status that will be stored in each frame * Changes the input status that will be stored in each frame

View File

@ -13,7 +13,7 @@ constexpr PadIdentifier identifier = {
.pad = 0, .pad = 0,
}; };
TouchScreen::TouchScreen(const std::string& input_engine_) : InputEngine(input_engine_) { TouchScreen::TouchScreen(std::string input_engine_) : InputEngine(std::move(input_engine_)) {
PreSetController(identifier); PreSetController(identifier);
} }

View File

@ -12,9 +12,9 @@ namespace InputCommon {
* A button device factory representing a keyboard. It receives keyboard events and forward them * A button device factory representing a keyboard. It receives keyboard events and forward them
* to all button devices it created. * to all button devices it created.
*/ */
class TouchScreen final : public InputCommon::InputEngine { class TouchScreen final : public InputEngine {
public: public:
explicit TouchScreen(const std::string& input_engine_); explicit TouchScreen(std::string input_engine_);
/** /**
* Signals that mouse has moved. * Signals that mouse has moved.

View File

@ -136,7 +136,7 @@ static void SocketLoop(Socket* socket) {
socket->Loop(); socket->Loop();
} }
UDPClient::UDPClient(const std::string& input_engine_) : InputEngine(input_engine_) { UDPClient::UDPClient(std::string input_engine_) : InputEngine(std::move(input_engine_)) {
LOG_INFO(Input, "Udp Initialization started"); LOG_INFO(Input, "Udp Initialization started");
ReloadSockets(); ReloadSockets();
} }

View File

@ -49,10 +49,10 @@ struct DeviceStatus {
* A button device factory representing a keyboard. It receives keyboard events and forward them * A button device factory representing a keyboard. It receives keyboard events and forward them
* to all button devices it created. * to all button devices it created.
*/ */
class UDPClient final : public InputCommon::InputEngine { class UDPClient final : public InputEngine {
public: public:
explicit UDPClient(const std::string& input_engine_); explicit UDPClient(std::string input_engine_);
~UDPClient(); ~UDPClient() override;
void ReloadSockets(); void ReloadSockets();

View File

@ -102,7 +102,7 @@ struct InputIdentifier {
class InputEngine { class InputEngine {
public: public:
explicit InputEngine(const std::string& input_engine_) : input_engine(input_engine_) {} explicit InputEngine(std::string input_engine_) : input_engine{std::move(input_engine_)} {}
virtual ~InputEngine() = default; virtual ~InputEngine() = default;