diff options
author | Wohlstand <Wohlstand@users.noreply.github.com> | 2024-05-23 01:43:56 +0300 |
---|---|---|
committer | Wohlstand <Wohlstand@users.noreply.github.com> | 2024-05-23 01:43:56 +0300 |
commit | 41d75bcfa213248697a64aec13d38bd56cfa7d3f (patch) | |
tree | c3504cb2fd37ce01ce6be25e31f0020e3dec0202 /src | |
parent | 1aaef3b46620efcfe8da955d6262016fca5ae187 (diff) | |
download | libADLMIDI-41d75bcfa213248697a64aec13d38bd56cfa7d3f.tar.gz libADLMIDI-41d75bcfa213248697a64aec13d38bd56cfa7d3f.tar.bz2 libADLMIDI-41d75bcfa213248697a64aec13d38bd56cfa7d3f.zip |
Serial: Fixed initialization on macOS
Diffstat (limited to 'src')
-rw-r--r-- | src/chips/opl_serial_misc.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/chips/opl_serial_misc.h b/src/chips/opl_serial_misc.h index 6972a1e..2583a4b 100644 --- a/src/chips/opl_serial_misc.h +++ b/src/chips/opl_serial_misc.h @@ -28,6 +28,11 @@ #include <cstring> #include <cstdio> #include <errno.h> +#include <sys/ioctl.h> +#endif + +#ifdef __APPLE__ +#include <IOKit/serial/ioss.h> #endif #ifdef _WIN32 @@ -171,7 +176,12 @@ public: m_portSetup.c_cflag &= ~CBAUD; #endif +#if defined (BSD) || defined(__FreeBSD__) + cfsetispeed(&m_portSetup, baudRate); + cfsetospeed(&m_portSetup, baudRate); +#elif !defined(__APPLE__) cfsetospeed(&m_portSetup, baud2enum(baudRate)); +#endif if(tcsetattr(m_port, TCSANOW, &m_portSetup) != 0) { @@ -181,6 +191,16 @@ public: return false; } +#ifdef __APPLE__ + if(ioctl(m_port, IOSSIOSPEED, &baudRate) == -1) + { + std::fprintf(stderr, "-- OPL Serial ERROR: Failed to set MacOS specific tty attributes for `%s': %s", portPath.c_str(), strerror(errno)); + std::fflush(stderr); + close(); + return false; + } +#endif + return true; } |