|
|
|
|
@ -84,7 +84,8 @@ enum class ConfigKey { |
|
|
|
|
NaturalScroll, |
|
|
|
|
ScrollMethod, |
|
|
|
|
ScrollButton, |
|
|
|
|
ClickMethod |
|
|
|
|
ClickMethod, |
|
|
|
|
ScrollFactor |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct ConfigData { |
|
|
|
|
@ -100,6 +101,10 @@ struct ConfigData { |
|
|
|
|
: key(_key) |
|
|
|
|
{ stringSetter.setter = _setter; stringSetter.defaultValue = _defaultValue; } |
|
|
|
|
|
|
|
|
|
explicit ConfigData(QByteArray _key, void (Device::*_setter)(qreal), qreal (Device::*_defaultValue)() const = nullptr) |
|
|
|
|
: key(_key) |
|
|
|
|
{ qrealSetter.setter = _setter; qrealSetter.defaultValue = _defaultValue; } |
|
|
|
|
|
|
|
|
|
QByteArray key; |
|
|
|
|
|
|
|
|
|
struct { |
|
|
|
|
@ -115,6 +120,10 @@ struct ConfigData { |
|
|
|
|
void (Device::*setter)(QString) = nullptr; |
|
|
|
|
QString (Device::*defaultValue)() const; |
|
|
|
|
} stringSetter; |
|
|
|
|
struct { |
|
|
|
|
void (Device::*setter)(qreal) = nullptr; |
|
|
|
|
qreal (Device::*defaultValue)() const; |
|
|
|
|
} qrealSetter; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static const QMap<ConfigKey, ConfigData> s_configData { |
|
|
|
|
@ -131,7 +140,8 @@ static const QMap<ConfigKey, ConfigData> s_configData { |
|
|
|
|
{ConfigKey::NaturalScroll, ConfigData(QByteArrayLiteral("NaturalScroll"), &Device::setNaturalScroll, &Device::naturalScrollEnabledByDefault)}, |
|
|
|
|
{ConfigKey::ScrollMethod, ConfigData(QByteArrayLiteral("ScrollMethod"), &Device::activateScrollMethodFromInt, &Device::defaultScrollMethodToInt)}, |
|
|
|
|
{ConfigKey::ScrollButton, ConfigData(QByteArrayLiteral("ScrollButton"), &Device::setScrollButton, &Device::defaultScrollButton)}, |
|
|
|
|
{ConfigKey::ClickMethod, ConfigData(QByteArrayLiteral("ClickMethod"), &Device::setClickMethodFromInt, &Device::defaultClickMethodToInt)} |
|
|
|
|
{ConfigKey::ClickMethod, ConfigData(QByteArrayLiteral("ClickMethod"), &Device::setClickMethodFromInt, &Device::defaultClickMethodToInt)}, |
|
|
|
|
{ConfigKey::ScrollFactor, ConfigData(QByteArrayLiteral("ScrollFactor"), &Device::setScrollFactor, &Device::scrollFactorDefault)} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
namespace { |
|
|
|
|
@ -209,6 +219,7 @@ Device::Device(libinput_device *device, QObject *parent) |
|
|
|
|
, m_supportedClickMethods(libinput_device_config_click_get_methods(m_device)) |
|
|
|
|
, m_defaultClickMethod(libinput_device_config_click_get_default_method(m_device)) |
|
|
|
|
, m_clickMethod(libinput_device_config_click_get_method(m_device)) |
|
|
|
|
, m_scrollFactor(scrollFactorDefault()) |
|
|
|
|
{ |
|
|
|
|
libinput_device_ref(m_device); |
|
|
|
|
|
|
|
|
|
@ -301,6 +312,7 @@ void Device::loadConfiguration() |
|
|
|
|
readEntry(key, it.value().booleanSetter, true); |
|
|
|
|
readEntry(key, it.value().quint32Setter, 0); |
|
|
|
|
readEntry(key, it.value().stringSetter, ""); |
|
|
|
|
readEntry(key, it.value().qrealSetter, 1.0); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
m_loading = false; |
|
|
|
|
@ -476,6 +488,15 @@ CONFIG(setMiddleEmulation, m_supportsMiddleEmulation == false, middle_emulation_ |
|
|
|
|
|
|
|
|
|
#undef CONFIG |
|
|
|
|
|
|
|
|
|
void Device::setScrollFactor(qreal factor) |
|
|
|
|
{ |
|
|
|
|
if (m_scrollFactor != factor) { |
|
|
|
|
m_scrollFactor = factor; |
|
|
|
|
writeEntry(ConfigKey::ScrollFactor, m_scrollFactor); |
|
|
|
|
emit scrollFactorChanged(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Device::setOrientation(Qt::ScreenOrientation orientation) |
|
|
|
|
{ |
|
|
|
|
if (!m_supportsCalibrationMatrix) { |
|
|
|
|
|