mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 00:12:40 +00:00
launcher: add resizable game grid/improve controller setup
This commit is contained in:
1 parent
3e9f88bf79
commit
7da3c4ed21
15 files changed
+1063
-311
No files matched your search
@@ -12,9 +12,9 @@
|
||||
|
||||
class ConfigurationItem;
|
||||
class CompatibilityDatabase;
|
||||
class ControllerPreview;
|
||||
class QEvent;
|
||||
class QTreeWidgetItem;
|
||||
class QPoint;
|
||||
|
||||
namespace Ui {
|
||||
class ConfigurationListWidget;
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
|
||||
void SetRunEnabled(bool flag) { m_run_enabled = flag; }
|
||||
void SetRuntimeDirectory(const QString& directory) { m_runtime_directory = directory; }
|
||||
void SetControllerPreview(ControllerPreview* preview) { m_controller_preview = preview; }
|
||||
|
||||
[[nodiscard]] const ConfigurationItem* GetSelectedItem() const { return m_selected_item; }
|
||||
ConfigurationItem* GetSelectedItem() { return m_selected_item; }
|
||||
@@ -65,13 +66,13 @@ protected slots:
|
||||
void edit_global_settings();
|
||||
void edit_input_mapping();
|
||||
void list_itemDoubleClicked(QTreeWidgetItem* witem, int column);
|
||||
void show_context_menu(const QPoint& pos);
|
||||
void open_game_folder();
|
||||
void remove_save_data();
|
||||
void filter_configurations(const QString& text);
|
||||
|
||||
private:
|
||||
void SelectItem(QTreeWidgetItem* witem);
|
||||
void ShowContextMenu(QTreeWidgetItem* witem);
|
||||
void ApplyCompatibility();
|
||||
void UpdateToolbarIcons();
|
||||
void ImportGameSettings(QWidget* parent);
|
||||
@@ -87,6 +88,7 @@ private:
|
||||
Configuration m_global_info;
|
||||
QMap<QString, Configuration*> m_custom_infos;
|
||||
CompatibilityDatabase* m_compatibility = nullptr;
|
||||
ControllerPreview* m_controller_preview = nullptr;
|
||||
};
|
||||
|
||||
#endif // CONFIGURATION_LIST_WIDGET_H
|
||||
@@ -1,29 +0,0 @@
|
||||
#ifndef CONTROLLER_LIGHTBAR_H
|
||||
#define CONTROLLER_LIGHTBAR_H
|
||||
|
||||
#include <QColor>
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
|
||||
#include <SDL3/SDL_gamepad.h>
|
||||
|
||||
class ControllerLightbar final: public QObject {
|
||||
public:
|
||||
explicit ControllerLightbar(QObject* parent = nullptr);
|
||||
~ControllerLightbar() override;
|
||||
|
||||
void SetColor(const QString& color);
|
||||
void Stop();
|
||||
|
||||
private:
|
||||
void Refresh();
|
||||
void ApplyColor(SDL_Gamepad* gamepad) const;
|
||||
|
||||
QTimer m_timer;
|
||||
QHash<SDL_JoystickID, SDL_Gamepad*> m_gamepads;
|
||||
QColor m_color;
|
||||
};
|
||||
|
||||
#endif // CONTROLLER_LIGHTBAR_H
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef CONTROLLER_PREVIEW_H
|
||||
#define CONTROLLER_PREVIEW_H
|
||||
|
||||
#include <QColor>
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <QPointF>
|
||||
#include <QSet>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
|
||||
#include <SDL3/SDL_gamepad.h>
|
||||
|
||||
class ControllerPreview final: public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ControllerPreview(QObject* parent = nullptr);
|
||||
~ControllerPreview() override;
|
||||
|
||||
void SetColor(const QString& color);
|
||||
void SetPreviewEnabled(bool enabled);
|
||||
void Stop();
|
||||
void SetSuspended(bool suspended);
|
||||
|
||||
[[nodiscard]] const QSet<QString>& Pressed() const { return m_pressed; }
|
||||
[[nodiscard]] QPointF LeftStick() const { return m_left_stick; }
|
||||
[[nodiscard]] QPointF RightStick() const { return m_right_stick; }
|
||||
[[nodiscard]] const QString& DeviceName() const { return m_device_name; }
|
||||
[[nodiscard]] const QString& Error() const { return m_error; }
|
||||
|
||||
signals:
|
||||
void StateChanged();
|
||||
|
||||
private:
|
||||
void UpdateRunning();
|
||||
void OpenGamepad(SDL_JoystickID id);
|
||||
void Refresh();
|
||||
void ApplyColor(SDL_Gamepad* gamepad) const;
|
||||
|
||||
QTimer m_timer;
|
||||
QMap<SDL_JoystickID, SDL_Gamepad*> m_gamepads;
|
||||
QColor m_color;
|
||||
bool m_preview_enabled = false;
|
||||
bool m_suspended = false;
|
||||
QSet<QString> m_pressed;
|
||||
QPointF m_left_stick;
|
||||
QPointF m_right_stick;
|
||||
QString m_device_name;
|
||||
QString m_error;
|
||||
};
|
||||
|
||||
#endif // CONTROLLER_PREVIEW_H
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef LAUNCHER_INCLUDE_DUALSENSE_WIDGET_H_
|
||||
#define LAUNCHER_INCLUDE_DUALSENSE_WIDGET_H_
|
||||
|
||||
#include <QPointF>
|
||||
#include <QSet>
|
||||
#include <QString>
|
||||
#include <QTransform>
|
||||
#include <QWidget>
|
||||
|
||||
class DualSenseWidget final: public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DualSenseWidget(QWidget* parent = nullptr);
|
||||
[[nodiscard]] QSize sizeHint() const override;
|
||||
void SetPressed(const QSet<QString>& pressed);
|
||||
void SetSelected(const QString& selected);
|
||||
void SetSticks(const QPointF& left, const QPointF& right);
|
||||
|
||||
signals:
|
||||
void ControlClicked(const QString& id);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent* event) override;
|
||||
void mouseMoveEvent(QMouseEvent* event) override;
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
void leaveEvent(QEvent* event) override;
|
||||
|
||||
private:
|
||||
[[nodiscard]] QTransform ViewTransform() const;
|
||||
[[nodiscard]] QString HitTest(const QPointF& position) const;
|
||||
|
||||
QSet<QString> m_pressed;
|
||||
QString m_selected;
|
||||
QString m_hovered;
|
||||
QPointF m_left_stick;
|
||||
QPointF m_right_stick;
|
||||
};
|
||||
|
||||
#endif /* LAUNCHER_INCLUDE_DUALSENSE_WIDGET_H_ */
|
||||
@@ -2,32 +2,38 @@
|
||||
#define LAUNCHER_INCLUDE_INPUT_MAPPING_DIALOG_H_
|
||||
|
||||
#include <QDialog>
|
||||
#include <QHash>
|
||||
#include <QStringList>
|
||||
|
||||
class ControllerPreview;
|
||||
class DualSenseWidget;
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
class QDoubleSpinBox;
|
||||
class QTreeWidget;
|
||||
class QTreeWidgetItem;
|
||||
class QWidget;
|
||||
|
||||
class InputMappingDialog final: public QDialog {
|
||||
public:
|
||||
explicit InputMappingDialog(const QStringList& mapping, QWidget* parent = nullptr);
|
||||
explicit InputMappingDialog(const QStringList& mapping, ControllerPreview* preview,
|
||||
QWidget* parent = nullptr);
|
||||
~InputMappingDialog() override;
|
||||
|
||||
[[nodiscard]] QStringList Mapping() const;
|
||||
|
||||
private:
|
||||
void ChangeBinding();
|
||||
void ClearBinding();
|
||||
void ChangeBinding(const QString& id);
|
||||
void RestoreDefaults();
|
||||
void SetBinding(QTreeWidgetItem* item, const QString& binding);
|
||||
void UpdateButtons();
|
||||
void UpdatePreview();
|
||||
void UpdateHighlights();
|
||||
|
||||
QTreeWidget* m_bindings = nullptr;
|
||||
QPushButton* m_change_button = nullptr;
|
||||
QPushButton* m_clear_button = nullptr;
|
||||
QDoubleSpinBox* m_sensitivity = nullptr;
|
||||
bool m_custom_bindings = false;
|
||||
ControllerPreview* m_preview;
|
||||
DualSenseWidget* m_controller = nullptr;
|
||||
QHash<QString, QString> m_bindings;
|
||||
QHash<QString, QPushButton*> m_buttons;
|
||||
QString m_selected;
|
||||
QLabel* m_status = nullptr;
|
||||
QDoubleSpinBox* m_sensitivity = nullptr;
|
||||
bool m_custom_bindings = false;
|
||||
};
|
||||
|
||||
#endif /* LAUNCHER_INCLUDE_INPUT_MAPPING_DIALOG_H_ */
|
||||
Reference in new issue
Block a user