mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-15 06:59:43 -05:00
Initialize keyboards from libinput
This commit is contained in:
parent
019fff06be
commit
0e75d157f5
12 changed files with 338 additions and 51 deletions
|
|
@ -5,6 +5,8 @@ include_directories(
|
|||
|
||||
add_library(wlr-types
|
||||
wlr_output.c
|
||||
wlr_keyboard.c
|
||||
wlr_input_device.c
|
||||
)
|
||||
|
||||
target_link_libraries(wlr-types
|
||||
|
|
|
|||
24
types/wlr_input_device.c
Normal file
24
types/wlr_input_device.c
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#define _XOPEN_SOURCE 500
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types.h>
|
||||
#include <wlr/common/list.h>
|
||||
#include "types.h"
|
||||
|
||||
struct wlr_input_device *wlr_input_device_create(
|
||||
enum wlr_input_device_type type, const char *name,
|
||||
int vendor, int product) {
|
||||
struct wlr_input_device *dev = calloc(1, sizeof(struct wlr_input_device));
|
||||
dev->type = type;
|
||||
dev->name = strdup(name);
|
||||
dev->vendor = vendor;
|
||||
dev->product = product;
|
||||
return dev;
|
||||
}
|
||||
|
||||
void wlr_input_device_destroy(struct wlr_input_device *dev) {
|
||||
if (!dev) return;
|
||||
free(dev->name);
|
||||
free(dev);
|
||||
}
|
||||
22
types/wlr_keyboard.c
Normal file
22
types/wlr_keyboard.c
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types.h>
|
||||
#include <wlr/common/list.h>
|
||||
#include "types.h"
|
||||
|
||||
struct wlr_keyboard *wlr_keyboard_create(struct wlr_keyboard_impl *impl,
|
||||
struct wlr_keyboard_state *state) {
|
||||
struct wlr_keyboard *kb = calloc(1, sizeof(struct wlr_keyboard));
|
||||
kb->impl = impl;
|
||||
kb->state = state;
|
||||
wl_signal_init(&kb->events.key);
|
||||
wl_signal_init(&kb->events.mods);
|
||||
return kb;
|
||||
}
|
||||
|
||||
void wlr_keyboard_destroy(struct wlr_keyboard *kb) {
|
||||
if (!kb) return;
|
||||
kb->impl->destroy(kb->state);
|
||||
free(kb);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue