From 2a2a81983248558cfefd7ae4132f99332f90b884 Mon Sep 17 00:00:00 2001 From: Roland Bosa Date: Mon, 11 Jun 2018 16:06:23 -0700 Subject: [PATCH] Modernized CMakeLists.txt file --- CMakeLists.txt | 275 ++++++++++++++++++++-------- FakeGameController.cpp | 125 +++++++++++++ FakeGameController.h | 61 ++++++ ForceEffects/CMakeLists.txt | 31 ---- ForceGraphWidgets/CMakeLists.txt | 18 -- ForceWidgets/CMakeLists.txt | 36 ---- GameController.cpp | 10 + Widgets/CMakeLists.txt | 42 ----- Widgets/SendCommandDialog.cpp | 38 ++-- Windows/import_windows_platform.cpp | 1 + 10 files changed, 422 insertions(+), 215 deletions(-) create mode 100644 FakeGameController.cpp create mode 100644 FakeGameController.h delete mode 100644 ForceEffects/CMakeLists.txt delete mode 100644 ForceGraphWidgets/CMakeLists.txt delete mode 100644 ForceWidgets/CMakeLists.txt delete mode 100644 Widgets/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 180f168..a04feb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,93 +1,222 @@ -cmake_minimum_required(VERSION 2.8.12) - -if(NOT EXISTS $ENV{QTDIR}) - message(FATAL_ERROR "Please define an environment variable QTDIR and point it to your Qt installation directory.") -endif() - -set(CMAKE_PREFIX_PATH $ENV{QTDIR}) -message("Using Qt at path: " ${CMAKE_PREFIX_PATH}) +cmake_minimum_required(VERSION 3.11.0) project(QForceStudio) -# Build a debug version -set(CMAKE_BUILD_TYPE Debug) - # Find includes in corresponding build directories set(CMAKE_INCLUDE_CURRENT_DIR ON) -# Instruct CMake to run moc automatically when needed. +# Instruct CMake to run moc, uic, rcc automatically when needed. set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) # Find all the required Qt modules -find_package(Qt5Widgets REQUIRED) +find_package(Qt5 COMPONENTS Core Widgets REQUIRED) add_definitions(-DQT5) add_definitions(-DUNICODE -D_UNICODE) -file(GLOB FORMS *.ui) -file(GLOB RESOURCES *.qrc) -file(GLOB HEADERS *.h) -file(GLOB SOURCES *.cpp) - -foreach(SUBDIR ForceEffects ForceWidgets Widgets ForceGraphWidgets) - include_directories(${SUBDIR}) - add_subdirectory(${SUBDIR}) -endforeach(SUBDIR) - -qt5_wrap_ui(UI_HEADERS ${FORMS}) -qt5_add_resources(UI_RESOURCES ${RESOURCES}) +set(FORMS + AboutBoxDialog.ui + ForceWidgets/FWCondition.ui + ForceWidgets/FWConstant.ui + ForceWidgets/FWPeriodic.ui + ForceWidgets/FWRamp.ui + ForceWidgets/FWRumble.ui + GameControllerInfoWidget.ui + MainWindow.ui + SelectGameControllerDialog.ui + Widgets/CodeGistWidget.ui + Widgets/ConditionWidget.ui + Widgets/DirectionWidget.ui + Widgets/DurationWidget.ui + Widgets/EnvelopeWidget.ui + Widgets/ForceButtonBox.ui + Widgets/PeriodFrequencyWidget.ui + Widgets/RampWidget.ui + Widgets/SendCommandDialog.ui) + +set(RESOURCES + Resources.qrc) + +set(HEADERS + AboutBoxDialog.h + FakeGameController.h + GameController.h + GameControllerInfoWidget.h + MainWindow.h + QForceStudio.h + SelectGameControllerDialog.h + ForceEffects/FECondition.h + ForceEffects/FEConstant.h + ForceEffects/FEDamper.h + ForceEffects/FEFriction.h + ForceEffects/FEInertia.h + ForceEffects/FEPeriodic.h + ForceEffects/FERamp.h + ForceEffects/FERumble.h + ForceEffects/FESpring.h + ForceEffects/ForceCondition.h + ForceEffects/ForceEffect.h + ForceEffects/ForceEnvelope.h + ForceGraphWidgets/DragHandle.h + ForceGraphWidgets/FGWCondition.h + ForceGraphWidgets/FGWConstant.h + ForceGraphWidgets/FGWPeriodic.h + ForceGraphWidgets/FGWRamp.h + ForceWidgets/ForceWidget.h + ForceWidgets/FWCondition.h + ForceWidgets/FWConstant.h + ForceWidgets/FWDamper.h + ForceWidgets/FWFriction.h + ForceWidgets/FWInertia.h + ForceWidgets/FWPeriodic.h + ForceWidgets/FWRamp.h + ForceWidgets/FWRumble.h + ForceWidgets/FWSpring.h + Widgets/AngleWidget.h + Widgets/CodeGistWidget.h + Widgets/ConditionWidget.h + Widgets/DirectionWidget.h + Widgets/DurationSliderWidget.h + Widgets/DurationWidget.h + Widgets/EnvelopeWidget.h + Widgets/ForceButtonBox.h + Widgets/PeriodFrequencyWidget.h + Widgets/RampWidget.h + Widgets/SendCommandDialog.h) + +set(SOURCES + AboutBoxDialog.cpp + FakeGameController.cpp + GameController.cpp + GameControllerInfoWidget.cpp + Main.cpp + MainWindow.cpp + QForceStudio.cpp + SelectGameControllerDialog.cpp + ForceEffects/FECondition.cpp + ForceEffects/FEConstant.cpp + ForceEffects/FEDamper.cpp + ForceEffects/FEFriction.cpp + ForceEffects/FEInertia.cpp + ForceEffects/FEPeriodic.cpp + ForceEffects/FERamp.cpp + ForceEffects/FERumble.cpp + ForceEffects/FESpring.cpp + ForceEffects/ForceCondition.cpp + ForceEffects/ForceEffect.cpp + ForceEffects/ForceEnvelope.cpp + ForceGraphWidgets/DragHandle.cpp + ForceGraphWidgets/FGWCondition.cpp + ForceGraphWidgets/FGWConstant.cpp + ForceGraphWidgets/FGWPeriodic.cpp + ForceGraphWidgets/FGWRamp.cpp + ForceWidgets/ForceWidget.cpp + ForceWidgets/FWCondition.cpp + ForceWidgets/FWConstant.cpp + ForceWidgets/FWDamper.cpp + ForceWidgets/FWFriction.cpp + ForceWidgets/FWInertia.cpp + ForceWidgets/FWPeriodic.cpp + ForceWidgets/FWRamp.cpp + ForceWidgets/FWRumble.cpp + ForceWidgets/FWSpring.cpp + Widgets/AngleWidget.cpp + Widgets/CodeGistWidget.cpp + Widgets/ConditionWidget.cpp + Widgets/DirectionWidget.cpp + Widgets/DurationSliderWidget.cpp + Widgets/DurationWidget.cpp + Widgets/EnvelopeWidget.cpp + Widgets/ForceButtonBox.cpp + Widgets/PeriodFrequencyWidget.cpp + Widgets/RampWidget.cpp + Widgets/SendCommandDialog.cpp) + +# platform specific files +if(APPLE) + list(APPEND HEADERS + OSXInput/linux/input.h) +elseif(WIN32) + list(APPEND HEADERS + GameControllerDirectInput.h) + list(APPEND SOURCES + GameControllerDirectInput.cpp + Windows/import_windows_platform.cpp) +else() + # TODO: add generic gamecontroller here +endif() -# This is for customization of the OSX build - none of this works properly yet, it's -# just copied from a sample file. At some point, I should just drop OSX support completely... -if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - add_executable(QForceStudio ${SOURCES} ${HEADERS} ${UI_HEADERS} ${UI_RESOURCES}) +if(APPLE) set(MACOSX_BUNDLE_ICON_FILE QForceStudio.icns) - SET_SOURCE_FILES_PROPERTIES( - QForceStudio.icns - PROPERTIES - MACOSX_PACKAGE_LOCATION Resources + set_source_files_properties( + QForceStudio.icns + PROPERTIES + MACOSX_PACKAGE_LOCATION Resources ) - INCLUDE_DIRECTORIES("OSXInput") - + add_executable(QForceStudio MACOSX_BUNDLE + ${SOURCES} + ${HEADERS} + ${UI_HEADERS} + ${UI_RESOURCES}) + target_include_directories(QForceStudio PRIVATE + OSXInput) elseif(WIN32) + list(APPEND SOURCES + Windows/*.cpp) + ##file(GLOB PLATFORM_SOURCES "Windows/*.cpp") + + # Change MS CRT to be static + foreach(flag_var + CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if(${flag_var} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") + endif(${flag_var} MATCHES "/MD") + endforeach(flag_var) + + # add winsock, shlwapi and opengl32 and the Qt EGL Libs + set(PLATFORM_LIBRARIES "ws2_32" "ShlWAPI" "Opengl32" "Imm32" ${Qt5Gui_OPENGL_LIBRARIES} ${Qt5Gui_EGL_LIBRARIES}) + list(APPEND PLATFORM_LIBRARIES "d3d9") + list(APPEND PLATFORM_LIBRARIES "dxguid") + list(APPEND PLATFORM_LIBRARIES "winmm") + + get_target_property(QtCore_location Qt5::Core LOCATION) + get_filename_component(QtCore_libpath ${QtCore_location} DIRECTORY) + list(APPEND PLATFORM_LIBRARIES "${Qt5Gui_PLUGINS}") + + add_executable(QForceStudio WIN32 + ${SOURCES} + ${HEADERS} + ${UI_HEADERS} + ${UI_RESOURCES}) + add_executable(QForceStudio WIN32 ${SOURCES} ${HEADERS} ${BFORMS} ${UI_HEADERS} ${UI_RESOURCES} ${PLATFORM_SOURCES}) + target_link_libraries(QForceStudio debug "${QtCore_libpath}/preprocessord.lib") + target_link_libraries(QForceStudio debug "${QtCore_libpath}/translatord.lib") + target_link_libraries(QForceStudio debug "${QtCore_libpath}/Qt5PlatformSupportd.lib") + target_link_libraries(QForceStudio optimized "${QtCore_libpath}/preprocessor.lib") + target_link_libraries(QForceStudio optimized "${QtCore_libpath}/translator.lib") + target_link_libraries(QForceStudio optimized "${QtCore_libpath}/Qt5PlatformSupport.lib") + +else() + add_executable(QForceStudio + ${SOURCES} + ${HEADERS} + ${UI_HEADERS} + ${UI_RESOURCES}) +endif() - file(GLOB PLATFORM_SOURCES "Windows/*.cpp") - - # Change MS CRT to be static - foreach(flag_var - CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) - if (${flag_var} MATCHES "/MD") - string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") - endif(${flag_var} MATCHES "/MD") - endforeach(flag_var) - - # add winsock, shlwapi and opengl32 and the Qt EGL Libs - set(PLATFORM_LIBRARIES "ws2_32" "ShlWAPI" "Opengl32" "Imm32" ${Qt5Gui_OPENGL_LIBRARIES} ${Qt5Gui_EGL_LIBRARIES}) - list(APPEND PLATFORM_LIBRARIES "d3d9") - list(APPEND PLATFORM_LIBRARIES "dxguid") - list(APPEND PLATFORM_LIBRARIES "winmm") - - get_target_property(QtCore_location Qt5::Core LOCATION) - get_filename_component(QtCore_libpath ${QtCore_location} DIRECTORY) - list(APPEND PLATFORM_LIBRARIES "${Qt5Gui_PLUGINS}") - - add_executable(QForceStudio WIN32 ${SOURCES} ${HEADERS} ${BFORMS} ${UI_HEADERS} ${UI_RESOURCES} ${PLATFORM_SOURCES}) - target_link_libraries(QForceStudio debug "${QtCore_libpath}/preprocessord.lib") - target_link_libraries(QForceStudio debug "${QtCore_libpath}/translatord.lib") - target_link_libraries(QForceStudio debug "${QtCore_libpath}/Qt5PlatformSupportd.lib") - target_link_libraries(QForceStudio optimized "${QtCore_libpath}/preprocessor.lib") - target_link_libraries(QForceStudio optimized "${QtCore_libpath}/translator.lib") - target_link_libraries(QForceStudio optimized "${QtCore_libpath}/Qt5PlatformSupport.lib") - -endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - -#qt5_use_modules(QForceStudio Widgets) -#target_link_libraries(QForceStudio ${Qt5Core_QTMAIN_LIBRARIES}) - -qt5_wrap_ui(UI_HEADERS ${BFORMS}) -qt5_add_resources(UI_RESOURCES ${BRESOURCES}) +target_compile_features(QForceStudio PRIVATE + cxx_std_11) -qt5_use_modules(QForceStudio Widgets Concurrent) +target_include_directories(QForceStudio PRIVATE + ForceEffects + ForceWidgets + Widgets + ForceGraphWidgets) -target_link_libraries(QForceStudio ${Qt5Core_QTMAIN_LIBRARIES} ${PLATFORM_LIBRARIES}) +target_link_libraries(QForceStudio + Qt5::Core + Qt5::Widgets + ${PLATFORM_LIBRARIES}) diff --git a/FakeGameController.cpp b/FakeGameController.cpp new file mode 100644 index 0000000..8f04840 --- /dev/null +++ b/FakeGameController.cpp @@ -0,0 +1,125 @@ +/* + * QForceStudio - Explore Force Feedback on Linux. + * + * Copyright (C) 2014 Logitech Europe S.A. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * To Contact Logitech Europe S.A. please send an email to + * devtechsupport@logitech.com or via mail at EPFL - Quartier de + * l'Innovation Daniel Borel Innovation Center CH - 1015 Lausanne, + * Attention Roland Bosa. + * + */ + +#include "QForceStudio.h" +#include "GameController.h" +#include "FakeGameController.h" +#include "ForceEffect.h" +#include + + +FakeGameController::FakeGameController(QObject *parent) + : GameController(parent) +{ + m_name = "Fake Game Controller"; + m_filename = "/tmp/fake_device"; + m_effectCount = 64; +} + + +FakeGameController::~FakeGameController(void) +{ +} + + +bool FakeGameController::open(const QString &filename) +{ + m_fd = 42; + return true; +} + + +void FakeGameController::close(void) +{ + m_fd = -1; +} + + +bool FakeGameController::addForce(ForceEffect *force) +{ + return true; +} + + +bool FakeGameController::startForce(ForceEffect *force) +{ + return true; +} + + +bool FakeGameController::stopForce(ForceEffect *force) +{ + return true; +} + + +bool FakeGameController::removeForce(ForceEffect *force) +{ + return true; +} + + +bool FakeGameController::stopAllForces(void) +{ + return true; +} + + +bool FakeGameController::pauseAllForces(void) +{ + return true; +} + + +bool FakeGameController::continueAllForces(void) +{ + return true; +} + + +bool FakeGameController::resetAllForces(void) +{ + return true; +} + + +bool FakeGameController::enableActuators(bool enable) +{ + return true; +} + + +bool FakeGameController::sendCommand(const QByteArray &command, QByteArray &response) +{ + return true; +} + + +bool FakeGameController::hasSupportFor(int capability) const +{ + return true; +} diff --git a/FakeGameController.h b/FakeGameController.h new file mode 100644 index 0000000..8afec95 --- /dev/null +++ b/FakeGameController.h @@ -0,0 +1,61 @@ +/* + * QForceStudio - Explore Force Feedback on Linux. + * + * Copyright (C) 2014 Logitech Europe S.A. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + * + * To Contact Logitech Europe S.A. please send an email to + * devtechsupport@logitech.com or via mail at EPFL - Quartier de + * l'Innovation Daniel Borel Innovation Center CH - 1015 Lausanne, + * Attention Roland Bosa. + * + */ + +#ifndef FAKEGAMECONTROLLER_H +#define FAKEGAMECONTROLLER_H + +#include "GameController.h" + +class FakeGameController : public GameController +{ +Q_OBJECT +public: + explicit FakeGameController(QObject *parent = 0); + virtual ~FakeGameController(void); + + // open/close + virtual bool open(const QString &filename = QString()); + virtual void close(void); + + virtual bool addForce(ForceEffect *force); + virtual bool startForce(ForceEffect *force); + virtual bool stopForce(ForceEffect *force); + virtual bool removeForce(ForceEffect *force); + + virtual bool stopAllForces(void); + virtual bool pauseAllForces(void); + virtual bool continueAllForces(void); + virtual bool resetAllForces(void); + virtual bool enableActuators(bool enable); + + virtual bool sendCommand(const QByteArray &command, QByteArray &response); + +protected: + virtual bool hasSupportFor(int capability) const; +}; + +#endif // FAKEGAMECONTROLLER_H diff --git a/ForceEffects/CMakeLists.txt b/ForceEffects/CMakeLists.txt deleted file mode 100644 index 07de316..0000000 --- a/ForceEffects/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -set(SOURCES - ${SOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/FECondition.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FEConstant.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FEDamper.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FEFriction.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FEInertia.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FEPeriodic.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FERamp.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FERumble.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FESpring.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ForceCondition.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ForceEffect.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ForceEnvelope.cpp - PARENT_SCOPE) - -set(HEADERS - ${HEADERS} - ${CMAKE_CURRENT_SOURCE_DIR}/FECondition.h - ${CMAKE_CURRENT_SOURCE_DIR}/FEConstant.h - ${CMAKE_CURRENT_SOURCE_DIR}/FEDamper.h - ${CMAKE_CURRENT_SOURCE_DIR}/FEFriction.h - ${CMAKE_CURRENT_SOURCE_DIR}/FEInertia.h - ${CMAKE_CURRENT_SOURCE_DIR}/FEPeriodic.h - ${CMAKE_CURRENT_SOURCE_DIR}/FERamp.h - ${CMAKE_CURRENT_SOURCE_DIR}/FERumble.h - ${CMAKE_CURRENT_SOURCE_DIR}/FESpring.h - ${CMAKE_CURRENT_SOURCE_DIR}/ForceCondition.h - ${CMAKE_CURRENT_SOURCE_DIR}/ForceEffect.h - ${CMAKE_CURRENT_SOURCE_DIR}/ForceEnvelope.h - PARENT_SCOPE) diff --git a/ForceGraphWidgets/CMakeLists.txt b/ForceGraphWidgets/CMakeLists.txt deleted file mode 100644 index 011cb8c..0000000 --- a/ForceGraphWidgets/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -set(SOURCES - ${SOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/DragHandle.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FGWPeriodic.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FGWCondition.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FGWConstant.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FGWRamp.cpp - PARENT_SCOPE) - -set(HEADERS - ${HEADERS} - ${CMAKE_CURRENT_SOURCE_DIR}/DragHandle.h - ${CMAKE_CURRENT_SOURCE_DIR}/FGWPeriodic.h - ${CMAKE_CURRENT_SOURCE_DIR}/FGWCondition.h - ${CMAKE_CURRENT_SOURCE_DIR}/FGWConstant.h - ${CMAKE_CURRENT_SOURCE_DIR}/FGWRamp.h - PARENT_SCOPE) - diff --git a/ForceWidgets/CMakeLists.txt b/ForceWidgets/CMakeLists.txt deleted file mode 100644 index 62d47fd..0000000 --- a/ForceWidgets/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -set(SOURCES - ${SOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/FWCondition.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FWConstant.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FWDamper.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FWFriction.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FWInertia.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FWPeriodic.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FWRamp.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FWRumble.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FWSpring.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ForceWidget.cpp - PARENT_SCOPE) - -set(HEADERS - ${HEADERS} - ${CMAKE_CURRENT_SOURCE_DIR}/FWCondition.h - ${CMAKE_CURRENT_SOURCE_DIR}/FWConstant.h - ${CMAKE_CURRENT_SOURCE_DIR}/FWDamper.h - ${CMAKE_CURRENT_SOURCE_DIR}/FWFriction.h - ${CMAKE_CURRENT_SOURCE_DIR}/FWInertia.h - ${CMAKE_CURRENT_SOURCE_DIR}/FWPeriodic.h - ${CMAKE_CURRENT_SOURCE_DIR}/FWRamp.h - ${CMAKE_CURRENT_SOURCE_DIR}/FWRumble.h - ${CMAKE_CURRENT_SOURCE_DIR}/FWSpring.h - ${CMAKE_CURRENT_SOURCE_DIR}/ForceWidget.h - PARENT_SCOPE) - -set(FORMS - ${FORMS} - ${CMAKE_CURRENT_SOURCE_DIR}/FWCondition.ui - ${CMAKE_CURRENT_SOURCE_DIR}/FWConstant.ui - ${CMAKE_CURRENT_SOURCE_DIR}/FWPeriodic.ui - ${CMAKE_CURRENT_SOURCE_DIR}/FWRamp.ui - ${CMAKE_CURRENT_SOURCE_DIR}/FWRumble.ui - PARENT_SCOPE) diff --git a/GameController.cpp b/GameController.cpp index c60dc63..0382776 100644 --- a/GameController.cpp +++ b/GameController.cpp @@ -27,6 +27,7 @@ #include "QForceStudio.h" #include "GameController.h" +#include "FakeGameController.h" #include "ForceEffect.h" #include @@ -272,6 +273,15 @@ bool GameController::canAdjustAutocenter(void) const return hasSupportFor(FF_AUTOCENTER); } +#ifdef Q_OS_MAC +GameControllerPtrList GameController::allControllers(void) +{ + GameControllerPtrList result; + result.append(GameControllerPtr(new FakeGameController)); + return result; +} +#endif + #ifdef Q_OS_LINUX GameControllerPtrList GameController::allControllers(void) { diff --git a/Widgets/CMakeLists.txt b/Widgets/CMakeLists.txt deleted file mode 100644 index e8276c1..0000000 --- a/Widgets/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -set(SOURCES - ${SOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/AngleWidget.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/CodeGistWidget.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ConditionWidget.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/DirectionWidget.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/DurationSliderWidget.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/DurationWidget.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/EnvelopeWidget.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ForceButtonBox.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/PeriodFrequencyWidget.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/RampWidget.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/SendCommandDialog.cpp - PARENT_SCOPE) - -set(HEADERS - ${HEADERS} - ${CMAKE_CURRENT_SOURCE_DIR}/AngleWidget.h - ${CMAKE_CURRENT_SOURCE_DIR}/CodeGistWidget.h - ${CMAKE_CURRENT_SOURCE_DIR}/ConditionWidget.h - ${CMAKE_CURRENT_SOURCE_DIR}/DirectionWidget.h - ${CMAKE_CURRENT_SOURCE_DIR}/DurationSliderWidget.h - ${CMAKE_CURRENT_SOURCE_DIR}/DurationWidget.h - ${CMAKE_CURRENT_SOURCE_DIR}/EnvelopeWidget.h - ${CMAKE_CURRENT_SOURCE_DIR}/ForceButtonBox.h - ${CMAKE_CURRENT_SOURCE_DIR}/PeriodFrequencyWidget.h - ${CMAKE_CURRENT_SOURCE_DIR}/RampWidget.h - ${CMAKE_CURRENT_SOURCE_DIR}/SendCommandDialog.h - PARENT_SCOPE) - -set(FORMS - ${FORMS} - ${CMAKE_CURRENT_SOURCE_DIR}/CodeGistWidget.ui - ${CMAKE_CURRENT_SOURCE_DIR}/ConditionWidget.ui - ${CMAKE_CURRENT_SOURCE_DIR}/DirectionWidget.ui - ${CMAKE_CURRENT_SOURCE_DIR}/DurationWidget.ui - ${CMAKE_CURRENT_SOURCE_DIR}/EnvelopeWidget.ui - ${CMAKE_CURRENT_SOURCE_DIR}/ForceButtonBox.ui - ${CMAKE_CURRENT_SOURCE_DIR}/PeriodFrequencyWidget.ui - ${CMAKE_CURRENT_SOURCE_DIR}/RampWidget.ui - ${CMAKE_CURRENT_SOURCE_DIR}/SendCommandDialog.ui - PARENT_SCOPE) diff --git a/Widgets/SendCommandDialog.cpp b/Widgets/SendCommandDialog.cpp index 821d5e6..594cab5 100644 --- a/Widgets/SendCommandDialog.cpp +++ b/Widgets/SendCommandDialog.cpp @@ -31,32 +31,39 @@ #include #include -SendCommandDialog::SendCommandDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::SendCommandDialog) + +SendCommandDialog::SendCommandDialog(QWidget *parent) + : QDialog(parent), + ui(new Ui::SendCommandDialog) { ui->setupUi(this); connect(ui->sendCommand, SIGNAL(pressed()), this, SLOT(onSendCommand())); - connect(ui->command, SIGNAL(textChanged(const QString&)), this, SLOT(commandChanged(const QString&))); + connect(ui->command, SIGNAL(textChanged( + const QString&)), this, SLOT(commandChanged( + const QString&))); ui->sendCommand->setEnabled(false); } + SendCommandDialog::~SendCommandDialog(void) { delete ui; } + void SendCommandDialog::setGameController(GameControllerPtr controller) { m_gameController = controller; } + GameControllerPtr SendCommandDialog::gameController(void) const { return m_gameController; } + void SendCommandDialog::onSendCommand(void) { if (m_gameController) @@ -65,7 +72,7 @@ void SendCommandDialog::onSendCommand(void) QString dbg = "Sending command: "; for (int i = 0; i < command.size(); i++) { - dbg += QString(" 0x%1").arg((unsigned char)command[i], 0, 16); + dbg += QString(" 0x%1").arg((unsigned char) command[i], 0, 16); } qDebug() << dbg; @@ -75,44 +82,45 @@ void SendCommandDialog::onSendCommand(void) QString responseString; for (int i = 0; i < response.size(); i++) { - responseString += QString("%1 ").arg((unsigned char)response[i], 0, 16); + responseString += QString("%1 ").arg((unsigned char) response[i], 0, 16); } ui->response->setText(responseString); } } -void SendCommandDialog::commandChanged(const QString& command) + +void SendCommandDialog::commandChanged(const QString &command) { ui->sendCommand->setEnabled(!commandAsBytes(command).isEmpty()); } -QByteArray SendCommandDialog::commandAsBytes(const QString& command) + +QByteArray SendCommandDialog::commandAsBytes(const QString &command) { QByteArray ret; QStringList bytes = command.split(" "); if (bytes.isEmpty()) { - return false; + return ret; } - foreach(const QString& byte, bytes) + for (const QString &byte : bytes) { if (byte.isEmpty()) { continue; } - QRegularExpression hexMatcher("^[0-9A-F]{1,2}$", - QRegularExpression::CaseInsensitiveOption); + QRegularExpression hexMatcher("^[0-9A-F]{1,2}$", QRegularExpression::CaseInsensitiveOption); if (!hexMatcher.match(byte).hasMatch()) { - return false; + return QByteArray(); } bool ok = false; - ret.append((unsigned char)byte.toUInt(&ok, 16)); - } + ret.append((unsigned char) byte.toUInt(&ok, 16)); + } return ret; } diff --git a/Windows/import_windows_platform.cpp b/Windows/import_windows_platform.cpp index db8374a..afd49bb 100644 --- a/Windows/import_windows_platform.cpp +++ b/Windows/import_windows_platform.cpp @@ -1,2 +1,3 @@ #include + Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)