2017-11-24 07:17:28 +00:00
|
|
|
#include "boo/inputdev/NintendoPowerA.hpp"
|
2019-08-19 23:08:54 +00:00
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
|
2018-10-07 02:49:22 +00:00
|
|
|
#include "boo/inputdev/DeviceSignature.hpp"
|
2019-08-19 23:08:54 +00:00
|
|
|
|
2018-12-08 05:17:51 +00:00
|
|
|
namespace boo {
|
2017-11-24 07:17:28 +00:00
|
|
|
NintendoPowerA::NintendoPowerA(DeviceToken* token)
|
2018-12-08 05:17:51 +00:00
|
|
|
: TDeviceBase<INintendoPowerACallback>(dev_typeid(NintendoPowerA), token) {}
|
2017-11-24 07:17:28 +00:00
|
|
|
|
2018-12-08 05:17:51 +00:00
|
|
|
NintendoPowerA::~NintendoPowerA() {}
|
2017-11-24 07:17:28 +00:00
|
|
|
|
2018-12-08 05:17:51 +00:00
|
|
|
void NintendoPowerA::deviceDisconnected() {
|
|
|
|
std::lock_guard<std::mutex> lk(m_callbackLock);
|
|
|
|
if (m_callback)
|
|
|
|
m_callback->controllerDisconnected();
|
2017-11-24 07:17:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void NintendoPowerA::initialCycle() {}
|
|
|
|
|
2018-12-08 05:17:51 +00:00
|
|
|
void NintendoPowerA::transferCycle() {
|
|
|
|
uint8_t payload[8];
|
|
|
|
size_t recvSz = receiveUSBInterruptTransfer(payload, sizeof(payload));
|
|
|
|
if (recvSz != 8)
|
|
|
|
return;
|
2017-11-24 07:17:28 +00:00
|
|
|
|
2018-12-08 05:17:51 +00:00
|
|
|
NintendoPowerAState state = *reinterpret_cast<NintendoPowerAState*>(&payload);
|
2017-11-24 07:17:28 +00:00
|
|
|
|
2018-12-08 05:17:51 +00:00
|
|
|
std::lock_guard<std::mutex> lk(m_callbackLock);
|
|
|
|
if (state != m_last && m_callback)
|
|
|
|
m_callback->controllerUpdate(state);
|
|
|
|
m_last = state;
|
2017-11-24 07:17:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void NintendoPowerA::finalCycle() {}
|
|
|
|
|
2018-12-08 05:17:51 +00:00
|
|
|
void NintendoPowerA::receivedHIDReport(const uint8_t* data, size_t length, HIDReportType tp, uint32_t message) {}
|
2017-11-24 07:17:28 +00:00
|
|
|
|
2019-08-16 06:06:51 +00:00
|
|
|
bool NintendoPowerAState::operator==(const NintendoPowerAState& other) const {
|
|
|
|
return memcmp(this, &other, sizeof(NintendoPowerAState)) == 0;
|
2017-11-24 07:17:28 +00:00
|
|
|
}
|
|
|
|
|
2019-08-16 06:06:51 +00:00
|
|
|
bool NintendoPowerAState::operator!=(const NintendoPowerAState& other) const { return !operator==(other); }
|
2017-11-24 07:17:28 +00:00
|
|
|
|
2018-12-08 05:17:51 +00:00
|
|
|
} // namespace boo
|