mirror of https://github.com/AxioDL/boo.git
General: Make member functions const where applicable
These functions don't modify instance state, so they can be marked const.
This commit is contained in:
parent
1822b555fa
commit
80c1103b44
|
@ -54,18 +54,18 @@ public:
|
||||||
bool sendUSBInterruptTransfer(const uint8_t* data, size_t length);
|
bool sendUSBInterruptTransfer(const uint8_t* data, size_t length);
|
||||||
size_t receiveUSBInterruptTransfer(uint8_t* data, size_t length);
|
size_t receiveUSBInterruptTransfer(uint8_t* data, size_t length);
|
||||||
|
|
||||||
inline unsigned getVendorId();
|
inline unsigned getVendorId() const;
|
||||||
inline unsigned getProductId();
|
inline unsigned getProductId() const;
|
||||||
inline std::string_view getVendorName();
|
inline std::string_view getVendorName() const;
|
||||||
inline std::string_view getProductName();
|
inline std::string_view getProductName() const;
|
||||||
|
|
||||||
/* High-Level API */
|
/* High-Level API */
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
#if !WINDOWS_STORE
|
#if !WINDOWS_STORE
|
||||||
const PHIDP_PREPARSED_DATA getReportDescriptor();
|
PHIDP_PREPARSED_DATA getReportDescriptor() const;
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
std::vector<uint8_t> getReportDescriptor();
|
std::vector<uint8_t> getReportDescriptor() const;
|
||||||
#endif
|
#endif
|
||||||
bool sendHIDReport(const uint8_t* data, size_t length, HIDReportType tp, uint32_t message = 0);
|
bool sendHIDReport(const uint8_t* data, size_t length, HIDReportType tp, uint32_t message = 0);
|
||||||
size_t receiveHIDReport(uint8_t* data, size_t length, HIDReportType tp,
|
size_t receiveHIDReport(uint8_t* data, size_t length, HIDReportType tp,
|
||||||
|
|
|
@ -41,11 +41,8 @@ private:
|
||||||
|
|
||||||
/* Friend methods for platform-listener to find/insert/remove
|
/* Friend methods for platform-listener to find/insert/remove
|
||||||
* tokens with type-filtering */
|
* tokens with type-filtering */
|
||||||
bool _hasToken(const std::string& path) {
|
bool _hasToken(const std::string& path) const {
|
||||||
auto preCheck = m_tokens.find(path);
|
return m_tokens.find(path) != m_tokens.end();
|
||||||
if (preCheck != m_tokens.end())
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
bool _insertToken(std::unique_ptr<DeviceToken>&& token) {
|
bool _insertToken(std::unique_ptr<DeviceToken>&& token) {
|
||||||
if (DeviceSignature::DeviceMatchToken(*token, m_types)) {
|
if (DeviceSignature::DeviceMatchToken(*token, m_types)) {
|
||||||
|
@ -77,8 +74,12 @@ public:
|
||||||
public:
|
public:
|
||||||
CDeviceTokensHandle(DeviceFinder& finder) : m_finder(finder) { m_finder.m_tokensLock.lock(); }
|
CDeviceTokensHandle(DeviceFinder& finder) : m_finder(finder) { m_finder.m_tokensLock.lock(); }
|
||||||
~CDeviceTokensHandle() { m_finder.m_tokensLock.unlock(); }
|
~CDeviceTokensHandle() { m_finder.m_tokensLock.unlock(); }
|
||||||
TDeviceTokens::iterator begin() { return m_finder.m_tokens.begin(); }
|
|
||||||
TDeviceTokens::iterator end() { return m_finder.m_tokens.end(); }
|
TDeviceTokens::iterator begin() noexcept { return m_finder.m_tokens.begin(); }
|
||||||
|
TDeviceTokens::iterator end() noexcept { return m_finder.m_tokens.end(); }
|
||||||
|
|
||||||
|
TDeviceTokens::const_iterator begin() const noexcept { return m_finder.m_tokens.begin(); }
|
||||||
|
TDeviceTokens::const_iterator end() const noexcept { return m_finder.m_tokens.end(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Application must specify its interested device-types */
|
/* Application must specify its interested device-types */
|
||||||
|
|
|
@ -136,7 +136,7 @@ public:
|
||||||
|
|
||||||
void stopRumble(int motor) { m_rumbleRequest &= ~EDualshockMotor(motor); }
|
void stopRumble(int motor) { m_rumbleRequest &= ~EDualshockMotor(motor); }
|
||||||
|
|
||||||
EDualshockLED getLED() { return m_led; }
|
EDualshockLED getLED() const { return m_led; }
|
||||||
|
|
||||||
void setLED(EDualshockLED led, bool on = true) {
|
void setLED(EDualshockLED led, bool on = true) {
|
||||||
if (on)
|
if (on)
|
||||||
|
|
|
@ -23,8 +23,8 @@ struct NintendoPowerAState {
|
||||||
uint8_t leftY;
|
uint8_t leftY;
|
||||||
uint8_t rightX;
|
uint8_t rightX;
|
||||||
uint8_t rightY;
|
uint8_t rightY;
|
||||||
bool operator==(const NintendoPowerAState& other);
|
bool operator==(const NintendoPowerAState& other) const;
|
||||||
bool operator!=(const NintendoPowerAState& other);
|
bool operator!=(const NintendoPowerAState& other) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NintendoPowerA;
|
class NintendoPowerA;
|
||||||
|
|
|
@ -249,7 +249,7 @@ public:
|
||||||
m_backcv.wait(lk, [this]() { return m_outstandingTasks == 0 || !m_running; });
|
m_backcv.wait(lk, [this]() { return m_outstandingTasks == 0 || !m_running; });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isReady() {
|
bool isReady() const {
|
||||||
return m_outstandingTasks == 0 || !m_running;
|
return m_outstandingTasks == 0 || !m_running;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,25 +37,25 @@ size_t DeviceBase::receiveUSBInterruptTransfer(uint8_t* data, size_t length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned DeviceBase::getVendorId() {
|
unsigned DeviceBase::getVendorId() const {
|
||||||
if (m_token)
|
if (m_token)
|
||||||
return m_token->getVendorId();
|
return m_token->getVendorId();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned DeviceBase::getProductId() {
|
unsigned DeviceBase::getProductId() const {
|
||||||
if (m_token)
|
if (m_token)
|
||||||
return m_token->getProductId();
|
return m_token->getProductId();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string_view DeviceBase::getVendorName() {
|
std::string_view DeviceBase::getVendorName() const {
|
||||||
if (m_token)
|
if (m_token)
|
||||||
return m_token->getVendorName();
|
return m_token->getVendorName();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string_view DeviceBase::getProductName() {
|
std::string_view DeviceBase::getProductName() const {
|
||||||
if (m_token)
|
if (m_token)
|
||||||
return m_token->getProductName();
|
return m_token->getProductName();
|
||||||
return {};
|
return {};
|
||||||
|
@ -63,14 +63,14 @@ std::string_view DeviceBase::getProductName() {
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
#if !WINDOWS_STORE
|
#if !WINDOWS_STORE
|
||||||
const PHIDP_PREPARSED_DATA DeviceBase::getReportDescriptor() {
|
PHIDP_PREPARSED_DATA DeviceBase::getReportDescriptor() const {
|
||||||
if (m_hidDev)
|
if (m_hidDev)
|
||||||
return m_hidDev->_getReportDescriptor();
|
return m_hidDev->_getReportDescriptor();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
std::vector<uint8_t> DeviceBase::getReportDescriptor() {
|
std::vector<uint8_t> DeviceBase::getReportDescriptor() const {
|
||||||
if (m_hidDev)
|
if (m_hidDev)
|
||||||
return m_hidDev->_getReportDescriptor();
|
return m_hidDev->_getReportDescriptor();
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -33,12 +33,10 @@ void NintendoPowerA::finalCycle() {}
|
||||||
|
|
||||||
void NintendoPowerA::receivedHIDReport(const uint8_t* data, size_t length, HIDReportType tp, uint32_t message) {}
|
void NintendoPowerA::receivedHIDReport(const uint8_t* data, size_t length, HIDReportType tp, uint32_t message) {}
|
||||||
|
|
||||||
bool NintendoPowerAState::operator==(const NintendoPowerAState& other) {
|
bool NintendoPowerAState::operator==(const NintendoPowerAState& other) const {
|
||||||
return !memcmp(this, &other, sizeof(NintendoPowerAState));
|
return memcmp(this, &other, sizeof(NintendoPowerAState)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NintendoPowerAState::operator!=(const NintendoPowerAState& other) {
|
bool NintendoPowerAState::operator!=(const NintendoPowerAState& other) const { return !operator==(other); }
|
||||||
return memcmp(this, &other, sizeof(NintendoPowerAState));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace boo
|
} // namespace boo
|
||||||
|
|
Loading…
Reference in New Issue