diff --git a/README.md b/README.md index d7acb0f..d3daa46 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,156 @@ + +[![All Releases](https://img.shields.io/github/downloads/Devocub/TabletDriver/total.svg?style=for-the-badge&logo=appveyor)](https://github.com/Devocub/TabletDriver/releases) +[![All Releases](https://img.shields.io/github/downloads/Devocub/TabletDriver/latest/total.svg?style=for-the-badge&logo=appveyor)](https://github.com/Devocub/TabletDriver/releases/latest) +![Alt text](https://img.shields.io/github/downloads/Devocub/TabletDriver/v0.1.5.5/TabletDriverV0.1.5.5.Devocub.Edition.zip) + +This is a my modified version of hawku's tablet driver. +Intended for Wacom tablets but will work with other tablets but not expect everything to work correct. +Comparison with original, added: +* Antichatter +* Prediction +* Mouse Wheel + +## Download +### https://github.com/Devocub/TabletDriver/releases +### Installing +1) If you have already Driver installed just: **close it, and unzip new version with replacing files**. +Your config will be preserved. Same for updating. + +If you have not installed the driver then: +follow instructions here: https://github.com/Devocub/TabletDriver#installation and after return to step 1. +My version based on 0.1.5 version of driver. + +_____ + # PRESETS + +### Smooth 2 + prediction = accurate with small overshot +[Plot link](http://yotx.ru/#!1/3_8hTp/4/0@A9YW1PuH@xvHewbMYT/tX0PmbQGp5H5j3/Cx3/F3x@ZD4TT9g/2tw72jRjC/9r@xh70YHd9Ywe8ubUL3oJu7R/sk2jYjZ1TxuPpFuNx6/Jid39rf2v79@@fv7Gxt3kAQZztgrcgO7vgLcgWdAtysX@wT6JhN0AHjMcd0BbjEXSwu7@1DwQ=) +![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/Smooth%202%20%2B%20prediction%20%3D%20accurate%20with%20small%20overshot.png) +Video: +[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/aZWoWwSmlEw/0.jpg)](https://www.youtube.com/watch?v=aZWoWwSmlEw) +Video - same but with prediction disabled: +[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/vimw1kihegk/0.jpg)](https://www.youtube.com/watch?v=vimw1kihegk) + +____________________ +### Straight - Pretty good realtime accurate +[Plot link](http://yotx.ru/#!1/3_8hTp/4/0@A9YW1PuH@xvHewbMYT/tX0PmbQGp5H5j3/Cx3/F3x@ZD4TT9g/2tw72jRjC/9r@xh70AILYXd/YOgBvbu2CLw6gW/sH@yQadmPnlPF4usV43Lq82N3f2t/a/v37529s7G3uQA52wQcQ2C74AAKCHkDO9g/2STTsBuiA8bgD2mI8gg5297f2AQc=) +![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/Straight%20-%20Pretty%20good%20realtime%20accurate.png) +Video: +[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/SMrSGq8IvaU/0.jpg)](https://www.youtube.com/watch?v=SMrSGq8IvaU) + +____________________ +### Big latency and big prediction +[Plot link](http://yotx.ru/#!1/3_8hTp/4/0@A9YW1PuH@xvHewbMYT/tX0PmbQGp5H5j3/Cx3/F3x@ZD4TT9g/2tw72jRjC/9r@xh70YHd9Ywe8ubUL3oJu7R/sk2jYjZ1TxuPpFuNx6/Jid39rf2v79@@fv7Gxt7kFOdsFH0AudsEX0API6f7BPomG3QAdMB53QFuMR9DB7v7WPgI=) +![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/Big%20latency%20and%20big%20prediction.png) +Video: +[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/k_KMV3Ujvjo/0.jpg)](https://www.youtube.com/watch?v=k_KMV3Ujvjo) + +____________________ +### Fun +[Plot link](http://yotx.ru/#!1/3_8hTp/4/0%40A9YW1PuH%40xvHewbMYT/tX0PmbQGp5H5j3/CRwBpTQn8JQP/4I8bpDXlLuPRQyatwWlk/uOf8PFf8fdH5gPhtMcNLCG1trt/sH%402b8QQ/tf2t7Z///75Gxt7m1u74AMI4mwXfAHd2j/YJ9GwG1swBOPxgPF4sLu/tb%40xB93aXd%404AG9u7YK3DqBb%40wf7JBp2Y%40eU8Xi6xXjcurzY3d/aBwU=) +![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/Fun.png) +Video: +[![IMAGE ALT TEXT HERE](https://img.youtube.com/vi/KthrzJrCrGc/0.jpg)](https://www.youtube.com/watch?v=KthrzJrCrGc) + + + +_____ + # Antichatter + +Antichatter feature is meant to prevent cursor chattering/rattling/shaking/trembling when it's almost doesn't moves and/or too high to prevent tablet noise. +Antichatter in it's primary form is useful for tablets which doesn't have any smoothing (including hardware smoothing). +Antichatter requires smoothing filter enabled for work. Latency and Rate values do affect on antichatter settings. + +Formula for smoothing is: +y(x) = (x + OffsetX)^(Strength\*-1)\*Multiplier+OffsetY +Where **x** is pen speed. And **y(x)** is value on which smoothing will be increased. Slower speed - more smoothing. Faster speed - less smoothing. +![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/formula_example.png) +[Link](http://yotx.ru/#!1/3_8hTp/4/0%40A9YW1PuH%40xvHewbMYT/tX0PmbQGp5H5j3/Cx3/F3x%40ZD4TT9g/2tw72jRjC/9r%40xh50C3K2u74BAm9u7YK3Dg6gW/sH%40yQadmPnlPF4usV43Lq82N3f2gcF) + +Strength, Multiplier, OffsetX and OffsetY is values which you can change in driver. + +**Strength**: is strength, useful values are from 1 up to 10. Higher values make smoothing more sharper, lower are smoother. + +**Multiplier**: zoomIns and zoomOuts the [plot](http://yotx.ru/#!1/3_8hTp/4/0%40A9YW1PuH%40xvHewbMYT/tX0PmbQGp5H5j3/Cx3/F3x%40ZD4TT9g/2tw72jRjC/9r%40xh50C3K2u74BAm9u7YK3Dg6gW/sH%40yQadmPnlPF4usV43Lq82N3f2gcF). Useful values are from 1 up to 1000. Makes smoothing softer. Default value is 1, means nothing changed. + +**Offset X**: Moves the [plot](http://yotx.ru/#!1/3_8hTp/4/0%40A9YW1PuH%40xvHewbMYT/tX0PmbQGp5H5j3/Cx3/F3x%40ZD4TT9g/2tw72jRjC/9r%40xh50C3K2u74BAm9u7YK3Dg6gW/sH%40yQadmPnlPF4usV43Lq82N3f2gcF) to the right. Negative values moves the [plot](http://yotx.ru/#!1/3_8hTp/4/0%40A9YW1PuH%40xvHewbMYT/tX0PmbQGp5H5j3/Cx3/F3x%40ZD4TT9g/2tw72jRjC/9r%40xh50C3K2u74BAm9u7YK3Dg6gW/sH%40yQadmPnlPF4usV43Lq82N3f2gcF) to the left. Higher values make smoothing weaker, lower values stornger and activate stronger smoothing earlier (in terms of cursor speed). Useful values are from -1 to 2. Default values is 0. + +**Offset Y**: Moves the [plot](http://yotx.ru/#!1/3_8hTp/4/0%40A9YW1PuH%40xvHewbMYT/tX0PmbQGp5H5j3/Cx3/F3x%40ZD4TT9g/2tw72jRjC/9r%40xh50C3K2u74BAm9u7YK3Dg6gW/sH%40yQadmPnlPF4usV43Lq82N3f2gcF) up. Useful values are from roughly -1 up to 10. Look at the plot, if strength of smoothing is near 0 then it provides almost raw data with lowest delay. If value is near 1 then it's usual smoothing. Also it defines minimal amount of smoothing. OffsetY 10 will make smoothing x10 (and latency). OffsetY 0.5 will make smoothing roughly twice weaker (and latency will be roughly twice less), 0.3 roughly triple weaker, etc. Default value is 1. + + +## Presets +**Simple**: Latency 5-50 ms, Strength 2-3, Multiplier 1, OffsetX 0, OffsetY 1. +[Interactive link](http://yotx.ru/#!1/3_8hTp/4/0%40A9YW1PuH%40xvHewbMYT/tX0PmbQGp5H5j3/Cx3/F3x%40ZD4TT9g/2tw72jRjC/9r%40xh70YHd94wK8ubUL3oJu7R/sk2jYjZ1TxuPpFuNx6/Jid39rHwM=) +![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/simple.png) +_____ +**Smooth**: Latency ~10 ms, Strength 3, Multiplier 100, OffsetX 1.5, OffsetY 1. +Change OffsetX between 0-2 to switch between stickyness and smooth. +Increase Strength to 4-10 to get more sharp. Decrease Strength to 1-2 to get more smoothing. +[Interactive link](http://yotx.ru/#!1/3_8hTp/4/0%40A9YW1PuH%40xvHewbMYT/tX0PmbQGp5H5j3/Cx3/F3x%40ZD4TT9g/2tw72jRjC/9r%40xh50C3K2u75xAd7c2gVvHRxAt/YP9kk07MbOKePxdIvxuHV5sbu/tQ8E) +![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/smooth.png) +_____ +**Straight**: Latency 20-40ms, Strength 20, Multiplier 1, OffsetX 0.7, OffsetY 0.6. This preset aren't good for high hovering. Because of OffsetY < 1 actual latency is less. +[Interactive link](http://yotx.ru/#!1/3_h/sH%401sH%400YM4X9t/2j/YH/rYN%40IIfyv7W/sQQ8giN31jZ0D8ObWLngLegA53T/YJ9GwGzunjMfTLcbj1uXF7v7WPgI=) +![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/straight.png) +_____ + +**Low latency**: Set Offset Y to 0 (and could be useful to set Latency to 1-10 ms but with some settings it can break smoothing, usually OffsetY 0 is enough) to being able to go to lowest latency. + +_____ + +# Prediction +How it works: It adds a predicted point to smoothing algoritm. It helps to preserve sharpness of movement, help with small movements. +Low values (~<10-15ms) of smoothing latency can cause problems for cursor movement. It's very preffered to use at least 10-15ms of smoothing latency, 20-40 ms is even better and recommended. In sum cursor can even outdistance real position (similar to Wacom 6.3.9w5 drivers). + +Formula for prediction is: +y(x) = 1/cosh((x-OffsetX)\*Sharpness)\*Strength+OffsetY +Where **x** is pen speed. And **y(x)** is strength of prediction. +![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/prediction_formula_example.png) +[Link](http://yotx.ru/#!1/3_8hTp/4/0%40A9YW1PuH%40xvHewbMYT/tX0PmbQGp5H5j3/CRwBpTQn8JQP/4PsH%401sH%400YM4X9tf2v79%40%40fv7Gxt7kFudgFb0G2dsEXkAPoAeRg/2CfRMNubMEQjMcDxuPB7v7WPgI=) + +Strength, Sharpness, OffsetX and OffsetY is values which you can change in driver. + +**Strength**: is max of peak of prediction. Useful values are from 0 to 2, or up to 3-4 depends of latency. + +**Sharpness**: changes how wide will be Strength. + +**OffsetX**: center of peak of prediction. Useful values are from 0.5 up to 5-7. Increase value to shift cursor speedup to bigger movements. + +**OffsetY**: Moves the plot up/down (positiove/negative values). Also defines minimal amount of prediction. + +### Presets: +**Simple+**: +Staright or Smooth preset of smoothing + +Strength 1-3 (for 5-50 ms respectively), Sharpness 1, OffsetX 0.8, OffsetY 0 +[Interactive link](http://yotx.ru/#!1/3_8hTp/4/0%40A9YW1PuH%40xvHewbMYT/tX0PmbQGp5H5j3/CRwBpTQn8JQP/4PsH%402f7Rgzhf21/Y2v79%40%40fv7Gxt3kAge2CtyAHu%40AdyBn0AHKwu3%40wT6JhN7ZgCMbjAePxYHd/ax8D) +![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/prediction_simplesmooth.png) +_____ +**Straight+**: +Staright preset of smoothing + +Strength 0.3, Sharpness 0.7, OffsetX 2, OffsetY 0.3 +[Interactive link](http://yotx.ru/#!1/3_8hTp/4/0@A9YW1PuH@xvHewbMYT/tX0PmbQGp5H5j3/CRwBpTQn8JQP/4PsH@2f7Rgzhf21/Y2v79@@fv7Gxt7kDOdgFH0AQu@ADyAX0AHKxu3@wT6JhN7ZgCMbjAePxYHd/ax8D) +![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/prediction_straight.png) +_____ +**Fun**: +Smoothing: Latency 40ms, Strength 3, Multiplier 10, OffsetX 1, OffsetY 1 + +Prediction: Strength 4, Sharpness 0.75, OffsetX 2.5, OffsetY 1 +[Interactive link](http://yotx.ru/#!1/3_8hTp/4/0%40A9YW1PuH%40xvHewbMYT/tX0PmbQGp5H5j3/CRwBpTQn8JQP/4I8bpDXlLuPRQyatwWlk/uOf8PFf8fdH5gPhtMcNLCG1trt/sH%402b8QQ/tf2t7Z///75Gxt7m1u74AMI4mwXfAHd2j/YJ9GwG1swBOPxgPF4sLu/tb%40xB93aXd%404AG9u7YK3DqBb%40wf7JBp2Y%40eU8Xi6xXjcurzY3d/aBwU=) +![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/prediction_fun.png) + + +______________________ +______________________ + + +![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/3.png) +![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/4.png) +![Alt text](https://raw.githubusercontent.com/Devocub/TabletDriver/master/images/7.png) + +## Star History +![Star History Chart](https://api.star-history.com/svg?repos=Devocub/TabletDriver&type=Date) + + + # TabletDriver This is a low latency graphics tablet driver that is meant to be used with rhythm game [osu!](https://osu.ppy.sh/home) @@ -12,7 +165,7 @@ The GUI minimizes to system tray / notification area. You can reopen the GUI by ## Download -### http://hwk.fi/TabletDriver/TabletDriverV0.1.0.zip +### http://hwk.fi/TabletDriver/TabletDriverV0.1.5.zip # @@ -26,27 +179,34 @@ The GUI minimizes to system tray / notification area. You can reopen the GUI by ### Supported tablets: - Wacom CTL-470 + - Wacom CTH-470 - Wacom CTL-471 - Wacom CTL-472 - Wacom CTL-480 - Wacom CTH-480 - Wacom CTL-490 - - XP Pen G430 - - XP Pen G640 - - Huion 420 - - Huion H640P - - Gaomon S56K - -### Configured, but not properly tested: - - Huion H420 - - Wacom CTH-470 - - Wacom CTH-670 + - Wacom CTH-490 - Wacom CTL-671 - Wacom CTL-672 - Wacom CTL-680 - Wacom CTH-680 - - Wacom CTH-490 - Wacom PTH-451 + - Wacom PTH-850 + - XP-Pen G430 (New 2017+ "Model B") + - XP-Pen G540 Pro + - XP-Pen G640 + - Huion 420 + - Huion H420 + - Huion H430P + - Huion H640P + - Gaomon S56K + +### Configured, but not properly tested: + - Huion osu!tablet + - XP-Pen Deco 01 + - Wacom CTL-4100 USB + - Wacom CTL-4100 Bluetooth + - https://github.com/hawku/TabletDriver/blob/master/TabletDriverService/config/wacom.cfg # @@ -57,16 +217,18 @@ The GUI minimizes to system tray / notification area. You can reopen the GUI by * https://aka.ms/vs/15/release/vc_redist.x86.exe 2. Unzip the driver to a folder (Shorter path is recommended, for example `C:\Temp\TabletDriver`) -3. Uninstall all other tablet drivers. +3. Uninstall all other tablet drivers. If you have problems with uninstalling the Wacom drivers, check the GitHub issue [#1](https://github.com/hawku/TabletDriver/issues/1) 4. Run `install_vmulti_driver.bat`. It might need a restart if there is another vmulti driver installed. 5. If you have Huion or Gaomon tablet, you need to run `install_huion_64.bat`, which is in the `driver_huion` directory. 6. Start the TabletDriverGUI.exe ## Updating to a new version + 1. Unzip the new version 2. Start the TabletDriverGUI.exe ## Uninstallation + 1. Uncheck the "Run at Windows startup" option in the GUI. 2. Run `remove_vmulti_driver.bat` 3. Run `remove_huion_64.bat`, which is in the `driver_huion` directory. @@ -86,6 +248,38 @@ If you want to compile the code and don't want to install anything from the Tabl # ## Changelog +>**v0.1.5:** +> - New tablet configurations: Wacom CTL-4100 (USB only model), XP-Pen G540 Pro, XP-Pen Deco 01 and Huion osu!tablet +> Thanks to /u/THEqrunt for capturing the XP-Pen Deco 01 USB data. +> - Added `ResetDistance` command, it controls the relative mode position reset distance. +> - Code refactoring. + +>**v0.1.4:** +> - Modified the Wacom CTL-471 full area size (147.20 x 92.25 mm to 152 x 95 mm) +> - New tablet configurations: Wacom PTH-850 and Huion H430P +> The PTH-850 configuration is made by [mojobojo](https://github.com/mojobojo) +> - Regenerated the wacom.cfg with new parameters, so it now includes PTH-450/650/850 and PTK-450/650 + +>**v0.1.3:** +> - Added left handed mode / tablet invert option. +> - Added Wacom driver device support for the CTL-471 and 472 +> - Noise reduction filter improvement (`Noise` command) + +>**v0.1.2:** +> - Added experimental support for leaving the Wacom drivers installed on the system. +> Supported tablets: CTL-470, CTL-480, CTH-480, CTL-4100 +> - Added `disable_wacom_drivers.bat` and `enable_wacom_drivers.bat` to the `tools` folder. +> These scripts are used to disable and enable Wacom drivers when using the experimental Wacom driver support. +> - Added driver restart button. + +>**v0.1.1:** +> - Added support for Wacom CTL-4100 (USB and Bluetooth) +> - Added settings import / export to the main menu. +> - Added Wacom backup reader to the Wacom area tool. +> - Added tablet benchmark tools to the console output context menu (Right click). +> - Moved the `config.xml` to the `config` folder. +> - Added noise reduction filter (`Noise` command, not in the GUI) +> - Code refactoring >**v0.1.0:** > - Added `Bench` / `Benchmark` command. @@ -139,7 +333,7 @@ If you want to compile the code and don't want to install anything from the Tabl > - New tablet configurations: Wacom CTH-470, CTH-670, PTH-451 > - Fix for the smoothing filter. The filter didn't turn on when the settings were applied. > - Fix for the Huion H640P clicking problem and also added better data validation for Huion 420, -> Gaomon S56K, XP Pen G430 and G640. +> Gaomon S56K, XP-Pen G430 and G640. > - Modified click detection on CTL-490 and CTH-490 (tablet.cfg ClickPressure). >**v0.0.9:** diff --git a/TabletDriver.sln b/TabletDriver.sln index 0b37878..54020ab 100644 --- a/TabletDriver.sln +++ b/TabletDriver.sln @@ -22,8 +22,8 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6793EBBD-0EC4-4254-9573-A19ECA79F2C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6793EBBD-0EC4-4254-9573-A19ECA79F2C8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6793EBBD-0EC4-4254-9573-A19ECA79F2C8}.Debug|Any CPU.ActiveCfg = Release|Any CPU + {6793EBBD-0EC4-4254-9573-A19ECA79F2C8}.Debug|Any CPU.Build.0 = Release|Any CPU {6793EBBD-0EC4-4254-9573-A19ECA79F2C8}.Debug|x64.ActiveCfg = Debug|Any CPU {6793EBBD-0EC4-4254-9573-A19ECA79F2C8}.Debug|x64.Build.0 = Debug|Any CPU {6793EBBD-0EC4-4254-9573-A19ECA79F2C8}.Debug|x86.ActiveCfg = Debug|Any CPU @@ -34,7 +34,8 @@ Global {6793EBBD-0EC4-4254-9573-A19ECA79F2C8}.Release|x64.Build.0 = Release|Any CPU {6793EBBD-0EC4-4254-9573-A19ECA79F2C8}.Release|x86.ActiveCfg = Release|Any CPU {6793EBBD-0EC4-4254-9573-A19ECA79F2C8}.Release|x86.Build.0 = Release|Any CPU - {3101CEC2-8F39-45FD-943B-79A488AD05EA}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {3101CEC2-8F39-45FD-943B-79A488AD05EA}.Debug|Any CPU.ActiveCfg = Release|Win32 + {3101CEC2-8F39-45FD-943B-79A488AD05EA}.Debug|Any CPU.Build.0 = Release|Win32 {3101CEC2-8F39-45FD-943B-79A488AD05EA}.Debug|x64.ActiveCfg = Debug|x64 {3101CEC2-8F39-45FD-943B-79A488AD05EA}.Debug|x64.Build.0 = Debug|x64 {3101CEC2-8F39-45FD-943B-79A488AD05EA}.Debug|x86.ActiveCfg = Debug|Win32 diff --git a/TabletDriverGUI/App.xaml.cs b/TabletDriverGUI/App.xaml.cs index 9a061a2..1072268 100644 --- a/TabletDriverGUI/App.xaml.cs +++ b/TabletDriverGUI/App.xaml.cs @@ -49,6 +49,43 @@ public App() } } + // + // Check Wacom processes + // + string[] wacomProcessNames = + { + "Pen_Tablet", + "Wacom_Tablet" + }; + + processes = Process.GetProcesses(); + foreach (Process process in processes) + { + foreach (string wacomProcessName in wacomProcessNames) + { + if (process.ProcessName.ToLower() == wacomProcessName.ToLower()) + { + try + { + process.Kill(); + } + catch (Exception) + { + MessageBox.Show( + "You have Wacom driver processes running in the background:\n " + + string.Join("\n ", wacomProcessNames) + + "\n\nPlease shutdown those before starting the GUI!", + "Error!", MessageBoxButton.OK, MessageBoxImage.Error + ); + instanceMutex.ReleaseMutex(); + Shutdown(); + return; + } + } + } + } + + MainWindow mainWindow = new MainWindow(); mainWindow.Show(); Exit += App_Exit; diff --git a/TabletDriverGUI/Configuration.cs b/TabletDriverGUI/Configuration.cs index 9f91ed9..0cc9bc5 100644 --- a/TabletDriverGUI/Configuration.cs +++ b/TabletDriverGUI/Configuration.cs @@ -15,6 +15,7 @@ public class Configuration public Area TabletFullArea; public bool ForceAspectRatio; public double Rotation; + public bool Invert; public bool ForceFullArea; public OutputModes OutputMode; public enum OutputModes @@ -26,9 +27,21 @@ public enum OutputModes public Area ScreenArea; - public double FilterLatency; - public int FilterInterval; - public bool FilterEnabled; + public double SmoothingLatency; + public int SmoothingInterval; + public bool SmoothingEnabled; + + public bool AntichatterEnabled; + public double AntichatterStrength; + public double AntichatterMultiplier; + public double AntichatterOffsetX; + public double AntichatterOffsetY; + + public bool PredictionEnabled; + public double PredictionSharpness; + public double PredictionStrength; + public double PredictionOffsetX; + public double PredictionOffsetY; public Area DesktopSize; public bool AutomaticDesktopSize; @@ -37,6 +50,7 @@ public enum OutputModes [XmlArrayItem("Button")] public int[] ButtonMap; public bool DisableButtons; + public int mouseWheelSpeed; [XmlArray("CommandsAfter")] [XmlArrayItem("Command")] @@ -52,7 +66,7 @@ public enum OutputModes public bool RunAtStartup; public string DriverPath; - public string DriverArguments; + public string DriverArguments; public bool DeveloperMode; @@ -77,21 +91,35 @@ public Configuration() ButtonMap = new int[] { 1, 2, 3 }; DisableButtons = false; + mouseWheelSpeed = 50; + + SmoothingEnabled = false; + SmoothingLatency = 0; + SmoothingInterval = 4; - FilterEnabled = false; - FilterLatency = 0; - FilterInterval = 4; + AntichatterEnabled = true; + AntichatterStrength = 3.0; + AntichatterMultiplier = 1.0; + AntichatterOffsetX = 0.0; + AntichatterOffsetY = 1.0; + + PredictionEnabled = true; + PredictionSharpness = 1.0; + PredictionStrength = 1.1; + PredictionOffsetX = 3.0; + PredictionOffsetY = 0.3; CommandsAfter = new string[] { "" }; CommandsBefore = new string[] { "" }; WindowWidth = 800; - WindowHeight = 690; + WindowHeight = 710; RunAtStartup = false; DriverPath = "bin/TabletDriverService.exe"; DriverArguments = "config/init.cfg"; + DeveloperMode = false; } diff --git a/TabletDriverGUI/MainWindow.xaml b/TabletDriverGUI/MainWindow.xaml index 4bc8fae..6a8e036 100644 --- a/TabletDriverGUI/MainWindow.xaml +++ b/TabletDriverGUI/MainWindow.xaml @@ -5,35 +5,48 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:TabletDriverGUI" mc:Ignorable="d" - Title="TabletDriverGUI" Height="670" Width="800" + Title="TabletDriverGUI" Height="786" Width="686" > - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Screen Map - - + + - You can drag the screen area with a mouse. - Drag + Control = Move area in X direction. @@ -41,13 +54,14 @@ - Drag + Shift = Move area Y direction. - Use the "Set Area" to set the screen area to single monitor or full desktop. - - - - - - - + + + + + + - + - + - - - - + + + 1920 - - - - - - - - px + + + + + + + 1080 - - - - - - - - px + + + + + + + 0 - - - - - - - - px + + + + + + + 0 - - - + + + - - - + + - + - - - + + + - - - - - + + + + + Tablet Area - - + + - You can drag the tablet area with a mouse. - Drag + Control = Move area in X direction. - Drag + Shift = Move area Y direction. - - For left handed mode, use rotation value of 180 degrees. + - For left handed mode, enable the "Left handed (Inverted)" checkbox or use a rotation value of 180 degrees. - Click Wacom Area button to type in the Wacom driver area settings. - - - + + + + + - + + + + + + - - - - - - - - + + - - - + + + Left handed + + (Inverted) + + + + + + + 0 - - - + + + + - - - - + + + + + + + + + + + Run at Windows startup - - - - - - - - - - 0.0.0 - - - - - + + + + + + + + + + + 0.0.0 + + + + + diff --git a/TabletDriverGUI/MainWindow.xaml.cs b/TabletDriverGUI/MainWindow.xaml.cs index 0fe8ee7..845106c 100644 --- a/TabletDriverGUI/MainWindow.xaml.cs +++ b/TabletDriverGUI/MainWindow.xaml.cs @@ -24,7 +24,7 @@ public partial class MainWindow : Window { // Version - public string Version = "0.1.0"; + public string Version = "0.1.5.6 Devocub Edition"; // Console stuff private List commandHistory; @@ -45,6 +45,7 @@ public partial class MainWindow : Window // Config private Configuration config; + private string configFilename; private bool isFirstStart = false; private bool isLoadingSettings; @@ -60,9 +61,6 @@ public partial class MainWindow : Window private Polygon polygonTabletAreaArrow; private TextBlock textTabletAspectRatio; - // Culture - CultureInfo cultureEnglish; - // Mouse drag private class MouseDrag { @@ -99,10 +97,6 @@ public MainWindow() // Set culture to en-US to force decimal format and etc. CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US"); - cultureEnglish = new CultureInfo("en-US"); - cultureEnglish.NumberFormat.PerMilleSymbol = ""; - cultureEnglish.NumberFormat.NumberGroupSeparator = ""; - cultureEnglish.NumberFormat.PercentDecimalSeparator = "."; // Create notify icon @@ -130,7 +124,6 @@ public MainWindow() commandHistory = new List { "" }; commandHistoryIndex = 0; - // Init tablet driver driver = new TabletDriver("TabletDriverService.exe"); driver.MessageReceived += OnDriverMessageReceived; @@ -181,20 +174,22 @@ public MainWindow() comboBoxButton2.Items.Add("Mouse " + i); comboBoxButton3.Items.Add("Mouse " + i); } + comboBoxButton2.Items.Add("Mouse Wheel"); + comboBoxButton3.Items.Add("Mouse Wheel"); comboBoxButton1.SelectedIndex = 0; comboBoxButton2.SelectedIndex = 0; comboBoxButton3.SelectedIndex = 0; // - // Filter rate ComboBox + // Smoothing rate ComboBox // - comboBoxFilterRate.Items.Clear(); - for (int i = 2; i <= 8; i++) + comboBoxSmoothingRate.Items.Clear(); + for (int i = 1; i <= 8; i++) { - comboBoxFilterRate.Items.Add((1000.0 / i).ToString("0") + " Hz"); + comboBoxSmoothingRate.Items.Add((1000.0 / i).ToString("0") + " Hz"); } - comboBoxFilterRate.SelectedIndex = 2; + comboBoxSmoothingRate.SelectedIndex = 1; // Process command line arguments ProcessCommandLineArguments(); @@ -208,6 +203,8 @@ public MainWindow() isLoadingSettings = false; } + + #region Window events // Window is closing -> Stop driver @@ -216,7 +213,7 @@ private void MainWindow_Closing(object sender, System.ComponentModel.CancelEvent notifyIcon.Visible = false; try { - config.Write("Config.xml"); + config.Write(configFilename); } catch (Exception) { @@ -227,10 +224,14 @@ private void MainWindow_Closing(object sender, System.ComponentModel.CancelEvent // Window loaded -> Start driver private void MainWindow_Loaded(object sender, RoutedEventArgs e) { + + // Configuration filename + configFilename = "config/config.xml"; + // Load configuration try { - config = Configuration.CreateFromFile("Config.xml"); + config = Configuration.CreateFromFile(configFilename); } catch (Exception) { @@ -269,8 +270,6 @@ private void MainWindow_Loaded(object sender, RoutedEventArgs e) // Update the settings back to the configuration UpdateSettingsToConfiguration(); - // Console timer - timerConsoleUpdate.Start(); // Set run at startup SetRunAtStartup(config.RunAtStartup); @@ -374,10 +373,10 @@ private void LoadSettingsFromConfiguration() // // Tablet area // - textTabletAreaWidth.Text = GetNumberString(config.TabletArea.Width); - textTabletAreaHeight.Text = GetNumberString(config.TabletArea.Height); - textTabletAreaX.Text = GetNumberString(config.TabletArea.X); - textTabletAreaY.Text = GetNumberString(config.TabletArea.Y); + textTabletAreaWidth.Text = Utils.GetNumberString(config.TabletArea.Width); + textTabletAreaHeight.Text = Utils.GetNumberString(config.TabletArea.Height); + textTabletAreaX.Text = Utils.GetNumberString(config.TabletArea.X); + textTabletAreaY.Text = Utils.GetNumberString(config.TabletArea.Y); checkBoxForceAspect.IsChecked = config.ForceAspectRatio; checkBoxForceFullArea.IsChecked = config.ForceFullArea; switch (config.OutputMode) @@ -392,9 +391,8 @@ private void LoadSettingsFromConfiguration() radioModeDigitizer.IsChecked = true; break; } - - textTabletAreaRotation.Text = GetNumberString(config.TabletArea.Rotation); - + textTabletAreaRotation.Text = Utils.GetNumberString(config.TabletArea.Rotation); + checkBoxInvert.IsChecked = config.Invert; // @@ -419,10 +417,10 @@ private void LoadSettingsFromConfiguration() // // Screen area // - textScreenAreaWidth.Text = GetNumberString(config.ScreenArea.Width, "0"); - textScreenAreaHeight.Text = GetNumberString(config.ScreenArea.Height, "0"); - textScreenAreaX.Text = GetNumberString(config.ScreenArea.X, "0"); - textScreenAreaY.Text = GetNumberString(config.ScreenArea.Y, "0"); + textScreenAreaWidth.Text = Utils.GetNumberString(config.ScreenArea.Width, "0"); + textScreenAreaHeight.Text = Utils.GetNumberString(config.ScreenArea.Height, "0"); + textScreenAreaX.Text = Utils.GetNumberString(config.ScreenArea.X, "0"); + textScreenAreaY.Text = Utils.GetNumberString(config.ScreenArea.Y, "0"); // @@ -430,8 +428,8 @@ private void LoadSettingsFromConfiguration() // if (config.AutomaticDesktopSize) { - textDesktopWidth.Text = GetNumberString(GetVirtualDesktopSize().Width); - textDesktopHeight.Text = GetNumberString(GetVirtualDesktopSize().Height); + textDesktopWidth.Text = Utils.GetNumberString(GetVirtualDesktopSize().Width); + textDesktopHeight.Text = Utils.GetNumberString(GetVirtualDesktopSize().Height); config.DesktopSize.Width = GetVirtualDesktopSize().Width; config.DesktopSize.Height = GetVirtualDesktopSize().Height; textDesktopWidth.IsEnabled = false; @@ -439,8 +437,8 @@ private void LoadSettingsFromConfiguration() } else { - textDesktopWidth.Text = GetNumberString(config.DesktopSize.Width); - textDesktopHeight.Text = GetNumberString(config.DesktopSize.Height); + textDesktopWidth.Text = Utils.GetNumberString(config.DesktopSize.Width); + textDesktopHeight.Text = Utils.GetNumberString(config.DesktopSize.Height); } checkBoxAutomaticDesktopSize.IsChecked = config.AutomaticDesktopSize; @@ -449,7 +447,7 @@ private void LoadSettingsFromConfiguration() if (config.ForceAspectRatio) { config.TabletArea.Height = config.TabletArea.Width / (config.ScreenArea.Width / config.ScreenArea.Height); - textTabletAreaHeight.Text = GetNumberString(config.TabletArea.Height); + textTabletAreaHeight.Text = Utils.GetNumberString(config.TabletArea.Height); textTabletAreaHeight.IsEnabled = false; } @@ -458,8 +456,8 @@ private void LoadSettingsFromConfiguration() // Move tablet area to a valid position // config.TabletArea.MoveInside(config.TabletFullArea); - textTabletAreaX.Text = GetNumberString(config.TabletArea.X); - textTabletAreaY.Text = GetNumberString(config.TabletArea.Y); + textTabletAreaX.Text = Utils.GetNumberString(config.TabletArea.X); + textTabletAreaY.Text = Utils.GetNumberString(config.TabletArea.Y); // @@ -467,6 +465,7 @@ private void LoadSettingsFromConfiguration() // if (config.ButtonMap.Count() == 3) { + textMouseWheelSpeed.Text = Utils.GetNumberString(config.mouseWheelSpeed); comboBoxButton1.SelectedIndex = config.ButtonMap[0]; comboBoxButton2.SelectedIndex = config.ButtonMap[1]; comboBoxButton3.SelectedIndex = config.ButtonMap[2]; @@ -479,24 +478,83 @@ private void LoadSettingsFromConfiguration() // - // Filter + // Smoothing filter // - checkBoxFilter.IsChecked = config.FilterEnabled; - textFilterLatency.Text = GetNumberString(config.FilterLatency); - comboBoxFilterRate.SelectedIndex = config.FilterInterval - 2; - if (config.FilterEnabled) - { - textFilterLatency.IsEnabled = true; - comboBoxFilterRate.IsEnabled = true; + checkBoxSmoothing.IsChecked = config.SmoothingEnabled; + textSmoothingLatency.Text = Utils.GetNumberString(config.SmoothingLatency); + comboBoxSmoothingRate.SelectedIndex = config.SmoothingInterval - 1; + + checkBoxAntichatter.IsChecked = config.AntichatterEnabled; + textAntichatterStrength.Text = Utils.GetNumberString(config.AntichatterStrength); + textAntichatterMultiplier.Text = Utils.GetNumberString(config.AntichatterMultiplier); + textAntichatterOffsetX.Text = Utils.GetNumberString(config.AntichatterOffsetX); + textAntichatterOffsetY.Text = Utils.GetNumberString(config.AntichatterOffsetY); + + checkBoxPrediction.IsChecked = config.PredictionEnabled; + textPredictionStrength.Text = Utils.GetNumberString(config.PredictionStrength); + textPredictionSharpness.Text = Utils.GetNumberString(config.PredictionSharpness); + textPredictionOffsetX.Text = Utils.GetNumberString(config.PredictionOffsetX); + textPredictionOffsetY.Text = Utils.GetNumberString(config.PredictionOffsetY); + + if (config.SmoothingEnabled) + { + textSmoothingLatency.IsEnabled = true; + comboBoxSmoothingRate.IsEnabled = true; + checkBoxAntichatter.IsEnabled = true; + checkBoxPrediction.IsEnabled = true; + + if (config.AntichatterEnabled) + { + textAntichatterStrength.IsEnabled = true; + textAntichatterMultiplier.IsEnabled = true; + textAntichatterOffsetX.IsEnabled = true; + textAntichatterOffsetY.IsEnabled = true; + } + else + { + textAntichatterStrength.IsEnabled = false; + textAntichatterMultiplier.IsEnabled = false; + textAntichatterOffsetX.IsEnabled = false; + textAntichatterOffsetY.IsEnabled = false; + } + + if (config.PredictionEnabled) + { + textPredictionStrength.IsEnabled = true; + textPredictionSharpness.IsEnabled = true; + textPredictionOffsetX.IsEnabled = true; + textPredictionOffsetY.IsEnabled = true; + } + else + { + textPredictionStrength.IsEnabled = false; + textPredictionSharpness.IsEnabled = false; + textPredictionOffsetX.IsEnabled = false; + textPredictionOffsetY.IsEnabled = false; + } } else { - textFilterLatency.IsEnabled = false; - comboBoxFilterRate.IsEnabled = false; - } + textSmoothingLatency.IsEnabled = false; + comboBoxSmoothingRate.IsEnabled = false; + + checkBoxAntichatter.IsEnabled = false; + textAntichatterStrength.IsEnabled = false; + textAntichatterMultiplier.IsEnabled = false; + textAntichatterOffsetX.IsEnabled = false; + textAntichatterOffsetY.IsEnabled = false; + + checkBoxPrediction.IsEnabled = false; + textPredictionStrength.IsEnabled = false; + textPredictionSharpness.IsEnabled = false; + textPredictionOffsetX.IsEnabled = false; + textPredictionOffsetY.IsEnabled = false; + } + // // Run at startup + // checkRunAtStartup.IsChecked = config.RunAtStartup; @@ -519,8 +577,11 @@ private void LoadSettingsFromConfiguration() } textCommandsAfter.Text = tmp; + + // Update canvases UpdateCanvasElements(); + isLoadingSettings = false; } @@ -535,20 +596,22 @@ private void UpdateSettingsToConfiguration() bool oldValue; // Tablet area - if (ParseNumber(textTabletAreaWidth.Text, out double value)) - config.TabletArea.Width = value; - if (ParseNumber(textTabletAreaHeight.Text, out value)) - config.TabletArea.Height = value; - if (ParseNumber(textTabletAreaX.Text, out value)) - config.TabletArea.X = value; - if (ParseNumber(textTabletAreaY.Text, out value)) - config.TabletArea.Y = value; - if (ParseNumber(textTabletAreaRotation.Text, out value)) - config.TabletArea.Rotation = value; - + if (Utils.ParseNumber(textTabletAreaWidth.Text, out double val)) + config.TabletArea.Width = val; + if (Utils.ParseNumber(textTabletAreaHeight.Text, out val)) + config.TabletArea.Height = val; + if (Utils.ParseNumber(textTabletAreaX.Text, out val)) + config.TabletArea.X = val; + if (Utils.ParseNumber(textTabletAreaY.Text, out val)) + config.TabletArea.Y = val; + if (Utils.ParseNumber(textTabletAreaRotation.Text, out val)) + config.TabletArea.Rotation = val; + + config.Invert = (bool)checkBoxInvert.IsChecked; config.ForceAspectRatio = (bool)checkBoxForceAspect.IsChecked; config.ForceFullArea = (bool)checkBoxForceFullArea.IsChecked; + // Output Mode if (radioModeAbsolute.IsChecked == true) config.OutputMode = Configuration.OutputModes.Absolute; if (radioModeRelative.IsChecked == true) config.OutputMode = Configuration.OutputModes.Relative; if (radioModeDigitizer.IsChecked == true) config.OutputMode = Configuration.OutputModes.Digitizer; @@ -568,37 +631,35 @@ private void UpdateSettingsToConfiguration() // Fit area to full area config.TabletArea.ScaleInside(config.TabletFullArea); - textTabletAreaWidth.Text = GetNumberString(config.TabletArea.Width); - textTabletAreaHeight.Text = GetNumberString(config.TabletArea.Height); + textTabletAreaWidth.Text = Utils.GetNumberString(config.TabletArea.Width); + textTabletAreaHeight.Text = Utils.GetNumberString(config.TabletArea.Height); - // Center - //config.TabletArea.X = config.TabletFullArea.Width / 2.0; - //config.TabletArea.Y = config.TabletFullArea.Height / 2.0; } + // Force the tablet area to be inside of the full area config.TabletArea.MoveInside(config.TabletFullArea); // Screen area - if (ParseNumber(textScreenAreaWidth.Text, out value)) - config.ScreenArea.Width = value; - if (ParseNumber(textScreenAreaHeight.Text, out value)) - config.ScreenArea.Height = value; - if (ParseNumber(textScreenAreaX.Text, out value)) - config.ScreenArea.X = value; - if (ParseNumber(textScreenAreaY.Text, out value)) - config.ScreenArea.Y = value; + if (Utils.ParseNumber(textScreenAreaWidth.Text, out val)) + config.ScreenArea.Width = val; + if (Utils.ParseNumber(textScreenAreaHeight.Text, out val)) + config.ScreenArea.Height = val; + if (Utils.ParseNumber(textScreenAreaX.Text, out val)) + config.ScreenArea.X = val; + if (Utils.ParseNumber(textScreenAreaY.Text, out val)) + config.ScreenArea.Y = val; // Desktop size - if (ParseNumber(textDesktopWidth.Text, out value)) - config.DesktopSize.Width = value; - if (ParseNumber(textDesktopHeight.Text, out value)) - config.DesktopSize.Height = value; + if (Utils.ParseNumber(textDesktopWidth.Text, out val)) + config.DesktopSize.Width = val; + if (Utils.ParseNumber(textDesktopHeight.Text, out val)) + config.DesktopSize.Height = val; config.AutomaticDesktopSize = (bool)checkBoxAutomaticDesktopSize.IsChecked; if (config.AutomaticDesktopSize == true) { - textDesktopWidth.Text = GetNumberString(GetVirtualDesktopSize().Width); - textDesktopHeight.Text = GetNumberString(GetVirtualDesktopSize().Height); + textDesktopWidth.Text = Utils.GetNumberString(GetVirtualDesktopSize().Width); + textDesktopHeight.Text = Utils.GetNumberString(GetVirtualDesktopSize().Height); config.DesktopSize.Width = GetVirtualDesktopSize().Width; config.DesktopSize.Height = GetVirtualDesktopSize().Height; } @@ -608,11 +669,13 @@ private void UpdateSettingsToConfiguration() if (config.ForceAspectRatio) { config.TabletArea.Height = config.TabletArea.Width / (config.ScreenArea.Width / config.ScreenArea.Height); - textTabletAreaHeight.Text = GetNumberString(config.TabletArea.Height); + textTabletAreaHeight.Text = Utils.GetNumberString(config.TabletArea.Height); } // Button map + if (Utils.ParseNumber(textMouseWheelSpeed.Text, out val)) + config.mouseWheelSpeed = (int)val; config.ButtonMap[0] = comboBoxButton1.SelectedIndex; config.ButtonMap[1] = comboBoxButton2.SelectedIndex; config.ButtonMap[2] = comboBoxButton3.SelectedIndex; @@ -621,20 +684,86 @@ private void UpdateSettingsToConfiguration() // Filter - config.FilterEnabled = (bool)checkBoxFilter.IsChecked; - config.FilterInterval = comboBoxFilterRate.SelectedIndex + 2; - if (ParseNumber(textFilterLatency.Text, out value)) - config.FilterLatency = value; + config.SmoothingEnabled = (bool)checkBoxSmoothing.IsChecked; + config.SmoothingInterval = comboBoxSmoothingRate.SelectedIndex + 1; + if (Utils.ParseNumber(textSmoothingLatency.Text, out val)) + config.SmoothingLatency = val; + + config.AntichatterEnabled = (bool)checkBoxAntichatter.IsChecked; + double value; + if (Utils.ParseNumber(textAntichatterStrength.Text, out value)) + config.AntichatterStrength = value; + if (Utils.ParseNumber(textAntichatterMultiplier.Text, out value)) + config.AntichatterMultiplier = value; + if (Utils.ParseNumber(textAntichatterOffsetX.Text, out value)) + config.AntichatterOffsetX = value; + if (Utils.ParseNumber(textAntichatterOffsetY.Text, out value)) + config.AntichatterOffsetY = value; + + config.PredictionEnabled = (bool)checkBoxPrediction.IsChecked; + if (Utils.ParseNumber(textPredictionStrength.Text, out value)) + config.PredictionStrength = value; + if (Utils.ParseNumber(textPredictionSharpness.Text, out value)) + config.PredictionSharpness = value; + if (Utils.ParseNumber(textPredictionOffsetX.Text, out value)) + config.PredictionOffsetX = value; + if (Utils.ParseNumber(textPredictionOffsetY.Text, out value)) + config.PredictionOffsetY = value; + + if (config.SmoothingEnabled) + { + textSmoothingLatency.IsEnabled = true; + comboBoxSmoothingRate.IsEnabled = true; + checkBoxAntichatter.IsEnabled = true; + checkBoxPrediction.IsEnabled = true; + + if (config.AntichatterEnabled) + { + textAntichatterStrength.IsEnabled = true; + textAntichatterMultiplier.IsEnabled = true; + textAntichatterOffsetX.IsEnabled = true; + textAntichatterOffsetY.IsEnabled = true; + } + else + { + textAntichatterStrength.IsEnabled = false; + textAntichatterMultiplier.IsEnabled = false; + textAntichatterOffsetX.IsEnabled = false; + textAntichatterOffsetY.IsEnabled = false; + } - if (config.FilterEnabled) - { - textFilterLatency.IsEnabled = true; - comboBoxFilterRate.IsEnabled = true; + if (config.PredictionEnabled) + { + textPredictionStrength.IsEnabled = true; + textPredictionSharpness.IsEnabled = true; + textPredictionOffsetX.IsEnabled = true; + textPredictionOffsetY.IsEnabled = true; + } + else + { + textPredictionStrength.IsEnabled = false; + textPredictionSharpness.IsEnabled = false; + textPredictionOffsetX.IsEnabled = false; + textPredictionOffsetY.IsEnabled = false; + } } else { - textFilterLatency.IsEnabled = false; - comboBoxFilterRate.IsEnabled = false; + textSmoothingLatency.IsEnabled = false; + comboBoxSmoothingRate.IsEnabled = false; + + checkBoxAntichatter.IsEnabled = false; + textAntichatterStrength.IsEnabled = false; + textAntichatterMultiplier.IsEnabled = false; + textAntichatterOffsetX.IsEnabled = false; + textAntichatterOffsetY.IsEnabled = false; + + checkBoxPrediction.IsEnabled = false; + textPredictionStrength.IsEnabled = false; + textPredictionSharpness.IsEnabled = false; + textPredictionOffsetX.IsEnabled = false; + textPredictionOffsetY.IsEnabled = false; + } // @@ -665,33 +794,6 @@ private void UpdateSettingsToConfiguration() } - // - // String to Number - // - private bool ParseNumber(string str, out double value) - { - value = 0; - if (double.TryParse(str, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, cultureEnglish.NumberFormat, out double tmp)) - { - value = tmp; - return true; - } - return false; - } - - // - // Number to String - // - private string GetNumberString(double value) - { - return GetNumberString(value, "0.##"); - } - private string GetNumberString(double value, string format) - { - return value.ToString(format, cultureEnglish.NumberFormat); - } - - // // Set run at startup // @@ -939,7 +1041,7 @@ void UpdateScreenMapCanvas() Canvas.SetTop(rectangleScreenMap, offsetY + config.ScreenArea.Y * scale); // Screen aspect ratio text - textScreenAspectRatio.Text = GetNumberString(config.ScreenArea.Width / config.ScreenArea.Height, "0.###") + ":1"; + textScreenAspectRatio.Text = Utils.GetNumberString(config.ScreenArea.Width / config.ScreenArea.Height, "0.###") + ":1"; Canvas.SetLeft(textScreenAspectRatio, offsetX + (config.ScreenArea.X + config.ScreenArea.Width / 2.0) * scale - textScreenAspectRatio.ActualWidth / 2.0 @@ -1055,7 +1157,7 @@ void UpdateTabletAreaCanvas() // // Tablet area aspect ratio text // - textTabletAspectRatio.Text = GetNumberString(config.TabletArea.Width / config.TabletArea.Height, "0.###") + ":1"; + textTabletAspectRatio.Text = Utils.GetNumberString(config.TabletArea.Width / config.TabletArea.Height, "0.###") + ":1"; Canvas.SetLeft(textTabletAspectRatio, offsetX + (config.TabletArea.X) * scale - textTabletAspectRatio.ActualWidth / 2.0); Canvas.SetTop(textTabletAspectRatio, offsetY + (config.TabletArea.Y) * scale - textTabletAspectRatio.ActualHeight / 2.0); @@ -1101,10 +1203,10 @@ private void Canvas_MouseUp(object sender, MouseButtonEventArgs e) mouseDrag.IsMouseDown = false; LoadSettingsFromConfiguration(); isLoadingSettings = true; - textScreenAreaX.Text = GetNumberString(config.ScreenArea.X, "0"); - textScreenAreaY.Text = GetNumberString(config.ScreenArea.Y, "0"); - textTabletAreaX.Text = GetNumberString(config.TabletArea.X); - textTabletAreaY.Text = GetNumberString(config.TabletArea.Y); + textScreenAreaX.Text = Utils.GetNumberString(config.ScreenArea.X, "0"); + textScreenAreaY.Text = Utils.GetNumberString(config.ScreenArea.Y, "0"); + textTabletAreaX.Text = Utils.GetNumberString(config.TabletArea.X); + textTabletAreaY.Text = Utils.GetNumberString(config.TabletArea.Y); isLoadingSettings = false; canvasScreenMap.ReleaseMouseCapture(); canvasTabletArea.ReleaseMouseCapture(); @@ -1216,8 +1318,8 @@ private void CheckboxChanged(object sender, RoutedEventArgs e) // Disable desktop size settings when automatic is checked if (checkBoxAutomaticDesktopSize.IsChecked == true) { - textDesktopWidth.Text = GetNumberString(GetVirtualDesktopSize().Width); - textDesktopHeight.Text = GetNumberString(GetVirtualDesktopSize().Height); + textDesktopWidth.Text = Utils.GetNumberString(GetVirtualDesktopSize().Width); + textDesktopHeight.Text = Utils.GetNumberString(GetVirtualDesktopSize().Height); textDesktopWidth.IsEnabled = false; textDesktopHeight.IsEnabled = false; } @@ -1296,18 +1398,18 @@ private void ComboBoxMonitor_SelectionChanged(object sender, SelectionChangedEve { textScreenAreaX.Text = "0"; textScreenAreaY.Text = "0"; - textScreenAreaWidth.Text = GetNumberString(config.DesktopSize.Width); - textScreenAreaHeight.Text = GetNumberString(config.DesktopSize.Height); + textScreenAreaWidth.Text = Utils.GetNumberString(config.DesktopSize.Width); + textScreenAreaHeight.Text = Utils.GetNumberString(config.DesktopSize.Height); } else if (index > 0) { index--; if (index >= 0 && index < screens.Length) { - textScreenAreaX.Text = GetNumberString(screens[index].Bounds.X - minX); - textScreenAreaY.Text = GetNumberString(screens[index].Bounds.Y - minY); - textScreenAreaWidth.Text = GetNumberString(screens[index].Bounds.Width); - textScreenAreaHeight.Text = GetNumberString(screens[index].Bounds.Height); + textScreenAreaX.Text = Utils.GetNumberString(screens[index].Bounds.X - minX); + textScreenAreaY.Text = Utils.GetNumberString(screens[index].Bounds.Y - minY); + textScreenAreaWidth.Text = Utils.GetNumberString(screens[index].Bounds.Width); + textScreenAreaHeight.Text = Utils.GetNumberString(screens[index].Bounds.Height); } } UpdateSettingsToConfiguration(); @@ -1320,7 +1422,7 @@ private void SaveSettings(object sender, RoutedEventArgs e) { try { - config.Write("Config.xml"); + config.Write(configFilename); SendSettingsToDriver(); SetStatus("Settings saved!"); } @@ -1343,6 +1445,74 @@ private void ApplySettings(object sender, RoutedEventArgs e) SetStatus("Settings applied!"); } + + // + // Main Menu Click + // + private void MainMenuClick(object sender, RoutedEventArgs e) + { + + // Import + if (sender == mainMenuImport) + { + OpenFileDialog dialog = new OpenFileDialog + { + InitialDirectory = Directory.GetCurrentDirectory(), + Filter = "XML File|*.xml" + }; + if (dialog.ShowDialog() == true) + { + try + { + Configuration tmpConfig = Configuration.CreateFromFile(dialog.FileName); + config = tmpConfig; + LoadSettingsFromConfiguration(); + SetStatus("Settings imported!"); + } + catch (Exception) + { + MessageBox.Show("Settings import failed!", "ERROR!", + MessageBoxButton.OK, MessageBoxImage.Error); + } + } + } + + // Export + else if (sender == mainMenuExport) + { + SaveFileDialog dialog = new SaveFileDialog + { + InitialDirectory = Directory.GetCurrentDirectory(), + AddExtension = true, + DefaultExt = "xml", + Filter = "XML File|*.xml" + + }; + if (dialog.ShowDialog() == true) + { + try + { + UpdateSettingsToConfiguration(); + config.Write(dialog.FileName); + SetStatus("Settings exported!"); + } + catch (Exception) + { + MessageBox.Show("Settings export failed!", "ERROR!", + MessageBoxButton.OK, MessageBoxImage.Error); + } + } + + } + + // Exit + else if (sender == mainMenuExit) + { + Close(); + } + + } + #endregion @@ -1505,8 +1675,18 @@ private void ParseDriverStatus(string line) // if (variableName == "tablet") { - Title = "TabletDriverGUI - " + stringValue; - notifyIcon.Text = Title; + string title = "TabletDriverGUI - " + stringValue; + Title = title; + + // Limit notify icon text length + if (title.Length > 63) + { + notifyIcon.Text = title.Substring(0, 63); + } + else + { + notifyIcon.Text = title; + } SetStatus("Connected to " + stringValue); } @@ -1515,10 +1695,10 @@ private void ParseDriverStatus(string line) // if (variableName == "width") { - if (ParseNumber(stringValue, out double value)) + if (Utils.ParseNumber(stringValue, out double val)) { - config.TabletFullArea.Width = value; - config.TabletFullArea.X = value / 2.0; + config.TabletFullArea.Width = val; + config.TabletFullArea.X = val / 2.0; LoadSettingsFromConfiguration(); UpdateSettingsToConfiguration(); if (isFirstStart) @@ -1531,10 +1711,10 @@ private void ParseDriverStatus(string line) // if (variableName == "height") { - if (ParseNumber(stringValue, out double value)) + if (Utils.ParseNumber(stringValue, out double val)) { - config.TabletFullArea.Height = value; - config.TabletFullArea.Y = value / 2.0; + config.TabletFullArea.Height = val; + config.TabletFullArea.Y = val / 2.0; LoadSettingsFromConfiguration(); UpdateSettingsToConfiguration(); if (isFirstStart) @@ -1571,18 +1751,37 @@ private void SendSettingsToDriver() // Screen area driver.SendCommand("ScreenArea " + - GetNumberString(config.ScreenArea.Width) + " " + GetNumberString(config.ScreenArea.Height) + " " + - GetNumberString(config.ScreenArea.X) + " " + GetNumberString(config.ScreenArea.Y) + Utils.GetNumberString(config.ScreenArea.Width) + " " + Utils.GetNumberString(config.ScreenArea.Height) + " " + + Utils.GetNumberString(config.ScreenArea.X) + " " + Utils.GetNumberString(config.ScreenArea.Y) ); + + // // Tablet area - driver.SendCommand("Area " + - GetNumberString(config.TabletArea.Width) + " " + GetNumberString(config.TabletArea.Height) + " " + - GetNumberString(config.TabletArea.X) + " " + GetNumberString(config.TabletArea.Y) - ); + // + // Inverted + if (config.Invert) + { + driver.SendCommand("TabletArea " + + Utils.GetNumberString(config.TabletArea.Width) + " " + + Utils.GetNumberString(config.TabletArea.Height) + " " + + Utils.GetNumberString(config.TabletFullArea.Width - config.TabletArea.X) + " " + + Utils.GetNumberString(config.TabletFullArea.Height - config.TabletArea.Y) + ); + driver.SendCommand("Rotate " + Utils.GetNumberString(config.TabletArea.Rotation + 180)); + } + // Normal + else + { + driver.SendCommand("TabletArea " + + Utils.GetNumberString(config.TabletArea.Width) + " " + + Utils.GetNumberString(config.TabletArea.Height) + " " + + Utils.GetNumberString(config.TabletArea.X) + " " + + Utils.GetNumberString(config.TabletArea.Y) + ); + driver.SendCommand("Rotate " + Utils.GetNumberString(config.TabletArea.Rotation)); + } - // Rotation - driver.SendCommand("Rotate " + GetNumberString(config.TabletArea.Rotation)); // Output Mode switch (config.OutputMode) @@ -1592,7 +1791,7 @@ private void SendSettingsToDriver() break; case Configuration.OutputModes.Relative: driver.SendCommand("Mode Relative"); - driver.SendCommand("Sensitivity " + GetNumberString(config.ScreenArea.Width / config.TabletArea.Width)); + driver.SendCommand("Sensitivity " + Utils.GetNumberString(config.ScreenArea.Width / config.TabletArea.Width)); break; case Configuration.OutputModes.Digitizer: driver.SendCommand("Mode Digitizer"); @@ -1610,15 +1809,40 @@ private void SendSettingsToDriver() driver.SendCommand("ButtonMap " + String.Join(" ", config.ButtonMap)); } - // Filter - if (config.FilterEnabled) + // Mouse Wheel Speed + driver.SendCommand("MouseWheelSpeed " + Utils.GetNumberString(config.mouseWheelSpeed)); + + // Smoothing filter + if (config.SmoothingEnabled) { - driver.SendCommand("Filter " + GetNumberString(config.FilterLatency)); - driver.SendCommand("FilterInterval " + GetNumberString(config.FilterInterval)); + driver.SendCommand("Smoothing " + Utils.GetNumberString(config.SmoothingLatency)); + driver.SendCommand("SmoothingInterval " + Utils.GetNumberString(config.SmoothingInterval)); + + if (config.AntichatterEnabled) + { + driver.SendCommand("AntichatterEnabled 1"); + driver.SendCommand("AntichatterStrength " + Utils.GetNumberString(config.AntichatterStrength)); + driver.SendCommand("AntichatterMultiplier " + Utils.GetNumberString(config.AntichatterMultiplier)); + driver.SendCommand("AntichatterOffsetX " + Utils.GetNumberString(config.AntichatterOffsetX)); + driver.SendCommand("AntichatterOffsetY " + Utils.GetNumberString(config.AntichatterOffsetY)); + } + else + driver.SendCommand("AntichatterEnabled 0"); + + if (config.PredictionEnabled) + { + driver.SendCommand("PredictionEnabled 1"); + driver.SendCommand("PredictionStrength " + Utils.GetNumberString(config.PredictionStrength)); + driver.SendCommand("PredictionSharpness " + Utils.GetNumberString(config.PredictionSharpness)); + driver.SendCommand("PredictionOffsetX " + Utils.GetNumberString(config.PredictionOffsetX)); + driver.SendCommand("PredictionOffsetY " + Utils.GetNumberString(config.PredictionOffsetY)); + } + else + driver.SendCommand("PredictionEnabled 0"); } else { - driver.SendCommand("Filter 0"); + driver.SendCommand("Smoothing 0"); } // Commands after settings @@ -1646,6 +1870,10 @@ void Start() try { running = true; + + // Console timer + timerConsoleUpdate.Start(); + driver.Start(config.DriverPath, config.DriverArguments); if (!driver.IsRunning) { @@ -1674,6 +1902,18 @@ void Stop() timerConsoleUpdate.Stop(); } + // + // Restart Driver button click + // + private void RestartDriverClick(object sender, RoutedEventArgs e) + { + if (running) + { + Stop(); + } + Start(); + } + #endregion @@ -1902,6 +2142,42 @@ private void ConsoleMenuClick(object sender, RoutedEventArgs e) } } + // Run benchmark + else if (sender == menuRunBenchmark) + { + ConsoleSendCommand("Benchmark"); + } + + // Copy Benchmark + else if (sender == menuCopyBenchmark) + { + string clipboard = ""; + List rows; + driver.ConsoleLock(); + rows = SearchRows(driver.ConsoleBuffer, " [STATUS] BENCHMARK ", 0, 0); + driver.ConsoleUnlock(); + foreach (string row in rows) + { + Match m = Regex.Match(row, " BENCHMARK ([0-9\\.]+) ([0-9\\.]+) ([0-9\\.]+) (.*)$"); + if (m.Success) + { + string tabletName = m.Groups[4].ToString(); + string totalPackets = m.Groups[1].ToString(); + string noiseWidth = m.Groups[2].ToString(); + string noiseHeight = m.Groups[3].ToString(); + clipboard = + "Tablet(" + tabletName + ") " + + "Noise(" + noiseWidth + " mm x " + noiseHeight + " mm) " + + "Packets(" + totalPackets + ")\r\n"; + } + } + + if (clipboard.Length > 0) + { + Clipboard.SetText(clipboard); + SetStatus("Benchmark result copied to clipboard"); + } + } // Open startup log else if (sender == menuOpenStartup) @@ -1967,11 +2243,11 @@ private void ConsoleMenuClick(object sender, RoutedEventArgs e) private void ButtonWacomArea_Click(object sender, RoutedEventArgs e) { WacomArea wacom = new WacomArea(); - wacom.textWacomLeft.Text = GetNumberString((config.TabletArea.X - config.TabletArea.Width / 2) * 100.0, "0"); - wacom.textWacomRight.Text = GetNumberString((config.TabletArea.X + config.TabletArea.Width / 2) * 100.0, "0"); + wacom.textWacomLeft.Text = Utils.GetNumberString((config.TabletArea.X - config.TabletArea.Width / 2) * 100.0, "0"); + wacom.textWacomRight.Text = Utils.GetNumberString((config.TabletArea.X + config.TabletArea.Width / 2) * 100.0, "0"); - wacom.textWacomTop.Text = GetNumberString((config.TabletArea.Y - config.TabletArea.Height / 2) * 100.0, "0"); - wacom.textWacomBottom.Text = GetNumberString((config.TabletArea.Y + config.TabletArea.Height / 2) * 100.0, "0"); + wacom.textWacomTop.Text = Utils.GetNumberString((config.TabletArea.Y - config.TabletArea.Height / 2) * 100.0, "0"); + wacom.textWacomBottom.Text = Utils.GetNumberString((config.TabletArea.Y + config.TabletArea.Height / 2) * 100.0, "0"); wacom.ShowDialog(); @@ -1979,10 +2255,10 @@ private void ButtonWacomArea_Click(object sender, RoutedEventArgs e) if (wacom.DialogResult == true) { if ( - ParseNumber(wacom.textWacomLeft.Text, out double left) && - ParseNumber(wacom.textWacomRight.Text, out double right) && - ParseNumber(wacom.textWacomTop.Text, out double top) && - ParseNumber(wacom.textWacomBottom.Text, out double bottom) + Utils.ParseNumber(wacom.textWacomLeft.Text, out double left) && + Utils.ParseNumber(wacom.textWacomRight.Text, out double right) && + Utils.ParseNumber(wacom.textWacomTop.Text, out double top) && + Utils.ParseNumber(wacom.textWacomBottom.Text, out double bottom) ) { double width, height; @@ -2043,7 +2319,9 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b return IntPtr.Zero; } + #endregion + } } \ No newline at end of file diff --git a/TabletDriverGUI/TabletDriver.cs b/TabletDriverGUI/TabletDriver.cs index 11c0de7..979b23a 100644 --- a/TabletDriverGUI/TabletDriver.cs +++ b/TabletDriverGUI/TabletDriver.cs @@ -73,7 +73,7 @@ private void TimerWatchdog_Elapsed(object sender, ElapsedEventArgs e) } processService.Refresh(); - switch(processService.PriorityClass) + switch (processService.PriorityClass) { case ProcessPriorityClass.High: case ProcessPriorityClass.RealTime: diff --git a/TabletDriverGUI/TabletDriverGUI.csproj b/TabletDriverGUI/TabletDriverGUI.csproj index 3bb7241..ed30a36 100644 --- a/TabletDriverGUI/TabletDriverGUI.csproj +++ b/TabletDriverGUI/TabletDriverGUI.csproj @@ -77,6 +77,7 @@ MSBuild:Compile Designer + diff --git a/TabletDriverGUI/Utils.cs b/TabletDriverGUI/Utils.cs new file mode 100644 index 0000000..1481209 --- /dev/null +++ b/TabletDriverGUI/Utils.cs @@ -0,0 +1,60 @@ +using System.Globalization; + +namespace TabletDriverGUI +{ + public class Utils + { + public static CultureInfo cultureInfo = null; + + + // + // Check and create culture info + // + public static void CheckCultureInfo() + { + if (cultureInfo == null) + { + cultureInfo = new CultureInfo("en-US"); + cultureInfo.NumberFormat.PerMilleSymbol = ""; + + cultureInfo.NumberFormat.NumberDecimalSeparator = "."; + cultureInfo.NumberFormat.NumberGroupSeparator = ""; + + cultureInfo.NumberFormat.PercentDecimalSeparator = "."; + cultureInfo.NumberFormat.PercentGroupSeparator = ""; + + cultureInfo.NumberFormat.CurrencyDecimalSeparator = "."; + cultureInfo.NumberFormat.CurrencyGroupSeparator = ""; + } + } + + // + // String to Number + // + public static bool ParseNumber(string str, out double val) + { + CheckCultureInfo(); + val = 0; + if (double.TryParse(str, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, cultureInfo.NumberFormat, out double tmp)) + { + val = tmp; + return true; + } + return false; + } + + // + // Number to String + // + public static string GetNumberString(double val) + { + CheckCultureInfo(); + return GetNumberString(val, "0.##"); + } + public static string GetNumberString(double val, string format) + { + CheckCultureInfo(); + return val.ToString(format, cultureInfo.NumberFormat); + } + } +} diff --git a/TabletDriverGUI/WacomArea.xaml b/TabletDriverGUI/WacomArea.xaml index 3433270..7e8b267 100644 --- a/TabletDriverGUI/WacomArea.xaml +++ b/TabletDriverGUI/WacomArea.xaml @@ -45,6 +45,7 @@ +