Addressed changes for better hid
This commit is contained in:
parent
56f35ab262
commit
5857aea94e
|
@ -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;
|
||||||
|
|
||||||
void ControllerBase::ActivateController() {
|
void ControllerBase::ActivateController() {
|
||||||
if (is_activated) {
|
if (is_activated) {
|
||||||
OnRelease();
|
OnRelease();
|
||||||
|
@ -23,5 +25,4 @@ void ControllerBase::DeactivateController() {
|
||||||
bool ControllerBase::IsControllerActivated() const {
|
bool ControllerBase::IsControllerActivated() const {
|
||||||
return is_activated;
|
return is_activated;
|
||||||
}
|
}
|
||||||
// ControllerBase::~ControllerBase() = default;
|
} // namespace Service::HID
|
||||||
}; // namespace Service::HID
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/swap.h"
|
#include "common/swap.h"
|
||||||
|
|
||||||
|
@ -10,6 +11,7 @@ namespace Service::HID {
|
||||||
class ControllerBase {
|
class ControllerBase {
|
||||||
public:
|
public:
|
||||||
ControllerBase() = default;
|
ControllerBase() = default;
|
||||||
|
virtual ~ControllerBase() = 0;
|
||||||
|
|
||||||
// Called when the controller is initialized
|
// Called when the controller is initialized
|
||||||
virtual void OnInit() = 0;
|
virtual void OnInit() = 0;
|
||||||
|
@ -18,7 +20,7 @@ public:
|
||||||
virtual void OnRelease() = 0;
|
virtual void OnRelease() = 0;
|
||||||
|
|
||||||
// When the controller is requesting an update for the shared memory
|
// When the controller is requesting an update for the shared memory
|
||||||
virtual void OnUpdate(u8* data, size_t size) = 0;
|
virtual void OnUpdate(u8* data, std::size_t size) = 0;
|
||||||
|
|
||||||
// Called when input devices should be loaded
|
// Called when input devices should be loaded
|
||||||
virtual void OnLoadInputDevices() = 0;
|
virtual void OnLoadInputDevices() = 0;
|
||||||
|
@ -40,4 +42,4 @@ protected:
|
||||||
};
|
};
|
||||||
static_assert(sizeof(CommonHeader) == 0x20, "CommonHeader is an invalid size");
|
static_assert(sizeof(CommonHeader) == 0x20, "CommonHeader is an invalid size");
|
||||||
};
|
};
|
||||||
}; // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -2,15 +2,21 @@
|
||||||
// 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.
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/swap.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;
|
||||||
|
|
||||||
void Controller_DebugPad::OnInit() {}
|
void Controller_DebugPad::OnInit() {}
|
||||||
|
|
||||||
void Controller_DebugPad::OnRelease() {}
|
void Controller_DebugPad::OnRelease() {}
|
||||||
void Controller_DebugPad::OnUpdate(u8* data, size_t size) {
|
|
||||||
|
void Controller_DebugPad::OnUpdate(u8* data, std::size_t size) {
|
||||||
shared_memory.header.timestamp = CoreTiming::GetTicks();
|
shared_memory.header.timestamp = CoreTiming::GetTicks();
|
||||||
shared_memory.header.total_entry_count = 17;
|
shared_memory.header.total_entry_count = 17;
|
||||||
|
|
||||||
|
@ -21,7 +27,7 @@ void Controller_DebugPad::OnUpdate(u8* data, size_t size) {
|
||||||
}
|
}
|
||||||
shared_memory.header.entry_count = 16;
|
shared_memory.header.entry_count = 16;
|
||||||
|
|
||||||
auto& last_entry = shared_memory.pad_states[shared_memory.header.last_entry_index];
|
const auto& last_entry = shared_memory.pad_states[shared_memory.header.last_entry_index];
|
||||||
shared_memory.header.last_entry_index = (shared_memory.header.last_entry_index + 1) % 17;
|
shared_memory.header.last_entry_index = (shared_memory.header.last_entry_index + 1) % 17;
|
||||||
auto& cur_entry = shared_memory.pad_states[shared_memory.header.last_entry_index];
|
auto& cur_entry = shared_memory.pad_states[shared_memory.header.last_entry_index];
|
||||||
|
|
||||||
|
@ -31,5 +37,6 @@ void Controller_DebugPad::OnUpdate(u8* data, size_t size) {
|
||||||
|
|
||||||
std::memcpy(data, &shared_memory, sizeof(SharedMemory));
|
std::memcpy(data, &shared_memory, sizeof(SharedMemory));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller_DebugPad::OnLoadInputDevices() {}
|
void Controller_DebugPad::OnLoadInputDevices() {}
|
||||||
}; // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
@ -12,7 +13,7 @@
|
||||||
namespace Service::HID {
|
namespace Service::HID {
|
||||||
class Controller_DebugPad final : public ControllerBase {
|
class Controller_DebugPad final : public ControllerBase {
|
||||||
public:
|
public:
|
||||||
Controller_DebugPad() = default;
|
Controller_DebugPad();
|
||||||
|
|
||||||
// Called when the controller is initialized
|
// Called when the controller is initialized
|
||||||
void OnInit() override;
|
void OnInit() override;
|
||||||
|
@ -21,7 +22,7 @@ public:
|
||||||
void OnRelease() override;
|
void OnRelease() override;
|
||||||
|
|
||||||
// When the controller is requesting an update for the shared memory
|
// When the controller is requesting an update for the shared memory
|
||||||
void OnUpdate(u8* data, size_t size) override;
|
void OnUpdate(u8* data, std::size_t size) override;
|
||||||
|
|
||||||
// Called when input devices should be loaded
|
// Called when input devices should be loaded
|
||||||
void OnLoadInputDevices() override;
|
void OnLoadInputDevices() override;
|
||||||
|
@ -51,4 +52,4 @@ private:
|
||||||
static_assert(sizeof(SharedMemory) == 0x400, "SharedMemory is an invalid size");
|
static_assert(sizeof(SharedMemory) == 0x400, "SharedMemory is an invalid size");
|
||||||
SharedMemory shared_memory{};
|
SharedMemory shared_memory{};
|
||||||
};
|
};
|
||||||
}; // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -2,16 +2,22 @@
|
||||||
// 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.
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/swap.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"
|
||||||
|
|
||||||
namespace Service::HID {
|
namespace Service::HID {
|
||||||
constexpr size_t SHARED_MEMORY_OFFSET = 0x3BA00;
|
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3BA00;
|
||||||
|
|
||||||
|
Controller_Gesture::Controller_Gesture() = default;
|
||||||
|
|
||||||
void Controller_Gesture::OnInit() {}
|
void Controller_Gesture::OnInit() {}
|
||||||
|
|
||||||
void Controller_Gesture::OnRelease() {}
|
void Controller_Gesture::OnRelease() {}
|
||||||
void Controller_Gesture::OnUpdate(u8* data, size_t size) {
|
|
||||||
|
void Controller_Gesture::OnUpdate(u8* data, std::size_t size) {
|
||||||
shared_memory.header.timestamp = CoreTiming::GetTicks();
|
shared_memory.header.timestamp = CoreTiming::GetTicks();
|
||||||
shared_memory.header.total_entry_count = 17;
|
shared_memory.header.total_entry_count = 17;
|
||||||
|
|
||||||
|
@ -22,7 +28,7 @@ void Controller_Gesture::OnUpdate(u8* data, size_t size) {
|
||||||
}
|
}
|
||||||
shared_memory.header.entry_count = 16;
|
shared_memory.header.entry_count = 16;
|
||||||
|
|
||||||
auto& last_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index];
|
const auto& last_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index];
|
||||||
shared_memory.header.last_entry_index = (shared_memory.header.last_entry_index + 1) % 17;
|
shared_memory.header.last_entry_index = (shared_memory.header.last_entry_index + 1) % 17;
|
||||||
auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index];
|
auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index];
|
||||||
|
|
||||||
|
@ -32,5 +38,6 @@ void Controller_Gesture::OnUpdate(u8* data, size_t size) {
|
||||||
|
|
||||||
std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory));
|
std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller_Gesture::OnLoadInputDevices() {}
|
void Controller_Gesture::OnLoadInputDevices() {}
|
||||||
}; // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/swap.h"
|
#include "common/swap.h"
|
||||||
|
@ -11,7 +12,7 @@
|
||||||
namespace Service::HID {
|
namespace Service::HID {
|
||||||
class Controller_Gesture final : public ControllerBase {
|
class Controller_Gesture final : public ControllerBase {
|
||||||
public:
|
public:
|
||||||
Controller_Gesture() = default;
|
Controller_Gesture();
|
||||||
|
|
||||||
// Called when the controller is initialized
|
// Called when the controller is initialized
|
||||||
void OnInit() override;
|
void OnInit() override;
|
||||||
|
@ -48,7 +49,7 @@ private:
|
||||||
f32 scale;
|
f32 scale;
|
||||||
f32 rotation;
|
f32 rotation;
|
||||||
s32_le location_count;
|
s32_le location_count;
|
||||||
std::array<Locations, 4> locations{};
|
std::array<Locations, 4> locations;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(GestureState) == 0x68, "GestureState is an invalid size");
|
static_assert(sizeof(GestureState) == 0x68, "GestureState is an invalid size");
|
||||||
|
|
||||||
|
@ -58,4 +59,4 @@ private:
|
||||||
};
|
};
|
||||||
SharedMemory shared_memory{};
|
SharedMemory shared_memory{};
|
||||||
};
|
};
|
||||||
}; // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -2,16 +2,22 @@
|
||||||
// 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.
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/swap.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"
|
||||||
|
|
||||||
namespace Service::HID {
|
namespace Service::HID {
|
||||||
constexpr size_t SHARED_MEMORY_OFFSET = 0x3800;
|
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3800;
|
||||||
|
|
||||||
|
Controller_Keyboard::Controller_Keyboard() = default;
|
||||||
|
|
||||||
void Controller_Keyboard::OnInit() {}
|
void Controller_Keyboard::OnInit() {}
|
||||||
|
|
||||||
void Controller_Keyboard::OnRelease() {}
|
void Controller_Keyboard::OnRelease() {}
|
||||||
void Controller_Keyboard::OnUpdate(u8* data, size_t size) {
|
|
||||||
|
void Controller_Keyboard::OnUpdate(u8* data, std::size_t size) {
|
||||||
shared_memory.header.timestamp = CoreTiming::GetTicks();
|
shared_memory.header.timestamp = CoreTiming::GetTicks();
|
||||||
shared_memory.header.total_entry_count = 17;
|
shared_memory.header.total_entry_count = 17;
|
||||||
|
|
||||||
|
@ -22,7 +28,7 @@ void Controller_Keyboard::OnUpdate(u8* data, size_t size) {
|
||||||
}
|
}
|
||||||
shared_memory.header.entry_count = 16;
|
shared_memory.header.entry_count = 16;
|
||||||
|
|
||||||
auto& last_entry = shared_memory.pad_states[shared_memory.header.last_entry_index];
|
const auto& last_entry = shared_memory.pad_states[shared_memory.header.last_entry_index];
|
||||||
shared_memory.header.last_entry_index = (shared_memory.header.last_entry_index + 1) % 17;
|
shared_memory.header.last_entry_index = (shared_memory.header.last_entry_index + 1) % 17;
|
||||||
auto& cur_entry = shared_memory.pad_states[shared_memory.header.last_entry_index];
|
auto& cur_entry = shared_memory.pad_states[shared_memory.header.last_entry_index];
|
||||||
|
|
||||||
|
@ -32,5 +38,6 @@ void Controller_Keyboard::OnUpdate(u8* data, size_t size) {
|
||||||
|
|
||||||
std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory));
|
std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller_Keyboard::OnLoadInputDevices() {}
|
void Controller_Keyboard::OnLoadInputDevices() {}
|
||||||
}; // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
@ -12,7 +13,7 @@
|
||||||
namespace Service::HID {
|
namespace Service::HID {
|
||||||
class Controller_Keyboard final : public ControllerBase {
|
class Controller_Keyboard final : public ControllerBase {
|
||||||
public:
|
public:
|
||||||
Controller_Keyboard() = default;
|
Controller_Keyboard();
|
||||||
|
|
||||||
// Called when the controller is initialized
|
// Called when the controller is initialized
|
||||||
void OnInit() override;
|
void OnInit() override;
|
||||||
|
@ -21,7 +22,7 @@ public:
|
||||||
void OnRelease() override;
|
void OnRelease() override;
|
||||||
|
|
||||||
// When the controller is requesting an update for the shared memory
|
// When the controller is requesting an update for the shared memory
|
||||||
void OnUpdate(u8* data, size_t size) override;
|
void OnUpdate(u8* data, std::size_t size) override;
|
||||||
|
|
||||||
// Called when input devices should be loaded
|
// Called when input devices should be loaded
|
||||||
void OnLoadInputDevices() override;
|
void OnLoadInputDevices() override;
|
||||||
|
@ -33,7 +34,7 @@ private:
|
||||||
|
|
||||||
s32_le modifier;
|
s32_le modifier;
|
||||||
s32_le attribute;
|
s32_le attribute;
|
||||||
std::array<u8, 32> key{};
|
std::array<u8, 32> key;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(KeyboardState) == 0x38, "KeyboardState is an invalid size");
|
static_assert(sizeof(KeyboardState) == 0x38, "KeyboardState is an invalid size");
|
||||||
|
|
||||||
|
@ -45,4 +46,4 @@ private:
|
||||||
static_assert(sizeof(SharedMemory) == 0x400, "SharedMemory is an invalid size");
|
static_assert(sizeof(SharedMemory) == 0x400, "SharedMemory is an invalid size");
|
||||||
SharedMemory shared_memory{};
|
SharedMemory shared_memory{};
|
||||||
};
|
};
|
||||||
}; // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -2,16 +2,22 @@
|
||||||
// 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.
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/swap.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"
|
||||||
|
|
||||||
namespace Service::HID {
|
namespace Service::HID {
|
||||||
constexpr size_t SHARED_MEMORY_OFFSET = 0x3400;
|
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3400;
|
||||||
|
|
||||||
|
Controller_Mouse::Controller_Mouse() = default;
|
||||||
|
|
||||||
void Controller_Mouse::OnInit() {}
|
void Controller_Mouse::OnInit() {}
|
||||||
|
|
||||||
void Controller_Mouse::OnRelease() {}
|
void Controller_Mouse::OnRelease() {}
|
||||||
void Controller_Mouse::OnUpdate(u8* data, size_t size) {
|
|
||||||
|
void Controller_Mouse::OnUpdate(u8* data, std::size_t size) {
|
||||||
shared_memory.header.timestamp = CoreTiming::GetTicks();
|
shared_memory.header.timestamp = CoreTiming::GetTicks();
|
||||||
shared_memory.header.total_entry_count = 17;
|
shared_memory.header.total_entry_count = 17;
|
||||||
|
|
||||||
|
@ -32,5 +38,6 @@ void Controller_Mouse::OnUpdate(u8* data, size_t size) {
|
||||||
|
|
||||||
std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory));
|
std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller_Mouse::OnLoadInputDevices() {}
|
void Controller_Mouse::OnLoadInputDevices() {}
|
||||||
}; // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/swap.h"
|
#include "common/swap.h"
|
||||||
|
@ -11,7 +12,7 @@
|
||||||
namespace Service::HID {
|
namespace Service::HID {
|
||||||
class Controller_Mouse final : public ControllerBase {
|
class Controller_Mouse final : public ControllerBase {
|
||||||
public:
|
public:
|
||||||
Controller_Mouse() = default;
|
Controller_Mouse();
|
||||||
|
|
||||||
// Called when the controller is initialized
|
// Called when the controller is initialized
|
||||||
void OnInit() override;
|
void OnInit() override;
|
||||||
|
@ -20,7 +21,7 @@ public:
|
||||||
void OnRelease() override;
|
void OnRelease() override;
|
||||||
|
|
||||||
// When the controller is requesting an update for the shared memory
|
// When the controller is requesting an update for the shared memory
|
||||||
void OnUpdate(u8* data, size_t size) override;
|
void OnUpdate(u8* data, std::size_t size) override;
|
||||||
|
|
||||||
// Called when input devices should be loaded
|
// Called when input devices should be loaded
|
||||||
void OnLoadInputDevices() override;
|
void OnLoadInputDevices() override;
|
||||||
|
@ -45,4 +46,4 @@ private:
|
||||||
};
|
};
|
||||||
SharedMemory shared_memory{};
|
SharedMemory shared_memory{};
|
||||||
};
|
};
|
||||||
}; // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -3,10 +3,14 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <cstring>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#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/swap.h"
|
#include "common/swap.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/core_timing.h"
|
#include "core/core_timing.h"
|
||||||
|
@ -22,15 +26,13 @@ constexpr u32 JOYCON_BODY_NEON_BLUE = 0x0AB9E6;
|
||||||
constexpr u32 JOYCON_BUTTONS_NEON_BLUE = 0x001E1E;
|
constexpr u32 JOYCON_BUTTONS_NEON_BLUE = 0x001E1E;
|
||||||
constexpr s32 HID_JOYSTICK_MAX = 0x7fff;
|
constexpr s32 HID_JOYSTICK_MAX = 0x7fff;
|
||||||
constexpr s32 HID_JOYSTICK_MIN = -0x7fff;
|
constexpr s32 HID_JOYSTICK_MIN = -0x7fff;
|
||||||
constexpr size_t NPAD_OFFSET = 0x9A00;
|
constexpr std::size_t NPAD_OFFSET = 0x9A00;
|
||||||
constexpr size_t MAX_CONTROLLER_COUNT = 9;
|
|
||||||
|
|
||||||
enum class JoystickId : size_t { Joystick_Left, Joystick_Right };
|
enum class JoystickId : std::size_t { Joystick_Left, Joystick_Right };
|
||||||
constexpr std::array<u32, MAX_CONTROLLER_COUNT> NPAD_ID_LIST{0, 1, 2, 3, 4, 5, 6, 7, 32};
|
|
||||||
size_t CONTROLLER_COUNT{};
|
|
||||||
std::array<Controller_NPad::NPadControllerType, MAX_CONTROLLER_COUNT> CONNECTED_CONTROLLERS{};
|
|
||||||
|
|
||||||
void Controller_NPad::InitNewlyAddedControler(size_t controller_idx) {
|
Controller_NPad::Controller_NPad() = default;
|
||||||
|
|
||||||
|
void Controller_NPad::InitNewlyAddedControler(std::size_t controller_idx) {
|
||||||
const auto controller_type = CONNECTED_CONTROLLERS[controller_idx];
|
const auto controller_type = CONNECTED_CONTROLLERS[controller_idx];
|
||||||
auto& controller = shared_memory_entries[controller_idx];
|
auto& controller = shared_memory_entries[controller_idx];
|
||||||
if (controller_type == NPadControllerType::None) {
|
if (controller_type == NPadControllerType::None) {
|
||||||
|
@ -79,7 +81,7 @@ void Controller_NPad::InitNewlyAddedControler(size_t controller_idx) {
|
||||||
controller.right_color.body_color = JOYCON_BODY_NEON_RED;
|
controller.right_color.body_color = JOYCON_BODY_NEON_RED;
|
||||||
controller.right_color.button_color = JOYCON_BUTTONS_NEON_RED;
|
controller.right_color.button_color = JOYCON_BUTTONS_NEON_RED;
|
||||||
|
|
||||||
controller.properties.is_verticle.Assign(1); // TODO(ogniK): Swap joycons orientations
|
controller.properties.is_vertical.Assign(1); // TODO(ogniK): Swap joycons orientations
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller_NPad::OnInit() {
|
void Controller_NPad::OnInit() {
|
||||||
|
@ -89,7 +91,7 @@ void Controller_NPad::OnInit() {
|
||||||
|
|
||||||
if (!IsControllerActivated())
|
if (!IsControllerActivated())
|
||||||
return;
|
return;
|
||||||
size_t controller{};
|
std::size_t controller{};
|
||||||
supported_npad_id_types.resize(NPAD_ID_LIST.size());
|
supported_npad_id_types.resize(NPAD_ID_LIST.size());
|
||||||
if (style.raw == 0) {
|
if (style.raw == 0) {
|
||||||
// We want to support all controllers
|
// We want to support all controllers
|
||||||
|
@ -118,10 +120,10 @@ void Controller_NPad::OnLoadInputDevices() {
|
||||||
|
|
||||||
void Controller_NPad::OnRelease() {}
|
void Controller_NPad::OnRelease() {}
|
||||||
|
|
||||||
void Controller_NPad::OnUpdate(u8* data, size_t data_len) {
|
void Controller_NPad::OnUpdate(u8* data, std::size_t data_len) {
|
||||||
if (!IsControllerActivated())
|
if (!IsControllerActivated())
|
||||||
return;
|
return;
|
||||||
for (size_t i = 0; i < shared_memory_entries.size(); i++) {
|
for (std::size_t i = 0; i < shared_memory_entries.size(); i++) {
|
||||||
auto& npad = shared_memory_entries[i];
|
auto& npad = shared_memory_entries[i];
|
||||||
const std::array<NPadGeneric*, 7> controller_npads{&npad.main_controller_states,
|
const std::array<NPadGeneric*, 7> controller_npads{&npad.main_controller_states,
|
||||||
&npad.handheld_states,
|
&npad.handheld_states,
|
||||||
|
@ -131,11 +133,12 @@ void Controller_NPad::OnUpdate(u8* data, size_t data_len) {
|
||||||
&npad.pokeball_states,
|
&npad.pokeball_states,
|
||||||
&npad.libnx};
|
&npad.libnx};
|
||||||
|
|
||||||
for (auto main_controller : controller_npads) {
|
for (auto* main_controller : controller_npads) {
|
||||||
main_controller->common.entry_count = 16;
|
main_controller->common.entry_count = 16;
|
||||||
main_controller->common.total_entry_count = 17;
|
main_controller->common.total_entry_count = 17;
|
||||||
|
|
||||||
auto& last_entry = main_controller->npad[main_controller->common.last_entry_index];
|
const auto& last_entry =
|
||||||
|
main_controller->npad[main_controller->common.last_entry_index];
|
||||||
|
|
||||||
main_controller->common.timestamp = CoreTiming::GetTicks();
|
main_controller->common.timestamp = CoreTiming::GetTicks();
|
||||||
main_controller->common.last_entry_index =
|
main_controller->common.last_entry_index =
|
||||||
|
@ -154,7 +157,7 @@ void Controller_NPad::OnUpdate(u8* data, size_t data_len) {
|
||||||
const auto& controller_type = CONNECTED_CONTROLLERS[i];
|
const auto& controller_type = CONNECTED_CONTROLLERS[i];
|
||||||
|
|
||||||
// Pad states
|
// Pad states
|
||||||
auto pad_state = ControllerPadState{};
|
ControllerPadState pad_state{};
|
||||||
using namespace Settings::NativeButton;
|
using namespace Settings::NativeButton;
|
||||||
pad_state.a.Assign(buttons[A - BUTTON_HID_BEGIN]->GetStatus());
|
pad_state.a.Assign(buttons[A - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
pad_state.b.Assign(buttons[B - BUTTON_HID_BEGIN]->GetStatus());
|
pad_state.b.Assign(buttons[B - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
|
@ -169,20 +172,20 @@ void Controller_NPad::OnUpdate(u8* data, size_t data_len) {
|
||||||
pad_state.plus.Assign(buttons[Plus - BUTTON_HID_BEGIN]->GetStatus());
|
pad_state.plus.Assign(buttons[Plus - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
pad_state.minus.Assign(buttons[Minus - BUTTON_HID_BEGIN]->GetStatus());
|
pad_state.minus.Assign(buttons[Minus - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
|
|
||||||
pad_state.dleft.Assign(buttons[DLeft - BUTTON_HID_BEGIN]->GetStatus());
|
pad_state.d_left.Assign(buttons[DLeft - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
pad_state.dup.Assign(buttons[DUp - BUTTON_HID_BEGIN]->GetStatus());
|
pad_state.d_up.Assign(buttons[DUp - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
pad_state.dright.Assign(buttons[DRight - BUTTON_HID_BEGIN]->GetStatus());
|
pad_state.d_right.Assign(buttons[DRight - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
pad_state.ddown.Assign(buttons[DDown - BUTTON_HID_BEGIN]->GetStatus());
|
pad_state.d_down.Assign(buttons[DDown - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
|
|
||||||
pad_state.lstickleft.Assign(buttons[LStick_Left - BUTTON_HID_BEGIN]->GetStatus());
|
pad_state.l_stick_left.Assign(buttons[LStick_Left - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
pad_state.lstickup.Assign(buttons[LStick_Up - BUTTON_HID_BEGIN]->GetStatus());
|
pad_state.l_stick_up.Assign(buttons[LStick_Up - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
pad_state.lstickright.Assign(buttons[LStick_Right - BUTTON_HID_BEGIN]->GetStatus());
|
pad_state.l_stick_right.Assign(buttons[LStick_Right - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
pad_state.lstickdown.Assign(buttons[LStick_Down - BUTTON_HID_BEGIN]->GetStatus());
|
pad_state.l_stick_down.Assign(buttons[LStick_Down - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
|
|
||||||
pad_state.rstickleft.Assign(buttons[RStick_Left - BUTTON_HID_BEGIN]->GetStatus());
|
pad_state.r_stick_left.Assign(buttons[RStick_Left - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
pad_state.rstickup.Assign(buttons[RStick_Up - BUTTON_HID_BEGIN]->GetStatus());
|
pad_state.r_stick_up.Assign(buttons[RStick_Up - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
pad_state.rstickright.Assign(buttons[RStick_Right - BUTTON_HID_BEGIN]->GetStatus());
|
pad_state.r_stick_right.Assign(buttons[RStick_Right - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
pad_state.rstickdown.Assign(buttons[RStick_Down - BUTTON_HID_BEGIN]->GetStatus());
|
pad_state.r_stick_down.Assign(buttons[RStick_Down - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
|
|
||||||
pad_state.sl.Assign(buttons[SL - BUTTON_HID_BEGIN]->GetStatus());
|
pad_state.sl.Assign(buttons[SL - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
pad_state.sr.Assign(buttons[SR - BUTTON_HID_BEGIN]->GetStatus());
|
pad_state.sr.Assign(buttons[SR - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
|
@ -191,9 +194,9 @@ void Controller_NPad::OnUpdate(u8* data, size_t data_len) {
|
||||||
AnalogPosition rstick_entry{};
|
AnalogPosition rstick_entry{};
|
||||||
|
|
||||||
const auto [stick_l_x_f, stick_l_y_f] =
|
const auto [stick_l_x_f, stick_l_y_f] =
|
||||||
sticks[static_cast<size_t>(JoystickId::Joystick_Left)]->GetStatus();
|
sticks[static_cast<std::size_t>(JoystickId::Joystick_Left)]->GetStatus();
|
||||||
const auto [stick_r_x_f, stick_r_y_f] =
|
const auto [stick_r_x_f, stick_r_y_f] =
|
||||||
sticks[static_cast<size_t>(JoystickId::Joystick_Right)]->GetStatus();
|
sticks[static_cast<std::size_t>(JoystickId::Joystick_Right)]->GetStatus();
|
||||||
lstick_entry.x = static_cast<s32>(stick_l_x_f * HID_JOYSTICK_MAX);
|
lstick_entry.x = static_cast<s32>(stick_l_x_f * HID_JOYSTICK_MAX);
|
||||||
lstick_entry.y = static_cast<s32>(stick_l_y_f * HID_JOYSTICK_MAX);
|
lstick_entry.y = static_cast<s32>(stick_l_y_f * HID_JOYSTICK_MAX);
|
||||||
rstick_entry.x = static_cast<s32>(stick_r_x_f * HID_JOYSTICK_MAX);
|
rstick_entry.x = static_cast<s32>(stick_r_x_f * HID_JOYSTICK_MAX);
|
||||||
|
@ -220,26 +223,26 @@ void Controller_NPad::OnUpdate(u8* data, size_t data_len) {
|
||||||
handheld_entry.connection_status.IsConnected.Assign(1);
|
handheld_entry.connection_status.IsConnected.Assign(1);
|
||||||
handheld_entry.connection_status.IsWired.Assign(1);
|
handheld_entry.connection_status.IsWired.Assign(1);
|
||||||
handheld_entry.pad_states.raw = pad_state.raw;
|
handheld_entry.pad_states.raw = pad_state.raw;
|
||||||
handheld_entry.lstick = lstick_entry;
|
handheld_entry.l_stick = lstick_entry;
|
||||||
handheld_entry.rstick = rstick_entry;
|
handheld_entry.r_stick = rstick_entry;
|
||||||
break;
|
break;
|
||||||
case NPadControllerType::JoyLeft:
|
case NPadControllerType::JoyLeft:
|
||||||
left_entry.connection_status.IsConnected.Assign(1);
|
left_entry.connection_status.IsConnected.Assign(1);
|
||||||
left_entry.pad_states.raw = pad_state.raw;
|
left_entry.pad_states.raw = pad_state.raw;
|
||||||
left_entry.lstick = lstick_entry;
|
left_entry.l_stick = lstick_entry;
|
||||||
left_entry.rstick = rstick_entry;
|
left_entry.r_stick = rstick_entry;
|
||||||
break;
|
break;
|
||||||
case NPadControllerType::JoyRight:
|
case NPadControllerType::JoyRight:
|
||||||
right_entry.connection_status.IsConnected.Assign(1);
|
right_entry.connection_status.IsConnected.Assign(1);
|
||||||
right_entry.pad_states.raw = pad_state.raw;
|
right_entry.pad_states.raw = pad_state.raw;
|
||||||
right_entry.lstick = lstick_entry;
|
right_entry.l_stick = lstick_entry;
|
||||||
right_entry.rstick = rstick_entry;
|
right_entry.r_stick = rstick_entry;
|
||||||
break;
|
break;
|
||||||
case NPadControllerType::Tabletop:
|
case NPadControllerType::Tabletop:
|
||||||
// TODO(ogniK): Figure out how to add proper tabletop support
|
// TODO(ogniK): Figure out how to add proper tabletop support
|
||||||
dual_entry.pad_states.raw = pad_state.raw;
|
dual_entry.pad_states.raw = pad_state.raw;
|
||||||
dual_entry.lstick = lstick_entry;
|
dual_entry.l_stick = lstick_entry;
|
||||||
dual_entry.rstick = rstick_entry;
|
dual_entry.r_stick = rstick_entry;
|
||||||
dual_entry.connection_status.IsConnected.Assign(1);
|
dual_entry.connection_status.IsConnected.Assign(1);
|
||||||
break;
|
break;
|
||||||
case NPadControllerType::Pokeball:
|
case NPadControllerType::Pokeball:
|
||||||
|
@ -247,13 +250,13 @@ void Controller_NPad::OnUpdate(u8* data, size_t data_len) {
|
||||||
pokeball_entry.connection_status.IsWired.Assign(1);
|
pokeball_entry.connection_status.IsWired.Assign(1);
|
||||||
|
|
||||||
pokeball_entry.pad_states.raw = pad_state.raw;
|
pokeball_entry.pad_states.raw = pad_state.raw;
|
||||||
pokeball_entry.lstick = lstick_entry;
|
pokeball_entry.l_stick = lstick_entry;
|
||||||
pokeball_entry.rstick = rstick_entry;
|
pokeball_entry.r_stick = rstick_entry;
|
||||||
break;
|
break;
|
||||||
case NPadControllerType::ProController:
|
case NPadControllerType::ProController:
|
||||||
main_controller.pad_states.raw = pad_state.raw;
|
main_controller.pad_states.raw = pad_state.raw;
|
||||||
main_controller.lstick = lstick_entry;
|
main_controller.l_stick = lstick_entry;
|
||||||
main_controller.rstick = rstick_entry;
|
main_controller.r_stick = rstick_entry;
|
||||||
main_controller.connection_status.IsConnected.Assign(1);
|
main_controller.connection_status.IsConnected.Assign(1);
|
||||||
main_controller.connection_status.IsWired.Assign(1);
|
main_controller.connection_status.IsWired.Assign(1);
|
||||||
break;
|
break;
|
||||||
|
@ -264,8 +267,8 @@ void Controller_NPad::OnUpdate(u8* data, size_t data_len) {
|
||||||
libnx_entry.connection_status.IsConnected.Assign(1);
|
libnx_entry.connection_status.IsConnected.Assign(1);
|
||||||
libnx_entry.connection_status.IsWired.Assign(1);
|
libnx_entry.connection_status.IsWired.Assign(1);
|
||||||
libnx_entry.pad_states.raw = pad_state.raw;
|
libnx_entry.pad_states.raw = pad_state.raw;
|
||||||
libnx_entry.lstick = lstick_entry;
|
libnx_entry.l_stick = lstick_entry;
|
||||||
libnx_entry.rstick = rstick_entry;
|
libnx_entry.r_stick = rstick_entry;
|
||||||
}
|
}
|
||||||
std::memcpy(data + NPAD_OFFSET, shared_memory_entries.data(),
|
std::memcpy(data + NPAD_OFFSET, shared_memory_entries.data(),
|
||||||
shared_memory_entries.size() * sizeof(NPadEntry));
|
shared_memory_entries.size() * sizeof(NPadEntry));
|
||||||
|
@ -279,18 +282,18 @@ Controller_NPad::NPadType Controller_NPad::GetSupportedStyleSet() const {
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller_NPad::SetSupportedNPadIdTypes(u8* data, size_t length) {
|
void Controller_NPad::SetSupportedNPadIdTypes(u8* data, std::size_t length) {
|
||||||
ASSERT(length > 0 && (length % sizeof(u32)) == 0);
|
ASSERT(length > 0 && (length % sizeof(u32)) == 0);
|
||||||
supported_npad_id_types.resize(length / 4);
|
supported_npad_id_types.resize(length / sizeof(u32));
|
||||||
std::memcpy(supported_npad_id_types.data(), data, length);
|
std::memcpy(supported_npad_id_types.data(), data, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller_NPad::GetSupportedNpadIdTypes(u32* data, size_t max_length) {
|
const 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());
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Controller_NPad::GetSupportedNPadIdTypesSize() const {
|
std::size_t Controller_NPad::GetSupportedNPadIdTypesSize() const {
|
||||||
return supported_npad_id_types.size();
|
return supported_npad_id_types.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +311,7 @@ void Controller_NPad::SetNpadMode(u32 npad_id, NPadAssignments assignment_mode)
|
||||||
|
|
||||||
void Controller_NPad::VibrateController(const std::vector<u32>& controller_ids,
|
void Controller_NPad::VibrateController(const std::vector<u32>& controller_ids,
|
||||||
const std::vector<Vibration>& vibrations) {
|
const std::vector<Vibration>& vibrations) {
|
||||||
for (size_t i = 0; i < controller_ids.size(); i++) {
|
for (std::size_t i = 0; i < controller_ids.size(); i++) {
|
||||||
if (i >= CONTROLLER_COUNT) {
|
if (i >= CONTROLLER_COUNT) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -326,11 +329,11 @@ Controller_NPad::Vibration Controller_NPad::GetLastVibration() const {
|
||||||
return last_processed_vibration;
|
return last_processed_vibration;
|
||||||
}
|
}
|
||||||
void Controller_NPad::AddNewController(NPadControllerType controller) {
|
void Controller_NPad::AddNewController(NPadControllerType controller) {
|
||||||
if (CONTROLLER_COUNT >= MAX_CONTROLLER_COUNT) {
|
if (CONTROLLER_COUNT >= CONNECTED_CONTROLLERS.size()) {
|
||||||
LOG_ERROR(Service_HID, "Cannot connect any more controllers!");
|
LOG_ERROR(Service_HID, "Cannot connect any more controllers!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CONNECTED_CONTROLLERS[CONTROLLER_COUNT] = controller;
|
CONNECTED_CONTROLLERS[CONTROLLER_COUNT] = controller;
|
||||||
InitNewlyAddedControler(CONTROLLER_COUNT++);
|
InitNewlyAddedControler(CONTROLLER_COUNT++);
|
||||||
}
|
}
|
||||||
}; // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -3,17 +3,24 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/frontend/input.h"
|
|
||||||
#include "core/hle/service/hid/controllers/controller_base.h"
|
#include "core/hle/service/hid/controllers/controller_base.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
|
|
||||||
|
namespace Input {
|
||||||
|
template <typename StatusType>
|
||||||
|
class InputDevice;
|
||||||
|
using ButtonDevice = InputDevice<bool>;
|
||||||
|
using AnalogDevice = InputDevice<std::tuple<float, float>>;
|
||||||
|
} // namespace Input
|
||||||
|
|
||||||
namespace Service::HID {
|
namespace Service::HID {
|
||||||
|
|
||||||
class Controller_NPad final : public ControllerBase {
|
class Controller_NPad final : public ControllerBase {
|
||||||
public:
|
public:
|
||||||
Controller_NPad() = default;
|
Controller_NPad();
|
||||||
|
|
||||||
// Called when the controller is initialized
|
// Called when the controller is initialized
|
||||||
void OnInit() override;
|
void OnInit() override;
|
||||||
|
@ -22,7 +29,7 @@ public:
|
||||||
void OnRelease() override;
|
void OnRelease() override;
|
||||||
|
|
||||||
// When the controller is requesting an update for the shared memory
|
// When the controller is requesting an update for the shared memory
|
||||||
void OnUpdate(u8* data, size_t size) override;
|
void OnUpdate(u8* data, std::size_t size) override;
|
||||||
|
|
||||||
// Called when input devices should be loaded
|
// Called when input devices should be loaded
|
||||||
void OnLoadInputDevices() override;
|
void OnLoadInputDevices() override;
|
||||||
|
@ -67,15 +74,15 @@ public:
|
||||||
JoyLeft,
|
JoyLeft,
|
||||||
JoyRight,
|
JoyRight,
|
||||||
Tabletop,
|
Tabletop,
|
||||||
Pokeball
|
Pokeball,
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetSupportedStyleSet(NPadType style_set);
|
void SetSupportedStyleSet(NPadType style_set);
|
||||||
NPadType GetSupportedStyleSet() const;
|
NPadType GetSupportedStyleSet() const;
|
||||||
|
|
||||||
void SetSupportedNPadIdTypes(u8* data, size_t length);
|
void SetSupportedNPadIdTypes(u8* data, std::size_t length);
|
||||||
void GetSupportedNpadIdTypes(u32* data, size_t max_length);
|
const void GetSupportedNpadIdTypes(u32* data, std::size_t max_length);
|
||||||
size_t GetSupportedNPadIdTypesSize() const;
|
std::size_t GetSupportedNPadIdTypesSize() const;
|
||||||
|
|
||||||
void SetHoldType(NpadHoldType joy_hold_type);
|
void SetHoldType(NpadHoldType joy_hold_type);
|
||||||
NpadHoldType GetHoldType() const;
|
NpadHoldType GetHoldType() const;
|
||||||
|
@ -123,22 +130,22 @@ private:
|
||||||
BitField<11, 1, u64_le> minus;
|
BitField<11, 1, u64_le> minus;
|
||||||
|
|
||||||
// D-Pad
|
// D-Pad
|
||||||
BitField<12, 1, u64_le> dleft;
|
BitField<12, 1, u64_le> d_left;
|
||||||
BitField<13, 1, u64_le> dup;
|
BitField<13, 1, u64_le> d_up;
|
||||||
BitField<14, 1, u64_le> dright;
|
BitField<14, 1, u64_le> d_right;
|
||||||
BitField<15, 1, u64_le> ddown;
|
BitField<15, 1, u64_le> d_down;
|
||||||
|
|
||||||
// Left JoyStick
|
// Left JoyStick
|
||||||
BitField<16, 1, u64_le> lstickleft;
|
BitField<16, 1, u64_le> l_stick_left;
|
||||||
BitField<17, 1, u64_le> lstickup;
|
BitField<17, 1, u64_le> l_stick_up;
|
||||||
BitField<18, 1, u64_le> lstickright;
|
BitField<18, 1, u64_le> l_stick_right;
|
||||||
BitField<19, 1, u64_le> lstickdown;
|
BitField<19, 1, u64_le> l_stick_down;
|
||||||
|
|
||||||
// Right JoyStick
|
// Right JoyStick
|
||||||
BitField<20, 1, u64_le> rstickleft;
|
BitField<20, 1, u64_le> r_stick_left;
|
||||||
BitField<21, 1, u64_le> rstickup;
|
BitField<21, 1, u64_le> r_stick_up;
|
||||||
BitField<22, 1, u64_le> rstickright;
|
BitField<22, 1, u64_le> r_stick_right;
|
||||||
BitField<23, 1, u64_le> rstickdown;
|
BitField<23, 1, u64_le> r_stick_down;
|
||||||
|
|
||||||
// Not always active?
|
// Not always active?
|
||||||
BitField<24, 1, u64_le> sl;
|
BitField<24, 1, u64_le> sl;
|
||||||
|
@ -166,8 +173,8 @@ private:
|
||||||
s64_le timestamp;
|
s64_le timestamp;
|
||||||
s64_le timestamp2;
|
s64_le timestamp2;
|
||||||
ControllerPadState pad_states;
|
ControllerPadState pad_states;
|
||||||
AnalogPosition lstick;
|
AnalogPosition l_stick;
|
||||||
AnalogPosition rstick;
|
AnalogPosition r_stick;
|
||||||
ConnectionState connection_status;
|
ConnectionState connection_status;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(GenericStates) == 0x30, "NPadGenericStates is an invalid size");
|
static_assert(sizeof(GenericStates) == 0x30, "NPadGenericStates is an invalid size");
|
||||||
|
@ -187,7 +194,7 @@ private:
|
||||||
struct NPadProperties {
|
struct NPadProperties {
|
||||||
union {
|
union {
|
||||||
s64_le raw{};
|
s64_le raw{};
|
||||||
BitField<11, 1, s64_le> is_verticle;
|
BitField<11, 1, s64_le> is_vertical;
|
||||||
BitField<12, 1, s64_le> is_horizontal;
|
BitField<12, 1, s64_le> is_horizontal;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -226,7 +233,7 @@ private:
|
||||||
// relying on this for the time being
|
// relying on this for the time being
|
||||||
INSERT_PADDING_BYTES(
|
INSERT_PADDING_BYTES(
|
||||||
0x708 *
|
0x708 *
|
||||||
6); // TODO(ogniK)L SixAxis states, require more information before implementation
|
6); // TODO(ogniK): SixAxis states, require more information before implementation
|
||||||
NPadDevice device_type;
|
NPadDevice device_type;
|
||||||
NPadProperties properties;
|
NPadProperties properties;
|
||||||
INSERT_PADDING_WORDS(4);
|
INSERT_PADDING_WORDS(4);
|
||||||
|
@ -242,8 +249,12 @@ 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;
|
||||||
size_t dump_idx{};
|
std::size_t dump_idx{};
|
||||||
Vibration last_processed_vibration{};
|
Vibration last_processed_vibration{};
|
||||||
void InitNewlyAddedControler(size_t controller_idx);
|
std::size_t CONTROLLER_COUNT{};
|
||||||
|
const std::array<u32, 9> NPAD_ID_LIST{0, 1, 2, 3, 4, 5, 6, 7, 32};
|
||||||
|
std::array<Controller_NPad::NPadControllerType, 9> CONNECTED_CONTROLLERS{};
|
||||||
|
|
||||||
|
void InitNewlyAddedControler(std::size_t controller_idx);
|
||||||
};
|
};
|
||||||
}; // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -2,15 +2,21 @@
|
||||||
// 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.
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/swap.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;
|
||||||
|
|
||||||
void Controller_Stubbed::OnInit() {}
|
void Controller_Stubbed::OnInit() {}
|
||||||
|
|
||||||
void Controller_Stubbed::OnRelease() {}
|
void Controller_Stubbed::OnRelease() {}
|
||||||
void Controller_Stubbed::OnUpdate(u8* data, size_t size) {
|
|
||||||
|
void Controller_Stubbed::OnUpdate(u8* data, std::size_t size) {
|
||||||
if (!smart_update) {
|
if (!smart_update) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -23,10 +29,11 @@ void Controller_Stubbed::OnUpdate(u8* data, size_t size) {
|
||||||
|
|
||||||
std::memcpy(data + common_offset, &header, sizeof(CommonHeader));
|
std::memcpy(data + common_offset, &header, sizeof(CommonHeader));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller_Stubbed::OnLoadInputDevices() {}
|
void Controller_Stubbed::OnLoadInputDevices() {}
|
||||||
|
|
||||||
void Controller_Stubbed::SetCommonHeaderOffset(size_t off) {
|
void Controller_Stubbed::SetCommonHeaderOffset(std::size_t off) {
|
||||||
common_offset = off;
|
common_offset = off;
|
||||||
smart_update = true;
|
smart_update = true;
|
||||||
}
|
}
|
||||||
}; // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -3,13 +3,14 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.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_Stubbed final : public ControllerBase {
|
class Controller_Stubbed final : public ControllerBase {
|
||||||
public:
|
public:
|
||||||
Controller_Stubbed() = default;
|
Controller_Stubbed();
|
||||||
|
|
||||||
// Called when the controller is initialized
|
// Called when the controller is initialized
|
||||||
void OnInit() override;
|
void OnInit() override;
|
||||||
|
@ -18,15 +19,15 @@ public:
|
||||||
void OnRelease() override;
|
void OnRelease() override;
|
||||||
|
|
||||||
// When the controller is requesting an update for the shared memory
|
// When the controller is requesting an update for the shared memory
|
||||||
void OnUpdate(u8* data, size_t size) override;
|
void OnUpdate(u8* data, std::size_t size) override;
|
||||||
|
|
||||||
// Called when input devices should be loaded
|
// Called when input devices should be loaded
|
||||||
void OnLoadInputDevices() override;
|
void OnLoadInputDevices() override;
|
||||||
|
|
||||||
void SetCommonHeaderOffset(size_t off);
|
void SetCommonHeaderOffset(std::size_t off);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool smart_update{};
|
bool smart_update{};
|
||||||
size_t common_offset{};
|
std::size_t common_offset{};
|
||||||
};
|
};
|
||||||
}; // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// 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.
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/swap.h"
|
#include "common/swap.h"
|
||||||
#include "core/core_timing.h"
|
#include "core/core_timing.h"
|
||||||
|
@ -11,10 +12,15 @@
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
|
|
||||||
namespace Service::HID {
|
namespace Service::HID {
|
||||||
constexpr size_t SHARED_MEMORY_OFFSET = 0x400;
|
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x400;
|
||||||
|
|
||||||
|
Controller_Touchscreen::Controller_Touchscreen() = default;
|
||||||
|
|
||||||
void Controller_Touchscreen::OnInit() {}
|
void Controller_Touchscreen::OnInit() {}
|
||||||
|
|
||||||
void Controller_Touchscreen::OnRelease() {}
|
void Controller_Touchscreen::OnRelease() {}
|
||||||
void Controller_Touchscreen::OnUpdate(u8* data, size_t size) {
|
|
||||||
|
void Controller_Touchscreen::OnUpdate(u8* data, std::size_t size) {
|
||||||
shared_memory.header.timestamp = CoreTiming::GetTicks();
|
shared_memory.header.timestamp = CoreTiming::GetTicks();
|
||||||
shared_memory.header.total_entry_count = 17;
|
shared_memory.header.total_entry_count = 17;
|
||||||
|
|
||||||
|
@ -25,14 +31,15 @@ void Controller_Touchscreen::OnUpdate(u8* data, size_t size) {
|
||||||
}
|
}
|
||||||
shared_memory.header.entry_count = 16;
|
shared_memory.header.entry_count = 16;
|
||||||
|
|
||||||
auto& last_entry = shared_memory.shared_memory_entries[shared_memory.header.last_entry_index];
|
const auto& last_entry =
|
||||||
|
shared_memory.shared_memory_entries[shared_memory.header.last_entry_index];
|
||||||
shared_memory.header.last_entry_index = (shared_memory.header.last_entry_index + 1) % 17;
|
shared_memory.header.last_entry_index = (shared_memory.header.last_entry_index + 1) % 17;
|
||||||
auto& cur_entry = shared_memory.shared_memory_entries[shared_memory.header.last_entry_index];
|
auto& cur_entry = shared_memory.shared_memory_entries[shared_memory.header.last_entry_index];
|
||||||
|
|
||||||
cur_entry.sampling_number = last_entry.sampling_number + 1;
|
cur_entry.sampling_number = last_entry.sampling_number + 1;
|
||||||
cur_entry.sampling_number2 = cur_entry.sampling_number;
|
cur_entry.sampling_number2 = cur_entry.sampling_number;
|
||||||
|
|
||||||
auto [x, y, pressed] = touch_device->GetStatus();
|
const auto [x, y, pressed] = touch_device->GetStatus();
|
||||||
auto& touch_entry = cur_entry.states[0];
|
auto& touch_entry = cur_entry.states[0];
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
touch_entry.x = static_cast<u16>(x * Layout::ScreenUndocked::Width);
|
touch_entry.x = static_cast<u16>(x * Layout::ScreenUndocked::Width);
|
||||||
|
@ -55,4 +62,4 @@ void Controller_Touchscreen::OnUpdate(u8* data, size_t size) {
|
||||||
void Controller_Touchscreen::OnLoadInputDevices() {
|
void Controller_Touchscreen::OnLoadInputDevices() {
|
||||||
touch_device = Input::CreateDevice<Input::TouchDevice>(Settings::values.touch_device);
|
touch_device = Input::CreateDevice<Input::TouchDevice>(Settings::values.touch_device);
|
||||||
}
|
}
|
||||||
}; // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -3,16 +3,22 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#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 Input {
|
||||||
|
template <typename StatusType>
|
||||||
|
class InputDevice;
|
||||||
|
using TouchDevice = InputDevice<std::tuple<float, float, bool>>;
|
||||||
|
} // namespace Input
|
||||||
|
|
||||||
namespace Service::HID {
|
namespace Service::HID {
|
||||||
class Controller_Touchscreen final : public ControllerBase {
|
class Controller_Touchscreen final : public ControllerBase {
|
||||||
public:
|
public:
|
||||||
Controller_Touchscreen() = default;
|
Controller_Touchscreen();
|
||||||
|
|
||||||
// Called when the controller is initialized
|
// Called when the controller is initialized
|
||||||
void OnInit() override;
|
void OnInit() override;
|
||||||
|
@ -21,7 +27,7 @@ public:
|
||||||
void OnRelease() override;
|
void OnRelease() override;
|
||||||
|
|
||||||
// When the controller is requesting an update for the shared memory
|
// When the controller is requesting an update for the shared memory
|
||||||
void OnUpdate(u8* data, size_t size) override;
|
void OnUpdate(u8* data, std::size_t size) override;
|
||||||
|
|
||||||
// Called when input devices should be loaded
|
// Called when input devices should be loaded
|
||||||
void OnLoadInputDevices() override;
|
void OnLoadInputDevices() override;
|
||||||
|
@ -58,4 +64,4 @@ private:
|
||||||
std::unique_ptr<Input::TouchDevice> touch_device;
|
std::unique_ptr<Input::TouchDevice> touch_device;
|
||||||
s64_le last_touch{};
|
s64_le last_touch{};
|
||||||
};
|
};
|
||||||
}; // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -2,16 +2,22 @@
|
||||||
// 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.
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/swap.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"
|
||||||
|
|
||||||
namespace Service::HID {
|
namespace Service::HID {
|
||||||
constexpr size_t SHARED_MEMORY_OFFSET = 0x3C00;
|
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C00;
|
||||||
|
|
||||||
|
Controller_XPad::Controller_XPad() = default;
|
||||||
|
|
||||||
void Controller_XPad::OnInit() {}
|
void Controller_XPad::OnInit() {}
|
||||||
|
|
||||||
void Controller_XPad::OnRelease() {}
|
void Controller_XPad::OnRelease() {}
|
||||||
void Controller_XPad::OnUpdate(u8* data, size_t size) {
|
|
||||||
|
void Controller_XPad::OnUpdate(u8* data, std::size_t size) {
|
||||||
for (auto& xpad_entry : shared_memory.shared_memory_entries) {
|
for (auto& xpad_entry : shared_memory.shared_memory_entries) {
|
||||||
xpad_entry.header.timestamp = CoreTiming::GetTicks();
|
xpad_entry.header.timestamp = CoreTiming::GetTicks();
|
||||||
xpad_entry.header.total_entry_count = 17;
|
xpad_entry.header.total_entry_count = 17;
|
||||||
|
@ -23,7 +29,7 @@ void Controller_XPad::OnUpdate(u8* data, size_t size) {
|
||||||
}
|
}
|
||||||
xpad_entry.header.entry_count = 16;
|
xpad_entry.header.entry_count = 16;
|
||||||
|
|
||||||
auto& last_entry = xpad_entry.pad_states[xpad_entry.header.last_entry_index];
|
const auto& last_entry = xpad_entry.pad_states[xpad_entry.header.last_entry_index];
|
||||||
xpad_entry.header.last_entry_index = (xpad_entry.header.last_entry_index + 1) % 17;
|
xpad_entry.header.last_entry_index = (xpad_entry.header.last_entry_index + 1) % 17;
|
||||||
auto& cur_entry = xpad_entry.pad_states[xpad_entry.header.last_entry_index];
|
auto& cur_entry = xpad_entry.pad_states[xpad_entry.header.last_entry_index];
|
||||||
|
|
||||||
|
@ -34,5 +40,6 @@ void Controller_XPad::OnUpdate(u8* data, size_t size) {
|
||||||
|
|
||||||
std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory));
|
std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller_XPad::OnLoadInputDevices() {}
|
void Controller_XPad::OnLoadInputDevices() {}
|
||||||
}; // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#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"
|
||||||
|
@ -12,7 +13,7 @@
|
||||||
namespace Service::HID {
|
namespace Service::HID {
|
||||||
class Controller_XPad final : public ControllerBase {
|
class Controller_XPad final : public ControllerBase {
|
||||||
public:
|
public:
|
||||||
Controller_XPad() = default;
|
Controller_XPad();
|
||||||
|
|
||||||
// Called when the controller is initialized
|
// Called when the controller is initialized
|
||||||
void OnInit() override;
|
void OnInit() override;
|
||||||
|
@ -21,7 +22,7 @@ public:
|
||||||
void OnRelease() override;
|
void OnRelease() override;
|
||||||
|
|
||||||
// When the controller is requesting an update for the shared memory
|
// When the controller is requesting an update for the shared memory
|
||||||
void OnUpdate(u8* data, size_t size) override;
|
void OnUpdate(u8* data, std::size_t size) override;
|
||||||
|
|
||||||
// Called when input devices should be loaded
|
// Called when input devices should be loaded
|
||||||
void OnLoadInputDevices() override;
|
void OnLoadInputDevices() override;
|
||||||
|
@ -56,4 +57,4 @@ private:
|
||||||
static_assert(sizeof(SharedMemory) == 0x1000, "SharedMemory is an invalid size");
|
static_assert(sizeof(SharedMemory) == 0x1000, "SharedMemory is an invalid size");
|
||||||
SharedMemory shared_memory{};
|
SharedMemory shared_memory{};
|
||||||
};
|
};
|
||||||
}; // namespace Service::HID
|
} // namespace Service::HID
|
||||||
|
|
|
@ -38,8 +38,8 @@ namespace Service::HID {
|
||||||
constexpr u64 pad_update_ticks = CoreTiming::BASE_CLOCK_RATE / 100;
|
constexpr u64 pad_update_ticks = CoreTiming::BASE_CLOCK_RATE / 100;
|
||||||
constexpr u64 accelerometer_update_ticks = CoreTiming::BASE_CLOCK_RATE / 100;
|
constexpr u64 accelerometer_update_ticks = CoreTiming::BASE_CLOCK_RATE / 100;
|
||||||
constexpr u64 gyroscope_update_ticks = CoreTiming::BASE_CLOCK_RATE / 100;
|
constexpr u64 gyroscope_update_ticks = CoreTiming::BASE_CLOCK_RATE / 100;
|
||||||
constexpr size_t SHARED_MEMORY_SIZE = 0x40000;
|
constexpr std::size_t SHARED_MEMORY_SIZE = 0x40000;
|
||||||
enum class HidController : size_t {
|
enum class HidController : std::size_t {
|
||||||
DebugPad,
|
DebugPad,
|
||||||
Touchscreen,
|
Touchscreen,
|
||||||
Mouse,
|
Mouse,
|
||||||
|
@ -52,7 +52,7 @@ enum class HidController : size_t {
|
||||||
NPad,
|
NPad,
|
||||||
Gesture,
|
Gesture,
|
||||||
|
|
||||||
MaxControllers
|
MaxControllers,
|
||||||
};
|
};
|
||||||
|
|
||||||
class IAppletResource final : public ServiceFramework<IAppletResource> {
|
class IAppletResource final : public ServiceFramework<IAppletResource> {
|
||||||
|
@ -68,33 +68,21 @@ public:
|
||||||
kernel, nullptr, SHARED_MEMORY_SIZE, Kernel::MemoryPermission::ReadWrite,
|
kernel, nullptr, SHARED_MEMORY_SIZE, Kernel::MemoryPermission::ReadWrite,
|
||||||
Kernel::MemoryPermission::Read, 0, Kernel::MemoryRegion::BASE, "HID:SharedMemory");
|
Kernel::MemoryPermission::Read, 0, Kernel::MemoryRegion::BASE, "HID:SharedMemory");
|
||||||
|
|
||||||
controllers[static_cast<size_t>(HidController::DebugPad)] =
|
MakeController<Controller_DebugPad>(HidController::DebugPad);
|
||||||
std::make_unique<Controller_DebugPad>();
|
MakeController<Controller_Touchscreen>(HidController::Touchscreen);
|
||||||
controllers[static_cast<size_t>(HidController::Touchscreen)] =
|
MakeController<Controller_Mouse>(HidController::Mouse);
|
||||||
std::make_unique<Controller_Touchscreen>();
|
MakeController<Controller_Keyboard>(HidController::Keyboard);
|
||||||
controllers[static_cast<size_t>(HidController::Mouse)] =
|
MakeController<Controller_XPad>(HidController::XPad);
|
||||||
std::make_unique<Controller_Mouse>();
|
MakeController<Controller_Stubbed>(HidController::Unknown1);
|
||||||
controllers[static_cast<size_t>(HidController::Keyboard)] =
|
MakeController<Controller_Stubbed>(HidController::Unknown2);
|
||||||
std::make_unique<Controller_Keyboard>();
|
MakeController<Controller_Stubbed>(HidController::Unknown3);
|
||||||
controllers[static_cast<size_t>(HidController::XPad)] = std::make_unique<Controller_XPad>();
|
MakeController<Controller_Stubbed>(HidController::SixAxisSensor);
|
||||||
|
MakeController<Controller_NPad>(HidController::NPad);
|
||||||
controllers[static_cast<size_t>(HidController::Unknown1)] =
|
MakeController<Controller_Gesture>(HidController::Gesture);
|
||||||
std::make_unique<Controller_Stubbed>();
|
|
||||||
controllers[static_cast<size_t>(HidController::Unknown2)] =
|
|
||||||
std::make_unique<Controller_Stubbed>();
|
|
||||||
controllers[static_cast<size_t>(HidController::Unknown3)] =
|
|
||||||
std::make_unique<Controller_Stubbed>();
|
|
||||||
|
|
||||||
controllers[static_cast<size_t>(HidController::SixAxisSensor)] =
|
|
||||||
std::make_unique<Controller_Stubbed>();
|
|
||||||
|
|
||||||
controllers[static_cast<size_t>(HidController::NPad)] = std::make_unique<Controller_NPad>();
|
|
||||||
controllers[static_cast<size_t>(HidController::Gesture)] =
|
|
||||||
std::make_unique<Controller_Gesture>();
|
|
||||||
|
|
||||||
// Homebrew doesn't try to activate some controllers, so we activate them by default
|
// Homebrew doesn't try to activate some controllers, so we activate them by default
|
||||||
controllers[static_cast<size_t>(HidController::NPad)]->ActivateController();
|
GetController<Controller_NPad>(HidController::NPad).ActivateController();
|
||||||
controllers[static_cast<size_t>(HidController::Touchscreen)]->ActivateController();
|
GetController<Controller_Touchscreen>(HidController::Touchscreen).ActivateController();
|
||||||
|
|
||||||
GetController<Controller_Stubbed>(HidController::Unknown1).SetCommonHeaderOffset(0x4c00);
|
GetController<Controller_Stubbed>(HidController::Unknown1).SetCommonHeaderOffset(0x4c00);
|
||||||
GetController<Controller_Stubbed>(HidController::Unknown2).SetCommonHeaderOffset(0x4e00);
|
GetController<Controller_Stubbed>(HidController::Unknown2).SetCommonHeaderOffset(0x4e00);
|
||||||
|
@ -118,6 +106,11 @@ public:
|
||||||
controllers[static_cast<size_t>(controller)]->DeactivateController();
|
controllers[static_cast<size_t>(controller)]->DeactivateController();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void MakeController(HidController controller) {
|
||||||
|
controllers[static_cast<std::size_t>(controller)] = std::make_unique<T>();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T& GetController(HidController controller) {
|
T& GetController(HidController controller) {
|
||||||
return static_cast<T&>(*controllers[static_cast<size_t>(controller)]);
|
return static_cast<T&>(*controllers[static_cast<size_t>(controller)]);
|
||||||
|
@ -136,7 +129,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateControllers(u64 userdata, int cycles_late) {
|
void UpdateControllers(u64 userdata, int cycles_late) {
|
||||||
bool should_reload = Settings::values.is_device_reload_pending.exchange(false);
|
const bool should_reload = Settings::values.is_device_reload_pending.exchange(false);
|
||||||
for (const auto& controller : controllers) {
|
for (const auto& controller : controllers) {
|
||||||
if (should_reload) {
|
if (should_reload) {
|
||||||
controller->OnLoadInputDevices();
|
controller->OnLoadInputDevices();
|
||||||
|
@ -386,7 +379,6 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx) {
|
void GetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx) {
|
||||||
std::string blah = ctx.Description();
|
|
||||||
auto& controller = applet_resource->GetController<Controller_NPad>(HidController::NPad);
|
auto& controller = applet_resource->GetController<Controller_NPad>(HidController::NPad);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
@ -434,7 +426,7 @@ private:
|
||||||
void SetNpadJoyHoldType(Kernel::HLERequestContext& ctx) {
|
void SetNpadJoyHoldType(Kernel::HLERequestContext& ctx) {
|
||||||
auto& controller = applet_resource->GetController<Controller_NPad>(HidController::NPad);
|
auto& controller = applet_resource->GetController<Controller_NPad>(HidController::NPad);
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
auto hold_type = rp.PopRaw<u64>();
|
const auto hold_type = rp.PopRaw<u64>();
|
||||||
controller.SetHoldType(Controller_NPad::NpadHoldType{hold_type});
|
controller.SetHoldType(Controller_NPad::NpadHoldType{hold_type});
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
@ -443,7 +435,8 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetNpadJoyHoldType(Kernel::HLERequestContext& ctx) {
|
void GetNpadJoyHoldType(Kernel::HLERequestContext& ctx) {
|
||||||
auto& controller = applet_resource->GetController<Controller_NPad>(HidController::NPad);
|
const auto& controller =
|
||||||
|
applet_resource->GetController<Controller_NPad>(HidController::NPad);
|
||||||
IPC::ResponseBuilder rb{ctx, 4};
|
IPC::ResponseBuilder rb{ctx, 4};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.Push<u64>(static_cast<u64>(controller.GetHoldType()));
|
rb.Push<u64>(static_cast<u64>(controller.GetHoldType()));
|
||||||
|
@ -458,8 +451,8 @@ private:
|
||||||
|
|
||||||
void SendVibrationValue(Kernel::HLERequestContext& ctx) {
|
void SendVibrationValue(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
auto controller_id = rp.PopRaw<u32>();
|
const auto controller_id = rp.PopRaw<u32>();
|
||||||
auto vibration_values = rp.PopRaw<Controller_NPad::Vibration>();
|
const auto vibration_values = rp.PopRaw<Controller_NPad::Vibration>();
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
@ -470,8 +463,8 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendVibrationValues(Kernel::HLERequestContext& ctx) {
|
void SendVibrationValues(Kernel::HLERequestContext& ctx) {
|
||||||
auto controllers = ctx.ReadBuffer(0);
|
const auto controllers = ctx.ReadBuffer(0);
|
||||||
auto vibrations = ctx.ReadBuffer(1);
|
const auto vibrations = ctx.ReadBuffer(1);
|
||||||
|
|
||||||
std::vector<u32> controller_list(controllers.size() / sizeof(u32));
|
std::vector<u32> controller_list(controllers.size() / sizeof(u32));
|
||||||
std::vector<Controller_NPad::Vibration> vibration_list(vibrations.size() /
|
std::vector<Controller_NPad::Vibration> vibration_list(vibrations.size() /
|
||||||
|
@ -501,7 +494,7 @@ private:
|
||||||
|
|
||||||
void SetNpadJoyAssignmentModeDual(Kernel::HLERequestContext& ctx) {
|
void SetNpadJoyAssignmentModeDual(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
auto npad_id = rp.PopRaw<u32>();
|
const auto npad_id = rp.PopRaw<u32>();
|
||||||
auto& controller = applet_resource->GetController<Controller_NPad>(HidController::NPad);
|
auto& controller = applet_resource->GetController<Controller_NPad>(HidController::NPad);
|
||||||
controller.SetNpadMode(npad_id, Controller_NPad::NPadAssignments::Dual);
|
controller.SetNpadMode(npad_id, Controller_NPad::NPadAssignments::Dual);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue