Add FreeBSD support
This commit is contained in:
parent
45755c79ae
commit
6ae5242ed5
10 changed files with 337 additions and 18 deletions
174
AutoStart/AutoStart-FreeBSD.cpp
Normal file
174
AutoStart/AutoStart-FreeBSD.cpp
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
#include "AutoStart-FreeBSD.h"
|
||||
#include "LogManager.h"
|
||||
#include "filesystem.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <sstream>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| FreeBSD AutoStart Implementation |
|
||||
| Public Methods |
|
||||
\*-----------------------------------------------------*/
|
||||
|
||||
AutoStart::AutoStart(std::string name)
|
||||
{
|
||||
InitAutoStart(name);
|
||||
}
|
||||
|
||||
bool AutoStart::DisableAutoStart()
|
||||
{
|
||||
std::error_code autostart_file_remove_errcode;
|
||||
bool success = false;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Check if the filename is valid |
|
||||
\*-------------------------------------------------*/
|
||||
if(autostart_file != "")
|
||||
{
|
||||
/*---------------------------------------------*\
|
||||
| If file doesn't exist, disable is successful |
|
||||
\*---------------------------------------------*/
|
||||
if(!filesystem::exists(autostart_file))
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
/*---------------------------------------------*\
|
||||
| Otherwise, delete the file |
|
||||
\*---------------------------------------------*/
|
||||
else
|
||||
{
|
||||
success = filesystem::remove(autostart_file, autostart_file_remove_errcode);
|
||||
|
||||
if(!success)
|
||||
{
|
||||
LOG_ERROR("[AutoStart] An error occurred removing the auto start file.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("Could not establish correct autostart file path.");
|
||||
}
|
||||
|
||||
return(success);
|
||||
}
|
||||
|
||||
bool AutoStart::EnableAutoStart(AutoStartInfo autostart_info)
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Check if the filename is valid |
|
||||
\*-------------------------------------------------*/
|
||||
if(autostart_file != "")
|
||||
{
|
||||
std::ofstream autostart_file_stream(autostart_file, std::ios::out | std::ios::trunc);
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Error out if the file could not be opened |
|
||||
\*---------------------------------------------*/
|
||||
if(!autostart_file_stream)
|
||||
{
|
||||
LOG_ERROR("Could not open %s for writing.", autostart_file.c_str());
|
||||
success = false;
|
||||
}
|
||||
/*---------------------------------------------*\
|
||||
| Otherwise, write the file |
|
||||
\*---------------------------------------------*/
|
||||
else
|
||||
{
|
||||
//autostart_file_stream << desktop_file;
|
||||
autostart_file_stream.close();
|
||||
success = !autostart_file_stream.fail();
|
||||
|
||||
if (!success)
|
||||
{
|
||||
LOG_ERROR("An error occurred writing the auto start file.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("Could not establish correct autostart file path.");
|
||||
}
|
||||
|
||||
return(success);
|
||||
}
|
||||
|
||||
bool AutoStart::IsAutoStartEnabled()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Check if the filename is valid |
|
||||
\*-------------------------------------------------*/
|
||||
if(autostart_file != "")
|
||||
{
|
||||
return(filesystem::exists(autostart_file));
|
||||
}
|
||||
else
|
||||
{
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
std::string AutoStart::GetExePath()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Create the OpenRGB executable path |
|
||||
\*-------------------------------------------------*/
|
||||
char exepath[ PATH_MAX ];
|
||||
|
||||
ssize_t count = readlink("/proc/self/exe", exepath, PATH_MAX);
|
||||
|
||||
return(std::string(exepath, (count > 0) ? count : 0));
|
||||
}
|
||||
|
||||
void AutoStart::InitAutoStart(std::string name)
|
||||
{
|
||||
std::string autostart_dir;
|
||||
|
||||
autostart_name = name;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Get home and config paths |
|
||||
\*-------------------------------------------------*/
|
||||
const char *xdg_config_home = getenv("XDG_CONFIG_HOME");
|
||||
const char *home = getenv("HOME");
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Determine where the autostart .desktop files are |
|
||||
| kept |
|
||||
\*-------------------------------------------------*/
|
||||
if(xdg_config_home != NULL)
|
||||
{
|
||||
autostart_dir = xdg_config_home;
|
||||
autostart_dir = autostart_dir + "/autostart/";
|
||||
}
|
||||
else if(home != NULL)
|
||||
{
|
||||
autostart_dir = home;
|
||||
autostart_dir = autostart_dir + "/.config/autostart/";
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Check if the filename is valid |
|
||||
\*-------------------------------------------------*/
|
||||
if(autostart_dir != "")
|
||||
{
|
||||
std::error_code ec;
|
||||
|
||||
bool success = true;
|
||||
|
||||
if(!filesystem::exists(autostart_dir))
|
||||
{
|
||||
success = filesystem::create_directories(autostart_dir, ec);
|
||||
}
|
||||
|
||||
if(success)
|
||||
{
|
||||
autostart_file = autostart_dir + autostart_name + ".desktop";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
19
AutoStart/AutoStart-FreeBSD.h
Normal file
19
AutoStart/AutoStart-FreeBSD.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "AutoStart.h"
|
||||
|
||||
class AutoStart: public AutoStartInterface
|
||||
{
|
||||
public:
|
||||
AutoStart(std::string name);
|
||||
|
||||
bool DisableAutoStart();
|
||||
bool EnableAutoStart(AutoStartInfo autostart_info);
|
||||
bool IsAutoStartEnabled();
|
||||
std::string GetExePath();
|
||||
|
||||
private:
|
||||
void InitAutoStart(std::string name);
|
||||
std::string GenerateLaunchAgentFile(AutoStartInfo autostart_info);
|
||||
};
|
||||
|
|
@ -37,4 +37,8 @@ protected:
|
|||
|
||||
#ifdef __APPLE__
|
||||
#include "AutoStart-MacOS.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include "AutoStart-FreeBSD.h"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,11 @@
|
|||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#ifdef __FreeBSD__
|
||||
#include <libusb.h>
|
||||
#else
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,11 @@
|
|||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairHydro.h"
|
||||
#include <vector>
|
||||
#ifdef __FreeBSD__
|
||||
#include <libusb.h>
|
||||
#else
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Corsair vendor ID |
|
||||
|
|
|
|||
|
|
@ -15,7 +15,11 @@
|
|||
#include "RGBController_LianLiUniHub.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <libusb.h>
|
||||
#else
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#endif
|
||||
|
||||
#define UNI_HUB_VID 0x0CF2
|
||||
#define UNI_HUB_PID 0x7750
|
||||
|
|
|
|||
|
|
@ -15,7 +15,11 @@
|
|||
|
||||
#include "RGBController.h"
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <libusb.h>
|
||||
#else
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------*\
|
||||
| Global definitions. |
|
||||
|
|
|
|||
114
OpenRGB.pro
114
OpenRGB.pro
|
|
@ -156,6 +156,11 @@ INCLUDEPATH +=
|
|||
RGBController/ \
|
||||
qt/
|
||||
|
||||
contains(QMAKE_PLATFORM, freebsd) {
|
||||
INCLUDEPATH -= \
|
||||
Controllers/GigabyteRGBFusion2GPUController/
|
||||
}
|
||||
|
||||
HEADERS += \
|
||||
Colors.h \
|
||||
dependencies/ColorWheel/ColorWheel.h \
|
||||
|
|
@ -542,6 +547,16 @@ HEADERS +=
|
|||
RGBController/RGBControllerKeyNames.h \
|
||||
RGBController/RGBController_Network.h \
|
||||
|
||||
contains(QMAKE_PLATFORM, freebsd) {
|
||||
HEADERS -= \
|
||||
Controllers/GigabyteRGBFusion2GPUController/GigabyteRGBFusion2GPUController.h \
|
||||
Controllers/GigabyteRGBFusion2GPUController/RGBController_GigabyteRGBFusion2GPU.h \
|
||||
Controllers/HoltekController/HoltekA070Controller.h \
|
||||
Controllers/HoltekController/HoltekA1FAController.h \
|
||||
Controllers/HoltekController/RGBController_HoltekA070.h \
|
||||
Controllers/HoltekController/RGBController_HoltekA1FA.h
|
||||
}
|
||||
|
||||
SOURCES += \
|
||||
dependencies/Swatches/swatches.cpp \
|
||||
dependencies/dmiinfo.cpp \
|
||||
|
|
@ -1037,6 +1052,18 @@ SOURCES +=
|
|||
RGBController/RGBControllerKeyNames.cpp \
|
||||
RGBController/RGBController_Network.cpp \
|
||||
|
||||
contains(QMAKE_PLATFORM, freebsd) {
|
||||
SOURCES -= \
|
||||
Controllers/GigabyteRGBFusion2GPUController/GigabyteRGBFusion2GPUController.cpp \
|
||||
Controllers/GigabyteRGBFusion2GPUController/GigabyteRGBFusion2GPUControllerDetect.cpp \
|
||||
Controllers/GigabyteRGBFusion2GPUController/RGBController_GigabyteRGBFusion2GPU.cpp \
|
||||
Controllers/HoltekController/HoltekA070Controller.cpp \
|
||||
Controllers/HoltekController/HoltekA1FAController.cpp \
|
||||
Controllers/HoltekController/HoltekControllerDetect.cpp \
|
||||
Controllers/HoltekController/RGBController_HoltekA070.cpp \
|
||||
Controllers/HoltekController/RGBController_HoltekA1FA.cpp
|
||||
}
|
||||
|
||||
RESOURCES += \
|
||||
qt/resources.qrc
|
||||
|
||||
|
|
@ -1288,7 +1315,7 @@ win32:contains(QMAKE_TARGET.arch, x86) {
|
|||
#-----------------------------------------------------------------------------------------------#
|
||||
# Linux-specific Configuration #
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
unix:!macx {
|
||||
contains(QMAKE_PLATFORM, linux) {
|
||||
TARGET = $$lower($$TARGET)
|
||||
|
||||
INCLUDEPATH += \
|
||||
|
|
@ -1401,6 +1428,91 @@ unix:!macx {
|
|||
INSTALLS += target desktop icon metainfo udev_rules
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
# FreeBSD-specific Configuration #
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
contains(QMAKE_PLATFORM, freebsd) {
|
||||
TARGET = $$lower($$TARGET)
|
||||
|
||||
INCLUDEPATH += \
|
||||
Controllers/FaustusController \
|
||||
Controllers/LinuxLEDController \
|
||||
|
||||
HEADERS += \
|
||||
AutoStart/AutoStart-FreeBSD.h \
|
||||
Controllers/ENESMBusController/ENESMBusInterface/ENESMBusInterface_SpectrixS40G.h \
|
||||
Controllers/FaustusController/RGBController_Faustus.h \
|
||||
Controllers/LinuxLEDController/LinuxLEDController.h \
|
||||
Controllers/LinuxLEDController/RGBController_LinuxLED.h \
|
||||
Controllers/OpenRazerController/RGBController_OpenRazer.h \
|
||||
|
||||
LIBS += \
|
||||
-lusb \
|
||||
-lmbedx509 \
|
||||
-lmbedtls \
|
||||
-lmbedcrypto \
|
||||
|
||||
COMPILER_VERSION = $$system($$QMAKE_CXX " -dumpversion")
|
||||
if (!versionAtLeast(COMPILER_VERSION, "9")) {
|
||||
LIBS += -lstdc++fs
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------------------#
|
||||
# Determine which hidapi to use based on availability #
|
||||
# Prefer hidraw backend, then libusb #
|
||||
#-------------------------------------------------------------------------------------------#
|
||||
packagesExist(hidapi-hidraw) {
|
||||
LIBS += -lhidapi-hidraw
|
||||
|
||||
#---------------------------------------------------------------------------------------#
|
||||
# hidapi-hidraw >= 0.10.1 supports USAGE/USAGE_PAGE #
|
||||
# Define USE_HID_USAGE if hidapi-hidraw supports it #
|
||||
#---------------------------------------------------------------------------------------#
|
||||
HIDAPI_HIDRAW_VERSION = $$system($$PKG_CONFIG --modversion hidapi-hidraw)
|
||||
if(versionAtLeast(HIDAPI_HIDRAW_VERSION, "0.10.1")) {
|
||||
DEFINES += USE_HID_USAGE
|
||||
}
|
||||
} else {
|
||||
packagesExist(hidapi-libusb) {
|
||||
LIBS += -lhidapi-libusb
|
||||
} else {
|
||||
LIBS += -lhidapi
|
||||
}
|
||||
}
|
||||
|
||||
SOURCES += \
|
||||
dependencies/hueplusplus-1.0.0/src/LinHttpHandler.cpp \
|
||||
serial_port/find_usb_serial_port_linux.cpp \
|
||||
AutoStart/AutoStart-FreeBSD.cpp \
|
||||
Controllers/ENESMBusController/XPGSpectrixS40GDetect.cpp \
|
||||
Controllers/ENESMBusController/ENESMBusInterface/ENESMBusInterface_SpectrixS40G.cpp \
|
||||
Controllers/FaustusController/RGBController_Faustus.cpp \
|
||||
Controllers/LinuxLEDController/LinuxLEDController.cpp \
|
||||
Controllers/LinuxLEDController/LinuxLEDControllerDetect.cpp \
|
||||
Controllers/LinuxLEDController/RGBController_LinuxLED.cpp \
|
||||
Controllers/OpenRazerController/OpenRazerDetect.cpp \
|
||||
Controllers/OpenRazerController/RGBController_OpenRazer.cpp \
|
||||
|
||||
#-------------------------------------------------------------------------------------------#
|
||||
# Set up install paths #
|
||||
# These install paths are used for AppImage and .deb packaging #
|
||||
#-------------------------------------------------------------------------------------------#
|
||||
isEmpty(PREFIX) {
|
||||
PREFIX = /usr
|
||||
}
|
||||
|
||||
target.path=$$PREFIX/bin/
|
||||
desktop.path=$$PREFIX/share/applications/
|
||||
desktop.files+=qt/OpenRGB.desktop
|
||||
icon.path=$$PREFIX/share/icons/hicolor/128x128/apps/
|
||||
icon.files+=qt/OpenRGB.png
|
||||
metainfo.path=$$PREFIX/share/metainfo/
|
||||
metainfo.files+=qt/org.openrgb.OpenRGB.metainfo.xml
|
||||
rules.path=$$PREFIX/lib/udev/rules.d/
|
||||
rules.files+=60-openrgb.rules
|
||||
INSTALLS += target desktop icon metainfo rules
|
||||
}
|
||||
|
||||
unix:!macx:CONFIG(asan) {
|
||||
message("ASan Mode")
|
||||
QMAKE_CFLAGS=-fsanitize=address
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ union i2c_smbus_data
|
|||
|
||||
#endif /* __linux__ */
|
||||
|
||||
#ifdef __APPLE__
|
||||
#if defined(__APPLE___) || defined(__FreeBSD__)
|
||||
|
||||
//Data for SMBus Messages
|
||||
#define I2C_SMBUS_BLOCK_MAX 32
|
||||
|
|
@ -53,7 +53,7 @@ union i2c_smbus_data
|
|||
u8 block[I2C_SMBUS_BLOCK_MAX + 2];
|
||||
};
|
||||
|
||||
#endif /* __APPLE__ */
|
||||
#endif /* __APPLE__ or __FreeBSD__ */
|
||||
|
||||
// i2c_smbus_xfer read or write markers
|
||||
#define I2C_SMBUS_READ 1
|
||||
|
|
|
|||
|
|
@ -1,23 +1,17 @@
|
|||
|
||||
|
||||
diff --git a/OpenRGB.pro b/OpenRGB.pro
|
||||
index 6295344a..d09bed44 100644
|
||||
--- a/OpenRGB.pro
|
||||
+++ b/OpenRGB.pro
|
||||
@@ -639,8 +639,6 @@ win32:contains(QMAKE_TARGET.arch, x86) {
|
||||
--- a/OpenRGB.pro 2022-05-02 15:26:15.375947000 +0200
|
||||
+++ b/OpenRGB.pro 2022-05-02 15:29:01.997135000 +0200
|
||||
@@ -1310,8 +1310,6 @@
|
||||
# Linux-specific Configuration #
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
unix:!macx {
|
||||
contains(QMAKE_PLATFORM, linux) {
|
||||
- TARGET = $$lower($$TARGET)
|
||||
-
|
||||
INCLUDEPATH += \
|
||||
Controllers/FaustusController \
|
||||
|
||||
diff --git a/qt/OpenRGB.desktop b/qt/OpenRGB.desktop
|
||||
index bd71a38a..b4a0f86a 100644
|
||||
--- a/qt/OpenRGB.desktop
|
||||
+++ b/qt/OpenRGB.desktop
|
||||
@@ -3,7 +3,7 @@ Type=Application
|
||||
Controllers/LinuxLEDController \
|
||||
--- a/qt/OpenRGB.desktop 2022-05-02 15:25:52.150332000 +0200
|
||||
+++ b/qt/OpenRGB.desktop 2022-05-02 15:28:27.749598000 +0200
|
||||
@@ -3,7 +3,7 @@
|
||||
Encoding=UTF-8
|
||||
Name=OpenRGB
|
||||
Comment=Control RGB lighting
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue