mirror of
https://github.com/AxioDL/boo.git
synced 2025-05-16 12:21:25 +00:00
NintendoPowerA: Use deduction guides for locks
Same behavior, but without the need to explicitly hardcode the mutex type.
This commit is contained in:
parent
7496109ff6
commit
2e0c7dc973
@ -11,9 +11,10 @@ NintendoPowerA::NintendoPowerA(DeviceToken* token)
|
|||||||
NintendoPowerA::~NintendoPowerA() = default;
|
NintendoPowerA::~NintendoPowerA() = default;
|
||||||
|
|
||||||
void NintendoPowerA::deviceDisconnected() {
|
void NintendoPowerA::deviceDisconnected() {
|
||||||
std::lock_guard<std::mutex> lk(m_callbackLock);
|
std::lock_guard lk{m_callbackLock};
|
||||||
if (m_callback)
|
if (m_callback != nullptr) {
|
||||||
m_callback->controllerDisconnected();
|
m_callback->controllerDisconnected();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NintendoPowerA::initialCycle() {}
|
void NintendoPowerA::initialCycle() {}
|
||||||
@ -21,14 +22,16 @@ void NintendoPowerA::initialCycle() {}
|
|||||||
void NintendoPowerA::transferCycle() {
|
void NintendoPowerA::transferCycle() {
|
||||||
uint8_t payload[8];
|
uint8_t payload[8];
|
||||||
size_t recvSz = receiveUSBInterruptTransfer(payload, sizeof(payload));
|
size_t recvSz = receiveUSBInterruptTransfer(payload, sizeof(payload));
|
||||||
if (recvSz != 8)
|
if (recvSz != 8) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
NintendoPowerAState state = *reinterpret_cast<NintendoPowerAState*>(&payload);
|
NintendoPowerAState state = *reinterpret_cast<NintendoPowerAState*>(&payload);
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lk(m_callbackLock);
|
std::lock_guard lk{m_callbackLock};
|
||||||
if (state != m_last && m_callback)
|
if (state != m_last && m_callback != nullptr) {
|
||||||
m_callback->controllerUpdate(state);
|
m_callback->controllerUpdate(state);
|
||||||
|
}
|
||||||
m_last = state;
|
m_last = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user