No functional changes.

We need to assign the custom ID_INPUT_* tags to uinput devices so it's easiest
to generate a specific match string and append all the custom tags to it.

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 tools/generate-udev-rules.c | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/tools/generate-udev-rules.c b/tools/generate-udev-rules.c
index b7d1381..379d6cc 100644
--- a/tools/generate-udev-rules.c
+++ b/tools/generate-udev-rules.c
@@ -52,16 +52,12 @@ static void print_udev_header (void)
        printf ("\n");
 }
 
-static void print_udev_entry_for_match (WacomDevice *device, const WacomMatch 
*match,
-                                       WacomBusType bus_type_filter)
+static char * generate_device_match(WacomDevice *device, const WacomMatch 
*match)
 {
        WacomBusType type       = libwacom_match_get_bustype (match);
        int          vendor     = libwacom_match_get_vendor_id (match);
        int          product    = libwacom_match_get_product_id (match);
-       char         *matchstr;
-
-       if (bus_type_filter != type)
-               return;
+       char         *matchstr = NULL;
 
        switch (type) {
                case WBUSTYPE_USB:
@@ -76,9 +72,14 @@ static void print_udev_entry_for_match (WacomDevice *device, 
const WacomMatch *m
                        break;
                default:
                        /* Not sure how to deal with serials  */
-                       return;
+                       return NULL;
        }
 
+       return matchstr;
+}
+
+static void print_udev_entry_matchstr(WacomDevice *device, const char 
*matchstr)
+{
        printf ("# %s\n", libwacom_get_name (device));
        /* unset joystick, set tablet */
        printf ("%s ENV{ID_INPUT}=\"1\", ENV{ID_INPUT_JOYSTICK}=\"\", 
ENV{ID_INPUT_TABLET}=\"1\"\n", matchstr);
@@ -93,8 +94,6 @@ static void print_udev_entry_for_match (WacomDevice *device, 
const WacomMatch *m
        /* set ID_INPUT_TABLET_PAD for pads */
        if (libwacom_get_num_buttons (device) > 0)
                printf ("ATTRS{name}==\"* Pad\", %s 
ENV{ID_INPUT_TABLET_PAD}=\"1\"\n", matchstr);
-
-       g_free (matchstr);
 }
 
 static void print_uinput_entry_for_match (WacomDevice *device, const 
WacomMatch *match,
@@ -141,8 +140,20 @@ static void print_udev_entry (WacomDevice *device, 
WacomBusType bus_type_filter)
        const WacomMatch **matches, **match;
 
        matches = libwacom_get_matches(device);
-       for (match = matches; *match; match++)
-               print_udev_entry_for_match(device, *match, bus_type_filter);
+       for (match = matches; *match; match++) {
+               WacomBusType type = libwacom_match_get_bustype (*match);
+               char *matchstr;
+
+               if (bus_type_filter != type)
+                       continue;
+
+               matchstr = generate_device_match (device, *match);
+               if (matchstr == NULL)
+                       continue;
+
+               print_udev_entry_matchstr (device, matchstr);
+               g_free (matchstr);
+       }
 }
 
 static void print_udev_trailer (void)
-- 
2.3.5


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to