]> git.mdlowis.com Git - proto/labwc.git/commitdiff
config: add tablet rotate configuration
authorJens Peters <jp7677@gmail.com>
Fri, 29 Dec 2023 21:36:06 +0000 (22:36 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Fri, 29 Dec 2023 22:32:41 +0000 (22:32 +0000)
Co-authored-by: Consolatis <35009135+Consolatis@users.noreply.github.com>
docs/rc.xml.all
include/config/rcxml.h
include/config/tablet.h
src/config/rcxml.c
src/config/tablet.c

index bbf61189311b9a7b46faf761949e4d52b7e18d19..ddd9236ac7d7f08146dc5bd9c5356e18d625c061 100644 (file)
   </mouse>
 
   <!--
-    Tablet buttons emulate regular mouse buttons.
+    The tablet orientation can be changed in 90 degree steps, thus
+    rotation can be set to [0|90|180|270].
 
-    The tablet *button* can be set to any of [tip|stylus|stylus2|stylus3].
-    Valid *to* mouse buttons are [left|right|middle].
+    Tablet buttons emulate regular mouse buttons. The tablet *button* can
+    be set to any of [tip|stylus|stylus2|stylus3]. Valid *to* mouse buttons
+    are [left|right|middle].
   -->
-  <tablet>
+  <tablet rotate="0">
     <map button="tip" to="left" />
     <map button="stylus" to="right" />
     <map button="stylus2" to="middle" />
index ead62c781e08097a486ad59fd2eb64fd05bcf2cb..acb34260104697bde31e9f84be1abde82a4413f8 100644 (file)
@@ -83,6 +83,7 @@ struct rcxml {
 
        /* graphics tablet */
        struct tablet_config {
+               enum rotation rotation;
                uint16_t button_map_count;
                struct button_map_entry button_map[BUTTON_MAP_MAX];
        } tablet;
index 25a232c3c5ecb7055b65854d3cb9ab1040ad0f8d..c5b90b937335fe0ee105203351cebfc1870aaa80 100644 (file)
@@ -4,12 +4,20 @@
 
 #include <stdint.h>
 
+enum rotation {
+       LAB_ROTATE_NONE = 0,
+       LAB_ROTATE_90,
+       LAB_ROTATE_180,
+       LAB_ROTATE_270,
+};
+
 #define BUTTON_MAP_MAX 16
 struct button_map_entry {
        uint32_t from;
        uint32_t to;
 };
 
+enum rotation tablet_parse_rotation(int value);
 uint32_t tablet_button_from_str(const char *button);
 uint32_t mouse_button_from_str(const char *button);
 void tablet_button_mapping_add(uint32_t from, uint32_t to);
index 321a51977f9d177fa8f3fa7c8b35e116e6df0248..4f3f5a547031570161f96754cd94be0bc81d1d8f 100644 (file)
@@ -826,6 +826,8 @@ entry(xmlNode *node, char *nodename, char *content)
                } else {
                        wlr_log(WLR_ERROR, "Invalid value for <resize popupShow />");
                }
+       } else if (!strcasecmp(nodename, "rotate.tablet")) {
+               rc.tablet.rotation = tablet_parse_rotation(atoi(content));
        } else if (!strcasecmp(nodename, "button.map.tablet")) {
                button_map_from = tablet_button_from_str(content);
        } else if (!strcasecmp(nodename, "to.map.tablet")) {
index 5d138af3097c05697b4416de482d068f62029907..81460db1bfbd12d69de7551094e120382ea677b1 100644 (file)
@@ -7,6 +7,24 @@
 #include "config/tablet.h"
 #include "config/rcxml.h"
 
+enum rotation tablet_parse_rotation(int value)
+{
+       switch (value) {
+       case 0:
+               return LAB_ROTATE_NONE;
+       case 90:
+               return LAB_ROTATE_90;
+       case 180:
+               return LAB_ROTATE_180;
+       case 270:
+               return LAB_ROTATE_270;
+       default:
+               wlr_log(WLR_ERROR, "Invalid value for tablet rotation: %d", value);
+               break;
+       }
+       return LAB_ROTATE_NONE;
+}
+
 uint32_t tablet_button_from_str(const char *button)
 {
        if (!strcasecmp(button, "Tip")) {