├── TabletDriverService ├── config │ ├── user.cfg │ ├── init.cfg │ ├── tablet.cfg │ └── wacom.cfg ├── ProcessCommand.h ├── stdafx.cpp ├── targetver.h ├── Vector2D.h ├── TabletBenchmark.h ├── TabletDriverService.vcxproj.user ├── PositionRingBuffer.h ├── TabletSettings.cpp ├── ScreenMapper.h ├── TabletFilterPeak.h ├── TabletFilter.h ├── TabletSettings.h ├── stdafx.h ├── TabletFilterNoiseReduction.h ├── Vector2D.cpp ├── CommandLine.h ├── HIDDevice.h ├── USBDevice.h ├── TabletBenchmark.cpp ├── TabletFilter.cpp ├── TabletFilterSmoothing.h ├── TabletFilterPeak.cpp ├── PositionRingBuffer.cpp ├── VMulti.h ├── Tablet.h ├── Logger.h ├── ScreenMapper.cpp ├── TabletFilterNoiseReduction.cpp ├── startuplog.txt ├── TabletDriverService.vcxproj.filters ├── TabletFilterSmoothing.cpp ├── Logger.cpp ├── HIDDevice.cpp ├── CommandLine.cpp ├── USBDevice.cpp ├── docs │ └── VMulti_Report_Descriptor.txt ├── Tablet.cpp ├── VMulti.cpp └── TabletDriverService.vcxproj ├── images ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png ├── 6.png ├── 7.png ├── Fun.png ├── simple.png ├── smooth.png ├── straight.png ├── formula_example.png ├── prediction_fun.png ├── prediction_straight.png ├── prediction_simplesmooth.png ├── prediction_formula_example.png ├── Big latency and big prediction.png ├── Straight - Pretty good realtime accurate.png └── Smooth 2 + prediction = accurate with small overshot.png ├── TabletDriverGUI ├── Resources │ ├── AppIcon.ico │ └── AppIcon.xcf ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── App.xaml ├── App.config ├── TabletDriverGUI.csproj.user ├── NativeMethods.cs ├── Utils.cs ├── WacomArea.xaml ├── app.manifest ├── App.xaml.cs ├── Area.cs ├── WacomArea.xaml.cs ├── Configuration.cs ├── TabletDriverGUI.csproj ├── VersionHelper.cs └── TabletDriver.cs ├── .github └── ISSUE_TEMPLATE.md ├── .gitignore └── TabletDriver.sln /TabletDriverService/config/user.cfg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/1.png -------------------------------------------------------------------------------- /images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/2.png -------------------------------------------------------------------------------- /images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/3.png -------------------------------------------------------------------------------- /images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/4.png -------------------------------------------------------------------------------- /images/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/5.png -------------------------------------------------------------------------------- /images/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/6.png -------------------------------------------------------------------------------- /images/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/7.png -------------------------------------------------------------------------------- /images/Fun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/Fun.png -------------------------------------------------------------------------------- /images/simple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/simple.png -------------------------------------------------------------------------------- /images/smooth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/smooth.png -------------------------------------------------------------------------------- /images/straight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/straight.png -------------------------------------------------------------------------------- /images/formula_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/formula_example.png -------------------------------------------------------------------------------- /images/prediction_fun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/prediction_fun.png -------------------------------------------------------------------------------- /images/prediction_straight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/prediction_straight.png -------------------------------------------------------------------------------- /images/prediction_simplesmooth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/prediction_simplesmooth.png -------------------------------------------------------------------------------- /TabletDriverGUI/Resources/AppIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/TabletDriverGUI/Resources/AppIcon.ico -------------------------------------------------------------------------------- /TabletDriverGUI/Resources/AppIcon.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/TabletDriverGUI/Resources/AppIcon.xcf -------------------------------------------------------------------------------- /images/prediction_formula_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/prediction_formula_example.png -------------------------------------------------------------------------------- /images/Big latency and big prediction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/Big latency and big prediction.png -------------------------------------------------------------------------------- /images/Straight - Pretty good realtime accurate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/Straight - Pretty good realtime accurate.png -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ## Hardware/software information 6 | Windows Version: 7 | 8 | Tablet Driver version: 9 | 10 | Tablet model: -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.vs 2 | /Release 3 | /Debug 4 | /TabletDriverGUI/bin/ 5 | /TabletDriverGUI/obj/ 6 | /TabletDriverService/Release/ 7 | /TabletDriverService/Debug/ 8 | 9 | -------------------------------------------------------------------------------- /TabletDriverService/config/init.cfg: -------------------------------------------------------------------------------- 1 | Log startuplog.txt 2 | LogDirect true 3 | Include "config\tablet.cfg" 4 | Include "config\wacom.cfg" 5 | Include "config\user.cfg" 6 | -------------------------------------------------------------------------------- /images/Smooth 2 + prediction = accurate with small overshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Devocub/TabletDriver/HEAD/images/Smooth 2 + prediction = accurate with small overshot.png -------------------------------------------------------------------------------- /TabletDriverGUI/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /TabletDriverService/ProcessCommand.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "CommandLine.h" 3 | 4 | bool ProcessCommand(CommandLine *cmd); 5 | bool ReadCommandFile(string filename); 6 | void LogTabletArea(string text); 7 | void LogInformation(); 8 | void LogStatus(); 9 | bool CheckTablet(); -------------------------------------------------------------------------------- /TabletDriverGUI/App.xaml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /TabletDriverGUI/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /TabletDriverService/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // TabletDriverService.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /TabletDriverService/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /TabletDriverService/Vector2D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class Vector2D { 3 | public: 4 | double x; 5 | double y; 6 | Vector2D(); 7 | ~Vector2D(); 8 | 9 | void Set(double x, double y); 10 | void Set(Vector2D vector); 11 | void Add(double x, double y); 12 | void Add(Vector2D vector); 13 | void Multiply(double value); 14 | double Distance(Vector2D target); 15 | void CopyTo(Vector2D target); 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /TabletDriverService/TabletBenchmark.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Vector2D.h" 4 | 5 | class TabletBenchmark { 6 | public: 7 | double minX; 8 | double maxX; 9 | double minY; 10 | double maxY; 11 | int totalPackets; 12 | int packetCounter; 13 | bool isRunning; 14 | 15 | TabletBenchmark(); 16 | ~TabletBenchmark(); 17 | void Start(int packetCount); 18 | void Update(Vector2D position); 19 | }; 20 | 21 | -------------------------------------------------------------------------------- /TabletDriverService/TabletDriverService.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | config\init.cfg 5 | WindowsLocalDebugger 6 | 7 | -------------------------------------------------------------------------------- /TabletDriverService/PositionRingBuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Vector2D.h" 4 | 5 | class PositionRingBuffer { 6 | public: 7 | Vector2D buffer[100]; 8 | int maxLength; 9 | int length; 10 | int count; 11 | int index; 12 | bool isValid; 13 | 14 | void SetLength(int length); 15 | void Add(Vector2D vector); 16 | bool GetLatest(Vector2D *output, int delta); 17 | void Reset(); 18 | 19 | Vector2D *operator[](std::size_t index); 20 | 21 | 22 | PositionRingBuffer(); 23 | ~PositionRingBuffer(); 24 | }; 25 | 26 | -------------------------------------------------------------------------------- /TabletDriverGUI/TabletDriverGUI.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | publish\ 5 | 6 | 7 | 8 | 9 | 10 | en-US 11 | false 12 | 13 | -------------------------------------------------------------------------------- /TabletDriverService/TabletSettings.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "TabletSettings.h" 3 | 4 | 5 | // 6 | // Constructor 7 | // 8 | TabletSettings::TabletSettings() { 9 | // Initial settings 10 | reportId = 0; 11 | reportLength = 8; 12 | detectMask = 0x00; 13 | ignoreMask = 0x00; 14 | maxX = 1; 15 | maxY = 1; 16 | maxPressure = 1; 17 | clickPressure = 0; 18 | width = 1; 19 | height = 1; 20 | skew = 0; 21 | type = TabletNormal; 22 | mouseWheelSpeed = 50; 23 | } 24 | 25 | // 26 | // Destructor 27 | // 28 | TabletSettings::~TabletSettings() { 29 | } 30 | -------------------------------------------------------------------------------- /TabletDriverService/ScreenMapper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Tablet.h" 3 | 4 | typedef struct { 5 | double x; 6 | double y; 7 | double width; 8 | double height; 9 | } Area; 10 | 11 | class ScreenMapper { 12 | public: 13 | Tablet * tablet; 14 | Area areaTablet; 15 | Area areaScreen; 16 | Area areaVirtualScreen; 17 | double rotationMatrix[4]; 18 | 19 | ScreenMapper(Tablet *t); 20 | void SetRotation(double angle); 21 | bool GetRotatedTabletPosition(double *x, double *y); 22 | bool GetScreenPosition(double *x, double *y); 23 | }; 24 | 25 | -------------------------------------------------------------------------------- /TabletDriverService/TabletFilterPeak.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "PositionRingBuffer.h" 4 | #include "Vector2D.h" 5 | 6 | class TabletFilterPeak : public TabletFilter { 7 | public: 8 | 9 | PositionRingBuffer buffer; 10 | Vector2D position; 11 | double distanceThreshold; 12 | 13 | void Reset(Vector2D targetVector); 14 | void SetTarget(Vector2D targetVector, double h); 15 | void SetPosition(Vector2D vector, double h); 16 | bool GetPosition(Vector2D *outputVector); 17 | void Update(); 18 | 19 | 20 | TabletFilterPeak(); 21 | ~TabletFilterPeak(); 22 | }; 23 | 24 | -------------------------------------------------------------------------------- /TabletDriverService/TabletFilter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class TabletFilter { 3 | public: 4 | virtual void SetTarget(Vector2D vector, double h) = 0; 5 | virtual void Reset(Vector2D vector) = 0; 6 | virtual void SetPosition(Vector2D vector, double h) = 0; 7 | virtual bool GetPosition(Vector2D *vector) = 0; 8 | virtual void Update() = 0; 9 | 10 | HANDLE timer; 11 | UINT uTimerID; 12 | LPTIMECALLBACK callback; 13 | double timerInterval; 14 | 15 | bool isEnabled; 16 | bool isValid; 17 | 18 | TabletFilter(); 19 | 20 | bool StartTimer(); 21 | bool StopTimer(); 22 | 23 | }; 24 | 25 | -------------------------------------------------------------------------------- /TabletDriverService/TabletSettings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class TabletSettings { 3 | public: 4 | 5 | enum TabletType { 6 | TabletNormal, 7 | TypeWacomIntuos, 8 | TypeWacom4100, 9 | TypeWacomDrivers 10 | }; 11 | 12 | BYTE detectMask; 13 | BYTE ignoreMask; 14 | int maxX; 15 | int maxY; 16 | int maxPressure; 17 | int clickPressure; 18 | int keepTipDown; 19 | double width; 20 | double height; 21 | BYTE reportId; 22 | int reportLength; 23 | double skew; 24 | TabletType type; 25 | int mouseWheelSpeed; 26 | 27 | TabletSettings(); 28 | ~TabletSettings(); 29 | }; 30 | 31 | -------------------------------------------------------------------------------- /TabletDriverGUI/NativeMethods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace TabletDriverGUI 5 | { 6 | public class NativeMethods 7 | { 8 | public const int HWND_BROADCAST = 0xffff; 9 | public static readonly int WM_SHOWTABLETDRIVERGUI = RegisterWindowMessage("WM_SHOWTABLETDRIVERGUI"); 10 | 11 | [DllImport("user32")] 12 | public static extern bool PostMessage(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam); 13 | [DllImport("user32")] 14 | public static extern int RegisterWindowMessage(string message); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /TabletDriverService/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | #pragma once 6 | #include "targetver.h" 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "VMulti.h" 13 | #include "Tablet.h" 14 | #include "ScreenMapper.h" 15 | 16 | // Global variables... 17 | extern VMulti *vmulti; 18 | extern Tablet *tablet; 19 | extern ScreenMapper *mapper; 20 | extern void CleanupAndExit(int code); 21 | 22 | 23 | // TODO: reference additional headers your program requires here 24 | -------------------------------------------------------------------------------- /TabletDriverService/TabletFilterNoiseReduction.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "PositionRingBuffer.h" 4 | 5 | class TabletFilterNoiseReduction : public TabletFilter { 6 | public: 7 | 8 | PositionRingBuffer buffer; 9 | Vector2D position; 10 | Vector2D lastTarget; 11 | 12 | int iterations; 13 | double distanceThreshold; 14 | 15 | void Reset(Vector2D position); 16 | void SetTarget(Vector2D targetVector, double h); 17 | void SetPosition(Vector2D vector, double h); 18 | bool GetPosition(Vector2D *outputVector); 19 | void Update(); 20 | 21 | bool GetAverageVector(Vector2D *output); 22 | bool GetGeometricMedianVector(Vector2D *output, int iterations); 23 | 24 | TabletFilterNoiseReduction(); 25 | ~TabletFilterNoiseReduction(); 26 | }; 27 | 28 | -------------------------------------------------------------------------------- /TabletDriverService/Vector2D.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "Vector2D.h" 3 | 4 | // 5 | // Constructor 6 | // 7 | Vector2D::Vector2D() { 8 | x = 0; 9 | y = 0; 10 | } 11 | 12 | // 13 | // Destructor 14 | // 15 | Vector2D::~Vector2D() { 16 | } 17 | 18 | void Vector2D::Set(double x, double y) { 19 | this->x = x; 20 | this->y = y; 21 | } 22 | 23 | void Vector2D::Set(Vector2D vector) { 24 | Set(vector.x, vector.y); 25 | } 26 | 27 | void Vector2D::Add(double x, double y) { 28 | this->x += x; 29 | this->y += y; 30 | } 31 | 32 | void Vector2D::Add(Vector2D vector) { 33 | Add(vector.x, vector.y); 34 | } 35 | 36 | void Vector2D::Multiply(double value) { 37 | this->x *= value; 38 | this->y *= value; 39 | } 40 | 41 | double Vector2D::Distance(Vector2D target) { 42 | double dx = target.x - this->x; 43 | double dy = target.y - this->y; 44 | return sqrt(dx * dx + dy * dy); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /TabletDriverService/CommandLine.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace std; 11 | 12 | class CommandLine { 13 | public: 14 | string line; 15 | string command; 16 | vector values; 17 | int valueCount; 18 | bool isValid; 19 | 20 | CommandLine(string text); 21 | ~CommandLine(); 22 | bool is(string command); 23 | int Parse(string text); 24 | string ParseHex(string str); 25 | string GetString(int index, string defaultValue); 26 | string GetStringLower(int index, string defaultValue); 27 | int GetInt(int index, int defaultValue); 28 | long GetLong(int index, long defaultValue); 29 | double GetDouble(int index, double defaultValue); 30 | float GetFloat(int index, float defaultValue); 31 | bool GetBoolean(int index, bool defaultValue); 32 | }; 33 | 34 | -------------------------------------------------------------------------------- /TabletDriverService/HIDDevice.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | using namespace std; 15 | 16 | class HIDDevice { 17 | private: 18 | HANDLE _deviceHandle; 19 | public: 20 | bool isOpen; 21 | bool debugEnabled; 22 | USHORT vendorId; 23 | USHORT productId; 24 | USHORT usagePage; 25 | USHORT usage; 26 | 27 | HIDDevice(USHORT VendorId, USHORT ProductId, USHORT UsagePage, USHORT Usage); 28 | HIDDevice(); 29 | ~HIDDevice(); 30 | bool OpenDevice(HANDLE *handle, USHORT vendorId, USHORT productId, USHORT usagePage, USHORT usage); 31 | int Read(void *buffer, int length); 32 | int Write(void *buffer, int length); 33 | bool SetFeature(void *buffer, int length); 34 | bool GetFeature(void *buffer, int length); 35 | void CloseDevice(); 36 | }; -------------------------------------------------------------------------------- /TabletDriverService/USBDevice.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace std; 17 | 18 | class USBDevice { 19 | private: 20 | HANDLE _deviceHandle; 21 | WINUSB_INTERFACE_HANDLE _usbHandle; 22 | bool OpenDevice(string usbDeviceGUIDString, int stringId, string stringMatch); 23 | public: 24 | string guid; 25 | int stringId; 26 | string stringMatch; 27 | 28 | bool isOpen; 29 | USBDevice(string Guid, int StringId, string StringMatch); 30 | ~USBDevice(); 31 | int Read(UCHAR pipeId, void *buffer, int length); 32 | int Write(UCHAR pipeId, void *buffer, int length); 33 | int ControlTransfer(UCHAR requestType, UCHAR request, USHORT value, USHORT index, void *buffer, USHORT length); 34 | void CloseDevice(); 35 | }; -------------------------------------------------------------------------------- /TabletDriverService/TabletBenchmark.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "TabletBenchmark.h" 3 | 4 | // 5 | // Constructor 6 | // 7 | TabletBenchmark::TabletBenchmark() { 8 | maxX = 0; 9 | minX = 0; 10 | maxY = 0; 11 | minY = 0; 12 | totalPackets = 0; 13 | packetCounter = 0; 14 | } 15 | 16 | // 17 | // Destructor 18 | // 19 | TabletBenchmark::~TabletBenchmark() { 20 | } 21 | 22 | 23 | // 24 | // Start tablet benchmark 25 | // 26 | void TabletBenchmark::Start(int packetCount) { 27 | maxX = -10000; 28 | maxY = -10000; 29 | minX = 10000; 30 | minY = 10000; 31 | totalPackets = packetCount; 32 | packetCounter = packetCount; 33 | isRunning = true; 34 | } 35 | 36 | void TabletBenchmark::Update(Vector2D position) { 37 | if (isRunning) { 38 | if (packetCounter > 0) { 39 | if (position.x < minX) minX = position.x; 40 | if (position.x > maxX) maxX = position.x; 41 | if (position.y < minY) minY = position.y; 42 | if (position.y > maxY) maxY = position.y; 43 | packetCounter--; 44 | } 45 | else { 46 | isRunning = false; 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /TabletDriverService/TabletFilter.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "TabletFilter.h" 3 | 4 | 5 | TabletFilter::TabletFilter() { 6 | timer = NULL; 7 | timerInterval = 2; 8 | isValid = false; 9 | isEnabled = false; 10 | } 11 | 12 | // 13 | // Start Timer 14 | // 15 | bool TabletFilter::StartTimer() { 16 | if (timer == NULL) { 17 | MMRESULT result = timeSetEvent( 18 | (UINT)timerInterval,//UINT uDelay, 19 | 0,//UINT uResolution, 20 | callback, //LPTIMECALLBACK lpTimeProc, 21 | NULL, //DWORD_PTR dwUser, 22 | TIME_PERIODIC | TIME_KILL_SYNCHRONOUS //UINT fuEvent 23 | ); 24 | if (result == NULL) { 25 | return false; 26 | } 27 | else { 28 | timer = (HANDLE)1; // for code compatibility purposes 29 | uTimerID = result; 30 | } 31 | } 32 | return true; 33 | } 34 | 35 | 36 | // 37 | // Stop Timer 38 | // 39 | bool TabletFilter::StopTimer() { 40 | if (timer == NULL) return false; 41 | 42 | MMRESULT result = timeKillEvent(uTimerID); 43 | // Returns TIMERR_NOERROR if successful or MMSYSERR_INVALPARAM if the specified timer event does not exist. 44 | if (result == TIMERR_NOERROR) 45 | { 46 | timer = NULL; 47 | return true; 48 | } 49 | return false; 50 | } -------------------------------------------------------------------------------- /TabletDriverGUI/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace TabletDriverGUI.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /TabletDriverService/TabletFilterSmoothing.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Vector2D.h" 4 | #include "TabletFilter.h" 5 | 6 | class TabletFilterSmoothing : public TabletFilter { 7 | public: 8 | double latency; 9 | double weight; 10 | double threshold; 11 | 12 | bool AntichatterEnabled; 13 | double antichatterStrength; 14 | double antichatterMultiplier; 15 | double antichatterOffsetX; 16 | double antichatterOffsetY; 17 | 18 | bool PredictionEnabled; 19 | double PredictionSharpness; 20 | double PredictionStrength; 21 | double PredictionOffsetX; 22 | double PredictionOffsetY; 23 | 24 | Vector2D target; 25 | Vector2D prev_target; 26 | Vector2D calculated_target; 27 | Vector2D position; 28 | double z; 29 | 30 | TabletFilterSmoothing(); 31 | ~TabletFilterSmoothing(); 32 | 33 | void SetTarget(Vector2D vector, double h); 34 | void SetPosition(Vector2D vector, double h); 35 | bool GetPosition(Vector2D *outputVector); 36 | void Update(); 37 | 38 | void Reset(Vector2D position); 39 | double SetPosition(double x, double y, double h); 40 | double GetLatency(double filterWeight, double interval, double threshold); 41 | double GetLatency(double filterWeight); 42 | double GetLatency(); 43 | double GetWeight(double latency, double interval, double threshold); 44 | double GetWeight(double latency); 45 | void SetLatency(double latency); 46 | }; 47 | 48 | -------------------------------------------------------------------------------- /TabletDriverService/TabletFilterPeak.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "TabletFilterPeak.h" 3 | 4 | #define LOG_MODULE "Peak" 5 | #include "Logger.h" 6 | 7 | // 8 | // Constructor 9 | // 10 | TabletFilterPeak::TabletFilterPeak() { 11 | 12 | // Buffer length 13 | buffer.SetLength(3); 14 | 15 | // Default distance threshold 16 | distanceThreshold = 10; 17 | } 18 | 19 | 20 | // 21 | // Destructor 22 | // 23 | TabletFilterPeak::~TabletFilterPeak() { 24 | } 25 | 26 | 27 | // 28 | // TabletFilter methods 29 | // 30 | // reset 31 | void TabletFilterPeak::Reset(Vector2D targetVector) { 32 | buffer.Reset(); 33 | } 34 | // Set target position 35 | void TabletFilterPeak::SetTarget(Vector2D targetVector, double h) { 36 | buffer.Add(targetVector); 37 | } 38 | // Set position 39 | void TabletFilterPeak::SetPosition(Vector2D vector, double h) { 40 | position.x = vector.x; 41 | position.y = vector.y; 42 | } 43 | // Get position 44 | bool TabletFilterPeak::GetPosition(Vector2D *outputVector) { 45 | outputVector->x = position.x; 46 | outputVector->y = position.y; 47 | return true; 48 | } 49 | // Update 50 | void TabletFilterPeak::Update() { 51 | Vector2D oldPosition; 52 | double distance; 53 | 54 | // Buffer valid? 55 | if ( 56 | buffer.GetLatest(&oldPosition, -1) 57 | && 58 | buffer.GetLatest(&position, 0) 59 | ) { 60 | 61 | // Jump longer than the distance threshold? 62 | distance = oldPosition.Distance(position); 63 | if (distance > distanceThreshold) { 64 | 65 | /* 66 | LOG_DEBUG("PEAK! %0.2f,%0.2f -> %0.2f,%0.2f = %0.2f mm\n", 67 | oldPosition.x, oldPosition.y, 68 | position.x, position.y, 69 | distance 70 | ); 71 | */ 72 | 73 | position.x = oldPosition.x; 74 | position.y = oldPosition.y; 75 | 76 | // Reset buffer 77 | buffer.Reset(); 78 | 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /TabletDriverService/PositionRingBuffer.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "PositionRingBuffer.h" 3 | 4 | 5 | // 6 | // Constructor 7 | // 8 | PositionRingBuffer::PositionRingBuffer() { 9 | maxLength = sizeof(buffer) / sizeof(Vector2D); 10 | length = 0; 11 | count = 0; 12 | index = 0; 13 | isValid = false; 14 | } 15 | 16 | 17 | // 18 | // Destructor 19 | // 20 | PositionRingBuffer::~PositionRingBuffer() { 21 | } 22 | 23 | 24 | // 25 | // Set buffer length 26 | // 27 | void PositionRingBuffer::SetLength(int len) { 28 | if(len > maxLength) { 29 | length = maxLength; 30 | } else { 31 | length = len; 32 | } 33 | } 34 | 35 | 36 | // 37 | // Add position to buffer 38 | // 39 | void PositionRingBuffer::Add(Vector2D vector) { 40 | buffer[index].x = vector.x; 41 | buffer[index].y = vector.y; 42 | index++; 43 | count++; 44 | if(count > length) { 45 | count = length; 46 | } 47 | if(index >= length) { 48 | index = 0; 49 | } 50 | isValid = true; 51 | } 52 | 53 | 54 | // 55 | // Get position history from the buffer 56 | // 57 | bool PositionRingBuffer::GetLatest(Vector2D *output, int delta) { 58 | int newIndex; 59 | 60 | // Buffer empty? 61 | if(count == 0) return false; 62 | 63 | // Valid delta? 64 | if(delta > 0 || delta <= -count) return false; 65 | 66 | newIndex = index - 1 + delta; 67 | 68 | // Limits 69 | if(newIndex < 0) newIndex = count + newIndex; 70 | 71 | if(newIndex < 0 || newIndex >= count) { 72 | return false; 73 | } 74 | 75 | output->x = buffer[newIndex].x; 76 | output->y = buffer[newIndex].y; 77 | return true; 78 | } 79 | 80 | 81 | // 82 | // Reset buffer 83 | // 84 | void PositionRingBuffer::Reset() { 85 | count = 0; 86 | index = 0; 87 | isValid = false; 88 | } 89 | 90 | 91 | 92 | // 93 | // [] operator 94 | // 95 | Vector2D *PositionRingBuffer::operator[](std::size_t index) { 96 | return &(buffer[index]); 97 | } -------------------------------------------------------------------------------- /TabletDriverGUI/Utils.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | 3 | namespace TabletDriverGUI 4 | { 5 | public class Utils 6 | { 7 | public static CultureInfo cultureInfo = null; 8 | 9 | 10 | // 11 | // Check and create culture info 12 | // 13 | public static void CheckCultureInfo() 14 | { 15 | if (cultureInfo == null) 16 | { 17 | cultureInfo = new CultureInfo("en-US"); 18 | cultureInfo.NumberFormat.PerMilleSymbol = ""; 19 | 20 | cultureInfo.NumberFormat.NumberDecimalSeparator = "."; 21 | cultureInfo.NumberFormat.NumberGroupSeparator = ""; 22 | 23 | cultureInfo.NumberFormat.PercentDecimalSeparator = "."; 24 | cultureInfo.NumberFormat.PercentGroupSeparator = ""; 25 | 26 | cultureInfo.NumberFormat.CurrencyDecimalSeparator = "."; 27 | cultureInfo.NumberFormat.CurrencyGroupSeparator = ""; 28 | } 29 | } 30 | 31 | // 32 | // String to Number 33 | // 34 | public static bool ParseNumber(string str, out double val) 35 | { 36 | CheckCultureInfo(); 37 | val = 0; 38 | if (double.TryParse(str, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, cultureInfo.NumberFormat, out double tmp)) 39 | { 40 | val = tmp; 41 | return true; 42 | } 43 | return false; 44 | } 45 | 46 | // 47 | // Number to String 48 | // 49 | public static string GetNumberString(double val) 50 | { 51 | CheckCultureInfo(); 52 | return GetNumberString(val, "0.##"); 53 | } 54 | public static string GetNumberString(double val, string format) 55 | { 56 | CheckCultureInfo(); 57 | return val.ToString(format, cultureInfo.NumberFormat); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /TabletDriverService/VMulti.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "HIDDevice.h" 4 | #include "Vector2D.h" 5 | 6 | class VMulti { 7 | private: 8 | HIDDevice * hidDevice; 9 | BYTE reportBuffer[65]; 10 | BYTE lastReportBuffer[65]; 11 | public: 12 | 13 | enum VMultiMode { 14 | ModeAbsoluteMouse, 15 | ModeRelativeMouse, 16 | ModeDigitizer, 17 | ModeSendInput 18 | }; 19 | 20 | struct { 21 | BYTE vmultiId; 22 | BYTE reportLength; 23 | BYTE reportId; 24 | BYTE buttons; 25 | USHORT x; 26 | USHORT y; 27 | BYTE wheel; 28 | } reportAbsoluteMouse; 29 | 30 | struct { 31 | BYTE vmultiId; 32 | BYTE reportLength; 33 | BYTE reportId; 34 | BYTE buttons; 35 | BYTE x; 36 | BYTE y; 37 | BYTE wheel; 38 | } reportRelativeMouse; 39 | 40 | struct { 41 | BYTE vmultiId; 42 | BYTE reportLength; 43 | BYTE reportId; 44 | BYTE buttons; 45 | USHORT x; 46 | USHORT y; 47 | USHORT pressure; 48 | } reportDigitizer; 49 | 50 | 51 | // Position Integer 52 | typedef struct { 53 | int x; 54 | int y; 55 | } PositionInt; 56 | 57 | // Relative mouse data 58 | struct { 59 | PositionInt currentPosition; 60 | Vector2D lastPosition; 61 | Vector2D targetPosition; 62 | double sensitivity; 63 | double resetDistance; 64 | } relativeData; 65 | 66 | 67 | struct { 68 | double primaryWidth = GetSystemMetrics(SM_CXSCREEN); 69 | double primaryHeight = GetSystemMetrics(SM_CYSCREEN); 70 | double virtualWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN); 71 | double virtualHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN); 72 | double virtualX = GetSystemMetrics(SM_XVIRTUALSCREEN); 73 | double virtualY = GetSystemMetrics(SM_YVIRTUALSCREEN); 74 | } monitorInfo; 75 | 76 | VMultiMode mode; 77 | bool isOpen; 78 | bool debugEnabled; 79 | bool outputEnabled; 80 | int lastButtons; 81 | 82 | 83 | 84 | VMulti(); 85 | ~VMulti(); 86 | bool HasReportChanged(); 87 | void ResetRelativeData(double x, double y); 88 | void UpdateMonitorInfo(); 89 | void CreateReport(BYTE buttons, double x, double y, double pressure); 90 | int ResetReport(); 91 | int WriteReport(); 92 | }; 93 | 94 | 95 | -------------------------------------------------------------------------------- /TabletDriverGUI/WacomArea.xaml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 |