diff --git a/.gitignore b/.gitignore index f147edf..c74505c 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,5 @@ compile_commands.json # QtCreator local machine specific files for imported projects *creator.user* + +build diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..1c23fad --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,28 @@ +# This file is a copy/paste from Qt manual +# see: https://doc.qt.io/qt-5/cmake-manual.html + +cmake_minimum_required(VERSION 3.16) + +project(SimPanel LANGUAGES CXX) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +find_package(Qt5 REQUIRED Qml Widgets) + +add_executable(SimPanel + src/datastore.cpp + src/KeyReceiver.cpp + src/main.cpp + src/qml.qrc + src/QtSimPanel.cpp + src/xplaneudpclient.cpp +) + +target_link_libraries(SimPanel Qt5::Qml Qt5::Widgets) diff --git a/README.md b/README.md index 1cc9a42..6f45008 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,15 @@ Todo list : - [ ] Provide compiled files for Rapberry, Mac and windows (linux 64 only at the moment0 QtSimPanel is writen in C++ / QML using Qt5. + + +## Build + +With Cmake: + +``` +$ mkdir build +$ cd build/ +$ cmake ../ +$ make +``` diff --git a/src/KeyReceiver.cpp b/src/KeyReceiver.cpp index e895d9f..d273775 100644 --- a/src/KeyReceiver.cpp +++ b/src/KeyReceiver.cpp @@ -1,7 +1,7 @@ -#include "KeyReceiver.h" -#include #include #include +#include "KeyReceiver.h" +#include "QtSimPanel.h" KeyReceiver::KeyReceiver(QtSimPanel* qtSimPanel) { diff --git a/src/KeyReceiver.h b/src/KeyReceiver.h index 362f40e..c58f1a4 100644 --- a/src/KeyReceiver.h +++ b/src/KeyReceiver.h @@ -2,7 +2,7 @@ #define KEYRECEIVER_H #include -#include +#include "QtSimPanel.h" class KeyReceiver : public QObject { diff --git a/src/QtSimPanel.cpp b/src/QtSimPanel.cpp index 2c63a9d..4968f53 100644 --- a/src/QtSimPanel.cpp +++ b/src/QtSimPanel.cpp @@ -1,10 +1,10 @@ -#include "QtSimPanel.h" -#include "xplaneudpclient.h" -#include #include #include #include #include +#include "QtSimPanel.h" +#include "xplaneudpclient.h" +#include "KeyReceiver.h" QtSimPanel::QtSimPanel(int argc, char** argv): QGuiApplication(argc, argv), m_settings(QDir::currentPath()+"/settings.ini", QSettings::IniFormat) diff --git a/src/QtSimPanel.h b/src/QtSimPanel.h index d26ba0c..4563744 100644 --- a/src/QtSimPanel.h +++ b/src/QtSimPanel.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include "datastore.h" class QtSimPanel : public QGuiApplication { diff --git a/src/main.cpp b/src/main.cpp index 0b7bb8c..e243ef5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include "QtSimPanel.h" int main(int argc, char *argv[]) { diff --git a/src/xplaneudpclient.cpp b/src/xplaneudpclient.cpp index c68ed91..ca4c1d3 100644 --- a/src/xplaneudpclient.cpp +++ b/src/xplaneudpclient.cpp @@ -1,3 +1,5 @@ +#include + #include "xplaneudpclient.h" XplaneUdpClient::XplaneUdpClient(DataStore *dataStore, QObject *parent) : QObject(parent) @@ -107,7 +109,7 @@ void XplaneUdpClient::readStream() union { int intValue; float floatValue; } ieee754Union; - if (buffer[0] == 'D' && buffer[1] == 'A' && buffer[2] == 'T' && buffer[3] == 'A') // Handle XPlane DATA + if (strncmp(buffer, "DATA", 4) == 0) { // Segments of data unsigned nbSegs = (datagramSize-5)/36; @@ -152,7 +154,7 @@ void XplaneUdpClient::readStream() } } } - else if (buffer[0] == 'D' && buffer[1] == 'R' && buffer[2] == 'E' && buffer[3] == 'F') // Handle XPlane DREF + else if (strncmp(buffer, "DREF", 4) == 0) { char dataSegment[500]; memcpy( dataSegment, &buffer[9], 500 ); @@ -184,7 +186,7 @@ void XplaneUdpClient::readStream() } } } - else if (buffer[0] == 'R' && buffer[1] == 'R' && buffer[2] == 'E' && buffer[3] == 'F') // Handle XPlane DREF + else if (strncmp(buffer, "RREF", 4) == 0) { // Segments of data