diff --git a/OpenRGB.pro b/OpenRGB.pro index fef8c81b..ad65eb90 100644 --- a/OpenRGB.pro +++ b/OpenRGB.pro @@ -629,9 +629,15 @@ QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.15 macx:ICON = qt/OpenRGB.icns unix:macx { + SOURCES += \ + serial_port/find_usb_serial_port_linux.cpp \ + INCLUDEPATH += \ /usr/local/include \ LIBS += \ -L/usr/local/lib -lusb-1.0 -lhidapi \ + + CONFIG += \ + c++14 \ } diff --git a/i2c_smbus/i2c_smbus.h b/i2c_smbus/i2c_smbus.h index 976af0ef..0fecc950 100644 --- a/i2c_smbus/i2c_smbus.h +++ b/i2c_smbus/i2c_smbus.h @@ -21,7 +21,7 @@ typedef unsigned short u16; typedef unsigned int u32; typedef int s32; -#ifdef WIN32 +#ifdef _WIN32 //Data for SMBus Messages #define I2C_SMBUS_BLOCK_MAX 32 @@ -33,11 +33,27 @@ union i2c_smbus_data u8 block[I2C_SMBUS_BLOCK_MAX + 2]; }; -#else /* WIN32 */ +#endif /* _WIN32 */ + +#ifdef __linux__ #include -#endif /* WIN32 */ +#endif /* __linux__ */ + +#ifdef __APPLE__ + +//Data for SMBus Messages +#define I2C_SMBUS_BLOCK_MAX 32 + +union i2c_smbus_data +{ + u8 byte; + u16 word; + u8 block[I2C_SMBUS_BLOCK_MAX + 2]; +}; + +#endif /* __APPLE__ */ // i2c_smbus_xfer read or write markers #define I2C_SMBUS_READ 1 diff --git a/qt/OpenRGB.icns b/qt/OpenRGB.icns new file mode 100644 index 00000000..737f1fa3 Binary files /dev/null and b/qt/OpenRGB.icns differ diff --git a/serial_port/serial_port.cpp b/serial_port/serial_port.cpp index d4eb7da9..819bd4f6 100644 --- a/serial_port/serial_port.cpp +++ b/serial_port/serial_port.cpp @@ -40,7 +40,7 @@ bool serial_port::serial_open() { // printf("SerialPort: Opening serial port %s at baud rate %d.\n", port_name, baud_rate); - #ifdef WIN32 +#ifdef _WIN32 file_descriptor = CreateFile(port_name, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if((int)file_descriptor < 0) @@ -74,7 +74,9 @@ bool serial_port::serial_open() timeouts.WriteTotalTimeoutMultiplier=10; SetCommTimeouts(file_descriptor, &timeouts); - #else +#endif /* _WIN32 */ + +#ifdef __linux__ file_descriptor = open(port_name, O_RDWR | O_NOCTTY | O_NDELAY); @@ -116,7 +118,7 @@ bool serial_port::serial_open() //} //fcntl(file_descriptor, F_SETFL, 0); - #endif +#endif /* __linux__ */ // printf("SerialPort: Serial port %s opened successfully.\n", port_name); return true; @@ -143,12 +145,15 @@ bool serial_port::serial_open(const char* name, unsigned int baud) void serial_port::serial_close() { // printf("SerialPort: Closing port %s.\n", port_name); - #ifdef WIN32 +#ifdef _WIN32 - #else +#endif /* _WIN32 */ + +#ifdef __linux__ close(file_descriptor); - #endif + +#endif /* __linux__ */ } // read @@ -158,18 +163,24 @@ void serial_port::serial_close() // available bytes int serial_port::serial_read(char * buffer, int length) { - #ifdef WIN32 +#ifdef _WIN32 + DWORD bytesread; ReadFile(file_descriptor, buffer, length, &bytesread, NULL); + return bytesread; - #else +#endif /* _WIN32 */ + +#ifdef __linux__ int bytesread; bytesread = read(file_descriptor, buffer, length); - #endif + return bytesread; + +#endif /* __linux__ */ //printf("SerialPort: Read %d bytes on port %s.\n", bytesread, port_name); - return bytesread; + return 0; } //write @@ -180,40 +191,53 @@ int serial_port::serial_read(char * buffer, int length) // past and may cause a segfault int serial_port::serial_write(char * buffer, int length) { - #ifdef WIN32 +#ifdef _WIN32 + DWORD byteswritten; WriteFile(file_descriptor, buffer, length, &byteswritten, NULL); + return byteswritten; - #else +#endif /* _WIN32 */ + +#ifdef __linux__ int byteswritten; byteswritten = write(file_descriptor, buffer, length); - #endif + return byteswritten; + +#endif /* __linux__ */ //printf("SerialPort: Wrote %d bytes on port %s.\n", byteswritten, port_name); - return byteswritten; + return 0; } //flush void serial_port::serial_flush_rx() { - #ifdef WIN32 +#ifdef _WIN32 + PurgeComm(file_descriptor, PURGE_RXABORT | PURGE_RXCLEAR); - #else +#endif /* _WIN32 */ + +#ifdef __linux__ tcflush(file_descriptor, TCIFLUSH); - #endif + +#endif /* __linux__ */ } void serial_port::serial_flush_tx() { +#ifdef _WIN32 - #ifdef WIN32 PurgeComm(file_descriptor, PURGE_TXABORT | PURGE_TXCLEAR); - #else +#endif /* _WIN32 */ + +#ifdef __linux__ tcflush(file_descriptor, TCOFLUSH); - #endif + +#endif /* __linux__ */ } diff --git a/serial_port/serial_port.h b/serial_port/serial_port.h index 4986ea59..73fb9311 100644 --- a/serial_port/serial_port.h +++ b/serial_port/serial_port.h @@ -13,10 +13,13 @@ #include #include -#ifdef WIN32 +#ifdef _WIN32 + #include -#else +#endif /* _WIN32 */ + +#ifdef __linux__ #include #include @@ -35,7 +38,7 @@ #include -#endif +#endif /* __linux__ */ //Serial Port Class