mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-07 18:45:59 +01:00
Add "on" and "off" for the bind of switch (#1342)
This commit is contained in:
parent
50e106f2e6
commit
e5dcbf73d8
3 changed files with 23 additions and 0 deletions
|
@ -287,6 +287,14 @@ void CKeybindManager::onSwitchEvent(const std::string& switchName) {
|
|||
handleKeybinds(0, "switch:" + switchName, 0, 0, true, 0);
|
||||
}
|
||||
|
||||
void CKeybindManager::onSwitchOnEvent(const std::string& switchName) {
|
||||
handleKeybinds(0, "switch:on:" + switchName, 0, 0, true, 0);
|
||||
}
|
||||
|
||||
void CKeybindManager::onSwitchOffEvent(const std::string& switchName) {
|
||||
handleKeybinds(0, "switch:off:" + switchName, 0, 0, true, 0);
|
||||
}
|
||||
|
||||
int repeatKeyHandler(void* data) {
|
||||
SKeybind** ppActiveKeybind = (SKeybind**)data;
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ class CKeybindManager {
|
|||
bool onAxisEvent(wlr_pointer_axis_event*);
|
||||
bool onMouseEvent(wlr_pointer_button_event*);
|
||||
void onSwitchEvent(const std::string&);
|
||||
void onSwitchOnEvent(const std::string&);
|
||||
void onSwitchOffEvent(const std::string&);
|
||||
|
||||
void addKeybind(SKeybind);
|
||||
void removeKeybind(uint32_t, const std::string&);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "InputManager.hpp"
|
||||
#include "../../Compositor.hpp"
|
||||
#include "wlr/types/wlr_switch.h"
|
||||
|
||||
void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) {
|
||||
static auto* const PSENS = &g_pConfigManager->getConfigValuePtr("general:sensitivity")->floatValue;
|
||||
|
@ -1215,6 +1216,18 @@ void CInputManager::newSwitch(wlr_input_device* pDevice) {
|
|||
Debug::log(LOG, "Switch %s fired, triggering binds.", NAME.c_str());
|
||||
|
||||
g_pKeybindManager->onSwitchEvent(NAME);
|
||||
|
||||
const auto event_data = (wlr_switch_toggle_event*)data;
|
||||
switch (event_data->switch_state) {
|
||||
case WLR_SWITCH_STATE_ON:
|
||||
Debug::log(LOG, "Switch %s turn on, triggering binds.", NAME.c_str());
|
||||
g_pKeybindManager->onSwitchOnEvent(NAME);
|
||||
break;
|
||||
case WLR_SWITCH_STATE_OFF:
|
||||
Debug::log(LOG, "Switch %s turn off, triggering binds.", NAME.c_str());
|
||||
g_pKeybindManager->onSwitchOffEvent(NAME);
|
||||
break;
|
||||
}
|
||||
},
|
||||
PNEWDEV, "SwitchDevice");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue