Skip to content

Commit 0c233c6

Browse files
DHrpcs3Megamouse
authored andcommitted
[android] hid: enumerate by vendor/product ids
1 parent 8100779 commit 0c233c6

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

rpcs3/Input/hid_pad_handler.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
LOG_CHANNEL(hid_log, "HID");
2020

2121
#ifdef ANDROID
22-
std::vector<int> g_android_usb_devices;
22+
std::vector<android_usb_device> g_android_usb_devices;
2323
std::mutex g_android_usb_devices_mutex;
2424
#endif
2525

@@ -192,7 +192,15 @@ void hid_pad_handler<Device>::enumerate_devices()
192192
std::lock_guard lock(g_android_usb_devices_mutex);
193193
for (auto device : g_android_usb_devices)
194194
{
195-
device_paths.insert(device);
195+
auto filter = [&](id_pair id)
196+
{
197+
return id.m_vid == device.vendorId && id.m_pid == device.productId;
198+
};
199+
200+
if (std::find_if(m_ids.begin(), m_ids.end(), filter) != m_ids.end())
201+
{
202+
device_paths.insert(device.fd);
203+
}
196204
}
197205
}
198206
#else

rpcs3/Input/hid_pad_handler.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,16 @@
1515
#ifdef ANDROID
1616
using hid_enumerated_device_type = int;
1717
using hid_enumerated_device_view = int;
18+
19+
struct android_usb_device
20+
{
21+
int fd;
22+
u16 vendorId;
23+
u16 productId;
24+
};
25+
1826
inline constexpr auto hid_enumerated_device_default = -1;
19-
extern std::vector<int> g_android_usb_devices;
27+
extern std::vector<android_usb_device> g_android_usb_devices;
2028
extern std::mutex g_android_usb_devices_mutex;
2129
#else
2230
using hid_enumerated_device_type = std::string;

0 commit comments

Comments
 (0)