-
Notifications
You must be signed in to change notification settings - Fork 2
/
settings.h
133 lines (100 loc) · 3.81 KB
/
settings.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// SPDX-License-Identifier: LicenseRef-AGPL-3.0-only-OpenSSL
#ifndef CHIAKI_SETTINGS_H
#define CHIAKI_SETTINGS_H
#include <chiaki/session.h>
#include "host.h"
#include <QSettings>
#include <QAudioDeviceInfo.h>
enum class ControllerButtonExt
{
// must not overlap with ChiakiControllerButton and ChiakiControllerAnalogButton
ANALOG_STICK_LEFT_X_UP = (1 << 18),
ANALOG_STICK_LEFT_X_DOWN = (1 << 19),
ANALOG_STICK_LEFT_Y_UP = (1 << 20),
ANALOG_STICK_LEFT_Y_DOWN = (1 << 21),
ANALOG_STICK_RIGHT_X_UP = (1 << 22),
ANALOG_STICK_RIGHT_X_DOWN = (1 << 23),
ANALOG_STICK_RIGHT_Y_UP = (1 << 24),
ANALOG_STICK_RIGHT_Y_DOWN = (1 << 25),
};
enum class DisconnectAction
{
AlwaysNothing,
AlwaysSleep,
Ask
};
enum class Decoder
{
Ffmpeg,
Pi
};
class Settings : public QObject
{
Q_OBJECT
private:
QSettings settings;
QMap<HostMAC, RegisteredHost> registered_hosts;
QMap<int, ManualHost> manual_hosts;
int manual_hosts_id_next;
void LoadRegisteredHosts();
void SaveRegisteredHosts();
void LoadManualHosts();
void SaveManualHosts();
public:
explicit Settings(QObject *parent = nullptr);
bool GetDiscoveryEnabled() const { return settings.value("settings/auto_discovery", true).toBool(); }
void SetDiscoveryEnabled(bool enabled) { settings.setValue("settings/auto_discovery", enabled); }
bool GetLogVerbose() const { return settings.value("settings/log_verbose", false).toBool(); }
void SetLogVerbose(bool enabled) { settings.setValue("settings/log_verbose", enabled); }
uint32_t GetLogLevelMask();
bool GetDualSenseEnabled() const { return settings.value("settings/dualsense_enabled", false).toBool(); }
void SetDualSenseEnabled(bool enabled) { settings.setValue("settings/dualsense_enabled", enabled); }
ChiakiVideoResolutionPreset GetResolution() const;
void SetResolution(ChiakiVideoResolutionPreset resolution);
/**
* @return 0 if set to "automatic"
*/
ChiakiVideoFPSPreset GetFPS() const;
void SetFPS(ChiakiVideoFPSPreset fps);
unsigned int GetBitrate() const;
void SetBitrate(unsigned int bitrate);
ChiakiCodec GetCodec() const;
void SetCodec(ChiakiCodec codec);
Decoder GetDecoder() const;
void SetDecoder(Decoder decoder);
QString GetHardwareDecoder() const;
void SetHardwareDecoder(const QString &hw_decoder);
unsigned int GetAudioBufferSizeDefault() const;
/**
* @return 0 if set to "automatic"
*/
unsigned int GetAudioBufferSizeRaw() const;
/**
* @return actual size to be used, default value if GetAudioBufferSizeRaw() would return 0
*/
unsigned int GetAudioBufferSize() const;
void SetAudioBufferSize(unsigned int size);
QString GetAudioOutDevice() const;
void SetAudioOutDevice(QString device_name);
ChiakiConnectVideoProfile GetVideoProfile();
DisconnectAction GetDisconnectAction();
void SetDisconnectAction(DisconnectAction action);
QList<RegisteredHost> GetRegisteredHosts() const { return registered_hosts.values(); }
void AddRegisteredHost(const RegisteredHost &host);
void RemoveRegisteredHost(const HostMAC &mac);
bool GetRegisteredHostRegistered(const HostMAC &mac) const { return registered_hosts.contains(mac); }
RegisteredHost GetRegisteredHost(const HostMAC &mac) const { return registered_hosts[mac]; }
QList<ManualHost> GetManualHosts() const { return manual_hosts.values(); }
int SetManualHost(const ManualHost &host);
void RemoveManualHost(int id);
bool GetManualHostExists(int id) { return manual_hosts.contains(id); }
ManualHost GetManualHost(int id) const { return manual_hosts[id]; }
static QString GetChiakiControllerButtonName(int);
void SetControllerButtonMapping(int, Qt::Key);
QMap<int, Qt::Key> GetControllerMapping();
QMap<Qt::Key, int> GetControllerMappingForDecoding();
signals:
void RegisteredHostsUpdated();
void ManualHostsUpdated();
};
#endif // CHIAKI_SETTINGS_H