aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2017-10-22 11:38:30 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2017-11-11 09:09:17 -0500
commit0f45fad18cf56910aa339c7c6ad1a661e96cfb0d (patch)
tree1ecf1d65177844ec0dc9ed3e1a8b55382e648be0 /sway/input.c
parentAlso need meson (diff)
downloadsway-0f45fad18cf56910aa339c7c6ad1a661e96cfb0d.tar.gz
sway-0f45fad18cf56910aa339c7c6ad1a661e96cfb0d.tar.zst
sway-0f45fad18cf56910aa339c7c6ad1a661e96cfb0d.zip
Establish sway input submodule
Diffstat (limited to 'sway/input.c')
-rw-r--r--sway/input.c69
1 files changed, 0 insertions, 69 deletions
diff --git a/sway/input.c b/sway/input.c
deleted file mode 100644
index 6263f79f..00000000
--- a/sway/input.c
+++ /dev/null
@@ -1,69 +0,0 @@
1#define _XOPEN_SOURCE 700
2#include <ctype.h>
3#include <float.h>
4#include <limits.h>
5#include <stdio.h>
6#include <string.h>
7#include <libinput.h>
8#include "sway/config.h"
9#include "sway/input.h"
10#include "list.h"
11#include "log.h"
12
13struct input_config *new_input_config(const char* identifier) {
14 struct input_config *input = calloc(1, sizeof(struct input_config));
15 if (!input) {
16 sway_log(L_DEBUG, "Unable to allocate input config");
17 return NULL;
18 }
19 sway_log(L_DEBUG, "new_input_config(%s)", identifier);
20 if (!(input->identifier = strdup(identifier))) {
21 free(input);
22 sway_log(L_DEBUG, "Unable to allocate input config");
23 return NULL;
24 }
25
26 input->tap = INT_MIN;
27 input->drag_lock = INT_MIN;
28 input->dwt = INT_MIN;
29 input->send_events = INT_MIN;
30 input->click_method = INT_MIN;
31 input->middle_emulation = INT_MIN;
32 input->natural_scroll = INT_MIN;
33 input->accel_profile = INT_MIN;
34 input->pointer_accel = FLT_MIN;
35 input->scroll_method = INT_MIN;
36 input->left_handed = INT_MIN;
37
38 return input;
39}
40
41char *libinput_dev_unique_id(struct libinput_device *device) {
42 int vendor = libinput_device_get_id_vendor(device);
43 int product = libinput_device_get_id_product(device);
44 char *name = strdup(libinput_device_get_name(device));
45
46 char *p = name;
47 for (; *p; ++p) {
48 if (*p == ' ') {
49 *p = '_';
50 }
51 }
52
53 sway_log(L_DEBUG, "rewritten name %s", name);
54
55 int len = strlen(name) + sizeof(char) * 6;
56 char *identifier = malloc(len);
57 if (!identifier) {
58 sway_log(L_ERROR, "Unable to allocate unique input device name");
59 return NULL;
60 }
61
62 const char *fmt = "%d:%d:%s";
63 snprintf(identifier, len, fmt, vendor, product, name);
64 free(name);
65 return identifier;
66}
67
68list_t *input_devices = NULL;
69struct input_config *current_input_config = NULL;