mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-12-16 08:56:26 -05:00
Allocate wlr_touch devices
This commit is contained in:
parent
7dfc2c28f1
commit
d6905f86cb
11 changed files with 104 additions and 14 deletions
|
|
@ -102,7 +102,7 @@ struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display,
|
|||
goto error_state;
|
||||
}
|
||||
|
||||
if (!(state->keyboards = list_create())) {
|
||||
if (!(state->devices = list_create())) {
|
||||
wlr_log(L_ERROR, "Allocation failed: %s", strerror(errno));
|
||||
goto error_backend;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ static struct wlr_input_device_impl input_device_impl = {
|
|||
.destroy = wlr_libinput_device_destroy
|
||||
};
|
||||
|
||||
static struct wlr_input_device *allocate_device(struct libinput_device *device,
|
||||
static struct wlr_input_device *allocate_device(
|
||||
struct wlr_backend_state *state, struct libinput_device *device,
|
||||
list_t *devices, enum wlr_input_device_type type) {
|
||||
int vendor = libinput_device_get_id_vendor(device);
|
||||
int product = libinput_device_get_id_product(device);
|
||||
|
|
@ -46,6 +47,7 @@ static struct wlr_input_device *allocate_device(struct libinput_device *device,
|
|||
type, &input_device_impl, devstate,
|
||||
name, vendor, product);
|
||||
list_add(devices, wlr_device);
|
||||
list_add(state->devices, wlr_device);
|
||||
return wlr_device;
|
||||
}
|
||||
|
||||
|
|
@ -65,19 +67,22 @@ static void handle_device_added(struct wlr_backend_state *state,
|
|||
wlr_log(L_DEBUG, "Added %s [%d:%d]", name, vendor, product);
|
||||
|
||||
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_KEYBOARD)) {
|
||||
struct wlr_input_device *wlr_device = allocate_device(device, devices,
|
||||
WLR_INPUT_DEVICE_KEYBOARD);
|
||||
struct wlr_input_device *wlr_device = allocate_device(state,
|
||||
device, devices, WLR_INPUT_DEVICE_KEYBOARD);
|
||||
wlr_device->keyboard = wlr_libinput_keyboard_create(device);
|
||||
wl_signal_emit(&state->backend->events.input_add, wlr_device);
|
||||
}
|
||||
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER)) {
|
||||
struct wlr_input_device *wlr_device = allocate_device(device, devices,
|
||||
WLR_INPUT_DEVICE_POINTER);
|
||||
struct wlr_input_device *wlr_device = allocate_device(state,
|
||||
device, devices, WLR_INPUT_DEVICE_POINTER);
|
||||
wlr_device->pointer = wlr_libinput_pointer_create(device);
|
||||
wl_signal_emit(&state->backend->events.input_add, wlr_device);
|
||||
}
|
||||
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH)) {
|
||||
// TODO
|
||||
struct wlr_input_device *wlr_device = allocate_device(state,
|
||||
device, devices, WLR_INPUT_DEVICE_TOUCH);
|
||||
wlr_device->touch = wlr_libinput_touch_create(device);
|
||||
wl_signal_emit(&state->backend->events.input_add, wlr_device);
|
||||
}
|
||||
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TABLET_TOOL)) {
|
||||
// TODO
|
||||
|
|
|
|||
15
backend/libinput/touch.c
Normal file
15
backend/libinput/touch.c
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <libinput.h>
|
||||
#include <wlr/session.h>
|
||||
#include <wlr/types.h>
|
||||
#include <wlr/common/list.h>
|
||||
#include "backend/libinput.h"
|
||||
#include "common/log.h"
|
||||
#include "types.h"
|
||||
|
||||
struct wlr_touch *wlr_libinput_touch_create(
|
||||
struct libinput_device *device) {
|
||||
assert(device);
|
||||
return wlr_touch_create(NULL, NULL);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue