2018-10-05 16:23:21 +02:00
|
|
|
// Copyright 2018 yuzu emulator team
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
2018-10-06 05:14:42 +02:00
|
|
|
|
2018-10-05 16:23:21 +02:00
|
|
|
#include <array>
|
2018-10-18 13:01:55 +02:00
|
|
|
#include "common/bit_field.h"
|
2018-10-05 16:23:21 +02:00
|
|
|
#include "common/common_funcs.h"
|
|
|
|
#include "common/common_types.h"
|
2021-04-15 01:07:40 +02:00
|
|
|
#include "common/settings.h"
|
2018-10-05 16:23:21 +02:00
|
|
|
#include "common/swap.h"
|
|
|
|
#include "core/hle/service/hid/controllers/controller_base.h"
|
2021-09-21 03:31:06 +02:00
|
|
|
#include "core/hle/service/hid/ring_lifo.h"
|
|
|
|
|
|
|
|
namespace Core::HID {
|
|
|
|
class EmulatedController;
|
|
|
|
struct DebugPadButton;
|
|
|
|
struct AnalogStickState;
|
|
|
|
} // namespace Core::HID
|
2018-10-05 16:23:21 +02:00
|
|
|
|
|
|
|
namespace Service::HID {
|
|
|
|
class Controller_DebugPad final : public ControllerBase {
|
|
|
|
public:
|
2021-05-04 10:04:05 +02:00
|
|
|
explicit Controller_DebugPad(Core::System& system_);
|
2018-10-18 02:34:25 +02:00
|
|
|
~Controller_DebugPad() override;
|
2018-10-05 16:23:21 +02:00
|
|
|
|
|
|
|
// Called when the controller is initialized
|
2019-09-22 08:41:34 +02:00
|
|
|
void OnInit() override;
|
2018-10-05 16:23:21 +02:00
|
|
|
|
|
|
|
// When the controller is released
|
|
|
|
void OnRelease() override;
|
|
|
|
|
|
|
|
// When the controller is requesting an update for the shared memory
|
2019-02-14 18:42:58 +01:00
|
|
|
void OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, std::size_t size) override;
|
2018-10-05 16:23:21 +02:00
|
|
|
|
|
|
|
private:
|
2021-09-21 03:31:06 +02:00
|
|
|
// This is nn::hid::DebugPadAttribute
|
|
|
|
struct DebugPadAttribute {
|
2018-10-18 13:01:55 +02:00
|
|
|
union {
|
|
|
|
u32_le raw{};
|
2019-01-25 18:26:47 +01:00
|
|
|
BitField<0, 1, u32> connected;
|
2018-10-18 13:01:55 +02:00
|
|
|
};
|
|
|
|
};
|
2021-09-21 03:31:06 +02:00
|
|
|
static_assert(sizeof(DebugPadAttribute) == 0x4, "DebugPadAttribute is an invalid size");
|
2018-10-18 13:01:55 +02:00
|
|
|
|
2021-09-21 03:31:06 +02:00
|
|
|
// This is nn::hid::DebugPadState
|
|
|
|
struct DebugPadState {
|
2018-10-05 16:23:21 +02:00
|
|
|
s64_le sampling_number;
|
2021-09-21 03:31:06 +02:00
|
|
|
DebugPadAttribute attribute;
|
|
|
|
Core::HID::DebugPadButton pad_state;
|
|
|
|
Core::HID::AnalogStickState r_stick;
|
|
|
|
Core::HID::AnalogStickState l_stick;
|
2018-10-05 16:23:21 +02:00
|
|
|
};
|
2021-09-21 03:31:06 +02:00
|
|
|
static_assert(sizeof(DebugPadState) == 0x20, "DebugPadState is an invalid state");
|
2018-10-05 16:23:21 +02:00
|
|
|
|
2021-09-21 03:31:06 +02:00
|
|
|
// This is nn::hid::detail::DebugPadLifo
|
|
|
|
Lifo<DebugPadState> debug_pad_lifo{};
|
|
|
|
static_assert(sizeof(debug_pad_lifo) == 0x2C8, "debug_pad_lifo is an invalid size");
|
|
|
|
DebugPadState next_state{};
|
2018-11-02 03:01:11 +01:00
|
|
|
|
2021-09-21 03:31:06 +02:00
|
|
|
Core::HID::EmulatedController* controller;
|
2018-10-05 16:23:21 +02:00
|
|
|
};
|
2018-10-06 05:14:42 +02:00
|
|
|
} // namespace Service::HID
|