mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-07-15 09:33:36 -07:00
Add StreamSession and connect Gamepad
This commit is contained in:
parent
a45ea63598
commit
c045dbba62
4 changed files with 101 additions and 3 deletions
|
@ -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)
|
||||
|
|
41
gui/include/streamsession.h
Normal file
41
gui/include/streamsession.h
Normal file
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CHIAKI_STREAMSESSION_H
|
||||
#define CHIAKI_STREAMSESSION_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QGamepad>
|
||||
|
||||
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
|
|
@ -3,6 +3,7 @@
|
|||
#include <videodecoder.h>
|
||||
#include <discoverycmd.h>
|
||||
#include <mainwindow.h>
|
||||
#include <streamsession.h>
|
||||
|
||||
#include <chiaki/session.h>
|
||||
#include <chiaki/base64.h>
|
||||
|
@ -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();
|
||||
|
|
52
gui/src/streamsession.cpp
Normal file
52
gui/src/streamsession.cpp
Normal file
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <streamsession.h>
|
||||
|
||||
#include <QGamepadManager>
|
||||
#include <QDebug>
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue