Skip to content

Commit

Permalink
Drop Support for QtGamepad
Browse files Browse the repository at this point in the history
  • Loading branch information
thestr4ng3r committed Jul 2, 2020
1 parent 699d6bb commit 57b0b68
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 104 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ tri_option(CHIAKI_ENABLE_SETSU "Enable libsetsu for touchpad input from controll
option(CHIAKI_LIB_ENABLE_OPUS "Use Opus as part of Chiaki Lib" ON)
option(CHIAKI_LIB_ENABLE_MBEDTLS "Use mbedtls instead of OpenSSL as part of Chiaki Lib" OFF)
option(CHIAKI_LIB_OPENSSL_EXTERNAL_PROJECT "Use OpenSSL as CMake external project" OFF)
option(CHIAKI_GUI_ENABLE_QT_GAMEPAD "Use QtGamepad for Input" OFF)
option(CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER "Use SDL Gamecontroller for Input" ON)
option(CHIAKI_CLI_ARGP_STANDALONE "Search for standalone argp lib for CLI" OFF)

Expand Down
10 changes: 0 additions & 10 deletions gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui Multimedia OpenGL Svg)
if(APPLE)
find_package(Qt5 REQUIRED COMPONENTS MacExtras)
endif()
if(CHIAKI_GUI_ENABLE_QT_GAMEPAD AND CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER)
message(FATAL_ERROR "Only one input method may be enabled. Disable either CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER or CHIAKI_GUI_ENABLE_QT_GAMEPAD.")
endif()
if(CHIAKI_GUI_ENABLE_QT_GAMEPAD)
find_package(Qt5 REQUIRED COMPONENTS Gamepad)
endif()
if(CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER)
find_package(SDL2 MODULE REQUIRED)
endif()
Expand Down Expand Up @@ -85,10 +79,6 @@ if(APPLE)
target_link_libraries(chiaki Qt5::MacExtras)
target_compile_definitions(chiaki PRIVATE CHIAKI_GUI_ENABLE_QT_MACEXTRAS)
endif()
if(CHIAKI_GUI_ENABLE_QT_GAMEPAD)
target_link_libraries(chiaki Qt5::Gamepad)
target_compile_definitions(chiaki PRIVATE CHIAKI_GUI_ENABLE_QT_GAMEPAD)
endif()
if(CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER)
target_link_libraries(chiaki SDL2::SDL2)
target_compile_definitions(chiaki PRIVATE CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER)
Expand Down
10 changes: 0 additions & 10 deletions gui/include/streamsession.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
#include <QMouseEvent>
#include <QTimer>

#if CHIAKI_GUI_ENABLE_QT_GAMEPAD
class QGamepad;
#endif

class QAudioOutput;
class QIODevice;
class QKeyEvent;
Expand Down Expand Up @@ -72,9 +68,6 @@ class StreamSession : public QObject
ChiakiSession session;
ChiakiOpusDecoder opus_decoder;

#if CHIAKI_GUI_ENABLE_QT_GAMEPAD
QGamepad *gamepad;
#endif
Controller *controller;

ChiakiControllerState keyboard_state;
Expand Down Expand Up @@ -103,9 +96,6 @@ class StreamSession : public QObject

void SetLoginPIN(const QString &pin);

#if CHIAKI_GUI_ENABLE_QT_GAMEPAD
QGamepad *GetGamepad() { return gamepad; }
#endif
Controller *GetController() { return controller; }
VideoDecoder *GetVideoDecoder() { return &video_decoder; }

Expand Down
81 changes: 0 additions & 81 deletions gui/src/streamsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@

#include <chiaki/base64.h>

#if CHIAKI_GUI_ENABLE_QT_GAMEPAD
#include <QGamepadManager>
#include <QGamepad>
#endif

#include <QKeyEvent>
#include <QAudioOutput>

Expand Down Expand Up @@ -53,9 +48,6 @@ static void EventCb(ChiakiEvent *event, void *user);
StreamSession::StreamSession(const StreamSessionConnectInfo &connect_info, QObject *parent)
: QObject(parent),
log(this, connect_info.log_level_mask, connect_info.log_file),
#if CHIAKI_GUI_ENABLE_QT_GAMEPAD
gamepad(nullptr),
#endif
controller(nullptr),
video_decoder(connect_info.hw_decode_engine, log.GetChiakiLog()),
audio_output(nullptr),
Expand Down Expand Up @@ -92,9 +84,6 @@ StreamSession::StreamSession(const StreamSessionConnectInfo &connect_info, QObje
chiaki_session_set_video_sample_cb(&session, VideoSampleCb, this);
chiaki_session_set_event_cb(&session, EventCb, this);

#if CHIAKI_GUI_ENABLE_QT_GAMEPAD
connect(QGamepadManager::instance(), &QGamepadManager::connectedGamepadsChanged, this, &StreamSession::UpdateGamepads);
#endif
#if CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER
connect(ControllerManager::GetInstance(), &ControllerManager::AvailableControllersUpdated, this, &StreamSession::UpdateGamepads);
#endif
Expand All @@ -108,9 +97,6 @@ StreamSession::~StreamSession()
chiaki_session_join(&session);
chiaki_session_fini(&session);
chiaki_opus_decoder_fini(&opus_decoder);
#if CHIAKI_GUI_ENABLE_QT_GAMEPAD
delete gamepad;
#endif
#if CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER
delete controller;
#endif
Expand Down Expand Up @@ -202,46 +188,6 @@ void StreamSession::HandleKeyboardEvent(QKeyEvent *event)

void StreamSession::UpdateGamepads()
{
#if CHIAKI_GUI_ENABLE_QT_GAMEPAD
if(!gamepad || !gamepad->isConnected())
{
if(gamepad)
{
CHIAKI_LOGI(log.GetChiakiLog(), "Gamepad %d disconnected", gamepad->deviceId());
delete gamepad;
gamepad = nullptr;
}
const auto connected_pads = QGamepadManager::instance()->connectedGamepads();
if(!connected_pads.isEmpty())
{
gamepad = new QGamepad(connected_pads[0], this);
CHIAKI_LOGI(log.GetChiakiLog(), "Gamepad %d connected: \"%s\"", connected_pads[0], gamepad->name().toLocal8Bit().constData());
connect(gamepad, &QGamepad::buttonAChanged, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::buttonBChanged, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::buttonXChanged, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::buttonYChanged, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::buttonLeftChanged, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::buttonRightChanged, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::buttonUpChanged, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::buttonDownChanged, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::buttonL1Changed, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::buttonR1Changed, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::buttonL1Changed, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::buttonL2Changed, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::buttonL3Changed, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::buttonR3Changed, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::buttonStartChanged, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::buttonSelectChanged, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::buttonGuideChanged, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::axisLeftXChanged, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::axisLeftYChanged, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::axisRightXChanged, this, &StreamSession::SendFeedbackState);
connect(gamepad, &QGamepad::axisRightYChanged, this, &StreamSession::SendFeedbackState);
}
}

SendFeedbackState();
#endif
#if CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER
if(!controller || !controller->IsConnected())
{
Expand Down Expand Up @@ -273,33 +219,6 @@ void StreamSession::SendFeedbackState()
{
ChiakiControllerState state = {};

#if CHIAKI_GUI_ENABLE_QT_GAMEPAD
if(gamepad)
{
state.buttons |= gamepad->buttonA() ? CHIAKI_CONTROLLER_BUTTON_CROSS : 0;
state.buttons |= gamepad->buttonB() ? CHIAKI_CONTROLLER_BUTTON_MOON : 0;
state.buttons |= gamepad->buttonX() ? CHIAKI_CONTROLLER_BUTTON_BOX : 0;
state.buttons |= gamepad->buttonY() ? CHIAKI_CONTROLLER_BUTTON_PYRAMID : 0;
state.buttons |= gamepad->buttonLeft() ? CHIAKI_CONTROLLER_BUTTON_DPAD_LEFT : 0;
state.buttons |= gamepad->buttonRight() ? CHIAKI_CONTROLLER_BUTTON_DPAD_RIGHT : 0;
state.buttons |= gamepad->buttonUp() ? CHIAKI_CONTROLLER_BUTTON_DPAD_UP : 0;
state.buttons |= gamepad->buttonDown() ? CHIAKI_CONTROLLER_BUTTON_DPAD_DOWN : 0;
state.buttons |= gamepad->buttonL1() ? CHIAKI_CONTROLLER_BUTTON_L1 : 0;
state.buttons |= gamepad->buttonR1() ? CHIAKI_CONTROLLER_BUTTON_R1 : 0;
state.buttons |= gamepad->buttonL3() ? CHIAKI_CONTROLLER_BUTTON_L3 : 0;
state.buttons |= gamepad->buttonR3() ? CHIAKI_CONTROLLER_BUTTON_R3 : 0;
state.buttons |= gamepad->buttonStart() ? CHIAKI_CONTROLLER_BUTTON_OPTIONS : 0;
state.buttons |= gamepad->buttonSelect() ? CHIAKI_CONTROLLER_BUTTON_SHARE : 0;
state.buttons |= gamepad->buttonGuide() ? CHIAKI_CONTROLLER_BUTTON_PS : 0;
state.l2_state = (uint8_t)(gamepad->buttonL2() * 0xff);
state.r2_state = (uint8_t)(gamepad->buttonR2() * 0xff);
state.left_x = static_cast<int16_t>(gamepad->axisLeftX() * 0x7fff);
state.left_y = static_cast<int16_t>(gamepad->axisLeftY() * 0x7fff);
state.right_x = static_cast<int16_t>(gamepad->axisRightX() * 0x7fff);
state.right_y = static_cast<int16_t>(gamepad->axisRightY() * 0x7fff);
}
#endif

#if CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER
if(controller)
state = controller->GetState();
Expand Down
1 change: 0 additions & 1 deletion scripts/appveyor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ cmake \
-DPYTHON_EXECUTABLE="$PYTHON" \
-DCHIAKI_ENABLE_TESTS=ON \
-DCHIAKI_ENABLE_CLI=OFF \
-DCHIAKI_GUI_ENABLE_QT_GAMEPAD=OFF \
-DCHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER=ON \
.. || exit 1

Expand Down
1 change: 0 additions & 1 deletion scripts/travis-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ cmake \
-DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH \
-DCHIAKI_ENABLE_TESTS=ON \
-DCHIAKI_ENABLE_CLI=OFF \
-DCHIAKI_GUI_ENABLE_QT_GAMEPAD=OFF \
-DCHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER=ON \
$CMAKE_EXTRA_ARGS \
.. || exit 1
Expand Down

0 comments on commit 57b0b68

Please sign in to comment.