diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt
index fa0e2ff..be0ca21 100644
--- a/gui/CMakeLists.txt
+++ b/gui/CMakeLists.txt
@@ -3,7 +3,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
-find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui Multimedia)
+find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui Multimedia Gamepad)
find_package(FFMPEG REQUIRED COMPONENTS avcodec)
@@ -22,9 +22,11 @@ add_executable(chiaki
include/serveritemwidget.h
src/serveritemwidget.cpp
include/discoverymanager.h
- src/discoverymanager.cpp)
+ src/discoverymanager.cpp
+ include/streamsession.h
+ src/streamsession.cpp)
target_include_directories(chiaki PRIVATE include)
target_link_libraries(chiaki chiaki-lib)
target_link_libraries(chiaki FFMPEG::avcodec)
-target_link_libraries(chiaki Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Multimedia)
+target_link_libraries(chiaki Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Multimedia Qt5::Gamepad)
diff --git a/gui/include/streamsession.h b/gui/include/streamsession.h
new file mode 100644
index 0000000..844fb7f
--- /dev/null
+++ b/gui/include/streamsession.h
@@ -0,0 +1,41 @@
+/*
+ * This file is part of Chiaki.
+ *
+ * Chiaki 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chiaki 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 Chiaki. If not, see .
+ */
+
+#ifndef CHIAKI_STREAMSESSION_H
+#define CHIAKI_STREAMSESSION_H
+
+#include
+#include
+
+class StreamSession : public QObject
+{
+ Q_OBJECT
+
+ private:
+ QGamepad *gamepad;
+
+ public:
+ explicit StreamSession(QObject *parent = nullptr);
+ ~StreamSession();
+
+ QGamepad *GetGamepad() { return gamepad; }
+
+ private slots:
+ void UpdateGamepads();
+};
+
+#endif // CHIAKI_STREAMSESSION_H
diff --git a/gui/src/main.cpp b/gui/src/main.cpp
index 1bfd141..c352f6e 100644
--- a/gui/src/main.cpp
+++ b/gui/src/main.cpp
@@ -3,6 +3,7 @@
#include
#include
#include
+#include
#include
#include
@@ -111,6 +112,8 @@ void video_sample_cb(uint8_t *buf, size_t buf_size, void *user)
int RunStream(QApplication &app, const QString &host, const QString ®istkey, const QString &ostype, const QString &auth, const QString &morning, const QString &did)
{
+ StreamSession stream_session;
+
QByteArray host_str = host.toUtf8();
QByteArray registkey_str = registkey.toUtf8();
QByteArray ostype_str = ostype.toUtf8();
diff --git a/gui/src/streamsession.cpp b/gui/src/streamsession.cpp
new file mode 100644
index 0000000..010fb7c
--- /dev/null
+++ b/gui/src/streamsession.cpp
@@ -0,0 +1,52 @@
+/*
+ * This file is part of Chiaki.
+ *
+ * Chiaki 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chiaki 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 Chiaki. If not, see .
+ */
+
+#include
+
+#include
+#include
+
+StreamSession::StreamSession(QObject *parent)
+ : QObject(parent),
+ gamepad(nullptr)
+{
+ connect(QGamepadManager::instance(), &QGamepadManager::connectedGamepadsChanged, this, &StreamSession::UpdateGamepads);
+ UpdateGamepads();
+}
+
+StreamSession::~StreamSession()
+{
+}
+
+void StreamSession::UpdateGamepads()
+{
+ if(!gamepad || !gamepad->isConnected())
+ {
+ if(gamepad)
+ {
+ qDebug() << "gamepad" << gamepad->deviceId() << "disconnected";
+ delete gamepad;
+ gamepad = nullptr;
+ }
+ const auto connected_pads = QGamepadManager::instance()->connectedGamepads();
+ if(!connected_pads.isEmpty())
+ {
+ gamepad = new QGamepad(connected_pads[0], this);
+ qDebug() << "gamepad" << connected_pads[0] << "connected: " << gamepad->name();
+ }
+ }
+}
\ No newline at end of file