Corrected typo in comment and renamed class for more clarity

This commit is contained in:
capitalistspz 2022-09-10 21:35:59 +01:00
parent b0e523a44e
commit 4fca69793b
3 changed files with 8 additions and 9 deletions

View File

@ -43,7 +43,7 @@ target_sources(CemuInput PRIVATE
api/DSU/DSUControllerProvider.h
api/DSU/DSUMessages.h
api/DSU/DSUMessages.cpp
api/DSU/TimeoutSocketOption.h
api/DSU/ReceiveTimeoutSocketOption.h
)
# Keyboard controller

View File

@ -1,6 +1,6 @@
#include "input/api/DSU/DSUControllerProvider.h"
#include "input/api/DSU/DSUController.h"
#include "input/api/DSU/TimeoutSocketOption.h"
#include "input/api/DSU/ReceiveTimeoutSocketOption.h"
DSUControllerProvider::DSUControllerProvider()
: base_type(), m_uid(rand()), m_socket(m_io_service)
@ -80,7 +80,7 @@ bool DSUControllerProvider::connect()
m_socket.open(ip::udp::v4());
// set timeout for our threads to give a chance to exit
m_socket.set_option(TimeoutSocketOption{200});
m_socket.set_option(ReceiveTimeoutSocketOption{200});
// reset data
m_state = {};

View File

@ -3,17 +3,16 @@
#if BOOST_OS_WINDOWS
#include <boost/asio/detail/socket_option.hpp>
#include <winsock2.h> // For SOL_SOCKET, SO_RCVTIMEO
using TimeoutSocketOption = boost::asio::detail::socket_option::integer<SOL_SOCKET, SO_RCVTIMEO>;
using ReceiveTimeoutSocketOption = boost::asio::detail::socket_option::integer<SOL_SOCKET, SO_RCVTIMEO>;
#elif BOOST_OS_LINUX || BOOST_OS_MACOS
// For making RCVTIME0 work on Linux and probably Mac too
class TimeoutSocketOption {
timeval m_data;
class ReceiveTimeoutSocketOption {
timeval m_data; // POSIX only allows timeeval to be parameter to option SO_RCVTIMEO
public:
constexpr explicit TimeoutSocketOption(int time_ms)
constexpr explicit ReceiveTimeoutSocketOption(int time_ms)
: m_data(timeval{.tv_usec = time_ms * 1000}){
}
TimeoutSocketOption& operator=(int time_ms){
ReceiveTimeoutSocketOption& operator=(int time_ms){
m_data = timeval{.tv_usec = time_ms * 1000};
return *this;
}