Hyprland/src/events/Devices.cpp

51 lines
2.1 KiB
C++
Raw Normal View History

2022-03-21 15:17:04 +01:00
#include "Events.hpp"
#include "../Compositor.hpp"
#include "../helpers/WLClasses.hpp"
2022-06-09 12:46:55 +02:00
#include "../managers/input/InputManager.hpp"
2022-03-21 15:17:04 +01:00
#include "../render/Renderer.hpp"
// ---------------------------------------------------- //
// _____ ________ _______ _____ ______ _____ //
// | __ \| ____\ \ / /_ _/ ____| ____|/ ____| //
// | | | | |__ \ \ / / | || | | |__ | (___ //
// | | | | __| \ \/ / | || | | __| \___ \ //
// | |__| | |____ \ / _| || |____| |____ ____) | //
// |_____/|______| \/ |_____\_____|______|_____/ //
// //
// ---------------------------------------------------- //
2022-07-16 11:44:12 +02:00
void Events::listener_newInput(wl_listener* listener, void* data) {
const auto DEVICE = (wlr_input_device*)data;
2022-03-21 15:17:04 +01:00
switch (DEVICE->type) {
2022-07-16 11:44:12 +02:00
case WLR_INPUT_DEVICE_KEYBOARD:
2023-09-06 12:51:36 +02:00
Debug::log(LOG, "Attached a keyboard with name {}", DEVICE->name);
2022-07-16 11:44:12 +02:00
g_pInputManager->newKeyboard(DEVICE);
break;
case WLR_INPUT_DEVICE_POINTER:
2023-09-06 12:51:36 +02:00
Debug::log(LOG, "Attached a mouse with name {}", DEVICE->name);
2022-07-16 11:44:12 +02:00
g_pInputManager->newMouse(DEVICE);
break;
case WLR_INPUT_DEVICE_TOUCH:
2023-09-06 12:51:36 +02:00
Debug::log(LOG, "Attached a touch device with name {}", DEVICE->name);
g_pInputManager->newTouchDevice(DEVICE);
2022-07-16 11:44:12 +02:00
break;
2024-03-09 17:35:35 +01:00
case WLR_INPUT_DEVICE_TABLET:
Debug::log(LOG, "Attached a tablet with name {}", DEVICE->name);
g_pInputManager->newTablet(DEVICE);
2022-07-16 11:44:12 +02:00
break;
case WLR_INPUT_DEVICE_TABLET_PAD:
2023-09-06 12:51:36 +02:00
Debug::log(LOG, "Attached a tablet pad with name {}", DEVICE->name);
2022-07-16 11:44:12 +02:00
g_pInputManager->newTabletPad(DEVICE);
break;
2022-10-04 21:07:21 +02:00
case WLR_INPUT_DEVICE_SWITCH:
2023-09-06 12:51:36 +02:00
Debug::log(LOG, "Attached a switch device with name {}", DEVICE->name);
2022-10-04 21:07:21 +02:00
g_pInputManager->newSwitch(DEVICE);
break;
2023-09-06 12:51:36 +02:00
default: Debug::log(WARN, "Unrecognized input device plugged in: {}", DEVICE->name); break;
2022-07-16 11:44:12 +02:00
}
2022-03-21 15:17:04 +01:00
2022-12-05 15:28:27 +01:00
g_pInputManager->updateCapabilities();
}