feat: tablet support

This commit is contained in:
sqooky! 2025-09-10 13:23:26 -04:00 committed by DreamMaoMao
parent 08c5ba33ff
commit b4fce75270
3 changed files with 255 additions and 9 deletions

View file

@ -68,6 +68,9 @@
#include <wlr/types/wlr_single_pixel_buffer_v1.h>
#include <wlr/types/wlr_subcompositor.h>
#include <wlr/types/wlr_switch.h>
#include <wlr/types/wlr_tablet_pad.h>
#include <wlr/types/wlr_tablet_tool.h>
#include <wlr/types/wlr_tablet_v2.h>
#include <wlr/types/wlr_viewporter.h>
#include <wlr/types/wlr_virtual_keyboard_v1.h>
#include <wlr/types/wlr_virtual_pointer_v1.h>
@ -3164,6 +3167,12 @@ void inputdevice(struct wl_listener *listener, void *data) {
case WLR_INPUT_DEVICE_KEYBOARD:
createkeyboard(wlr_keyboard_from_input_device(device));
break;
case WLR_INPUT_DEVICE_TABLET:
createtablet(device);
break;
case WLR_INPUT_DEVICE_TABLET_PAD:
tablet_pad = wlr_tablet_pad_create(tablet_mgr, seat, device);
break;
case WLR_INPUT_DEVICE_POINTER:
createpointer(wlr_pointer_from_input_device(device));
break;
@ -4629,14 +4638,15 @@ void setup(void) {
dpy = wl_display_create();
event_loop = wl_display_get_event_loop(dpy);
pointer_manager = wlr_relative_pointer_manager_v1_create(dpy);
/* The backend is a wlroots feature which abstracts the underlying input
* and output hardware. The autocreate option will choose the most
* suitable backend based on the current environment, such as opening an
* X11 window if an X11 server is running. The NULL argument here
* optionally allows you to pass in a custom renderer if wlr_renderer
* doesn't meet your needs. The backend uses the renderer, for example,
* to fall back to software cursors if the backend does not support
* hardware cursors (some older GPUs don't). */
tablet_mgr = wlr_tablet_v2_create(dpy);
/* The backend is a wlroots feature which abstracts the underlying input and
* output hardware. The autocreate option will choose the most suitable
* backend based on the current environment, such as opening an X11 window
* if an X11 server is running. The NULL argument here optionally allows you
* to pass in a custom renderer if wlr_renderer doesn't meet your needs. The
* backend uses the renderer, for example, to fall back to software cursors
* if the backend does not support hardware cursors (some older GPUs
* don't). */
if (!(backend = wlr_backend_autocreate(event_loop, &session)))
die("couldn't create backend");
@ -4803,6 +4813,11 @@ void setup(void) {
wl_signal_add(&cursor->events.button, &cursor_button);
wl_signal_add(&cursor->events.axis, &cursor_axis);
wl_signal_add(&cursor->events.frame, &cursor_frame);
wl_signal_add(&cursor->events.tablet_tool_proximity,
&tablet_tool_proximity);
wl_signal_add(&cursor->events.tablet_tool_axis, &tablet_tool_axis);
wl_signal_add(&cursor->events.tablet_tool_button, &tablet_tool_button);
wl_signal_add(&cursor->events.tablet_tool_tip, &tablet_tool_tip);
// 这两句代码会造成obs窗口里的鼠标光标消失,不知道注释有什么影响
cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1);