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.
|
|
|
|
|
2018-10-06 05:14:42 +02:00
|
|
|
#include <cstring>
|
2018-10-05 16:23:21 +02:00
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "core/core_timing.h"
|
|
|
|
#include "core/hle/service/hid/controllers/xpad.h"
|
|
|
|
|
|
|
|
namespace Service::HID {
|
2018-10-06 05:14:42 +02:00
|
|
|
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C00;
|
|
|
|
|
2021-05-04 10:04:05 +02:00
|
|
|
Controller_XPad::Controller_XPad(Core::System& system_) : ControllerBase{system_} {}
|
2018-10-18 02:34:25 +02:00
|
|
|
Controller_XPad::~Controller_XPad() = default;
|
2018-10-06 05:14:42 +02:00
|
|
|
|
2019-09-22 08:41:34 +02:00
|
|
|
void Controller_XPad::OnInit() {}
|
2018-10-06 05:14:42 +02:00
|
|
|
|
2018-10-05 16:23:21 +02:00
|
|
|
void Controller_XPad::OnRelease() {}
|
2018-10-06 05:14:42 +02:00
|
|
|
|
2019-02-14 18:42:58 +01:00
|
|
|
void Controller_XPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data,
|
|
|
|
std::size_t size) {
|
2021-09-21 03:31:06 +02:00
|
|
|
if (!IsControllerActivated()) {
|
|
|
|
basic_xpad_lifo.entry_count = 0;
|
|
|
|
basic_xpad_lifo.last_entry_index = 0;
|
|
|
|
std::memcpy(data, &basic_xpad_lifo, sizeof(basic_xpad_lifo));
|
|
|
|
return;
|
2018-10-05 16:23:21 +02:00
|
|
|
}
|
2021-09-21 03:31:06 +02:00
|
|
|
|
|
|
|
const auto& last_entry = basic_xpad_lifo.ReadCurrentEntry().state;
|
|
|
|
next_state.sampling_number = last_entry.sampling_number + 1;
|
2018-10-05 16:23:21 +02:00
|
|
|
// TODO(ogniK): Update xpad states
|
|
|
|
|
2021-09-21 03:31:06 +02:00
|
|
|
basic_xpad_lifo.WriteNextEntry(next_state);
|
|
|
|
std::memcpy(data + SHARED_MEMORY_OFFSET, &basic_xpad_lifo, sizeof(basic_xpad_lifo));
|
2018-10-05 16:23:21 +02:00
|
|
|
}
|
2018-10-06 05:14:42 +02:00
|
|
|
|
|
|
|
} // namespace Service::HID
|