mirror of
https://github.com/AxioDL/boo.git
synced 2025-12-08 21:17:50 +00:00
Add support for wired switch controllers from PowerA
This commit is contained in:
53
lib/inputdev/NintendoPowerA.cpp
Normal file
53
lib/inputdev/NintendoPowerA.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "boo/inputdev/NintendoPowerA.hpp"
|
||||
#include <memory.h>
|
||||
namespace boo
|
||||
{
|
||||
NintendoPowerA::NintendoPowerA(DeviceToken* token)
|
||||
: DeviceBase(token)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NintendoPowerA::~NintendoPowerA()
|
||||
{
|
||||
}
|
||||
|
||||
void NintendoPowerA::deviceDisconnected()
|
||||
{
|
||||
if (m_callback)
|
||||
m_callback->controllerDisconnected();
|
||||
}
|
||||
|
||||
void NintendoPowerA::initialCycle() {}
|
||||
|
||||
void NintendoPowerA::transferCycle()
|
||||
{
|
||||
uint8_t payload[8];
|
||||
size_t recvSz = receiveUSBInterruptTransfer(payload, sizeof(payload));
|
||||
if (recvSz != 8)
|
||||
return;
|
||||
|
||||
NintendoPowerAState state = *reinterpret_cast<NintendoPowerAState*>(&payload);
|
||||
|
||||
if (state != m_last && m_callback)
|
||||
m_callback->controllerUpdate(state);
|
||||
m_last = state;
|
||||
}
|
||||
|
||||
void NintendoPowerA::finalCycle() {}
|
||||
|
||||
void NintendoPowerA::receivedHIDReport(const uint8_t* data, size_t length, HIDReportType tp, uint32_t message)
|
||||
{
|
||||
}
|
||||
|
||||
bool NintendoPowerAState::operator==(const NintendoPowerAState &other)
|
||||
{
|
||||
return !memcmp(this, &other, sizeof(NintendoPowerAState));
|
||||
}
|
||||
|
||||
bool NintendoPowerAState::operator!=(const NintendoPowerAState &other)
|
||||
{
|
||||
return memcmp(this, &other, sizeof(NintendoPowerAState));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user