devices: refactor class member vars (#10206)

This commit is contained in:
davc0n 2025-04-29 19:51:07 +02:00 committed by GitHub
parent 40147d3a3f
commit e9c3fcbb64
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 585 additions and 578 deletions

View file

@ -98,12 +98,12 @@ void CInputManager::onMouseMoved(IPointer::SMotionEvent e) {
Vector2D unaccel = e.unaccel;
if (e.device) {
if (e.device->isTouchpad) {
if (e.device->flipX) {
if (e.device->m_isTouchpad) {
if (e.device->m_flipX) {
delta.x = -delta.x;
unaccel.x = -unaccel.x;
}
if (e.device->flipY) {
if (e.device->m_flipY) {
delta.y = -delta.y;
unaccel.y = -unaccel.y;
}
@ -945,14 +945,14 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
m_vHIDs.emplace_back(keeb);
try {
keeb->hlName = getNameForNewDevice(keeb->deviceName);
keeb->m_hlName = getNameForNewDevice(keeb->m_deviceName);
} catch (std::exception& e) {
Debug::log(ERR, "Keyboard had no name???"); // logic error
}
keeb->events.destroy.registerStaticListener(
keeb->m_events.destroy.registerStaticListener(
[this](void* owner, std::any data) {
auto PKEEB = ((IKeyboard*)owner)->self.lock();
auto PKEEB = ((IKeyboard*)owner)->m_self.lock();
if (!PKEEB)
return;
@ -962,37 +962,37 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
},
keeb.get());
keeb->keyboardEvents.key.registerStaticListener(
keeb->m_keyboardEvents.key.registerStaticListener(
[this](void* owner, std::any data) {
auto PKEEB = ((IKeyboard*)owner)->self.lock();
auto PKEEB = ((IKeyboard*)owner)->m_self.lock();
onKeyboardKey(data, PKEEB);
if (PKEEB->enabled)
if (PKEEB->m_enabled)
PROTO::idle->onActivity();
if (PKEEB->enabled && *PDPMS && !g_pCompositor->m_dpmsStateOn)
if (PKEEB->m_enabled && *PDPMS && !g_pCompositor->m_dpmsStateOn)
g_pKeybindManager->dpms("on");
},
keeb.get());
keeb->keyboardEvents.modifiers.registerStaticListener(
keeb->m_keyboardEvents.modifiers.registerStaticListener(
[this](void* owner, std::any data) {
auto PKEEB = ((IKeyboard*)owner)->self.lock();
auto PKEEB = ((IKeyboard*)owner)->m_self.lock();
onKeyboardMod(PKEEB);
if (PKEEB->enabled)
if (PKEEB->m_enabled)
PROTO::idle->onActivity();
if (PKEEB->enabled && *PDPMS && !g_pCompositor->m_dpmsStateOn)
if (PKEEB->m_enabled && *PDPMS && !g_pCompositor->m_dpmsStateOn)
g_pKeybindManager->dpms("on");
},
keeb.get());
keeb->keyboardEvents.keymap.registerStaticListener(
keeb->m_keyboardEvents.keymap.registerStaticListener(
[](void* owner, std::any data) {
auto PKEEB = ((IKeyboard*)owner)->self.lock();
auto PKEEB = ((IKeyboard*)owner)->m_self.lock();
const auto LAYOUT = PKEEB->getActiveLayout();
if (PKEEB == g_pSeatManager->keyboard) {
@ -1000,7 +1000,7 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
g_pKeybindManager->m_mKeyToCodeCache.clear();
}
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEEB->hlName + "," + LAYOUT});
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEEB->m_hlName + "," + LAYOUT});
EMIT_HOOK_EVENT("activeLayout", (std::vector<std::any>{PKEEB, LAYOUT}));
},
keeb.get());
@ -1022,7 +1022,7 @@ void CInputManager::setKeyboardLayout() {
}
void CInputManager::applyConfigToKeyboard(SP<IKeyboard> pKeyboard) {
auto devname = pKeyboard->hlName;
auto devname = pKeyboard->m_hlName;
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
@ -1044,14 +1044,14 @@ void CInputManager::applyConfigToKeyboard(SP<IKeyboard> pKeyboard) {
const auto ENABLED = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "enabled") : true;
const auto ALLOWBINDS = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "keybinds") : true;
pKeyboard->enabled = ENABLED;
pKeyboard->resolveBindsBySym = RESOLVEBINDSBYSYM;
pKeyboard->allowBinds = ALLOWBINDS;
pKeyboard->m_enabled = ENABLED;
pKeyboard->m_resolveBindsBySym = RESOLVEBINDSBYSYM;
pKeyboard->m_allowBinds = ALLOWBINDS;
try {
if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" &&
RULES == pKeyboard->currentRules.rules && MODEL == pKeyboard->currentRules.model && LAYOUT == pKeyboard->currentRules.layout &&
VARIANT == pKeyboard->currentRules.variant && OPTIONS == pKeyboard->currentRules.options && FILEPATH == pKeyboard->xkbFilePath) {
if (NUMLOCKON == pKeyboard->m_numlockOn && REPEATDELAY == pKeyboard->m_repeatDelay && REPEATRATE == pKeyboard->m_repeatRate && RULES != "" &&
RULES == pKeyboard->m_currentRules.rules && MODEL == pKeyboard->m_currentRules.model && LAYOUT == pKeyboard->m_currentRules.layout &&
VARIANT == pKeyboard->m_currentRules.variant && OPTIONS == pKeyboard->m_currentRules.options && FILEPATH == pKeyboard->m_xkbFilePath) {
Debug::log(LOG, "Not applying config to keyboard, it did not change.");
return;
}
@ -1060,19 +1060,20 @@ void CInputManager::applyConfigToKeyboard(SP<IKeyboard> pKeyboard) {
// we can ignore those and just apply
}
pKeyboard->repeatRate = std::max(0, REPEATRATE);
pKeyboard->repeatDelay = std::max(0, REPEATDELAY);
pKeyboard->numlockOn = NUMLOCKON;
pKeyboard->xkbFilePath = FILEPATH;
pKeyboard->m_repeatRate = std::max(0, REPEATRATE);
pKeyboard->m_repeatDelay = std::max(0, REPEATDELAY);
pKeyboard->m_numlockOn = NUMLOCKON;
pKeyboard->m_xkbFilePath = FILEPATH;
pKeyboard->setKeymap(IKeyboard::SStringRuleNames{LAYOUT, MODEL, VARIANT, OPTIONS, RULES});
const auto LAYOUTSTR = pKeyboard->getActiveLayout();
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->hlName + "," + LAYOUTSTR});
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->m_hlName + "," + LAYOUTSTR});
EMIT_HOOK_EVENT("activeLayout", (std::vector<std::any>{pKeyboard, LAYOUTSTR}));
Debug::log(LOG, "Set the keyboard layout to {} and variant to {} for keyboard \"{}\"", pKeyboard->currentRules.layout, pKeyboard->currentRules.variant, pKeyboard->hlName);
Debug::log(LOG, "Set the keyboard layout to {} and variant to {} for keyboard \"{}\"", pKeyboard->m_currentRules.layout, pKeyboard->m_currentRules.variant,
pKeyboard->m_hlName);
}
void CInputManager::newVirtualMouse(SP<CVirtualPointerV1Resource> mouse) {
@ -1095,7 +1096,7 @@ void CInputManager::setupMouse(SP<IPointer> mauz) {
m_vHIDs.emplace_back(mauz);
try {
mauz->hlName = getNameForNewDevice(mauz->deviceName);
mauz->m_hlName = getNameForNewDevice(mauz->m_deviceName);
} catch (std::exception& e) {
Debug::log(ERR, "Mouse had no name???"); // logic error
}
@ -1110,18 +1111,18 @@ void CInputManager::setupMouse(SP<IPointer> mauz) {
g_pPointerManager->attachPointer(mauz);
mauz->connected = true;
mauz->m_connected = true;
setPointerConfigs();
mauz->events.destroy.registerStaticListener(
mauz->m_events.destroy.registerStaticListener(
[this](void* mouse, std::any data) {
const auto PMOUSE = (IPointer*)mouse;
if (!PMOUSE)
return;
destroyPointer(PMOUSE->self.lock());
destroyPointer(PMOUSE->m_self.lock());
},
mauz.get());
@ -1132,18 +1133,18 @@ void CInputManager::setupMouse(SP<IPointer> mauz) {
void CInputManager::setPointerConfigs() {
for (auto const& m : m_vPointers) {
auto devname = m->hlName;
auto devname = m->m_hlName;
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
if (HASCONFIG) {
const auto ENABLED = g_pConfigManager->getDeviceInt(devname, "enabled");
if (ENABLED && !m->connected) {
if (ENABLED && !m->m_connected) {
g_pPointerManager->attachPointer(m);
m->connected = true;
} else if (!ENABLED && m->connected) {
m->m_connected = true;
} else if (!ENABLED && m->m_connected) {
g_pPointerManager->detachPointer(m);
m->connected = false;
m->m_connected = false;
}
}
@ -1227,8 +1228,8 @@ void CInputManager::setPointerConfigs() {
const auto LIBINPUTSENS = std::clamp(g_pConfigManager->getDeviceFloat(devname, "sensitivity", "input:sensitivity"), -1.f, 1.f);
libinput_device_config_accel_set_speed(LIBINPUTDEV, LIBINPUTSENS);
m->flipX = g_pConfigManager->getDeviceInt(devname, "flip_x", "input:touchpad:flip_x") != 0;
m->flipY = g_pConfigManager->getDeviceInt(devname, "flip_y", "input:touchpad:flip_y") != 0;
m->m_flipX = g_pConfigManager->getDeviceInt(devname, "flip_x", "input:touchpad:flip_x") != 0;
m->m_flipY = g_pConfigManager->getDeviceInt(devname, "flip_y", "input:touchpad:flip_y") != 0;
const auto ACCELPROFILE = g_pConfigManager->getDeviceString(devname, "accel_profile", "input:accel_profile");
const auto SCROLLPOINTS = g_pConfigManager->getDeviceString(devname, "scroll_points", "input:scroll_points");
@ -1281,7 +1282,7 @@ void CInputManager::setPointerConfigs() {
libinput_device_config_scroll_set_button_lock(LIBINPUTDEV,
SCROLLBUTTONLOCK == 0 ? LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_DISABLED : LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_ENABLED);
Debug::log(LOG, "Applied config to mouse {}, sens {:.2f}", m->hlName, LIBINPUTSENS);
Debug::log(LOG, "Applied config to mouse {}, sens {:.2f}", m->m_hlName, LIBINPUTSENS);
}
}
}
@ -1375,7 +1376,7 @@ void CInputManager::updateKeyboardsLeds(SP<IKeyboard> pKeyboard) {
}
void CInputManager::onKeyboardKey(std::any event, SP<IKeyboard> pKeyboard) {
if (!pKeyboard->enabled)
if (!pKeyboard->m_enabled)
return;
const bool DISALLOWACTION = pKeyboard->isVirtual() && shouldIgnoreVirtualKeyboard(pKeyboard);
@ -1403,14 +1404,14 @@ void CInputManager::onKeyboardKey(std::any event, SP<IKeyboard> pKeyboard) {
}
void CInputManager::onKeyboardMod(SP<IKeyboard> pKeyboard) {
if (!pKeyboard->enabled)
if (!pKeyboard->m_enabled)
return;
const bool DISALLOWACTION = pKeyboard->isVirtual() && shouldIgnoreVirtualKeyboard(pKeyboard);
const auto ALLMODS = accumulateModsFromAllKBs();
auto MODS = pKeyboard->modifiersState;
auto MODS = pKeyboard->m_modifiersState;
MODS.depressed = ALLMODS;
const auto IME = m_sIMERelay.m_pIME.lock();
@ -1425,14 +1426,14 @@ void CInputManager::onKeyboardMod(SP<IKeyboard> pKeyboard) {
updateKeyboardsLeds(pKeyboard);
if (pKeyboard->modifiersState.group != pKeyboard->activeLayout) {
pKeyboard->activeLayout = pKeyboard->modifiersState.group;
if (pKeyboard->m_modifiersState.group != pKeyboard->m_activeLayout) {
pKeyboard->m_activeLayout = pKeyboard->m_modifiersState.group;
const auto LAYOUT = pKeyboard->getActiveLayout();
Debug::log(LOG, "LAYOUT CHANGED TO {} GROUP {}", LAYOUT, MODS.group);
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->hlName + "," + LAYOUT});
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->m_hlName + "," + LAYOUT});
EMIT_HOOK_EVENT("activeLayout", (std::vector<std::any>{pKeyboard, LAYOUT}));
}
}
@ -1556,7 +1557,7 @@ uint32_t CInputManager::accumulateModsFromAllKBs() {
if (kb->isVirtual() && shouldIgnoreVirtualKeyboard(kb))
continue;
if (!kb->enabled)
if (!kb->m_enabled)
continue;
finalMask |= kb->getModifiers();
@ -1571,7 +1572,7 @@ void CInputManager::disableAllKeyboards(bool virt) {
if (k->isVirtual() != virt)
continue;
k->active = false;
k->m_active = false;
}
}
@ -1580,7 +1581,7 @@ void CInputManager::newTouchDevice(SP<Aquamarine::ITouch> pDevice) {
m_vHIDs.emplace_back(PNEWDEV);
try {
PNEWDEV->hlName = getNameForNewDevice(PNEWDEV->deviceName);
PNEWDEV->m_hlName = getNameForNewDevice(PNEWDEV->m_deviceName);
} catch (std::exception& e) {
Debug::log(ERR, "Touch Device had no name???"); // logic error
}
@ -1588,9 +1589,9 @@ void CInputManager::newTouchDevice(SP<Aquamarine::ITouch> pDevice) {
setTouchDeviceConfigs(PNEWDEV);
g_pPointerManager->attachTouch(PNEWDEV);
PNEWDEV->events.destroy.registerStaticListener(
PNEWDEV->m_events.destroy.registerStaticListener(
[this](void* owner, std::any data) {
auto PDEV = ((ITouch*)owner)->self.lock();
auto PDEV = ((ITouch*)owner)->m_self.lock();
if (!PDEV)
return;
@ -1607,20 +1608,20 @@ void CInputManager::setTouchDeviceConfigs(SP<ITouch> dev) {
if (PTOUCHDEV->aq() && PTOUCHDEV->aq()->getLibinputHandle()) {
const auto LIBINPUTDEV = PTOUCHDEV->aq()->getLibinputHandle();
const auto ENABLED = g_pConfigManager->getDeviceInt(PTOUCHDEV->hlName, "enabled", "input:touchdevice:enabled");
const auto ENABLED = g_pConfigManager->getDeviceInt(PTOUCHDEV->m_hlName, "enabled", "input:touchdevice:enabled");
const auto mode = ENABLED ? LIBINPUT_CONFIG_SEND_EVENTS_ENABLED : LIBINPUT_CONFIG_SEND_EVENTS_DISABLED;
if (libinput_device_config_send_events_get_mode(LIBINPUTDEV) != mode)
libinput_device_config_send_events_set_mode(LIBINPUTDEV, mode);
if (libinput_device_config_calibration_has_matrix(LIBINPUTDEV)) {
Debug::log(LOG, "Setting calibration matrix for device {}", PTOUCHDEV->hlName);
Debug::log(LOG, "Setting calibration matrix for device {}", PTOUCHDEV->m_hlName);
// default value of transform being -1 means it's unset.
const int ROTATION = std::clamp(g_pConfigManager->getDeviceInt(PTOUCHDEV->hlName, "transform", "input:touchdevice:transform"), -1, 7);
const int ROTATION = std::clamp(g_pConfigManager->getDeviceInt(PTOUCHDEV->m_hlName, "transform", "input:touchdevice:transform"), -1, 7);
if (ROTATION > -1)
libinput_device_config_calibration_set_matrix(LIBINPUTDEV, MATRICES[ROTATION]);
}
auto output = g_pConfigManager->getDeviceString(PTOUCHDEV->hlName, "output", "input:touchdevice:output");
auto output = g_pConfigManager->getDeviceString(PTOUCHDEV->m_hlName, "output", "input:touchdevice:output");
bool bound = !output.empty() && output != STRVAL_EMPTY;
const bool AUTODETECT = output == "[[Auto]]";
if (!bound && AUTODETECT) {
@ -1631,13 +1632,13 @@ void CInputManager::setTouchDeviceConfigs(SP<ITouch> dev) {
// bound = true;
// }
}
PTOUCHDEV->boundOutput = bound ? output : "";
const auto PMONITOR = bound ? g_pCompositor->getMonitorFromName(output) : nullptr;
PTOUCHDEV->m_boundOutput = bound ? output : "";
const auto PMONITOR = bound ? g_pCompositor->getMonitorFromName(output) : nullptr;
if (PMONITOR) {
Debug::log(LOG, "Binding touch device {} to output {}", PTOUCHDEV->hlName, PMONITOR->szName);
Debug::log(LOG, "Binding touch device {} to output {}", PTOUCHDEV->m_hlName, PMONITOR->szName);
// wlr_cursor_map_input_to_output(g_pCompositor->m_sWLRCursor, &PTOUCHDEV->wlr()->base, PMONITOR->output);
} else if (bound)
Debug::log(ERR, "Failed to bind touch device {} to output '{}': monitor not found", PTOUCHDEV->hlName, output);
Debug::log(ERR, "Failed to bind touch device {} to output '{}': monitor not found", PTOUCHDEV->m_hlName, output);
}
};
@ -1654,11 +1655,11 @@ void CInputManager::setTouchDeviceConfigs(SP<ITouch> dev) {
void CInputManager::setTabletConfigs() {
for (auto const& t : m_vTablets) {
if (t->aq()->getLibinputHandle()) {
const auto NAME = t->hlName;
const auto NAME = t->m_hlName;
const auto LIBINPUTDEV = t->aq()->getLibinputHandle();
const auto RELINPUT = g_pConfigManager->getDeviceInt(NAME, "relative_input", "input:tablet:relative_input");
t->relativeInput = RELINPUT;
t->m_relativeInput = RELINPUT;
const int ROTATION = std::clamp(g_pConfigManager->getDeviceInt(NAME, "transform", "input:tablet:transform"), -1, 7);
Debug::log(LOG, "Setting calibration matrix for device {}", NAME);
@ -1673,22 +1674,22 @@ void CInputManager::setTabletConfigs() {
const auto OUTPUT = g_pConfigManager->getDeviceString(NAME, "output", "input:tablet:output");
if (OUTPUT != STRVAL_EMPTY) {
Debug::log(LOG, "Binding tablet {} to output {}", NAME, OUTPUT);
t->boundOutput = OUTPUT;
t->m_boundOutput = OUTPUT;
} else
t->boundOutput = "";
t->m_boundOutput = "";
const auto REGION_POS = g_pConfigManager->getDeviceVec(NAME, "region_position", "input:tablet:region_position");
const auto REGION_SIZE = g_pConfigManager->getDeviceVec(NAME, "region_size", "input:tablet:region_size");
t->boundBox = {REGION_POS, REGION_SIZE};
t->m_boundBox = {REGION_POS, REGION_SIZE};
const auto ABSOLUTE_REGION_POS = g_pConfigManager->getDeviceInt(NAME, "absolute_region_position", "input:tablet:absolute_region_position");
t->absolutePos = ABSOLUTE_REGION_POS;
t->m_absolutePos = ABSOLUTE_REGION_POS;
const auto ACTIVE_AREA_SIZE = g_pConfigManager->getDeviceVec(NAME, "active_area_size", "input:tablet:active_area_size");
const auto ACTIVE_AREA_POS = g_pConfigManager->getDeviceVec(NAME, "active_area_position", "input:tablet:active_area_position");
if (ACTIVE_AREA_SIZE.x != 0 || ACTIVE_AREA_SIZE.y != 0) {
t->activeArea = CBox{ACTIVE_AREA_POS.x / t->aq()->physicalSize.x, ACTIVE_AREA_POS.y / t->aq()->physicalSize.y,
(ACTIVE_AREA_POS.x + ACTIVE_AREA_SIZE.x) / t->aq()->physicalSize.x, (ACTIVE_AREA_POS.y + ACTIVE_AREA_SIZE.y) / t->aq()->physicalSize.y};
t->m_activeArea = CBox{ACTIVE_AREA_POS.x / t->aq()->physicalSize.x, ACTIVE_AREA_POS.y / t->aq()->physicalSize.y,
(ACTIVE_AREA_POS.x + ACTIVE_AREA_SIZE.x) / t->aq()->physicalSize.x, (ACTIVE_AREA_POS.y + ACTIVE_AREA_SIZE.y) / t->aq()->physicalSize.y};
}
}
}
@ -1752,7 +1753,7 @@ std::string CInputManager::getNameForNewDevice(std::string internalName) {
auto makeNewName = [&]() { return (proposedNewName.empty() ? "unknown-device" : proposedNewName) + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); };
while (std::find_if(m_vHIDs.begin(), m_vHIDs.end(), [&](const auto& other) { return other->hlName == makeNewName(); }) != m_vHIDs.end())
while (std::find_if(m_vHIDs.begin(), m_vHIDs.end(), [&](const auto& other) { return other->m_hlName == makeNewName(); }) != m_vHIDs.end())
dupeno++;
return makeNewName();

View file

@ -11,9 +11,9 @@ static void unfocusTool(SP<CTabletTool> tool) {
return;
tool->setSurface(nullptr);
if (tool->isDown)
if (tool->m_isDown)
PROTO::tablet->up(tool);
for (auto const& b : tool->buttonsDown) {
for (auto const& b : tool->m_buttonsDown) {
PROTO::tablet->buttonTool(tool, b, false);
}
PROTO::tablet->proximityOut(tool);
@ -28,9 +28,9 @@ static void focusTool(SP<CTabletTool> tool, SP<CTablet> tablet, SP<CWLSurfaceRes
tool->setSurface(surf);
PROTO::tablet->proximityIn(tool, tablet, surf);
if (tool->isDown)
if (tool->m_isDown)
PROTO::tablet->down(tool);
for (auto const& b : tool->buttonsDown) {
for (auto const& b : tool->m_buttonsDown) {
PROTO::tablet->buttonTool(tool, b, true);
}
}
@ -38,7 +38,7 @@ static void focusTool(SP<CTabletTool> tool, SP<CTablet> tablet, SP<CWLSurfaceRes
static void refocusTablet(SP<CTablet> tab, SP<CTabletTool> tool, bool motion = false) {
const auto LASTHLSURFACE = CWLSurface::fromResource(g_pSeatManager->state.pointerFocus.lock());
if (!LASTHLSURFACE || !tool->active) {
if (!LASTHLSURFACE || !tool->m_active) {
if (tool->getSurface())
unfocusTool(tool);
@ -69,9 +69,9 @@ static void refocusTablet(SP<CTablet> tab, SP<CTabletTool> tool, bool motion = f
// yes, this technically ignores any regions set by the app. Too bad!
if (LASTHLSURFACE->getWindow())
local = tool->absolutePos * LASTHLSURFACE->getWindow()->m_realSize->goal();
local = tool->m_absolutePos * LASTHLSURFACE->getWindow()->m_realSize->goal();
else
local = tool->absolutePos * BOX->size();
local = tool->m_absolutePos * BOX->size();
if (LASTHLSURFACE->getWindow() && LASTHLSURFACE->getWindow()->m_isX11)
local = local * LASTHLSURFACE->getWindow()->m_X11SurfaceScaledBy;
@ -106,7 +106,7 @@ void CInputManager::onTabletAxis(CTablet::SAxisEvent e) {
const auto PTAB = e.tablet;
const auto PTOOL = ensureTabletToolPresent(e.tool);
if (PTOOL->active && (e.updatedAxes & (CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_X | CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_Y))) {
if (PTOOL->m_active && (e.updatedAxes & (CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_X | CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_Y))) {
double x = (e.updatedAxes & CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_X) ? e.axis.x : NAN;
double dx = (e.updatedAxes & CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_X) ? e.axisDelta.x : NAN;
double y = (e.updatedAxes & CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_Y) ? e.axis.y : NAN;
@ -121,14 +121,14 @@ void CInputManager::onTabletAxis(CTablet::SAxisEvent e) {
}
default: {
if (!std::isnan(x))
PTOOL->absolutePos.x = x;
PTOOL->m_absolutePos.x = x;
if (!std::isnan(y))
PTOOL->absolutePos.y = y;
PTOOL->m_absolutePos.y = y;
if (PTAB->relativeInput)
if (PTAB->m_relativeInput)
g_pPointerManager->move(delta);
else
g_pPointerManager->warpAbsolute(transformToActiveRegion({x, y}, PTAB->activeArea), PTAB);
g_pPointerManager->warpAbsolute(transformToActiveRegion({x, y}, PTAB->m_activeArea), PTAB);
break;
}
@ -155,13 +155,13 @@ void CInputManager::onTabletAxis(CTablet::SAxisEvent e) {
PROTO::tablet->wheel(PTOOL, e.wheelDelta);
if (e.updatedAxes & CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_TILT_X)
PTOOL->tilt.x = e.tilt.x;
PTOOL->m_tilt.x = e.tilt.x;
if (e.updatedAxes & CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_TILT_Y)
PTOOL->tilt.y = e.tilt.y;
PTOOL->m_tilt.y = e.tilt.y;
if (e.updatedAxes & (CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_TILT_X | CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_TILT_Y))
PROTO::tablet->tilt(PTOOL, PTOOL->tilt);
PROTO::tablet->tilt(PTOOL, PTOOL->m_tilt);
}
void CInputManager::onTabletTip(CTablet::STipEvent e) {
@ -169,10 +169,10 @@ void CInputManager::onTabletTip(CTablet::STipEvent e) {
const auto PTOOL = ensureTabletToolPresent(e.tool);
const auto POS = e.tip;
if (PTAB->relativeInput)
if (PTAB->m_relativeInput)
g_pPointerManager->move({0, 0});
else
g_pPointerManager->warpAbsolute(transformToActiveRegion(POS, PTAB->activeArea), PTAB);
g_pPointerManager->warpAbsolute(transformToActiveRegion(POS, PTAB->m_activeArea), PTAB);
if (e.in)
refocus();
@ -184,7 +184,7 @@ void CInputManager::onTabletTip(CTablet::STipEvent e) {
else
PROTO::tablet->up(PTOOL);
PTOOL->isDown = e.in;
PTOOL->m_isDown = e.in;
}
void CInputManager::onTabletButton(CTablet::SButtonEvent e) {
@ -196,16 +196,16 @@ void CInputManager::onTabletButton(CTablet::SButtonEvent e) {
PROTO::tablet->buttonTool(PTOOL, e.button, e.down);
if (e.down)
PTOOL->buttonsDown.push_back(e.button);
PTOOL->m_buttonsDown.push_back(e.button);
else
std::erase(PTOOL->buttonsDown, e.button);
std::erase(PTOOL->m_buttonsDown, e.button);
}
void CInputManager::onTabletProximity(CTablet::SProximityEvent e) {
const auto PTAB = e.tablet;
const auto PTOOL = ensureTabletToolPresent(e.tool);
PTOOL->active = e.in;
PTOOL->m_active = e.in;
if (!e.in) {
if (PTOOL->getSurface())
@ -221,16 +221,16 @@ void CInputManager::newTablet(SP<Aquamarine::ITablet> pDevice) {
m_vHIDs.emplace_back(PNEWTABLET);
try {
PNEWTABLET->hlName = g_pInputManager->getNameForNewDevice(pDevice->getName());
PNEWTABLET->m_hlName = g_pInputManager->getNameForNewDevice(pDevice->getName());
} catch (std::exception& e) {
Debug::log(ERR, "Tablet had no name???"); // logic error
}
g_pPointerManager->attachTablet(PNEWTABLET);
PNEWTABLET->events.destroy.registerStaticListener(
PNEWTABLET->m_events.destroy.registerStaticListener(
[this](void* owner, std::any d) {
auto TABLET = ((CTablet*)owner)->self;
auto TABLET = ((CTablet*)owner)->m_self;
destroyTablet(TABLET.lock());
},
PNEWTABLET.get());
@ -249,14 +249,14 @@ SP<CTabletTool> CInputManager::ensureTabletToolPresent(SP<Aquamarine::ITabletToo
m_vHIDs.emplace_back(PTOOL);
try {
PTOOL->hlName = g_pInputManager->getNameForNewDevice(pTool->getName());
PTOOL->m_hlName = g_pInputManager->getNameForNewDevice(pTool->getName());
} catch (std::exception& e) {
Debug::log(ERR, "Tablet had no name???"); // logic error
}
PTOOL->events.destroy.registerStaticListener(
PTOOL->m_events.destroy.registerStaticListener(
[this](void* owner, std::any d) {
auto TOOL = ((CTabletTool*)owner)->self;
auto TOOL = ((CTabletTool*)owner)->m_self;
destroyTabletTool(TOOL.lock());
},
PTOOL.get());
@ -269,44 +269,44 @@ void CInputManager::newTabletPad(SP<Aquamarine::ITabletPad> pDevice) {
m_vHIDs.emplace_back(PNEWPAD);
try {
PNEWPAD->hlName = g_pInputManager->getNameForNewDevice(pDevice->getName());
PNEWPAD->m_hlName = g_pInputManager->getNameForNewDevice(pDevice->getName());
} catch (std::exception& e) {
Debug::log(ERR, "Pad had no name???"); // logic error
}
// clang-format off
PNEWPAD->events.destroy.registerStaticListener([this](void* owner, std::any d) {
auto PAD = ((CTabletPad*)owner)->self;
PNEWPAD->m_events.destroy.registerStaticListener([this](void* owner, std::any d) {
auto PAD = ((CTabletPad*)owner)->m_self;
destroyTabletPad(PAD.lock());
}, PNEWPAD.get());
PNEWPAD->padEvents.button.registerStaticListener([](void* owner, std::any e) {
PNEWPAD->m_padEvents.button.registerStaticListener([](void* owner, std::any e) {
const auto E = std::any_cast<CTabletPad::SButtonEvent>(e);
const auto PPAD = ((CTabletPad*)owner)->self.lock();
const auto PPAD = ((CTabletPad*)owner)->m_self.lock();
PROTO::tablet->mode(PPAD, 0, E.mode, E.timeMs);
PROTO::tablet->buttonPad(PPAD, E.button, E.timeMs, E.down);
}, PNEWPAD.get());
PNEWPAD->padEvents.strip.registerStaticListener([](void* owner, std::any e) {
PNEWPAD->m_padEvents.strip.registerStaticListener([](void* owner, std::any e) {
const auto E = std::any_cast<CTabletPad::SStripEvent>(e);
const auto PPAD = ((CTabletPad*)owner)->self.lock();
const auto PPAD = ((CTabletPad*)owner)->m_self.lock();
PROTO::tablet->strip(PPAD, E.strip, E.position, E.finger, E.timeMs);
}, PNEWPAD.get());
PNEWPAD->padEvents.ring.registerStaticListener([](void* owner, std::any e) {
PNEWPAD->m_padEvents.ring.registerStaticListener([](void* owner, std::any e) {
const auto E = std::any_cast<CTabletPad::SRingEvent>(e);
const auto PPAD = ((CTabletPad*)owner)->self.lock();
const auto PPAD = ((CTabletPad*)owner)->m_self.lock();
PROTO::tablet->ring(PPAD, E.ring, E.position, E.finger, E.timeMs);
}, PNEWPAD.get());
PNEWPAD->padEvents.attach.registerStaticListener([](void* owner, std::any e) {
const auto PPAD = ((CTabletPad*)owner)->self.lock();
PNEWPAD->m_padEvents.attach.registerStaticListener([](void* owner, std::any e) {
const auto PPAD = ((CTabletPad*)owner)->m_self.lock();
const auto TOOL = std::any_cast<SP<CTabletTool>>(e);
PPAD->parent = TOOL;
PPAD->m_parent = TOOL;
}, PNEWPAD.get());
// clang-format on
}

View file

@ -23,7 +23,7 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) {
static auto PSWIPEINVR = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_touch_invert");
EMIT_HOOK_EVENT_CANCELLABLE("touchDown", e);
auto PMONITOR = g_pCompositor->getMonitorFromName(!e.device->boundOutput.empty() ? e.device->boundOutput : "");
auto PMONITOR = g_pCompositor->getMonitorFromName(!e.device->m_boundOutput.empty() ? e.device->m_boundOutput : "");
PMONITOR = PMONITOR ? PMONITOR : g_pCompositor->m_lastMonitor.lock();