Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions TabletDriverGUI/App.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Application x:Class="TabletDriverGUI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
</Application.Resources>
<Application.Resources>
</Application.Resources>
</Application>
6 changes: 1 addition & 5 deletions TabletDriverGUI/Area.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,9 @@ public double Rotation
}
public bool IsEnabled;



private double _rotation;
private readonly double[] _rotationMatrix;
private readonly Point[] _corners;

private readonly Point[] _corners;

//
// Constructors
Expand Down Expand Up @@ -238,6 +235,5 @@ public override string ToString()
Utils.GetNumberString(Height) +
"]";
}

}
}
91 changes: 50 additions & 41 deletions TabletDriverGUI/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@ namespace TabletDriverGUI
[XmlRootAttribute("Configuration", IsNullable = true)]
public class Configuration
{
public int ConfigVersion;
public const string DEFAULT_CONFIG_FILE = "config/configs/Default.xml";

public int ConfigVersion;
public string TabletName;

public Area ScreenArea;

[XmlArray("ScreenAreas")]
[XmlArrayItem("ScreenArea")]
public Area[] ScreenAreas;
public Area SelectedScreenArea;

public Area SelectedScreenArea;
public Area TabletArea;

[XmlArray("TabletAreas")]
[XmlArrayItem("TabletArea")]
public Area[] TabletAreas;

public Area SelectedTabletArea;

public Area TabletFullArea;
Expand All @@ -37,6 +40,7 @@ public enum OutputPositioning
Absolute = 0,
Relative = 1
}

public enum OutputModes
{
Standard = 0,
Expand All @@ -63,17 +67,20 @@ public class AntiSmoothingSetting
public double Velocity;
public double Shape;
public double Compensation;

public AntiSmoothingSetting()
{
Enabled = false;
Velocity = 0;
Shape = 0.5;
Compensation = 0;
}
};
}

[XmlArray("AntiSmoothingSettingsList")]
[XmlArrayItem("AntiSmoothingSettings")]
public AntiSmoothingSetting[] AntiSmoothingSettings;

public bool AntiSmoothingOnlyWhenHover;
public double AntiSmoothingDragMultiplier;

Expand All @@ -83,11 +90,13 @@ public AntiSmoothingSetting()
[XmlArray("ButtonMap")]
[XmlArrayItem("Button")]
public string[] ButtonMap;

public bool DisableButtons;

[XmlArray("TabletButtonMap")]
[XmlArrayItem("Button")]
public string[] TabletButtonMap;

public bool DisableTabletButtons;

public double PressureSensitivity;
Expand Down Expand Up @@ -123,6 +132,7 @@ public class TabletViewSettings
public Point OffsetPressure;
public bool FadeInOut;
public bool Borderless;

public TabletViewSettings()
{
BackgroundColor = "#FFFFFF";
Expand All @@ -141,7 +151,8 @@ public TabletViewSettings()
FadeInOut = false;
Borderless = false;
}
};
}

public TabletViewSettings TabletView;

public bool AutomaticRestart;
Expand All @@ -157,17 +168,15 @@ public class Preset
{
public string Name;
public Action<Configuration> Action;

public Preset(string name, Action<Configuration> action)
{
Name = name;
Action = action;
}
public override string ToString()
{
return Name;
}
}

public override string ToString() => Name;
}

public Configuration()
{
Expand All @@ -176,21 +185,25 @@ public Configuration()
// Screen Map
ScreenArea = null;
ScreenAreas = new Area[3];

for (int i = 0; i < ScreenAreas.Length; i++)
{
ScreenAreas[i] = new Area(0, 0, 0, 0)
{
IsEnabled = false
};
}

ScreenAreas[0].IsEnabled = true;
ScreenAreas[1] = new Area(1000, 500, 500, 250);

// Tablet area
TabletArea = null;
TabletAreas = new Area[ScreenAreas.Length];

for (int i = 0; i < GetAreaCount(); i++)
TabletAreas[i] = new Area(100, 56, 50, 28);

TabletFullArea = new Area(100, 50, 50, 25);
Mode = OutputModes.Standard;
ForceAspectRatio = true;
Expand All @@ -203,7 +216,9 @@ public Configuration()
DisableButtons = false;

TabletButtonMap = new string[16];

for (int i = 0; i < 16; i++) TabletButtonMap[i] = "";

DisableTabletButtons = false;

PressureSensitivity = 0;
Expand All @@ -222,12 +237,14 @@ public Configuration()

AntiSmoothingEnabled = false;
AntiSmoothingSettings = new AntiSmoothingSetting[5];

for (int i = 0; i < AntiSmoothingSettings.Length; i++)
AntiSmoothingSettings[i] = new AntiSmoothingSetting();

AntiSmoothingDragMultiplier = 1.0;
AntiSmoothingOnlyWhenHover = false;

CustomCommands = new string[] { "" };
CustomCommands = new string[0];

WindowWidth = 700;
WindowHeight = 700;
Expand All @@ -252,17 +269,15 @@ public int GetAreaCount()
{
if (ScreenAreas.Length <= TabletAreas.Length)
return ScreenAreas.Length;

return TabletAreas.Length;
}


//
// Get maximum number of areas
//
public int GetMaxAreaCount()
{
return 5;
}
public int GetMaxAreaCount() => 5;


//
Expand Down Expand Up @@ -305,53 +320,47 @@ public void SetAntiSmoothingSetting(int index, bool enabled, double velocity, do
AntiSmoothingSettings[index].Compensation = compensation;
}


//
// Write configuration to a XML file
//
public void Write(string filename)
{
var fileWriter = new StreamWriter(filename);
var serializer = new XmlSerializer(typeof(Configuration));
var xmlWriterSettings = new XmlWriterSettings { Indent = true };

XmlSerializer serializer = new XmlSerializer(typeof(Configuration));
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings() { Indent = true };
XmlWriter writer = XmlWriter.Create(fileWriter, xmlWriterSettings);
try
{
serializer.Serialize(writer, this);
}
catch (Exception)
using (var file = new StreamWriter(filename))
{
fileWriter.Close();
throw;
var writer = XmlWriter.Create(file, xmlWriterSettings);

serializer.Serialize(file, this);
}
fileWriter.Close();
}

//
// Create configuration from a XML file
//
public static Configuration CreateFromFile(string filename)
{
Configuration config = null;
if (!File.Exists(filename))
throw new FileNotFoundException("Could not find configuration file", filename);

var serializer = new XmlSerializer(typeof(Configuration));
var settings = new XmlWriterSettings() { Indent = true };
var reader = XmlReader.Create(filename);

try
using (var file = File.OpenRead(filename))
{
config = (Configuration)serializer.Deserialize(reader);
return (Configuration)serializer.Deserialize(file);
}
catch (Exception)
{
reader.Close();
throw;
}
reader.Close();
return config;
}

}
public static string GetSelectedConfig()
{
if (!File.Exists("config/.current"))
return DEFAULT_CONFIG_FILE;

return File.ReadAllText("config/.current").Trim('\r', '\n', '\t', ' ');
}

public static void SetSelectedConfig(string path)
=> File.WriteAllText("config/.current", path);
}
}
Loading