diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-10-04 20:07:21 +0100 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-10-04 20:07:21 +0100 |
| commit | 0d702b556d0a52f1df53ac1e52fac11b8302783b (patch) | |
| tree | 39e5f11ad37ec82248b7bbdb1ca09587dc511813 /src/managers/input/InputManager.cpp | |
| parent | 9bbae5b8e2e593b04f6505c9f35c7e9affa9ab6f (diff) | |
Add switch device handling and binds
Diffstat (limited to 'src/managers/input/InputManager.cpp')
| -rw-r--r-- | src/managers/input/InputManager.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index a5ba9c65..6b717ed2 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -1006,3 +1006,29 @@ void CInputManager::destroyTouchDevice(STouchDevice* pDevice) { m_lTouchDevices.remove(*pDevice); } + +void CInputManager::newSwitch(wlr_input_device* pDevice) { + const auto PNEWDEV = &m_lSwitches.emplace_back(); + PNEWDEV->pWlrDevice = pDevice; + + Debug::log(LOG, "New switch with name \"%s\" added", pDevice->name); + + PNEWDEV->hyprListener_destroy.initCallback(&pDevice->events.destroy, [&](void* owner, void* data) { + destroySwitch((SSwitchDevice*)owner); + }, PNEWDEV, "SwitchDevice"); + + const auto PSWITCH = wlr_switch_from_input_device(pDevice); + + PNEWDEV->hyprListener_toggle.initCallback(&PSWITCH->events.toggle, [&](void* owner, void* data) { + const auto PDEVICE = (SSwitchDevice*)owner; + const auto NAME = std::string(PDEVICE->pWlrDevice->name); + + Debug::log(LOG, "Switch %s fired, triggering binds.", NAME.c_str()); + + g_pKeybindManager->onSwitchEvent(NAME); + }, PNEWDEV, "SwitchDevice"); +} + +void CInputManager::destroySwitch(SSwitchDevice* pDevice) { + m_lSwitches.remove(*pDevice); +}
\ No newline at end of file |
