2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

Merge pull request #1516 from lioncash/hid

hid: Minor cleanup-related changes
This commit is contained in:
bunnei 2018-10-19 22:52:31 -04:00 committed by GitHub
commit 298ebf444f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 33 additions and 19 deletions

View file

@ -5,6 +5,8 @@
#include "core/hle/service/hid/controllers/controller_base.h" #include "core/hle/service/hid/controllers/controller_base.h"
namespace Service::HID { namespace Service::HID {
ControllerBase::ControllerBase() = default;
ControllerBase::~ControllerBase() = default; ControllerBase::~ControllerBase() = default;
void ControllerBase::ActivateController() { void ControllerBase::ActivateController() {

View file

@ -10,8 +10,8 @@
namespace Service::HID { namespace Service::HID {
class ControllerBase { class ControllerBase {
public: public:
ControllerBase() = default; ControllerBase();
virtual ~ControllerBase() = 0; virtual ~ControllerBase();
// Called when the controller is initialized // Called when the controller is initialized
virtual void OnInit() = 0; virtual void OnInit() = 0;

View file

@ -4,13 +4,13 @@
#include <cstring> #include <cstring>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/swap.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/hle/service/hid/controllers/debug_pad.h" #include "core/hle/service/hid/controllers/debug_pad.h"
namespace Service::HID { namespace Service::HID {
Controller_DebugPad::Controller_DebugPad() = default; Controller_DebugPad::Controller_DebugPad() = default;
Controller_DebugPad::~Controller_DebugPad() = default;
void Controller_DebugPad::OnInit() {} void Controller_DebugPad::OnInit() {}

View file

@ -14,6 +14,7 @@ namespace Service::HID {
class Controller_DebugPad final : public ControllerBase { class Controller_DebugPad final : public ControllerBase {
public: public:
Controller_DebugPad(); Controller_DebugPad();
~Controller_DebugPad() override;
// Called when the controller is initialized // Called when the controller is initialized
void OnInit() override; void OnInit() override;

View file

@ -4,7 +4,6 @@
#include <cstring> #include <cstring>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/swap.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/hle/service/hid/controllers/gesture.h" #include "core/hle/service/hid/controllers/gesture.h"
@ -12,6 +11,7 @@ namespace Service::HID {
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3BA00; constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3BA00;
Controller_Gesture::Controller_Gesture() = default; Controller_Gesture::Controller_Gesture() = default;
Controller_Gesture::~Controller_Gesture() = default;
void Controller_Gesture::OnInit() {} void Controller_Gesture::OnInit() {}

View file

@ -13,6 +13,7 @@ namespace Service::HID {
class Controller_Gesture final : public ControllerBase { class Controller_Gesture final : public ControllerBase {
public: public:
Controller_Gesture(); Controller_Gesture();
~Controller_Gesture() override;
// Called when the controller is initialized // Called when the controller is initialized
void OnInit() override; void OnInit() override;

View file

@ -4,7 +4,6 @@
#include <cstring> #include <cstring>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/swap.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/hle/service/hid/controllers/keyboard.h" #include "core/hle/service/hid/controllers/keyboard.h"
@ -12,6 +11,7 @@ namespace Service::HID {
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3800; constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3800;
Controller_Keyboard::Controller_Keyboard() = default; Controller_Keyboard::Controller_Keyboard() = default;
Controller_Keyboard::~Controller_Keyboard() = default;
void Controller_Keyboard::OnInit() {} void Controller_Keyboard::OnInit() {}

View file

@ -14,6 +14,7 @@ namespace Service::HID {
class Controller_Keyboard final : public ControllerBase { class Controller_Keyboard final : public ControllerBase {
public: public:
Controller_Keyboard(); Controller_Keyboard();
~Controller_Keyboard() override;
// Called when the controller is initialized // Called when the controller is initialized
void OnInit() override; void OnInit() override;

View file

@ -4,7 +4,6 @@
#include <cstring> #include <cstring>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/swap.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/hle/service/hid/controllers/mouse.h" #include "core/hle/service/hid/controllers/mouse.h"
@ -12,6 +11,7 @@ namespace Service::HID {
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3400; constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3400;
Controller_Mouse::Controller_Mouse() = default; Controller_Mouse::Controller_Mouse() = default;
Controller_Mouse::~Controller_Mouse() = default;
void Controller_Mouse::OnInit() {} void Controller_Mouse::OnInit() {}

View file

@ -13,6 +13,7 @@ namespace Service::HID {
class Controller_Mouse final : public ControllerBase { class Controller_Mouse final : public ControllerBase {
public: public:
Controller_Mouse(); Controller_Mouse();
~Controller_Mouse() override;
// Called when the controller is initialized // Called when the controller is initialized
void OnInit() override; void OnInit() override;

View file

@ -2,8 +2,6 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#pragma once
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <cstring> #include <cstring>
@ -11,7 +9,6 @@
#include "common/bit_field.h" #include "common/bit_field.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/swap.h"
#include "core/core.h" #include "core/core.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/frontend/input.h" #include "core/frontend/input.h"
@ -20,6 +17,7 @@
#include "core/settings.h" #include "core/settings.h"
namespace Service::HID { namespace Service::HID {
constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28; constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28;
constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A; constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A;
constexpr u32 JOYCON_BODY_NEON_BLUE = 0x0AB9E6; constexpr u32 JOYCON_BODY_NEON_BLUE = 0x0AB9E6;
@ -28,9 +26,18 @@ constexpr s32 HID_JOYSTICK_MAX = 0x7fff;
constexpr s32 HID_JOYSTICK_MIN = -0x7fff; constexpr s32 HID_JOYSTICK_MIN = -0x7fff;
constexpr std::size_t NPAD_OFFSET = 0x9A00; constexpr std::size_t NPAD_OFFSET = 0x9A00;
constexpr u32 BATTERY_FULL = 2; constexpr u32 BATTERY_FULL = 2;
enum class JoystickId : std::size_t { Joystick_Left, Joystick_Right };
constexpr std::array<u32, 10> npad_id_list{
0, 1, 2, 3, 4, 5, 6, 7, 32, 16,
};
enum class JoystickId : std::size_t {
Joystick_Left,
Joystick_Right,
};
Controller_NPad::Controller_NPad() = default; Controller_NPad::Controller_NPad() = default;
Controller_NPad::~Controller_NPad() = default;
void Controller_NPad::InitNewlyAddedControler(std::size_t controller_idx) { void Controller_NPad::InitNewlyAddedControler(std::size_t controller_idx) {
const auto controller_type = connected_controllers[controller_idx].type; const auto controller_type = connected_controllers[controller_idx].type;
@ -315,7 +322,7 @@ void Controller_NPad::SetSupportedNPadIdTypes(u8* data, std::size_t length) {
std::memcpy(supported_npad_id_types.data(), data, length); std::memcpy(supported_npad_id_types.data(), data, length);
} }
const void Controller_NPad::GetSupportedNpadIdTypes(u32* data, std::size_t max_length) { void Controller_NPad::GetSupportedNpadIdTypes(u32* data, std::size_t max_length) {
ASSERT(max_length < supported_npad_id_types.size()); ASSERT(max_length < supported_npad_id_types.size());
std::memcpy(data, supported_npad_id_types.data(), supported_npad_id_types.size()); std::memcpy(data, supported_npad_id_types.data(), supported_npad_id_types.size());
} }

View file

@ -15,6 +15,7 @@ namespace Service::HID {
class Controller_NPad final : public ControllerBase { class Controller_NPad final : public ControllerBase {
public: public:
Controller_NPad(); Controller_NPad();
~Controller_NPad() override;
// Called when the controller is initialized // Called when the controller is initialized
void OnInit() override; void OnInit() override;
@ -77,7 +78,7 @@ public:
position1.Assign(light2); position1.Assign(light2);
position1.Assign(light3); position1.Assign(light3);
position1.Assign(light4); position1.Assign(light4);
}; }
union { union {
u64 raw{}; u64 raw{};
BitField<0, 1, u64> position1; BitField<0, 1, u64> position1;
@ -91,7 +92,7 @@ public:
NPadType GetSupportedStyleSet() const; NPadType GetSupportedStyleSet() const;
void SetSupportedNPadIdTypes(u8* data, std::size_t length); void SetSupportedNPadIdTypes(u8* data, std::size_t length);
const void GetSupportedNpadIdTypes(u32* data, std::size_t max_length); void GetSupportedNpadIdTypes(u32* data, std::size_t max_length);
std::size_t GetSupportedNPadIdTypesSize() const; std::size_t GetSupportedNPadIdTypesSize() const;
void SetHoldType(NpadHoldType joy_hold_type); void SetHoldType(NpadHoldType joy_hold_type);
@ -277,9 +278,7 @@ private:
std::vector<u32> supported_npad_id_types{}; std::vector<u32> supported_npad_id_types{};
NpadHoldType hold_type{NpadHoldType::Vertical}; NpadHoldType hold_type{NpadHoldType::Vertical};
Kernel::SharedPtr<Kernel::Event> styleset_changed_event; Kernel::SharedPtr<Kernel::Event> styleset_changed_event;
std::size_t dump_idx{};
Vibration last_processed_vibration{}; Vibration last_processed_vibration{};
static constexpr std::array<u32, 10> npad_id_list{0, 1, 2, 3, 4, 5, 6, 7, 32, 16};
std::array<ControllerHolder, 10> connected_controllers{}; std::array<ControllerHolder, 10> connected_controllers{};
bool can_controllers_vibrate{true}; bool can_controllers_vibrate{true};

View file

@ -4,13 +4,13 @@
#include <cstring> #include <cstring>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/swap.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/hle/service/hid/controllers/stubbed.h" #include "core/hle/service/hid/controllers/stubbed.h"
namespace Service::HID { namespace Service::HID {
Controller_Stubbed::Controller_Stubbed() = default; Controller_Stubbed::Controller_Stubbed() = default;
Controller_Stubbed::~Controller_Stubbed() = default;
void Controller_Stubbed::OnInit() {} void Controller_Stubbed::OnInit() {}

View file

@ -11,6 +11,7 @@ namespace Service::HID {
class Controller_Stubbed final : public ControllerBase { class Controller_Stubbed final : public ControllerBase {
public: public:
Controller_Stubbed(); Controller_Stubbed();
~Controller_Stubbed() override;
// Called when the controller is initialized // Called when the controller is initialized
void OnInit() override; void OnInit() override;

View file

@ -4,7 +4,6 @@
#include <cstring> #include <cstring>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/swap.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/frontend/emu_window.h" #include "core/frontend/emu_window.h"
#include "core/frontend/input.h" #include "core/frontend/input.h"
@ -15,6 +14,7 @@ namespace Service::HID {
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x400; constexpr std::size_t SHARED_MEMORY_OFFSET = 0x400;
Controller_Touchscreen::Controller_Touchscreen() = default; Controller_Touchscreen::Controller_Touchscreen() = default;
Controller_Touchscreen::~Controller_Touchscreen() = default;
void Controller_Touchscreen::OnInit() {} void Controller_Touchscreen::OnInit() {}

View file

@ -14,6 +14,7 @@ namespace Service::HID {
class Controller_Touchscreen final : public ControllerBase { class Controller_Touchscreen final : public ControllerBase {
public: public:
Controller_Touchscreen(); Controller_Touchscreen();
~Controller_Touchscreen() override;
// Called when the controller is initialized // Called when the controller is initialized
void OnInit() override; void OnInit() override;

View file

@ -4,7 +4,6 @@
#include <cstring> #include <cstring>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/swap.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/hle/service/hid/controllers/xpad.h" #include "core/hle/service/hid/controllers/xpad.h"
@ -12,6 +11,7 @@ namespace Service::HID {
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C00; constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C00;
Controller_XPad::Controller_XPad() = default; Controller_XPad::Controller_XPad() = default;
Controller_XPad::~Controller_XPad() = default;
void Controller_XPad::OnInit() {} void Controller_XPad::OnInit() {}

View file

@ -7,13 +7,13 @@
#include "common/common_funcs.h" #include "common/common_funcs.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "common/swap.h" #include "common/swap.h"
#include "core/frontend/input.h"
#include "core/hle/service/hid/controllers/controller_base.h" #include "core/hle/service/hid/controllers/controller_base.h"
namespace Service::HID { namespace Service::HID {
class Controller_XPad final : public ControllerBase { class Controller_XPad final : public ControllerBase {
public: public:
Controller_XPad(); Controller_XPad();
~Controller_XPad() override;
// Called when the controller is initialized // Called when the controller is initialized
void OnInit() override; void OnInit() override;