summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2019-11-10 13:24:59 +0100
committerGitHub <noreply@github.com>2019-11-10 13:24:59 +0100
commit7fa5a95800794ceff297913fef13dbca7f3ea34b (patch)
treecba6dddf04addf47aee58db9ef0e22c235fe5673 /Source/Core
parenteebc64aaf872917c4a7d480026545fe8a87d662f (diff)
parente85e51e5ce9fa6e25f74f5768b00197527434d34 (diff)
Merge pull request #8462 from jordan-woyak/wm-real-linux-fix
HW/WiimoteReal: Linux fix.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/WiimoteReal/IOLinux.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/Source/Core/Core/HW/WiimoteReal/IOLinux.cpp b/Source/Core/Core/HW/WiimoteReal/IOLinux.cpp
index de0831e796..aa094aa92b 100644
--- a/Source/Core/Core/HW/WiimoteReal/IOLinux.cpp
+++ b/Source/Core/Core/HW/WiimoteReal/IOLinux.cpp
@@ -6,7 +6,7 @@
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
#include <bluetooth/l2cap.h>
-#include <sys/select.h>
+#include <sys/poll.h>
#include <unistd.h>
#include "Common/CommonTypes.h"
@@ -223,20 +223,23 @@ void WiimoteLinux::IOWakeup()
// zero = error
int WiimoteLinux::IORead(u8* buf)
{
- // Block select for 1/2000th of a second
+ std::array<pollfd, 2> pollfds = {};
- fd_set fds;
- FD_ZERO(&fds);
- FD_SET(m_int_sock, &fds);
- FD_SET(m_wakeup_pipe_r, &fds);
+ auto& poll_wakeup = pollfds[0];
+ poll_wakeup.fd = m_wakeup_pipe_r;
+ poll_wakeup.events = POLLIN;
- if (select(m_int_sock + 1, &fds, nullptr, nullptr, nullptr) == -1)
+ auto& poll_sock = pollfds[1];
+ poll_sock.fd = m_int_sock;
+ poll_sock.events = POLLIN;
+
+ if (poll(pollfds.data(), pollfds.size(), -1) == -1)
{
- ERROR_LOG(WIIMOTE, "Unable to select Wiimote %i input socket.", m_index + 1);
+ ERROR_LOG(WIIMOTE, "Unable to poll Wiimote %i input socket.", m_index + 1);
return -1;
}
- if (FD_ISSET(m_wakeup_pipe_r, &fds))
+ if (poll_wakeup.revents & POLLIN)
{
char c;
if (read(m_wakeup_pipe_r, &c, 1) != 1)
@@ -246,7 +249,7 @@ int WiimoteLinux::IORead(u8* buf)
return -1;
}
- if (!FD_ISSET(m_int_sock, &fds))
+ if (!(poll_sock.revents & POLLIN))
return -1;
// Read the pending message into the buffer