yuzu/src/core/hle/service/hid/controllers/touchscreen.h

77 lines
2.4 KiB
C++
Raw Normal View History

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
#include "common/bit_field.h"
2018-10-05 16:23:21 +02:00
#include "common/common_funcs.h"
#include "common/common_types.h"
#include "common/point.h"
2018-10-05 16:23:21 +02:00
#include "common/swap.h"
#include "core/hid/hid_core.h"
#include "core/hid/hid_types.h"
2018-10-05 16:23:21 +02:00
#include "core/hle/service/hid/controllers/controller_base.h"
#include "core/hle/service/hid/ring_lifo.h"
2018-10-05 16:23:21 +02:00
namespace Service::HID {
class Controller_Touchscreen final : public ControllerBase {
public:
// This is nn::hid::TouchScreenModeForNx
2021-09-10 17:09:22 +02:00
enum class TouchScreenModeForNx : u8 {
UseSystemSetting,
Finger,
Heat2,
};
// This is nn::hid::TouchScreenConfigurationForNx
2021-09-10 17:09:22 +02:00
struct TouchScreenConfigurationForNx {
TouchScreenModeForNx mode;
INSERT_PADDING_BYTES_NOINIT(0x7);
INSERT_PADDING_BYTES_NOINIT(0xF); // Reserved
};
static_assert(sizeof(TouchScreenConfigurationForNx) == 0x17,
"TouchScreenConfigurationForNx is an invalid size");
explicit Controller_Touchscreen(Core::System& system_);
~Controller_Touchscreen() 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
void OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, std::size_t size) override;
2018-10-05 16:23:21 +02:00
private:
static constexpr std::size_t MAX_FINGERS = 16;
// This is nn::hid::TouchScreenState
struct TouchScreenState {
2018-10-05 16:23:21 +02:00
s64_le sampling_number;
s32_le entry_count;
INSERT_PADDING_BYTES(4); // Reserved
std::array<Core::HID::TouchState, MAX_FINGERS> states;
2018-10-05 16:23:21 +02:00
};
static_assert(sizeof(TouchScreenState) == 0x290, "TouchScreenState is an invalid size");
2021-01-01 03:40:55 +01:00
struct Finger {
u64_le last_touch{};
Common::Point<float> position;
2021-01-01 03:40:55 +01:00
u32_le id{};
bool pressed{};
Core::HID::TouchAttribute attribute;
2021-01-01 03:40:55 +01:00
};
// This is nn::hid::detail::TouchScreenLifo
Lifo<TouchScreenState> touch_screen_lifo{};
static_assert(sizeof(touch_screen_lifo) == 0x2C38, "touch_screen_lifo is an invalid size");
TouchScreenState next_state{};
2021-01-01 03:40:55 +01:00
std::array<Finger, MAX_FINGERS> fingers;
Core::HID::EmulatedConsole* console;
2018-10-05 16:23:21 +02:00
};
2018-10-06 05:14:42 +02:00
} // namespace Service::HID