mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-07 07:31:53 -07:00
Add "on" and "off" for the bind of switch (#1342)
This commit is contained in:
@@ -287,6 +287,14 @@ void CKeybindManager::onSwitchEvent(const std::string& switchName) {
|
|||||||
handleKeybinds(0, "switch:" + switchName, 0, 0, true, 0);
|
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) {
|
int repeatKeyHandler(void* data) {
|
||||||
SKeybind** ppActiveKeybind = (SKeybind**)data;
|
SKeybind** ppActiveKeybind = (SKeybind**)data;
|
||||||
|
|
||||||
|
@@ -40,6 +40,8 @@ class CKeybindManager {
|
|||||||
bool onAxisEvent(wlr_pointer_axis_event*);
|
bool onAxisEvent(wlr_pointer_axis_event*);
|
||||||
bool onMouseEvent(wlr_pointer_button_event*);
|
bool onMouseEvent(wlr_pointer_button_event*);
|
||||||
void onSwitchEvent(const std::string&);
|
void onSwitchEvent(const std::string&);
|
||||||
|
void onSwitchOnEvent(const std::string&);
|
||||||
|
void onSwitchOffEvent(const std::string&);
|
||||||
|
|
||||||
void addKeybind(SKeybind);
|
void addKeybind(SKeybind);
|
||||||
void removeKeybind(uint32_t, const std::string&);
|
void removeKeybind(uint32_t, const std::string&);
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#include "InputManager.hpp"
|
#include "InputManager.hpp"
|
||||||
#include "../../Compositor.hpp"
|
#include "../../Compositor.hpp"
|
||||||
|
#include "wlr/types/wlr_switch.h"
|
||||||
|
|
||||||
void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) {
|
void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) {
|
||||||
static auto* const PSENS = &g_pConfigManager->getConfigValuePtr("general:sensitivity")->floatValue;
|
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());
|
Debug::log(LOG, "Switch %s fired, triggering binds.", NAME.c_str());
|
||||||
|
|
||||||
g_pKeybindManager->onSwitchEvent(NAME);
|
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");
|
PNEWDEV, "SwitchDevice");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user