mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-20 16:37:03 +00:00
[Linux/MacOS] Further Wiimote changes for parity with Windows (#945)
This commit is contained in:
parent
d8b9a74d86
commit
5e84862e28
8 changed files with 23 additions and 19 deletions
|
|
@ -5,8 +5,8 @@ static constexpr uint16 WIIMOTE_PRODUCT_ID = 0x0306;
|
|||
static constexpr uint16 WIIMOTE_MP_PRODUCT_ID = 0x0330;
|
||||
static constexpr uint16 WIIMOTE_MAX_INPUT_REPORT_LENGTH = 22;
|
||||
|
||||
HidapiWiimote::HidapiWiimote(hid_device* dev, uint64_t identifier)
|
||||
: m_handle(dev), m_identifier(identifier) {
|
||||
HidapiWiimote::HidapiWiimote(hid_device* dev, uint64_t identifier, std::string_view path)
|
||||
: m_handle(dev), m_identifier(identifier), m_path(path) {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -35,11 +35,12 @@ std::vector<WiimoteDevicePtr> HidapiWiimote::get_devices() {
|
|||
cemuLog_logDebug(LogType::Force, "Unable to open Wiimote device at {}: {}", it->path, boost::nowide::narrow(hid_error(nullptr)));
|
||||
}
|
||||
else {
|
||||
hid_set_nonblocking(dev, true);
|
||||
// Enough to have a unique id for each device within a session
|
||||
uint64_t id = (static_cast<uint64>(it->interface_number) << 32) |
|
||||
(static_cast<uint64>(it->usage_page) << 16) |
|
||||
(it->usage);
|
||||
wiimote_devices.push_back(std::make_shared<HidapiWiimote>(dev, id));
|
||||
wiimote_devices.push_back(std::make_shared<HidapiWiimote>(dev, id, it->path));
|
||||
}
|
||||
}
|
||||
hid_free_enumeration(device_enumeration);
|
||||
|
|
@ -47,7 +48,8 @@ std::vector<WiimoteDevicePtr> HidapiWiimote::get_devices() {
|
|||
}
|
||||
|
||||
bool HidapiWiimote::operator==(WiimoteDevice& o) const {
|
||||
return m_identifier == static_cast<HidapiWiimote&>(o).m_identifier;
|
||||
auto const& other_mote = static_cast<HidapiWiimote const&>(o);
|
||||
return m_identifier == other_mote.m_identifier && other_mote.m_path == m_path;
|
||||
}
|
||||
|
||||
HidapiWiimote::~HidapiWiimote() {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
class HidapiWiimote : public WiimoteDevice {
|
||||
public:
|
||||
HidapiWiimote(hid_device* dev, uint64_t identifier);
|
||||
HidapiWiimote(hid_device* dev, uint64_t identifier, std::string_view path);
|
||||
~HidapiWiimote() override;
|
||||
|
||||
bool write_data(const std::vector<uint8> &data) override;
|
||||
|
|
@ -16,7 +16,8 @@ public:
|
|||
|
||||
private:
|
||||
hid_device* m_handle;
|
||||
uint64_t m_identifier;
|
||||
const uint64_t m_identifier;
|
||||
const std::string m_path;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue