yuzu/src/core/hle/service/hid/controllers/xpad.cpp

38 lines
1.2 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.
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;
Controller_XPad::Controller_XPad(Core::System& system_) : ControllerBase{system_} {}
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
void Controller_XPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data,
std::size_t size) {
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
}
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
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