diff --git a/.modules/OpenTabletDriver b/.modules/OpenTabletDriver index 69a67b4..aab2d42 160000 --- a/.modules/OpenTabletDriver +++ b/.modules/OpenTabletDriver @@ -1 +1 @@ -Subproject commit 69a67b4f48641e3e6079b1f53b4a6a6d9f9249c3 +Subproject commit aab2d42a226bc3b06bb77fbbc0b53a3b5924df7a diff --git a/OpenTabletDriver.udev/Program.cs b/OpenTabletDriver.udev/Program.cs index 4a27634..681d508 100755 --- a/OpenTabletDriver.udev/Program.cs +++ b/OpenTabletDriver.udev/Program.cs @@ -61,11 +61,14 @@ static IEnumerable CreateRules(DirectoryInfo directory) if (string.IsNullOrWhiteSpace(tablet.Name)) continue; yield return string.Format("# {0}", tablet.Name); - - foreach (var rule in RuleCreator.CreateAccessRules(tablet, "hidraw", "0666")) + + foreach (var rule in RuleCreator.CreateAccessRules(tablet, "hidraw")) + yield return rule; + + foreach (var rule in RuleCreator.CreateAccessRules(tablet, "usb")) yield return rule; - - foreach (var rule in RuleCreator.CreateAccessRules(tablet, "usb", "0666")) + + foreach (var rule in RuleCreator.CreateModuleRules(tablet)) yield return rule; if (tablet.Attributes.TryGetValue("libinputoverride", out var value) && (value == "1" || value.ToLower() == "true")) diff --git a/OpenTabletDriver.udev/RuleCreator.cs b/OpenTabletDriver.udev/RuleCreator.cs index 2731fa8..391443e 100755 --- a/OpenTabletDriver.udev/RuleCreator.cs +++ b/OpenTabletDriver.udev/RuleCreator.cs @@ -9,6 +9,12 @@ namespace OpenTabletDriver.udev { internal static class RuleCreator { + private static IEnumerable GetDistinctIdentifiers(TabletConfiguration config) + { + var allIdentifiers = config.DigitizerIdentifiers.Concat(config.AuxilaryDeviceIdentifiers); + return allIdentifiers.Distinct(new IdentifierComparer()); + } + public static Rule CreateAccessRule(string module, string subsystem) { return new Rule( @@ -19,13 +25,7 @@ public static Rule CreateAccessRule(string module, string subsystem) ); } - private static IEnumerable GetDistinctIdentifiers(TabletConfiguration config) - { - var allIdentifiers = config.DigitizerIdentifiers.Concat(config.AuxilaryDeviceIdentifiers); - return allIdentifiers.Distinct(new IdentifierComparer()); - } - - public static IEnumerable CreateAccessRules(TabletConfiguration tablet, string subsystem, string mode) + public static IEnumerable CreateAccessRules(TabletConfiguration tablet, string subsystem) { foreach (var id in GetDistinctIdentifiers(tablet)) { @@ -33,7 +33,7 @@ public static IEnumerable CreateAccessRules(TabletConfiguration tablet, st new Token("SUBSYSTEM", Operator.Equal, subsystem), new ATTRS("idVendor", Operator.Equal, id.VendorID.ToHexFormat()), new ATTRS("idProduct", Operator.Equal, id.ProductID.ToHexFormat()), - new Token("MODE", Operator.Assign, mode) + new Token("TAG", Operator.Add, "uaccess") ); } } @@ -50,5 +50,20 @@ public static IEnumerable CreateOverrideRules(TabletConfiguration tablet) ); } } + + public static IEnumerable CreateModuleRules(TabletConfiguration tablet) + { + foreach (var id in GetDistinctIdentifiers(tablet)) + { + var module = id.VendorID == 1386 ? "wacom" : "hid_uclogic"; + yield return new Rule( + new Token("SUBSYSTEM", Operator.Equal, "input"), + new ATTRS("idVendor", Operator.Equal, id.VendorID.ToHexFormat()), + new ATTRS("idProduct", Operator.Equal, id.ProductID.ToHexFormat()), + new Token("ACTION", Operator.Assign, "add"), + new Token("PROGRAM", Operator.Assign, $"/sbin/rmmod {module}") + ); + } + } } } \ No newline at end of file