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-18 13:34:30 +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-05-28 13:58:55 +02:00
|
|
|
#include "common/point.h"
|
2018-10-05 16:23:21 +02:00
|
|
|
#include "common/swap.h"
|
2021-09-21 03:33:50 +02:00
|
|
|
#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"
|
2021-09-21 03:33:50 +02:00
|
|
|
#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:
|
2021-09-21 03:33:50 +02:00
|
|
|
// This is nn::hid::TouchScreenModeForNx
|
2021-09-10 17:09:22 +02:00
|
|
|
enum class TouchScreenModeForNx : u8 {
|
|
|
|
UseSystemSetting,
|
|
|
|
Finger,
|
|
|
|
Heat2,
|
|
|
|
};
|
|
|
|
|
2021-09-21 03:33:50 +02:00
|
|
|
// 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");
|
|
|
|
|
2021-05-04 10:04:05 +02:00
|
|
|
explicit Controller_Touchscreen(Core::System& system_);
|
2018-10-18 02:34:25 +02:00
|
|
|
~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
|
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-01-03 05:04:50 +01:00
|
|
|
static constexpr std::size_t MAX_FINGERS = 16;
|
2021-01-01 19:32:29 +01:00
|
|
|
|
2021-09-21 03:33:50 +02:00
|
|
|
// This is nn::hid::TouchScreenState
|
|
|
|
struct TouchScreenState {
|
2018-10-05 16:23:21 +02:00
|
|
|
s64_le sampling_number;
|
|
|
|
s32_le entry_count;
|
2021-09-21 03:33:50 +02:00
|
|
|
INSERT_PADDING_BYTES(4); // Reserved
|
|
|
|
std::array<Core::HID::TouchState, MAX_FINGERS> states;
|
2018-10-05 16:23:21 +02:00
|
|
|
};
|
2021-09-21 03:33:50 +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{};
|
2021-05-28 13:58:55 +02:00
|
|
|
Common::Point<float> position;
|
2021-01-01 03:40:55 +01:00
|
|
|
u32_le id{};
|
|
|
|
bool pressed{};
|
2021-09-21 03:33:50 +02:00
|
|
|
Core::HID::TouchAttribute attribute;
|
2021-01-01 03:40:55 +01:00
|
|
|
};
|
|
|
|
|
2021-09-21 03:33:50 +02: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;
|
2021-09-21 03:33:50 +02:00
|
|
|
Core::HID::EmulatedConsole* console;
|
2018-10-05 16:23:21 +02:00
|
|
|
};
|
2018-10-06 05:14:42 +02:00
|
|
|
} // namespace Service::HID
|