Add additionnal matrices and rename config var

This commit is contained in:
Histausse 2022-10-08 19:55:07 +02:00
parent 32ae0c51f0
commit 406b2fe6dc
No known key found for this signature in database
GPG key ID: 67486F107F62E9E9
2 changed files with 24 additions and 15 deletions

View file

@ -147,7 +147,7 @@ void CConfigManager::setDefaultVars() {
configValues["input:touchpad:tap-to-click"].intValue = 1; configValues["input:touchpad:tap-to-click"].intValue = 1;
configValues["input:touchpad:drag_lock"].intValue = 0; configValues["input:touchpad:drag_lock"].intValue = 0;
configValues["input:touchpad:scroll_factor"].floatValue = 1.f; configValues["input:touchpad:scroll_factor"].floatValue = 1.f;
configValues["input:touchdevice:td_rotation"].intValue = 0; configValues["input:touchdevice:transform"].intValue = 0;
configValues["binds:pass_mouse_when_bound"].intValue = 0; configValues["binds:pass_mouse_when_bound"].intValue = 0;
configValues["binds:scroll_event_delay"].intValue = 300; configValues["binds:scroll_event_delay"].intValue = 300;
@ -188,7 +188,7 @@ void CConfigManager::setDeviceDefaultVars(const std::string& dev) {
cfgValues["drag_lock"].intValue = 0; cfgValues["drag_lock"].intValue = 0;
cfgValues["left_handed"].intValue = 0; cfgValues["left_handed"].intValue = 0;
cfgValues["scroll_method"].strValue = STRVAL_EMPTY; cfgValues["scroll_method"].strValue = STRVAL_EMPTY;
cfgValues["td_rotation"].intValue = 0; cfgValues["transform"].intValue = 0;
} }
void CConfigManager::setDefaultAnimationVars() { void CConfigManager::setDefaultAnimationVars() {

View file

@ -1044,27 +1044,41 @@ void CInputManager::newTouchDevice(wlr_input_device* pDevice) {
} }
void CInputManager::setTouchDeviceConfigs() { void CInputManager::setTouchDeviceConfigs() {
// The rotation matrices.
// The third row is always 0 0 1 and is not expected by `libinput_device_config_calibration_set_matrix` // The third row is always 0 0 1 and is not expected by `libinput_device_config_calibration_set_matrix`
const float MATRICES[4][6] = { const float MATRICES[8][6] = {
{ { // normal
1, 0, 0, 1, 0, 0,
0, 1, 0 0, 1, 0
}, },
{ { // rotation 90°
0, -1, 1, 0, -1, 1,
1, 0, 0 1, 0, 0
}, },
{ { // rotation 180°
-1, 0, 1, -1, 0, 1,
0, -1, 1 0, -1, 1
}, },
{ { // rotation 270°
0, 1, 0, 0, 1, 0,
-1, 0, 1 -1, 0, 1
},
{ // flipped
-1, 0, 1,
0, 1, 0
},
{ // flipped + rotation 90°
0, 1, 0,
1, 0, 0
},
{ // flipped + rotation 180°
1, 0, 0,
0, -1, 1
},
{ // flipped + rotation 270°
0, -1, 1,
-1, 0, 1
} }
}; };
const int NB_MATRICES = 4;
for (auto& m : m_lTouchDevices) { for (auto& m : m_lTouchDevices) {
const auto PTOUCHDEV = &m; const auto PTOUCHDEV = &m;
@ -1073,15 +1087,10 @@ void CInputManager::setTouchDeviceConfigs() {
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname); const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
if (HASCONFIG)
Debug::log(LOG, "Touch Screen %s has config", devname.c_str());
else
Debug::log(LOG, "Touch Screen %s has no config", devname.c_str());
if (wlr_input_device_is_libinput(m.pWlrDevice)) { if (wlr_input_device_is_libinput(m.pWlrDevice)) {
const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(m.pWlrDevice); const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(m.pWlrDevice);
const int ROTATION = ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "td_rotation") : g_pConfigManager->getInt("input:touchdevice:td_rotation")) % NB_MATRICES + NB_MATRICES) % NB_MATRICES; const int ROTATION = std::clamp(HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "transform") : g_pConfigManager->getInt("input:touchdevice:transform"), 0, 7);
libinput_device_config_calibration_set_matrix(LIBINPUTDEV, MATRICES[ROTATION]); libinput_device_config_calibration_set_matrix(LIBINPUTDEV, MATRICES[ROTATION]);
} }
} }