aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sway/ipc-json.c198
-rw-r--r--sway/sway-ipc.7.scd144
-rw-r--r--swaymsg/main.c10
3 files changed, 317 insertions, 35 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 20dcafb1..e9564b04 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -617,6 +617,187 @@ json_object *ipc_json_describe_node_recursive(struct sway_node *node) {
617 return object; 617 return object;
618} 618}
619 619
620static json_object *describe_libinput_device(struct libinput_device *device) {
621 json_object *object = json_object_new_object();
622
623 const char *events = "unknown";
624 switch (libinput_device_config_send_events_get_mode(device)) {
625 case LIBINPUT_CONFIG_SEND_EVENTS_ENABLED:
626 events = "enabled";
627 break;
628 case LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE:
629 events = "disabled_on_external_mouse";
630 break;
631 case LIBINPUT_CONFIG_SEND_EVENTS_DISABLED:
632 events = "disabled";
633 break;
634 }
635 json_object_object_add(object, "send_events",
636 json_object_new_string(events));
637
638 if (libinput_device_config_tap_get_finger_count(device) > 0) {
639 const char *tap = "unknown";
640 switch (libinput_device_config_tap_get_enabled(device)) {
641 case LIBINPUT_CONFIG_TAP_ENABLED:
642 tap = "enabled";
643 break;
644 case LIBINPUT_CONFIG_TAP_DISABLED:
645 tap = "disabled";
646 break;
647 }
648 json_object_object_add(object, "tap", json_object_new_string(tap));
649
650 const char *button_map = "unknown";
651 switch (libinput_device_config_tap_get_button_map(device)) {
652 case LIBINPUT_CONFIG_TAP_MAP_LRM:
653 button_map = "lrm";
654 break;
655 case LIBINPUT_CONFIG_TAP_MAP_LMR:
656 button_map = "lmr";
657 break;
658 }
659 json_object_object_add(object, "tap_button_map",
660 json_object_new_string(button_map));
661
662 const char* drag = "unknown";
663 switch (libinput_device_config_tap_get_drag_enabled(device)) {
664 case LIBINPUT_CONFIG_DRAG_ENABLED:
665 drag = "enabled";
666 break;
667 case LIBINPUT_CONFIG_DRAG_DISABLED:
668 drag = "disabled";
669 break;
670 }
671 json_object_object_add(object, "tap_drag",
672 json_object_new_string(drag));
673
674 const char *drag_lock = "unknown";
675 switch (libinput_device_config_tap_get_drag_lock_enabled(device)) {
676 case LIBINPUT_CONFIG_DRAG_LOCK_ENABLED:
677 drag_lock = "enabled";
678 break;
679 case LIBINPUT_CONFIG_DRAG_LOCK_DISABLED:
680 drag_lock = "disabled";
681 break;
682 }
683 json_object_object_add(object, "tap_drag_lock",
684 json_object_new_string(drag_lock));
685 }
686
687 if (libinput_device_config_accel_is_available(device)) {
688 double accel = libinput_device_config_accel_get_speed(device);
689 json_object_object_add(object, "accel_speed",
690 json_object_new_double(accel));
691
692 const char *accel_profile = "unknown";
693 switch (libinput_device_config_accel_get_profile(device)) {
694 case LIBINPUT_CONFIG_ACCEL_PROFILE_NONE:
695 accel_profile = "none";
696 break;
697 case LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT:
698 accel_profile = "flat";
699 break;
700 case LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE:
701 accel_profile = "adaptive";
702 break;
703 }
704 json_object_object_add(object, "accel_profile",
705 json_object_new_string(accel_profile));
706 }
707
708 if (libinput_device_config_scroll_has_natural_scroll(device)) {
709 const char *natural_scroll = "disabled";
710 if (libinput_device_config_scroll_get_natural_scroll_enabled(device)) {
711 natural_scroll = "enabled";
712 }
713 json_object_object_add(object, "natural_scroll",
714 json_object_new_string(natural_scroll));
715 }
716
717 if (libinput_device_config_left_handed_is_available(device)) {
718 const char *left_handed = "disabled";
719 if (libinput_device_config_left_handed_get(device) != 0) {
720 left_handed = "enabled";
721 }
722 json_object_object_add(object, "left_handed",
723 json_object_new_string(left_handed));
724 }
725
726 uint32_t click_methods = libinput_device_config_click_get_methods(device);
727 if ((click_methods & ~LIBINPUT_CONFIG_CLICK_METHOD_NONE) != 0) {
728 const char *click_method = "unknown";
729 switch (libinput_device_config_click_get_method(device)) {
730 case LIBINPUT_CONFIG_CLICK_METHOD_NONE:
731 click_method = "none";
732 break;
733 case LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS:
734 click_method = "button_areas";
735 break;
736 case LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER:
737 click_method = "clickfinger";
738 break;
739 }
740 json_object_object_add(object, "click_method",
741 json_object_new_string(click_method));
742 }
743
744 if (libinput_device_config_middle_emulation_is_available(device)) {
745 const char *middle_emulation = "unknown";
746 switch (libinput_device_config_middle_emulation_get_enabled(device)) {
747 case LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED:
748 middle_emulation = "enabled";
749 break;
750 case LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED:
751 middle_emulation = "disabled";
752 break;
753 }
754 json_object_object_add(object, "middle_emulation",
755 json_object_new_string(middle_emulation));
756 }
757
758 uint32_t scroll_methods = libinput_device_config_scroll_get_methods(device);
759 if ((scroll_methods & ~LIBINPUT_CONFIG_SCROLL_NO_SCROLL) != 0) {
760 const char *scroll_method = "unknown";
761 switch (libinput_device_config_scroll_get_method(device)) {
762 case LIBINPUT_CONFIG_SCROLL_NO_SCROLL:
763 scroll_method = "none";
764 break;
765 case LIBINPUT_CONFIG_SCROLL_2FG:
766 scroll_method = "two_finger";
767 break;
768 case LIBINPUT_CONFIG_SCROLL_EDGE:
769 scroll_method = "edge";
770 break;
771 case LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN:
772 scroll_method = "on_button_down";
773 break;
774 }
775 json_object_object_add(object, "scroll_method",
776 json_object_new_string(scroll_method));
777
778 if ((scroll_methods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) != 0) {
779 uint32_t button = libinput_device_config_scroll_get_button(device);
780 json_object_object_add(object, "scroll_button",
781 json_object_new_int(button));
782 }
783 }
784
785 if (libinput_device_config_dwt_is_available(device)) {
786 const char *dwt = "unknown";
787 switch (libinput_device_config_dwt_get_enabled(device)) {
788 case LIBINPUT_CONFIG_DWT_ENABLED:
789 dwt = "enabled";
790 break;
791 case LIBINPUT_CONFIG_DWT_DISABLED:
792 dwt = "disabled";
793 break;
794 }
795 json_object_object_add(object, "dwt", json_object_new_string(dwt));
796 }
797
798 return object;
799}
800
620json_object *ipc_json_describe_input(struct sway_input_device *device) { 801json_object *ipc_json_describe_input(struct sway_input_device *device) {
621 if (!(sway_assert(device, "Device must not be null"))) { 802 if (!(sway_assert(device, "Device must not be null"))) {
622 return NULL; 803 return NULL;
@@ -660,21 +841,8 @@ json_object *ipc_json_describe_input(struct sway_input_device *device) {
660 if (wlr_input_device_is_libinput(device->wlr_device)) { 841 if (wlr_input_device_is_libinput(device->wlr_device)) {
661 struct libinput_device *libinput_dev; 842 struct libinput_device *libinput_dev;
662 libinput_dev = wlr_libinput_get_device_handle(device->wlr_device); 843 libinput_dev = wlr_libinput_get_device_handle(device->wlr_device);
663 844 json_object_object_add(object, "libinput",
664 const char *events = "unknown"; 845 describe_libinput_device(libinput_dev));
665 switch (libinput_device_config_send_events_get_mode(libinput_dev)) {
666 case LIBINPUT_CONFIG_SEND_EVENTS_ENABLED:
667 events = "enabled";
668 break;
669 case LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE:
670 events = "disabled_on_external_mouse";
671 break;
672 case LIBINPUT_CONFIG_SEND_EVENTS_DISABLED:
673 events = "disabled";
674 break;
675 }
676 json_object_object_add(object, "libinput_send_events",
677 json_object_new_string(events));
678 } 846 }
679 847
680 return object; 848 return object;
diff --git a/sway/sway-ipc.7.scd b/sway/sway-ipc.7.scd
index 6b400453..b43b3030 100644
--- a/sway/sway-ipc.7.scd
+++ b/sway/sway-ipc.7.scd
@@ -1034,10 +1034,66 @@ following properties:
1034|- xkb_active_layout_name 1034|- xkb_active_layout_name
1035: string 1035: string
1036: (Only keyboards) The active keyboard layout in use 1036: (Only keyboards) The active keyboard layout in use
1037|- libinput_send_events 1037|- libinput
1038: object
1039: (Only libinput devices) An object describing the current device settings.
1040 See below for more information
1041
1042The _libinput_ object describes the device configuration for libinput devices.
1043Only properties that are supported for the device will be added to the object.
1044In addition to the possible options listed, all string properties may also be
1045_unknown_, in the case that a new option is added to libinput. See
1046*sway-input*(5) for information on the meaning of the possible values. The
1047following properties will be included for devices that support them:
1048
1049[- *PROPERTY*
1050:- *DATA TYPE*
1051:- *DESCRIPTION*
1052|- send_events
1053: string
1054:[ Whether events are being sent by the device. It can be _enabled_,
1055 _disabled_, or _disabled\_on\_external\_mouse_
1056|- tap
1057: string
1058: Whether tap to click is enabled. It can be _enabled_ or _disabled_
1059|- tap_button_map
1060: string
1061: The finger to button mapping in use. It can be _lmr_ or _lrm_
1062|- tap_drag
1063: string
1064: Whether tap-and-drag is enabled. It can be _enabled_ or _disabled_
1065|- tap_drag_lock
1066: string
1067: Whether drag-lock is enabled. It can be _enabled_ or _disabled_
1068|- accel_speed
1069: double
1070: The pointer-acceleration in use
1071|- accel_profile
1072: string
1073: The acceleration profile in use. It can be _none_, _flat_, or _adaptive_
1074|- natural_scroll
1075: string
1076: Whether natural scrolling is enabled. It can be _enabled_ or _disabled_
1077|- left_handed
1078: string
1079: Whether left-handed mode is enabled. It can be _enabled_ or _disabled_
1080|- click_method
1081: string
1082: The click method in use. It can be _none_, _button_areas_, or _clickfinger_
1083|- middle_emulation
1084: string
1085: Whether middle emulation is enabled. It can be _enabled_ or _disabled_
1086|- scroll_method
1087: string
1088: The scroll method in use. It can be _none_, _two_finger_, _edge_, or
1089 _on_button_down_
1090|- scroll_button
1091: int
1092: The scroll button to use when _scroll_method_ is _on_button_down_. This
1093 will be given as an input event code
1094|- dwt
1038: string 1095: string
1039: (Only libinput devices) The send events value in use by libinput for this 1096: Whether disable-while-typing is enabled. It can be _enabled_ or _disabled_
1040 device. It can be _enabled_, _disabled_, or _disabled\_on\_external\_mouse_
1041 1097
1042 1098
1043*Example Reply:* 1099*Example Reply:*
@@ -1050,7 +1106,9 @@ following properties:
1050 "product": 1, 1106 "product": 1,
1051 "type": "keyboard", 1107 "type": "keyboard",
1052 "xkb_active_layout_name": "English (US)", 1108 "xkb_active_layout_name": "English (US)",
1053 "libinput_send_events": "enabled" 1109 "libinput": {
1110 "send_events": "enabled"
1111 }
1054 }, 1112 },
1055 { 1113 {
1056 "identifier": "1267:5:Elan_Touchpad", 1114 "identifier": "1267:5:Elan_Touchpad",
@@ -1058,7 +1116,21 @@ following properties:
1058 "vendor": 1267, 1116 "vendor": 1267,
1059 "product": 5, 1117 "product": 5,
1060 "type": "pointer", 1118 "type": "pointer",
1061 "libinput_send_events": "enabled" 1119 "libinput": {
1120 "send_events": "enabled",
1121 "tap": "enabled",
1122 "tap_button_map": "lmr",
1123 "tap_drag": "enabled",
1124 "tap_drag_lock": "disabled",
1125 "accel_speed": 0.0,
1126 "accel_profile": "none",
1127 "natural_scroll", "disabled",
1128 "left_handed": "disabled",
1129 "click_method": "button_areas",
1130 "middle_emulation": "disabled",
1131 "scroll_method": "edge",
1132 "dwt": "enabled"
1133 }
1062 }, 1134 },
1063 { 1135 {
1064 "identifier": "3034:22494:USB2.0_VGA_UVC_WebCam:_USB2.0_V", 1136 "identifier": "3034:22494:USB2.0_VGA_UVC_WebCam:_USB2.0_V",
@@ -1067,7 +1139,9 @@ following properties:
1067 "product": 22494, 1139 "product": 22494,
1068 "type": "keyboard", 1140 "type": "keyboard",
1069 "xkb_active_layout_name": "English (US)", 1141 "xkb_active_layout_name": "English (US)",
1070 "libinput_send_events": "enabled" 1142 "libinput": {
1143 "send_events": "enabled"
1144 }
1071 }, 1145 },
1072 { 1146 {
1073 "identifier": "0:3:Sleep_Button", 1147 "identifier": "0:3:Sleep_Button",
@@ -1076,7 +1150,9 @@ following properties:
1076 "product": 3, 1150 "product": 3,
1077 "type": "keyboard", 1151 "type": "keyboard",
1078 "xkb_active_layout_name": "English (US)", 1152 "xkb_active_layout_name": "English (US)",
1079 "libinput_send_events": "enabled" 1153 "libinput": {
1154 "send_events": "enabled"
1155 }
1080 }, 1156 },
1081 { 1157 {
1082 "identifier": "0:5:Lid_Switch", 1158 "identifier": "0:5:Lid_Switch",
@@ -1084,7 +1160,10 @@ following properties:
1084 "vendor": 0, 1160 "vendor": 0,
1085 "product": 5, 1161 "product": 5,
1086 "type": "switch", 1162 "type": "switch",
1087 "libinput_send_events": "enabled" 1163 "libinput": {
1164 "send_events": "enabled"
1165 }
1166 },
1088 { 1167 {
1089 "identifier": "0:6:Video_Bus", 1168 "identifier": "0:6:Video_Bus",
1090 "name": "Video Bus", 1169 "name": "Video Bus",
@@ -1092,7 +1171,9 @@ following properties:
1092 "product": 6, 1171 "product": 6,
1093 "type": "keyboard", 1172 "type": "keyboard",
1094 "xkb_active_layout_name": "English (US)", 1173 "xkb_active_layout_name": "English (US)",
1095 "libinput_send_events": "enabled" 1174 "libinput": {
1175 "send_events": "enabled"
1176 }
1096 }, 1177 },
1097 { 1178 {
1098 "identifier": "0:1:Power_Button", 1179 "identifier": "0:1:Power_Button",
@@ -1101,7 +1182,9 @@ following properties:
1101 "product": 1, 1182 "product": 1,
1102 "type": "keyboard", 1183 "type": "keyboard",
1103 "xkb_active_layout_name": "English (US)", 1184 "xkb_active_layout_name": "English (US)",
1104 "libinput_send_events": "enabled" 1185 "libinput": {
1186 "send_events": "enabled"
1187 }
1105 } 1188 }
1106] 1189]
1107``` 1190```
@@ -1150,7 +1233,9 @@ one seat. Each object has the following properties:
1150 "product": 1, 1233 "product": 1,
1151 "type": "keyboard", 1234 "type": "keyboard",
1152 "xkb_active_layout_name": "English (US)", 1235 "xkb_active_layout_name": "English (US)",
1153 "libinput_send_events": "enabled" 1236 "libinput": {
1237 "send_events": "enabled"
1238 }
1154 }, 1239 },
1155 { 1240 {
1156 "identifier": "1267:5:Elan_Touchpad", 1241 "identifier": "1267:5:Elan_Touchpad",
@@ -1158,7 +1243,21 @@ one seat. Each object has the following properties:
1158 "vendor": 1267, 1243 "vendor": 1267,
1159 "product": 5, 1244 "product": 5,
1160 "type": "pointer", 1245 "type": "pointer",
1161 "libinput_send_events": "enabled" 1246 "libinput": {
1247 "send_events": "enabled",
1248 "tap": "enabled",
1249 "tap_button_map": "lmr",
1250 "tap_drag": "enabled",
1251 "tap_drag_lock": "disabled",
1252 "accel_speed": 0.0,
1253 "accel_profile": "none",
1254 "natural_scroll", "disabled",
1255 "left_handed": "disabled",
1256 "click_method": "button_areas",
1257 "middle_emulation": "disabled",
1258 "scroll_method": "edge",
1259 "dwt": "enabled"
1260 }
1162 }, 1261 },
1163 { 1262 {
1164 "identifier": "3034:22494:USB2.0_VGA_UVC_WebCam:_USB2.0_V", 1263 "identifier": "3034:22494:USB2.0_VGA_UVC_WebCam:_USB2.0_V",
@@ -1167,7 +1266,9 @@ one seat. Each object has the following properties:
1167 "product": 22494, 1266 "product": 22494,
1168 "type": "keyboard", 1267 "type": "keyboard",
1169 "xkb_active_layout_name": "English (US)", 1268 "xkb_active_layout_name": "English (US)",
1170 "libinput_send_events": "enabled" 1269 "libinput": {
1270 "send_events": "enabled"
1271 }
1171 }, 1272 },
1172 { 1273 {
1173 "identifier": "0:3:Sleep_Button", 1274 "identifier": "0:3:Sleep_Button",
@@ -1176,7 +1277,9 @@ one seat. Each object has the following properties:
1176 "product": 3, 1277 "product": 3,
1177 "type": "keyboard", 1278 "type": "keyboard",
1178 "xkb_active_layout_name": "English (US)", 1279 "xkb_active_layout_name": "English (US)",
1179 "libinput_send_events": "enabled" 1280 "libinput": {
1281 "send_events": "enabled"
1282 }
1180 }, 1283 },
1181 { 1284 {
1182 "identifier": "0:5:Lid_Switch", 1285 "identifier": "0:5:Lid_Switch",
@@ -1184,7 +1287,10 @@ one seat. Each object has the following properties:
1184 "vendor": 0, 1287 "vendor": 0,
1185 "product": 5, 1288 "product": 5,
1186 "type": "switch", 1289 "type": "switch",
1187 "libinput_send_events": "enabled" 1290 "libinput": {
1291 "send_events": "enabled"
1292 }
1293 },
1188 { 1294 {
1189 "identifier": "0:6:Video_Bus", 1295 "identifier": "0:6:Video_Bus",
1190 "name": "Video Bus", 1296 "name": "Video Bus",
@@ -1192,7 +1298,9 @@ one seat. Each object has the following properties:
1192 "product": 6, 1298 "product": 6,
1193 "type": "keyboard", 1299 "type": "keyboard",
1194 "xkb_active_layout_name": "English (US)", 1300 "xkb_active_layout_name": "English (US)",
1195 "libinput_send_events": "enabled" 1301 "libinput": {
1302 "send_events": "enabled"
1303 }
1196 }, 1304 },
1197 { 1305 {
1198 "identifier": "0:1:Power_Button", 1306 "identifier": "0:1:Power_Button",
@@ -1201,7 +1309,9 @@ one seat. Each object has the following properties:
1201 "product": 1, 1309 "product": 1,
1202 "type": "keyboard", 1310 "type": "keyboard",
1203 "xkb_active_layout_name": "English (US)", 1311 "xkb_active_layout_name": "English (US)",
1204 "libinput_send_events": "enabled" 1312 "libinput": {
1313 "send_events": "enabled"
1314 }
1205 } 1315 }
1206 ] 1316 ]
1207 } 1317 }
diff --git a/swaymsg/main.c b/swaymsg/main.c
index 716d2d2e..e51c00d9 100644
--- a/swaymsg/main.c
+++ b/swaymsg/main.c
@@ -113,7 +113,7 @@ static const char *pretty_type_name(const char *name) {
113} 113}
114 114
115static void pretty_print_input(json_object *i) { 115static void pretty_print_input(json_object *i) {
116 json_object *id, *name, *type, *product, *vendor, *kbdlayout, *events; 116 json_object *id, *name, *type, *product, *vendor, *kbdlayout, *libinput;
117 json_object_object_get_ex(i, "identifier", &id); 117 json_object_object_get_ex(i, "identifier", &id);
118 json_object_object_get_ex(i, "name", &name); 118 json_object_object_get_ex(i, "name", &name);
119 json_object_object_get_ex(i, "type", &type); 119 json_object_object_get_ex(i, "type", &type);
@@ -139,8 +139,12 @@ static void pretty_print_input(json_object *i) {
139 printf(" Active Keyboard Layout: %s\n", layout ? layout : "(unnamed)"); 139 printf(" Active Keyboard Layout: %s\n", layout ? layout : "(unnamed)");
140 } 140 }
141 141
142 if (json_object_object_get_ex(i, "libinput_send_events", &events)) { 142 if (json_object_object_get_ex(i, "libinput", &libinput)) {
143 printf(" Libinput Send Events: %s\n", json_object_get_string(events)); 143 json_object *events;
144 if (json_object_object_get_ex(libinput, "send_events", &events)) {
145 printf(" Libinput Send Events: %s\n",
146 json_object_get_string(events));
147 }
144 } 148 }
145 149
146 printf("\n"); 150 printf("\n");