diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-12-18 14:27:38 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-12-18 14:27:38 -0500 |
commit | f2985000f364693fbeb832df1c4fd468c608e40f (patch) | |
tree | f84600bdc02e4239fd93f203eb020a90fc7a5f48 /sway/ipc-json.c | |
parent | Merge branch 'wlroots' into feature/input (diff) | |
download | sway-f2985000f364693fbeb832df1c4fd468c608e40f.tar.gz sway-f2985000f364693fbeb832df1c4fd468c608e40f.tar.zst sway-f2985000f364693fbeb832df1c4fd468c608e40f.zip |
ipc get_inputs
Diffstat (limited to 'sway/ipc-json.c')
-rw-r--r-- | sway/ipc-json.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 09a32c1b..bab9a201 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -141,3 +141,40 @@ json_object *ipc_json_describe_container_recursive(swayc_t *c) { | |||
141 | 141 | ||
142 | return object; | 142 | return object; |
143 | } | 143 | } |
144 | |||
145 | static const char *describe_device_type(struct sway_input_device *device) { | ||
146 | switch (device->wlr_device->type) { | ||
147 | case WLR_INPUT_DEVICE_POINTER: | ||
148 | return "pointer"; | ||
149 | case WLR_INPUT_DEVICE_KEYBOARD: | ||
150 | return "keyboard"; | ||
151 | case WLR_INPUT_DEVICE_TOUCH: | ||
152 | return "touch"; | ||
153 | case WLR_INPUT_DEVICE_TABLET_TOOL: | ||
154 | return "tablet_tool"; | ||
155 | case WLR_INPUT_DEVICE_TABLET_PAD: | ||
156 | return "tablet_pad"; | ||
157 | } | ||
158 | return "unknown"; | ||
159 | } | ||
160 | |||
161 | json_object *ipc_json_describe_input(struct sway_input_device *device) { | ||
162 | if (!(sway_assert(device, "Device must not be null"))) { | ||
163 | return NULL; | ||
164 | } | ||
165 | |||
166 | json_object *object = json_object_new_object(); | ||
167 | |||
168 | json_object_object_add(object, "identifier", | ||
169 | json_object_new_string(device->identifier)); | ||
170 | json_object_object_add(object, "name", | ||
171 | json_object_new_string(device->wlr_device->name)); | ||
172 | json_object_object_add(object, "vendor", | ||
173 | json_object_new_int(device->wlr_device->vendor)); | ||
174 | json_object_object_add(object, "product", | ||
175 | json_object_new_int(device->wlr_device->product)); | ||
176 | json_object_object_add(object, "type", | ||
177 | json_object_new_string(describe_device_type(device))); | ||
178 | |||
179 | return object; | ||
180 | } | ||