public static TabletProperties ConvertHawku(IEnumerable <string> hawkuConfigLines) { var tablet = new TabletProperties(); var lines = hawkuConfigLines.ToList(); tablet.TabletName = lines.FindValue <string>("Name").Replace("\"", ""); if (lines[0].StartsWith("HIDTablet")) { // Tablet descriptors var info = lines.FindValue <string>("HIDTablet").Split(' '); tablet.VendorID = int.Parse(info[0].Replace("0x", ""), NumberStyles.HexNumber); tablet.ProductID = int.Parse(info[1].Replace("0x", ""), NumberStyles.HexNumber); tablet.InputReportLength = lines.FindValue <uint>("ReportLength"); // Tablet properties tablet.Width = lines.FindValue <float>("Width"); tablet.Height = lines.FindValue <float>("Height"); tablet.MaxX = lines.FindValue <float>("MaxX"); tablet.MaxY = lines.FindValue <float>("MaxY"); tablet.MaxPressure = lines.FindValue <uint>("MaxPressure"); var mask = lines.FindValue <string>("DetectMask"); tablet.MinimumRange = uint.Parse(mask.Replace("0x", ""), NumberStyles.HexNumber); Log.Write("Hawku Converter", "Converted HIDTablet configuration: " + tablet.TabletName); } else if (lines[0].StartsWith("USBTablet")) { return(null); } else { throw new ArgumentException("Configuration is not a hawku configuration."); } return(tablet); }
public Task <bool> SetTablet(TabletProperties tablet) { var match = Driver.TryMatch(tablet); TabletChanged?.Invoke(this, match ? tablet : null); return(Task.FromResult(match)); }
public bool Open(TabletProperties tablet) { Log.Write("Detect", $"Searching for tablet '{tablet.TabletName}'"); try { var matching = Devices.Where(d => d.ProductID == tablet.ProductID && d.VendorID == tablet.VendorID); var tabletDevice = matching.FirstOrDefault(d => d.GetMaxInputReportLength() == tablet.InputReportLength); var parser = PluginManager.ConstructObject <IDeviceReportParser>(tablet.ReportParserName) ?? new TabletReportParser(); if (tabletDevice == null && !string.IsNullOrEmpty(tablet.CustomReportParserName)) { tabletDevice = matching.FirstOrDefault(d => d.GetMaxInputReportLength() == tablet.CustomInputReportLength); if (tabletDevice != null) { parser = PluginManager.ConstructObject <IDeviceReportParser>(tablet.CustomReportParserName); } } TabletProperties = tablet; var tabletOpened = Open(tabletDevice, parser); if (tabletOpened && tablet.AuxReportLength > 0) { var auxDevice = matching.FirstOrDefault(d => d.GetMaxInputReportLength() == tablet.AuxReportLength); var auxReportParser = PluginManager.ConstructObject <IDeviceReportParser>(tablet.AuxReportParserName) ?? new AuxReportParser(); if (!OpenAux(auxDevice, auxReportParser)) { Log.Debug("Failed to open aux device!", true); } } return(tabletOpened); } catch (ArgumentOutOfRangeException ex) { if (Debugging) { Log.Exception(ex); } if (PlatformInfo.IsLinux && typeof(UCLogicInfo.VendorIDs).EnumContains(tablet.VendorID)) { Log.Write("Detect", "Failed to get device input report length. " + "Ensure the 'hid-uclogic' module is disabled.", true); } else { Log.Write("Detect", "Failed to get device input report length. " + "Visit the wiki (https://github.com/InfinityGhost/OpenTabletDriver/wiki) for more information.", true); } return(false); } catch (Exception ex) { Log.Exception(ex); return(false); } }
public TabletProperties DetectTablets() { var configDir = new DirectoryInfo(AppInfo.Current.ConfigurationDirectory); if (configDir.Exists) { foreach (var file in configDir.EnumerateFiles("*.json", SearchOption.AllDirectories)) { var tablet = TabletProperties.Read(file); if (SetTablet(tablet)) { return(GetTablet()); } } } return(null); }
public TabletProperties DetectTablets() { var configDir = new DirectoryInfo(AppInfo.Current.ConfigurationDirectory); if (configDir.Exists) { foreach (var file in configDir.EnumerateFiles("*.json", SearchOption.AllDirectories)) { var tablet = TabletProperties.Read(file); if (SetTablet(tablet)) { return(GetTablet()); } } } else { Log.Write("Detect", $"The configuration directory '{configDir.FullName}' does not exist.", LogLevel.Error); } return(null); }
public bool SetTablet(TabletProperties tablet) { return(Driver.TryMatch(tablet)); }