Skip to content

Commit

Permalink
v0.1.5
Browse files Browse the repository at this point in the history
 - New tablet configurations:
Wacom CTL-4100 (USB only model), XP-Pen G540 Pro, XP-Pen Deco 01 and Huion osu!tablet
- Added `ResetDistance` command
- Code refactoring.
  • Loading branch information
hawku committed Apr 15, 2018
1 parent 5091471 commit b033436
Show file tree
Hide file tree
Showing 17 changed files with 436 additions and 120 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The GUI minimizes to system tray / notification area. You can reopen the GUI by

## Download

### http://hwk.fi/TabletDriver/TabletDriverV0.1.4.zip
### http://hwk.fi/TabletDriver/TabletDriverV0.1.5.zip

#

Expand Down Expand Up @@ -61,7 +61,7 @@ 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
Expand Down Expand Up @@ -92,6 +92,12 @@ 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
Expand Down
15 changes: 12 additions & 3 deletions TabletDriverGUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public partial class MainWindow : Window
{

// Version
public string Version = "0.1.4";
public string Version = "0.1.5";

// Console stuff
private List<string> commandHistory;
Expand Down Expand Up @@ -1546,8 +1546,17 @@ 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);
}

Expand Down
94 changes: 66 additions & 28 deletions TabletDriverService/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ void RunTabletThread() {
bool isFirstReport = true;
bool isResent = false;
double x, y;
TabletFilter *filter;
bool filterTimedEnabled;

chrono::high_resolution_clock::time_point timeBegin = chrono::high_resolution_clock::now();
chrono::high_resolution_clock::time_point timeNow = chrono::high_resolution_clock::now();
Expand All @@ -60,10 +62,10 @@ void RunTabletThread() {
// Read tablet position
//
status = tablet->ReadPosition();

// Position OK
if(status == Tablet::PacketValid) {
isResent = false;
// Position invalid

// Invalid packet id
} else if(status == Tablet::PacketInvalid) {
Expand Down Expand Up @@ -111,17 +113,40 @@ void RunTabletThread() {
}

//
// Packet filter
// Packet filters
//
if(tablet->filterPacket != NULL && tablet->filterPacket->isEnabled) {
tablet->filterPacket->SetTarget(tablet->state.position);
tablet->filterPacket->Update();
tablet->filterPacket->GetPosition(&tablet->state.position);
// Is there any filters?
if(tablet->filterPacketCount > 0) {

// Loop through filters
for(int filterIndex = 0; filterIndex < tablet->filterPacketCount; filterIndex++) {

// Filter
filter = tablet->filterPacket[filterIndex];

// Enabled?
if(filter != NULL && filter->isEnabled) {

// Process
filter->SetTarget(tablet->state.position);
filter->Update();
filter->GetPosition(&tablet->state.position);
}

}
}


// Timed filter enabled?
filterTimedEnabled = false;
for(int filterIndex = 0; filterIndex < tablet->filterTimedCount; filterIndex++) {
if(tablet->filterTimed[filterIndex]->isEnabled)
filterTimedEnabled = true;
}


// Do not write report when timed filter is enabled
if(tablet->filterTimed == NULL || !tablet->filterTimed->isEnabled) {
if(tablet->filterTimedCount == 0 || !filterTimedEnabled) {

// Relative mode
if(vmulti->mode == VMulti::ModeRelativeMouse) {
Expand Down Expand Up @@ -165,34 +190,40 @@ void RunTabletThread() {
//
VOID CALLBACK FilterTimerCallback(_In_ PVOID lpParameter, _In_ BOOLEAN TimerOrWaitFired) {
Vector2D position;
TabletFilter *filter;

// Set position
position.Set(tablet->state.position);

TabletFilter *filter = tablet->filterTimed;
// Loop through filters
for(int filterIndex = 0; filterIndex < tablet->filterTimedCount; filterIndex++) {

// Filter enabled?
if(!filter->isEnabled) return;
// Filter
filter = tablet->filterTimed[filterIndex];

// Set filter targets
filter->SetTarget(tablet->state.position);
// Filter enabled?
if(!filter->isEnabled) return;

// Update filter position
filter->Update();
// Set filter targets
filter->SetTarget(position);

// Set output vector
filter->GetPosition(&position);
// Update filter position
filter->Update();

// Set output vector
filter->GetPosition(&position);

}


//
// Relative mode
//
if(vmulti->mode == VMulti::ModeRelativeMouse) {

// Map position to virtual screen (values between 0 and 1)
mapper->GetRotatedTabletPosition(&position.x, &position.y);

// Large distance -> Reset relative position
double distance = tablet->state.position.Distance(vmulti->relativeData.lastPosition);
if(distance > 10) {
vmulti->ResetRelativeData(position.x, position.y);
}

// Create VMulti report
vmulti->CreateReport(
tablet->state.buttons,
Expand All @@ -207,12 +238,17 @@ VOID CALLBACK FilterTimerCallback(_In_ PVOID lpParameter, _In_ BOOLEAN TimerOrWa
vmulti->reportRelativeMouse.x != 0
||
vmulti->reportRelativeMouse.y != 0
) {
) {
vmulti->WriteReport();
}


}

//
// Absolute / Digitizer mode
} else {
//
else {


// Map position to virtual screen (values betweeb 0->1)
Expand Down Expand Up @@ -338,8 +374,10 @@ int main(int argc, char**argv) {
running = true;

// Timed filter timer
tablet->filterTimed->callback = FilterTimerCallback;
tablet->filterTimed->StartTimer();
if(tablet->filterPacketCount > 0) {
tablet->filterTimed[0]->callback = FilterTimerCallback;
tablet->filterTimed[0]->StartTimer();
}

// Start the tablet thread
tabletThread = new thread(RunTabletThread);
Expand Down Expand Up @@ -389,8 +427,8 @@ void CleanupAndExit(int code) {

// Delete filter timer
if(tablet != NULL) {
if(tablet->filterTimed != NULL) {
tablet->filterTimed->StopTimer();
if(tablet->filterTimedCount != 0) {
tablet->filterTimed[0]->StopTimer();
}
}

Expand Down
97 changes: 97 additions & 0 deletions TabletDriverService/PositionRingBuffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#include "stdafx.h"
#include "PositionRingBuffer.h"


//
// Constructor
//
PositionRingBuffer::PositionRingBuffer() {
maxLength = sizeof(buffer) / sizeof(Vector2D);
length = 0;
count = 0;
index = 0;
isValid = false;
}


//
// Destructor
//
PositionRingBuffer::~PositionRingBuffer() {
}


//
// Set buffer length
//
void PositionRingBuffer::SetLength(int len) {
if(len > maxLength) {
length = maxLength;
} else {
length = len;
}
}


//
// Add position to buffer
//
void PositionRingBuffer::Add(Vector2D vector) {
buffer[index].x = vector.x;
buffer[index].y = vector.y;
index++;
count++;
if(count > length) {
count = length;
}
if(index >= length) {
index = 0;
}
isValid = true;
}


//
// Get position history from the buffer
//
bool PositionRingBuffer::GetLatest(Vector2D *output, int delta) {
int newIndex;

// Buffer empty?
if(count == 0) return false;

// Valid delta?
if(delta > 0 || delta <= -count) return false;

newIndex = index - 1 + delta;

// Limits
if(newIndex < 0) newIndex = count + newIndex;

if(newIndex < 0 || newIndex >= count) {
return false;
}

output->x = buffer[newIndex].x;
output->y = buffer[newIndex].y;
return true;
}


//
// Reset buffer
//
void PositionRingBuffer::Reset() {
count = 0;
index = 0;
isValid = false;
}



//
// [] operator
//
Vector2D *PositionRingBuffer::operator[](std::size_t index) {
return &(buffer[index]);
}
25 changes: 25 additions & 0 deletions TabletDriverService/PositionRingBuffer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#include "Vector2D.h"

class PositionRingBuffer {
public:
Vector2D buffer[100];
int maxLength;
int length;
int count;
int index;
bool isValid;

void SetLength(int length);
void Add(Vector2D vector);
bool GetLatest(Vector2D *output, int delta);
void Reset();

Vector2D *operator[](std::size_t index);


PositionRingBuffer();
~PositionRingBuffer();
};

Loading

0 comments on commit b033436

Please sign in to comment.