summaryrefslogtreecommitdiff
path: root/sbin/wsconsctl
diff options
context:
space:
mode:
authorUlf Brosziewski <bru@cvs.openbsd.org>2023-07-02 21:44:05 +0000
committerUlf Brosziewski <bru@cvs.openbsd.org>2023-07-02 21:44:05 +0000
commit54b2bf92bd107ecf4154b4d436c23cf265ba1289 (patch)
tree7074735e1c9c83b65b997d96b8875ce281551996 /sbin/wsconsctl
parente9d425bbe4989fcae33ff7295ab4b97a57d39723 (diff)
Add button mappings for two- and three-finger clicks on clickpads.
Based on a proposal of tobhe@. ok tobhe@
Diffstat (limited to 'sbin/wsconsctl')
-rw-r--r--sbin/wsconsctl/mouse.c13
-rw-r--r--sbin/wsconsctl/mousecfg.c41
-rw-r--r--sbin/wsconsctl/mousecfg.h3
3 files changed, 30 insertions, 27 deletions
diff --git a/sbin/wsconsctl/mouse.c b/sbin/wsconsctl/mouse.c
index e04642dacbc..c880c92b57b 100644
--- a/sbin/wsconsctl/mouse.c
+++ b/sbin/wsconsctl/mouse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mouse.c,v 1.20 2019/08/19 21:42:33 bru Exp $ */
+/* $OpenBSD: mouse.c,v 1.21 2023/07/02 21:44:04 bru Exp $ */
/* $NetBSD: mouse.c,v 1.3 1999/11/15 13:47:30 ad Exp $ */
/*-
@@ -57,6 +57,7 @@ struct field mouse_field_tab[] = {
{ "reverse_scrolling", &cfg_revscroll, FMT_CFG, FLG_NORDBACK },
/* touchpad-specific options: */
{ "tp.tapping", &cfg_tapping, FMT_CFG, FLG_NORDBACK },
+ { "tp.mtbuttons", &cfg_mtbuttons, FMT_CFG, FLG_NORDBACK },
{ "tp.scaling", &cfg_scaling, FMT_CFG, FLG_NORDBACK },
{ "tp.swapsides", &cfg_swapsides, FMT_CFG, FLG_NORDBACK },
{ "tp.disable", &cfg_disable, FMT_CFG, FLG_NORDBACK },
@@ -69,6 +70,10 @@ struct field mouse_field_tab[] = {
static int dev_index = -1;
+static struct wsmouse_parameters mtbtn_maxdist = {
+ (struct wsmouse_param[]) { { WSMOUSECFG_MTBTN_MAXDIST, 0 } }, 1
+};
+
void
mouse_init(int devfd, int devidx) {
@@ -91,6 +96,12 @@ mouse_init(int devfd, int devidx) {
if (f->format == FMT_CFG) {
f->flags &= ~FLG_DEAD;
}
+ /* Hide the 'mtbuttons' field if the feature is unavailable. */
+ if (mousecfg_get_field(&mtbtn_maxdist) ||
+ mtbtn_maxdist.params[0].value < 0) {
+ f = field_by_value(mouse_field_tab, &cfg_mtbuttons);
+ f->flags |= FLG_DEAD;
+ }
} else {
for (f = mouse_field_tab; f->name != NULL; f++)
if (f->format == FMT_CFG) {
diff --git a/sbin/wsconsctl/mousecfg.c b/sbin/wsconsctl/mousecfg.c
index 76a9984bd86..7fd7bff3d21 100644
--- a/sbin/wsconsctl/mousecfg.c
+++ b/sbin/wsconsctl/mousecfg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mousecfg.c,v 1.9 2021/03/03 19:44:37 bru Exp $ */
+/* $OpenBSD: mousecfg.c,v 1.10 2023/07/02 21:44:04 bru Exp $ */
/*
* Copyright (c) 2017 Ulf Brosziewski
@@ -35,30 +35,15 @@
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
#endif
-#define BASE_FIRST WSMOUSECFG_DX_SCALE
-#define BASE_LAST WSMOUSECFG_REVERSE_SCROLLING
-#define TP_FILTER_FIRST WSMOUSECFG_DX_MAX
-#define TP_FILTER_LAST WSMOUSECFG_SMOOTHING
-#define TP_FEATURES_FIRST WSMOUSECFG_SOFTBUTTONS
-#define TP_FEATURES_LAST WSMOUSECFG_DISABLE
-#define TP_SETUP_FIRST WSMOUSECFG_LEFT_EDGE
-#define TP_SETUP_LAST WSMOUSECFG_TAP_THREE_BTNMAP
-#define LOG_FIRST WSMOUSECFG_LOG_INPUT
-#define LOG_LAST WSMOUSECFG_LOG_EVENTS
-
-#define BASESIZE ((BASE_LAST - BASE_FIRST + 1) + (LOG_LAST - LOG_FIRST + 1))
-
-#define BUFSIZE (BASESIZE \
- + (TP_FILTER_LAST - TP_FILTER_FIRST + 1) \
- + (TP_FEATURES_LAST - TP_FEATURES_FIRST + 1) \
- + (TP_SETUP_LAST - TP_SETUP_FIRST + 1))
+#define BASESIZE ((WSMOUSECFG__FILTERS - WSMOUSECFG_DX_SCALE) \
+ + (WSMOUSECFG__DEBUG - WSMOUSECFG_LOG_INPUT))
static const int range[][2] = {
- { BASE_FIRST, BASE_LAST },
- { LOG_FIRST, LOG_LAST },
- { TP_FILTER_FIRST, TP_FILTER_LAST },
- { TP_FEATURES_FIRST, TP_FEATURES_LAST },
- { TP_SETUP_FIRST, TP_SETUP_LAST },
+ { WSMOUSECFG_DX_SCALE, WSMOUSECFG__FILTERS - 1 },
+ { WSMOUSECFG_LOG_INPUT, WSMOUSECFG__DEBUG - 1 },
+ { WSMOUSECFG_DX_MAX, WSMOUSECFG__TPFILTERS - 1 },
+ { WSMOUSECFG_SOFTBUTTONS, WSMOUSECFG__TPFEATURES - 1 },
+ { WSMOUSECFG_LEFT_EDGE, WSMOUSECFG__TPSETUP - 1 },
};
static const int touchpad_types[] = {
@@ -77,6 +62,12 @@ struct wsmouse_parameters cfg_tapping = {
3
};
+struct wsmouse_parameters cfg_mtbuttons = {
+ (struct wsmouse_param[]) {
+ { WSMOUSECFG_MTBUTTONS, 0 }, },
+ 1
+};
+
struct wsmouse_parameters cfg_scaling = {
(struct wsmouse_param[]) {
{ WSMOUSECFG_DX_SCALE, 0 },
@@ -124,7 +115,7 @@ int cfg_touchpad;
static int cfg_horiz_res;
static int cfg_vert_res;
-static struct wsmouse_param cfg_buffer[BUFSIZE];
+static struct wsmouse_param cfg_buffer[WSMOUSECFG_MAX];
int
@@ -171,7 +162,7 @@ mousecfg_init(int dev_fd, const char **errstr)
}
if (cfg_touchpad) {
parameters.params = cfg_buffer + BASESIZE;
- parameters.nparams = BUFSIZE - BASESIZE;
+ parameters.nparams = WSMOUSECFG_MAX - BASESIZE;
if (ioctl(dev_fd, WSMOUSEIO_GETPARAMS, &parameters))
cfg_touchpad = 0;
}
diff --git a/sbin/wsconsctl/mousecfg.h b/sbin/wsconsctl/mousecfg.h
index 8e99139d280..161ed05e476 100644
--- a/sbin/wsconsctl/mousecfg.h
+++ b/sbin/wsconsctl/mousecfg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mousecfg.h,v 1.4 2019/08/19 21:42:33 bru Exp $ */
+/* $OpenBSD: mousecfg.h,v 1.5 2023/07/02 21:44:04 bru Exp $ */
/*
* Copyright (c) 2017 Ulf Brosziewski
@@ -17,6 +17,7 @@
*/
extern struct wsmouse_parameters cfg_tapping;
+extern struct wsmouse_parameters cfg_mtbuttons;
extern struct wsmouse_parameters cfg_scaling;
extern struct wsmouse_parameters cfg_edges;
extern struct wsmouse_parameters cfg_swapsides;