Skip to content

Instantly share code, notes, and snippets.

@Ryochan7
Last active June 5, 2018 22:22
Show Gist options
  • Select an option

  • Save Ryochan7/63cc5be3b7bb73eaa11ab5118092e730 to your computer and use it in GitHub Desktop.

Select an option

Save Ryochan7/63cc5be3b7bb73eaa11ab5118092e730 to your computer and use it in GitHub Desktop.
Changes made to Touchmote project
diff --git a/.gitignore b/.gitignore
index cff167c..793ee80 100644
--- a/.gitignore
+++ b/.gitignore
@@ -115,7 +115,8 @@ _UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
-
+*.VC.db
+*.VC.opendb
############
## Windows
diff --git a/D3DCursor/D3DCursor.vcxproj b/D3DCursor/D3DCursor.vcxproj
index 3132ac2..3225919 100644
--- a/D3DCursor/D3DCursor.vcxproj
+++ b/D3DCursor/D3DCursor.vcxproj
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@@ -22,28 +22,29 @@
<ProjectGuid>{4796387A-2F8E-4ED0-96E4-A72137B4428C}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>D3DCursor</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<ConfigurationType>DynamicLibrary</ConfigurationType>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<WholeProgramOptimization>true</WholeProgramOptimization>
diff --git a/Touchmote.sln b/Touchmote.sln
index 63038eb..b9fcb58 100644
--- a/Touchmote.sln
+++ b/Touchmote.sln
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0.21005.1
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WiiTUIO", "WiiTUIO\WiiTUIO.csproj", "{87CC8302-A614-490E-9100-1059AF5FE8FC}"
ProjectSection(ProjectDependencies) = postProject
@@ -40,7 +40,6 @@ Global
{87CC8302-A614-490E-9100-1059AF5FE8FC}.Release|x86.ActiveCfg = Release|x86
{87CC8302-A614-490E-9100-1059AF5FE8FC}.Release|x86.Build.0 = Release|x86
{14BD1D44-261D-4FC2-A7DD-A3CDA413D790}.Debug|x64.ActiveCfg = Debug|x64
- {14BD1D44-261D-4FC2-A7DD-A3CDA413D790}.Debug|x64.Build.0 = Debug|x64
{14BD1D44-261D-4FC2-A7DD-A3CDA413D790}.Debug|x86.ActiveCfg = Debug|x86
{14BD1D44-261D-4FC2-A7DD-A3CDA413D790}.Debug|x86.Build.0 = Debug|x86
{14BD1D44-261D-4FC2-A7DD-A3CDA413D790}.Release|x64.ActiveCfg = Release|x64
@@ -48,7 +47,6 @@ Global
{14BD1D44-261D-4FC2-A7DD-A3CDA413D790}.Release|x86.ActiveCfg = Release|x86
{14BD1D44-261D-4FC2-A7DD-A3CDA413D790}.Release|x86.Build.0 = Release|x86
{78EB9DE8-B6FC-47F3-970F-0B4FCB0F38A8}.Debug|x64.ActiveCfg = Debug|x64
- {78EB9DE8-B6FC-47F3-970F-0B4FCB0F38A8}.Debug|x64.Build.0 = Debug|x64
{78EB9DE8-B6FC-47F3-970F-0B4FCB0F38A8}.Debug|x86.ActiveCfg = Debug|Win32
{78EB9DE8-B6FC-47F3-970F-0B4FCB0F38A8}.Debug|x86.Build.0 = Debug|Win32
{78EB9DE8-B6FC-47F3-970F-0B4FCB0F38A8}.Release|x64.ActiveCfg = Release|x64
@@ -56,7 +54,6 @@ Global
{78EB9DE8-B6FC-47F3-970F-0B4FCB0F38A8}.Release|x86.ActiveCfg = Release|Win32
{78EB9DE8-B6FC-47F3-970F-0B4FCB0F38A8}.Release|x86.Build.0 = Release|Win32
{9E8F1D50-74EA-4C60-BD5C-AB2C5B53BC66}.Debug|x64.ActiveCfg = Debug|x64
- {9E8F1D50-74EA-4C60-BD5C-AB2C5B53BC66}.Debug|x64.Build.0 = Debug|x64
{9E8F1D50-74EA-4C60-BD5C-AB2C5B53BC66}.Debug|x86.ActiveCfg = Debug|x86
{9E8F1D50-74EA-4C60-BD5C-AB2C5B53BC66}.Debug|x86.Build.0 = Debug|x86
{9E8F1D50-74EA-4C60-BD5C-AB2C5B53BC66}.Release|x64.ActiveCfg = Release|x64
@@ -76,7 +73,6 @@ Global
{D1E85F1A-3BE3-46C1-B086-EF1335457EF5}.Release|x86.ActiveCfg = Release|x86
{D1E85F1A-3BE3-46C1-B086-EF1335457EF5}.Release|x86.Build.0 = Release|x86
{4796387A-2F8E-4ED0-96E4-A72137B4428C}.Debug|x64.ActiveCfg = Debug|x64
- {4796387A-2F8E-4ED0-96E4-A72137B4428C}.Debug|x64.Build.0 = Debug|x64
{4796387A-2F8E-4ED0-96E4-A72137B4428C}.Debug|x86.ActiveCfg = Debug|Win32
{4796387A-2F8E-4ED0-96E4-A72137B4428C}.Debug|x86.Build.0 = Debug|Win32
{4796387A-2F8E-4ED0-96E4-A72137B4428C}.Release|x64.ActiveCfg = Release|x64
diff --git a/WiiCPP/WiiCPP.h b/WiiCPP/WiiCPP.h
index 0ab30d4..983047b 100644
--- a/WiiCPP/WiiCPP.h
+++ b/WiiCPP/WiiCPP.h
@@ -35,7 +35,7 @@ namespace WiiCPP {
Status status;
int numberPaired;
bool removeMode;
- array<String^>^ deviceNames;
+ cli::array<String^>^ deviceNames;
};
public interface class WiiPairListener
@@ -135,7 +135,7 @@ namespace WiiCPP {
report->removeMode = removeMode;
- report->deviceNames = gcnew array<String^>(10);
+ report->deviceNames = gcnew cli::array<String^>(10);
do
{
@@ -476,7 +476,7 @@ namespace WiiCPP {
}
- static array<MonitorInfo^>^ enumerateMonitors(){
+ static cli::array<MonitorInfo^>^ enumerateMonitors(){
int numMonitors = 0;
int curMonitor = 0;
@@ -512,7 +512,7 @@ namespace WiiCPP {
}
}
- array<MonitorInfo^>^ monitors = gcnew array<MonitorInfo^>(monitormap.size());
+ cli::array<MonitorInfo^>^ monitors = gcnew cli::array<MonitorInfo^>(monitormap.size());
for (map<int, gcroot<MonitorInfo^>>::iterator iter = monitormap.begin();
iter != monitormap.end();
diff --git a/WiiCPP/WiiCPP.vcxproj b/WiiCPP/WiiCPP.vcxproj
index 8af7fcb..db7b436 100644
--- a/WiiCPP/WiiCPP.vcxproj
+++ b/WiiCPP/WiiCPP.vcxproj
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@@ -20,36 +20,37 @@
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{78EB9DE8-B6FC-47F3-970F-0B4FCB0F38A8}</ProjectGuid>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<Keyword>ManagedCProj</Keyword>
<RootNamespace>WiiCPP</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v141</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v141</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v141</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v141</PlatformToolset>
<CLRSupport>true</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
diff --git a/WiiTUIO/Input/WiiProvider/Keymap/WiiKeyMap.cs b/WiiTUIO/Input/WiiProvider/Keymap/WiiKeyMap.cs
index 4e2f131..bcc6014 100644
--- a/WiiTUIO/Input/WiiProvider/Keymap/WiiKeyMap.cs
+++ b/WiiTUIO/Input/WiiProvider/Keymap/WiiKeyMap.cs
@@ -161,12 +161,12 @@ public void updateAccelerometer(AccelState accelState)
updateStickHandlers(outConfig, 0);
}
- if (accelState.Values.X * 2 > outConfig.Threshold && !PressedButtons["AccelX+"])
+ if (accelState.Values.X > outConfig.Threshold && !PressedButtons["AccelX+"])
{
PressedButtons["AccelX+"] = true;
this.executeButtonDown("AccelX+");
}
- else if (accelState.Values.X * 2 < outConfig.Threshold && PressedButtons["AccelX+"])
+ else if (accelState.Values.X < outConfig.Threshold && PressedButtons["AccelX+"])
{
PressedButtons["AccelX+"] = false;
this.executeButtonUp("AccelX+");
@@ -183,12 +183,12 @@ public void updateAccelerometer(AccelState accelState)
updateStickHandlers(outConfig, 0);
}
- if (accelState.Values.X * -2 > outConfig.Threshold && !PressedButtons["AccelX-"])
+ if (accelState.Values.X * -1 > outConfig.Threshold && !PressedButtons["AccelX-"])
{
PressedButtons["AccelX-"] = true;
this.executeButtonDown("AccelX-");
}
- else if (accelState.Values.X * -2 < outConfig.Threshold && PressedButtons["AccelX-"])
+ else if (accelState.Values.X * -1 < outConfig.Threshold && PressedButtons["AccelX-"])
{
PressedButtons["AccelX-"] = false;
this.executeButtonUp("AccelX-");
@@ -205,12 +205,12 @@ public void updateAccelerometer(AccelState accelState)
updateStickHandlers(outConfig, 0);
}
- if (accelState.Values.Y * 2 > outConfig.Threshold && !PressedButtons["AccelY+"])
+ if (accelState.Values.Y > outConfig.Threshold && !PressedButtons["AccelY+"])
{
PressedButtons["AccelY+"] = true;
this.executeButtonDown("AccelY+");
}
- else if (accelState.Values.Y * 2 < outConfig.Threshold && PressedButtons["AccelY+"])
+ else if (accelState.Values.Y < outConfig.Threshold && PressedButtons["AccelY+"])
{
PressedButtons["AccelY+"] = false;
this.executeButtonUp("AccelY+");
@@ -227,12 +227,12 @@ public void updateAccelerometer(AccelState accelState)
updateStickHandlers(outConfig, 0);
}
- if (accelState.Values.Y * -2 > outConfig.Threshold && !PressedButtons["AccelY-"])
+ if (accelState.Values.Y * -1 > outConfig.Threshold && !PressedButtons["AccelY-"])
{
PressedButtons["AccelY-"] = true;
this.executeButtonDown("AccelY-");
}
- else if (accelState.Values.Y * -2 < outConfig.Threshold && PressedButtons["AccelY-"])
+ else if (accelState.Values.Y * -1 < outConfig.Threshold && PressedButtons["AccelY-"])
{
PressedButtons["AccelY-"] = false;
this.executeButtonUp("AccelY-");
@@ -249,12 +249,12 @@ public void updateAccelerometer(AccelState accelState)
updateStickHandlers(outConfig, 0);
}
- if (accelState.Values.Z * 2 > outConfig.Threshold && !PressedButtons["AccelZ+"])
+ if (accelState.Values.Z > outConfig.Threshold && !PressedButtons["AccelZ+"])
{
PressedButtons["AccelZ+"] = true;
this.executeButtonDown("AccelZ+");
}
- else if (accelState.Values.Z * 2 < outConfig.Threshold && PressedButtons["AccelZ+"])
+ else if (accelState.Values.Z < outConfig.Threshold && PressedButtons["AccelZ+"])
{
PressedButtons["AccelZ+"] = false;
this.executeButtonUp("AccelZ+");
@@ -271,12 +271,12 @@ public void updateAccelerometer(AccelState accelState)
updateStickHandlers(outConfig, 0);
}
- if (accelState.Values.Z * -2 > outConfig.Threshold && !PressedButtons["AccelZ-"])
+ if (accelState.Values.Z * -1 > outConfig.Threshold && !PressedButtons["AccelZ-"])
{
PressedButtons["AccelZ-"] = true;
this.executeButtonDown("AccelZ-");
}
- else if (accelState.Values.Z * -2 < outConfig.Threshold && PressedButtons["AccelZ-"])
+ else if (accelState.Values.Z * -1 < outConfig.Threshold && PressedButtons["AccelZ-"])
{
PressedButtons["AccelZ-"] = false;
this.executeButtonUp("AccelZ-");
@@ -392,12 +392,12 @@ public void updateNunchuk(NunchukState nunchuk)
updateStickHandlers(outConfig, 0);
}
- if (accelState.Values.X * 2 > outConfig.Threshold && !PressedButtons["Nunchuk.AccelX+"])
+ if (accelState.Values.X > outConfig.Threshold && !PressedButtons["Nunchuk.AccelX+"])
{
PressedButtons["Nunchuk.AccelX+"] = true;
this.executeButtonDown("Nunchuk.AccelX+");
}
- else if (accelState.Values.X * 2 < outConfig.Threshold && PressedButtons["Nunchuk.AccelX+"])
+ else if (accelState.Values.X < outConfig.Threshold && PressedButtons["Nunchuk.AccelX+"])
{
PressedButtons["Nunchuk.AccelX+"] = false;
this.executeButtonUp("Nunchuk.AccelX+");
@@ -414,12 +414,12 @@ public void updateNunchuk(NunchukState nunchuk)
updateStickHandlers(outConfig, 0);
}
- if (accelState.Values.X * -2 > outConfig.Threshold && !PressedButtons["Nunchuk.AccelX-"])
+ if (accelState.Values.X * -1 > outConfig.Threshold && !PressedButtons["Nunchuk.AccelX-"])
{
PressedButtons["Nunchuk.AccelX-"] = true;
this.executeButtonDown("Nunchuk.AccelX-");
}
- else if (accelState.Values.X * -2 < outConfig.Threshold && PressedButtons["Nunchuk.AccelX-"])
+ else if (accelState.Values.X * -1 < outConfig.Threshold && PressedButtons["Nunchuk.AccelX-"])
{
PressedButtons["Nunchuk.AccelX-"] = false;
this.executeButtonUp("Nunchuk.AccelX-");
@@ -436,12 +436,12 @@ public void updateNunchuk(NunchukState nunchuk)
updateStickHandlers(outConfig, 0);
}
- if (accelState.Values.Y * 2 > outConfig.Threshold && !PressedButtons["Nunchuk.AccelY+"])
+ if (accelState.Values.Y > outConfig.Threshold && !PressedButtons["Nunchuk.AccelY+"])
{
PressedButtons["Nunchuk.AccelY+"] = true;
this.executeButtonDown("Nunchuk.AccelY+");
}
- else if (accelState.Values.Y * 2 < outConfig.Threshold && PressedButtons["Nunchuk.AccelY+"])
+ else if (accelState.Values.Y < outConfig.Threshold && PressedButtons["Nunchuk.AccelY+"])
{
PressedButtons["Nunchuk.AccelY+"] = false;
this.executeButtonUp("Nunchuk.AccelY+");
@@ -458,12 +458,12 @@ public void updateNunchuk(NunchukState nunchuk)
updateStickHandlers(outConfig, 0);
}
- if (accelState.Values.Y * -2 > outConfig.Threshold && !PressedButtons["Nunchuk.AccelY-"])
+ if (accelState.Values.Y * -1 > outConfig.Threshold && !PressedButtons["Nunchuk.AccelY-"])
{
PressedButtons["Nunchuk.AccelY-"] = true;
this.executeButtonDown("Nunchuk.AccelY-");
}
- else if (accelState.Values.Y * -2 < outConfig.Threshold && PressedButtons["Nunchuk.AccelY-"])
+ else if (accelState.Values.Y * -1 < outConfig.Threshold && PressedButtons["Nunchuk.AccelY-"])
{
PressedButtons["Nunchuk.AccelY-"] = false;
this.executeButtonUp("Nunchuk.AccelY-");
@@ -480,12 +480,12 @@ public void updateNunchuk(NunchukState nunchuk)
updateStickHandlers(outConfig, 0);
}
- if (accelState.Values.Z * 2 > outConfig.Threshold && !PressedButtons["Nunchuk.AccelZ+"])
+ if (accelState.Values.Z > outConfig.Threshold && !PressedButtons["Nunchuk.AccelZ+"])
{
PressedButtons["Nunchuk.AccelZ+"] = true;
this.executeButtonDown("Nunchuk.AccelZ+");
}
- else if (accelState.Values.Z * 2 < outConfig.Threshold && PressedButtons["Nunchuk.AccelZ+"])
+ else if (accelState.Values.Z < outConfig.Threshold && PressedButtons["Nunchuk.AccelZ+"])
{
PressedButtons["Nunchuk.AccelZ+"] = false;
this.executeButtonUp("Nunchuk.AccelZ+");
@@ -502,12 +502,12 @@ public void updateNunchuk(NunchukState nunchuk)
updateStickHandlers(outConfig, 0);
}
- if (accelState.Values.Z * -2 > outConfig.Threshold && !PressedButtons["Nunchuk.AccelZ-"])
+ if (accelState.Values.Z * -1 > outConfig.Threshold && !PressedButtons["Nunchuk.AccelZ-"])
{
PressedButtons["Nunchuk.AccelZ-"] = true;
this.executeButtonDown("Nunchuk.AccelZ-");
}
- else if (accelState.Values.Z * -2 < outConfig.Threshold && PressedButtons["Nunchuk.AccelZ-"])
+ else if (accelState.Values.Z * -1 < outConfig.Threshold && PressedButtons["Nunchuk.AccelZ-"])
{
PressedButtons["Nunchuk.AccelZ-"] = false;
this.executeButtonUp("Nunchuk.AccelZ-");
diff --git a/WiiTUIO/Input/WiiProvider/Pointer/ScreenPositionCalculator.cs b/WiiTUIO/Input/WiiProvider/Pointer/ScreenPositionCalculator.cs
index 7468919..530d423 100644
--- a/WiiTUIO/Input/WiiProvider/Pointer/ScreenPositionCalculator.cs
+++ b/WiiTUIO/Input/WiiProvider/Pointer/ScreenPositionCalculator.cs
@@ -239,9 +239,11 @@ public CursorPos CalculateCursorPos(WiimoteState wiimoteState)
//relativePosition.X = 1 - relativePosition.X;
//relativePosition.Y = 1 - relativePosition.Y;
}
-
- x = Convert.ToInt32((float)maxWidth * relativePosition.X + minXPos);
- y = Convert.ToInt32((float)maxHeight * relativePosition.Y + minYPos) + offsetY;
+
+ //x = Convert.ToInt32((float)maxWidth * relativePosition.X + minXPos);
+ //y = Convert.ToInt32((float)maxHeight * relativePosition.Y + minYPos) + offsetY;
+ x = Convert.ToInt32((float)3902 * relativePosition.X + (-1170)); // input: [0.3, 0.65]
+ y = Convert.ToInt32((float)2191 * relativePosition.Y + (-657)) + offsetY; // Input: [0.3, 0.65]
if (x <= 0)
{
diff --git a/WiiTUIO/Input/WiiProvider/SpatiotemporalClassifier.cs b/WiiTUIO/Input/WiiProvider/SpatiotemporalClassifier.cs
index 9a01f3b..0572b8d 100644
--- a/WiiTUIO/Input/WiiProvider/SpatiotemporalClassifier.cs
+++ b/WiiTUIO/Input/WiiProvider/SpatiotemporalClassifier.cs
@@ -731,6 +731,8 @@ public void resize(int iSmoothSize, bool bPreserve)
public void clear()
{
this.iSmoothIndex = 0;
+ // Create a new array.
+ tSmoothBuffer = new Vector[tSmoothBuffer.Length];
}
/// <summary>
@@ -744,7 +746,8 @@ public void addValue(double x, double y)
int iIndex = iSmoothIndex % tSmoothBuffer.Length;
tSmoothBuffer[iIndex].X = x;
tSmoothBuffer[iIndex].Y = y;
- ++iSmoothIndex;
+ //++iSmoothIndex;
+ iSmoothIndex = iIndex + 1;
}
/// <summary>
@@ -754,15 +757,19 @@ public void addValue(double x, double y)
public void addValue(Vector vPoint)
{
// Insert the value then update the counter.
- tSmoothBuffer[iSmoothIndex % tSmoothBuffer.Length] = vPoint;
- ++iSmoothIndex;
+ //tSmoothBuffer[iSmoothIndex % tSmoothBuffer.Length] = vPoint;
+ //++iSmoothIndex;
+ int iIndex = iSmoothIndex % tSmoothBuffer.Length;
+ tSmoothBuffer[iIndex] = vPoint;
+ iSmoothIndex = iIndex + 1;
}
public void replaceLast(Vector vPoint)
{
// Insert the value then update the counter.
- int lastIndex = (iSmoothIndex - 1) % tSmoothBuffer.Length;
- if(lastIndex<0)
+ //int lastIndex = (iSmoothIndex - 1) % tSmoothBuffer.Length;
+ int lastIndex = Math.Abs(iSmoothIndex - 1) % tSmoothBuffer.Length;
+ if (lastIndex<0)
{
lastIndex = tSmoothBuffer.Length-1;
}
@@ -779,9 +786,9 @@ public Vector getSmoothedValue()
{
// Get the number of values to iterate too.
Vector tSmooth = new Vector(0, 0);
- int iMax = Math.Min(iSmoothIndex, tSmoothBuffer.Length);
- if (iMax == 0)
- throw new Exception("No values in the smoothing buffer!");
+ //int iMax = Math.Min(iSmoothIndex, tSmoothBuffer.Length);
+ //if (iMax == 0)
+ // throw new Exception("No values in the smoothing buffer!");
/*
Vector curVector = tSmoothBuffer[iMax-1];
@@ -798,7 +805,7 @@ public Vector getSmoothedValue()
}
*/
// Sum up the values in the array.
- for (int i = 0; i < iMax; ++i)
+ /*for (int i = 0; i < iMax; ++i)
{
tSmooth.X += tSmoothBuffer[i].X;
tSmooth.Y += tSmoothBuffer[i].Y;
@@ -807,6 +814,21 @@ public Vector getSmoothedValue()
// Divide to average.
tSmooth.X /= iMax;
tSmooth.Y /= iMax;
+ */
+
+ double currentWeight = 1.0;
+ double finalWeight = 0.0;
+ for (int i = 0, buflen = tSmoothBuffer.Length; i < buflen; i++)
+ {
+ int idx = (iSmoothIndex - i - 1 + buflen) % buflen;
+ tSmooth.X += tSmoothBuffer[idx].X * currentWeight;
+ tSmooth.Y += tSmoothBuffer[idx].Y * currentWeight;
+ finalWeight += currentWeight;
+ currentWeight *= 0.5;
+ }
+
+ tSmooth.X /= finalWeight;
+ tSmooth.Y /= finalWeight;
// Return the value.
return tSmooth;
diff --git a/WiiTUIO/Output/Handlers/MouseHandler.cs b/WiiTUIO/Output/Handlers/MouseHandler.cs
index 7aa5f8b..50eb0c9 100644
--- a/WiiTUIO/Output/Handlers/MouseHandler.cs
+++ b/WiiTUIO/Output/Handlers/MouseHandler.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -9,6 +10,8 @@
using WiiTUIO.Provider;
using WindowsInput;
using WindowsInput.Native;
+using DS4Windows;
+
namespace WiiTUIO.Output.Handlers
{
@@ -19,12 +22,60 @@ public class MouseHandler : IButtonHandler, IStickHandler, ICursorHandler
private bool mouseLeftDown = false;
private bool mouseRightDown = false;
+ // Remainder values used for partial mouse distance calculations.
+ private double remainderX = 0.0;
+ private double remainderY = 0.0;
+ // PointerX and PointerY values from previous Wiimote poll.
+ private double previousPointerX = 0.5;
+ private double previousPointerY = 0.5;
+
+ // Check elapsed time that delta acceleration is applied.
+ private Stopwatch deltaEasingTimeX;
+ private Stopwatch deltaEasingTimeY;
+
+ // Keep track of current acceleration multiplier in directions.
+ private double accelHelperX = 0.0;
+ private double accelHelperY = 0.0;
+ // Keep track of travel value that caused acceleration
+ private double accelTravelX = 0.0;
+ private double accelTravelY = 0.0;
+
+ // Add period of mouse movement when remote is out of IR range.
+ private Stopwatch outOfReachElapsed;
+ private bool outOfReachStatus = true;
+
+ // Add dead period when remote is initially moved into IR range.
+ private Stopwatch initialInReachElapsed;
+ private bool initialInReachStatus = false;
+
+ // Add small easing region in final acceleration region
+ // for X axis
+ private Stopwatch regionEasingX;
+ //private bool enableRegionEasing = true;
+
private CursorPositionHelper cursorPositionHelper;
+ // Measured in milliseconds
+ public const int OUTOFREACH_ELAPSED_TIME = 1000;
+ public const int INITIAL_INREACH_ELAPSED_TIME = 125;
+
+ private bool initialMouseMove = false;
+ private double mouseOffsetX = 0.0;
+ private double mouseOffsetY = 0.0;
+ //private double cosAngle = 0.0;
+ //private double sinAngle = 0.0;
+ private double unitX = 0.0;
+ private double unitY = 0.0;
+
public MouseHandler()
{
this.inputSimulator = new InputSimulator();
cursorPositionHelper = new CursorPositionHelper();
+ this.deltaEasingTimeX = new Stopwatch();
+ this.deltaEasingTimeY = new Stopwatch();
+ this.outOfReachElapsed = new Stopwatch();
+ this.initialInReachElapsed = new Stopwatch();
+ this.regionEasingX = new Stopwatch();
}
public bool reset()
@@ -76,7 +127,7 @@ public bool setButtonUp(string key)
break;
case MouseCode.MOUSERIGHT:
this.inputSimulator.Mouse.RightButtonUp();
- mouseLeftDown = false;
+ mouseRightDown = false;
break;
default:
return false;
@@ -101,27 +152,589 @@ public bool setPosition(string key, CursorPos cursorPos)
if (key.Equals("fpsmouse"))
{
- Point smoothedPos = cursorPositionHelper.getSmoothedPosition(new Point(cursorPos.RelativeX, cursorPos.RelativeY));
+ bool shouldMoveFPSCursor = !outOfReachStatus;
+ initialMouseMove = false;
- /*
- * TODO: Consider sensor bar position?
- if (Settings.Default.pointer_sensorBarPos == "top")
+ if (!cursorPos.OutOfReach)
{
- smoothedPos.Y = smoothedPos.Y - Settings.Default.pointer_sensorBarPosCompensation;
+ // If remote in IR range, uncheck out of reach status.
+ outOfReachStatus = false;
+ if (outOfReachElapsed.IsRunning)
+ {
+ outOfReachElapsed.Stop();
+ }
+
+ // Check if remote has been moved into IR range.
+ if (initialInReachStatus)
+ {
+ if (!initialInReachElapsed.IsRunning)
+ {
+ // Start timer if not running.
+ initialInReachElapsed.Restart();
+ }
+
+ if (initialInReachElapsed.IsRunning)
+ {
+ if (initialInReachElapsed.ElapsedMilliseconds < INITIAL_INREACH_ELAPSED_TIME)
+ {
+ shouldMoveFPSCursor = false;
+ }
+ else
+ {
+ shouldMoveFPSCursor = true;
+ initialInReachStatus = false;
+ initialMouseMove = true;
+ initialInReachElapsed.Stop();
+ }
+ }
+ }
+ else
+ {
+ shouldMoveFPSCursor = true;
+ }
}
- else if (Settings.Default.pointer_sensorBarPos == "bottom")
+ else if (!outOfReachStatus)
{
- smoothedPos.Y = smoothedPos.Y + Settings.Default.pointer_sensorBarPosCompensation;
+ if (!outOfReachElapsed.IsRunning)
+ {
+ // Start timer if not running.
+ outOfReachElapsed.Restart();
+ }
+
+ if (outOfReachElapsed.IsRunning)
+ {
+ // Check if time has passed. If so, mark out of reach
+ // status bool shouldMoveFPSCursor = !outOfReachStatus;and stop timer.
+ long elapsed = outOfReachElapsed.ElapsedMilliseconds;
+ if (elapsed >= OUTOFREACH_ELAPSED_TIME)
+ {
+ outOfReachStatus = true;
+ outOfReachElapsed.Stop();
+ }
+ else
+ {
+ // Time has not elapsed. Keep out of reach status
+ // at false.
+ outOfReachStatus = false;
+ }
+ }
+
}
- */
- double deadzone = Settings.Default.fpsmouse_deadzone; // TODO: Move to settings
- double shiftX = Math.Abs(smoothedPos.X - 0.5) > deadzone ? smoothedPos.X - 0.5 : 0;
- double shiftY = Math.Abs(smoothedPos.Y - 0.5) > deadzone ? smoothedPos.Y - 0.5 : 0;
- this.inputSimulator.Mouse.MoveMouseBy((int)(Settings.Default.fpsmouse_speed * shiftX), (int)(Settings.Default.fpsmouse_speed * shiftY));
+ //Debug.WriteLine("DUDE BRO: " + Convert.ToString(initialMouseMove));
- return true;
+ // Checks show that remote should be considered in IR range.
+ if (shouldMoveFPSCursor)
+ //if (!outOfReachStatus)
+ {
+ //Point smoothedPos = cursorPositionHelper.getSmoothedPosition(new Point(cursorPos.RelativeX, cursorPos.RelativeY));
+ // Use proper IR values for full IR range and to take
+ // margins into account.
+ Point smoothedPos = cursorPositionHelper.getRelativePosition(new Point(cursorPos.X, cursorPos.Y));
+
+ /* TODO: Consider sensor bar position?
+ if (Settings.Default.pointer_sensorBarPos == "top")
+ {
+ smoothedPos.Y = smoothedPos.Y - Settings.Default.pointer_sensorBarPosCompensation;
+ }
+ else if (Settings.Default.pointer_sensorBarPos == "bottom")
+ {
+ smoothedPos.Y = smoothedPos.Y + Settings.Default.pointer_sensorBarPosCompensation;
+ }
+ */
+ //double deadzone = Settings.Default.fpsmouse_deadzone; // TODO: Move to settings
+ double deadzone = Settings.Default.fpsmouse_deadzone;
+
+ // Make dead zone region circular instead of a square.
+ double tempdeadangle = Math.Atan2(-(smoothedPos.Y - 0.5), smoothedPos.X - 0.5);
+ unitX = Math.Abs(Math.Cos(tempdeadangle));
+ unitY = Math.Abs(Math.Sin(tempdeadangle));
+ double deadzoneX = deadzone * unitX;
+ double deadzoneY = deadzone * 1.0 * unitY;
+
+ double fps_mouse_speed = Settings.Default.fpsmouse_speed;
+
+ double testAccelMulti = Settings.Default.test_deltaAccelMulti;
+ double testAccelMinTravel = Settings.Default.test_deltaAccelMinTravel;
+ double testAccelMaxTravel = Settings.Default.test_deltaAccelMaxTravel > testAccelMinTravel ? Settings.Default.test_deltaAccelMaxTravel : 0.5;
+ double testAccelEasingDuration = Settings.Default.test_deltaAccelEasingDuration;
+ bool testDeltaAccel = Settings.Default.test_deltaAccel;
+
+ bool enableRegionEasing = Settings.Default.test_regionEasingXDuration > 0.0;
+ double easingOffset = Settings.Default.test_regionEasingXOffset;
+
+ double shiftX = 0.0;
+ double shiftY = 0.0;
+
+ // Find X distance away from assigned dead zone
+ if (Math.Abs(smoothedPos.X - 0.5) > deadzoneX)
+ {
+ if (smoothedPos.X >= 0.5)
+ {
+ shiftX = (smoothedPos.X - 0.5 - deadzoneX) / (1.0 - 0.5 - deadzoneX);
+ }
+ else
+ {
+ shiftX = (smoothedPos.X - (0.5 - deadzoneX)) / (1.0 - 0.5 - deadzoneX);
+ }
+ }
+
+ // Find Y distance away from assigned dead zone
+ if (Math.Abs(smoothedPos.Y - 0.5) > deadzoneY)
+ {
+ if (smoothedPos.Y >= 0.5)
+ {
+ shiftY = (smoothedPos.Y - 0.5 - deadzoneY) / (1.0 - 0.5 - deadzoneY);
+ }
+ else
+ {
+ shiftY = (smoothedPos.Y - (0.5 - deadzoneY)) / (1.0 - 0.5 - deadzoneY);
+ }
+ }
+
+ //double shiftX = Math.Abs(smoothedPos.X - 0.5) > deadzone ? (smoothedPos.X - 0.5) : 0;
+ //double shiftY = Math.Abs(smoothedPos.Y - 0.5) > deadzone ? (smoothedPos.Y - 0.5) : 0;
+
+ // Need sign components for later calculations
+ double signshiftX = (shiftX >= 0) ? 1.0 : -1.0;
+ double signshiftY = (shiftY >= 0) ? 1.0 : -1.0;
+
+ // Need absolute values for later calculations
+ double absX = Math.Abs(shiftX);
+ double absY = Math.Abs(shiftY);
+
+ if (absX <= 0.75 && regionEasingX.IsRunning)
+ {
+ // No longer in easing region
+ regionEasingX.Stop();
+ }
+ else if (absX > 0.75 && regionEasingX.IsRunning &&
+ (previousPointerX >= 0.5) != (smoothedPos.X >= 0.5))
+ {
+ // Direction changed quickly. Restart easing timer.
+ regionEasingX.Restart();
+ }
+
+ // Use three types of acceleration depending on distance
+ // away from dead zone. Will need to change later.
+ if (absX <= 0.4)
+ {
+ //shiftX = 0.395 * absX;
+ shiftX = 0.414 * absX;
+ }
+ else if (absX <= 0.75)
+ {
+ //shiftX = 1.0 * absX - 0.242;
+ shiftX = 1.0 * absX - 0.2344;
+ }
+ else
+ {
+ double tempAbsx = absX;
+
+ if (enableRegionEasing)
+ {
+ double easingDuration = Settings.Default.test_regionEasingXDuration;
+
+ double easingElapsed = 0.0;
+ double elapsedDiff = 1.0;
+ if (regionEasingX.IsRunning)
+ {
+ easingElapsed = regionEasingX.ElapsedMilliseconds;
+ }
+ else
+ {
+ regionEasingX.Restart();
+ }
+
+ double adjustedEasingDuration = ((4.0 * absX) - 3.0) * easingDuration;
+ //double adjustedEasingDuration = easingDuration;
+ if (easingDuration > 0.0 && adjustedEasingDuration > 0.0 &&
+ (easingElapsed * 0.001) < adjustedEasingDuration)
+ {
+ //elapsedDiff = (easingElapsed * 0.001) / easingDuration;
+ //double minAbsRegionX = 0.75;
+ double minAbsRegionX = absX + (easingOffset * (absX - 0.75));
+ elapsedDiff = (easingElapsed * 0.001) / adjustedEasingDuration;
+ //elapsedDiff = (absX - 0.75) * elapsedDiff + 0.75;
+ elapsedDiff = (absX - minAbsRegionX) * elapsedDiff + minAbsRegionX;
+ }
+ else
+ {
+ elapsedDiff = absX;
+ }
+
+ tempAbsx = elapsedDiff;
+ }
+
+ //shiftX = 1.968 * tempAbsx - 0.968;
+ shiftX = 1.9376 * tempAbsx - 0.9376;
+ }
+
+ // Use three types of acceleration depending on distance
+ // away from dead zone. Will need to change later.
+ if (absY <= 0.4)
+ {
+ //shiftY = 0.395 * absY;
+ shiftY = 0.414 * absY;
+ }
+ else if (absY <= 0.75)
+ {
+ //shiftY = 1.0 * absY - 0.242;
+ shiftY = 1.0 * absY - 0.2344;
+ }
+ else
+ {
+ //shiftY = 1.968 * absY - 0.968;
+ shiftY = 1.9376 * absY - 0.9376;
+ }
+
+ // Add sign bit
+ shiftX = signshiftX * shiftX;
+ shiftY = signshiftY * shiftY;
+
+ // Calculate delta acceleration slope and offset.
+ double accelSlope = (testAccelMulti - 1.0) / (testAccelMaxTravel - testAccelMinTravel);
+ double accelOffset = 1.0 - (accelSlope * testAccelMinTravel);
+
+ // If deltaX >= 0.1 and displacement is increasing then
+ // use acceleration multiplier.
+ if (absX > 0.0 && testDeltaAccel && !initialMouseMove &&
+ Math.Abs(previousPointerX - smoothedPos.X) >= testAccelMinTravel &&
+ (smoothedPos.X - previousPointerX >= 0.0) == (smoothedPos.X >= 0.5))
+ {
+ double tempTravel = Math.Min(Math.Abs(previousPointerX - smoothedPos.X), testAccelMaxTravel);
+ if (accelHelperX > 1.0)
+ {
+ // Already in acceleration mode. Add accel
+ // dead zone to travel.
+ //tempTravel = Math.Min(tempTravel + testAccelMinTravel, testAccelMaxTravel);
+ }
+
+ //double tempDist = Math.Min(tempTravel / 0.5, 1.0);
+ double tempDist = Math.Min(tempTravel, testAccelMaxTravel);
+
+ /*double currentAccelMultiTemp = (accelSlope * tempDist + accelOffset);
+ double getMultiDiff = (currentAccelMultiTemp - 1.0) / (testAccelMulti - 1.0);
+ //currentAccelMultiTemp = -(testAccelMulti - 1.0) / (getMultiDiff * (getMultiDiff - 2.0)) + 1.0;
+ currentAccelMultiTemp = (testAccelMulti - 1.0) / Math.Sin(getMultiDiff * (Math.PI / 2.0)) + 1.0;
+
+ shiftX = shiftX * currentAccelMultiTemp;
+ previousPointerX = smoothedPos.X;
+ accelHelperX = currentAccelMultiTemp;
+ accelTravelX = tempTravel;
+ deltaEasingTimeX.Restart();
+ */
+
+ shiftX = shiftX * (accelSlope * tempDist + accelOffset);
+ previousPointerX = smoothedPos.X;
+ accelHelperX = (accelSlope * tempDist + accelOffset);
+ accelTravelX = tempTravel;
+ deltaEasingTimeX.Restart();
+ }
+ else if (absX > 0.0 && testDeltaAccel && !initialMouseMove && testAccelEasingDuration > 0.00 &&
+ accelHelperX > 0.0 &&
+ Math.Abs(smoothedPos.X - previousPointerX) < testAccelMinTravel &&
+ (previousPointerX >= 0.5) == (smoothedPos.X >= 0.5))
+ {
+ double timeElapsed = deltaEasingTimeX.ElapsedMilliseconds;
+ double elapsedDiff = 1.0;
+ double tempAccel = accelHelperX;
+ double tempTravel = accelTravelX;
+
+ if ((smoothedPos.X - previousPointerX >= 0.0) != (smoothedPos.X >= 0.5))
+ {
+ // Travelling towards dead zone. Decrease acceleration and duration.
+ double minstop2 = Math.Min(testAccelMinTravel, tempTravel);
+ double tempmix2 = Math.Abs(smoothedPos.X - previousPointerX);
+ tempmix2 = Math.Min(tempmix2, minstop2);
+
+ double tempmixslope = (testAccelMinTravel - tempTravel) / (minstop2);
+ double tempshitintercept = tempTravel;
+
+ double finalmanham = (tempmixslope * tempmix2 + tempshitintercept);
+ //tempAccel = finalmanham;
+ tempTravel = finalmanham;
+ tempAccel = (accelSlope * tempTravel + accelOffset);
+
+ /*tempTravel = Math.Min(Math.Abs(previousPointerX - smoothedPos.X), testAccelMaxTravel);
+ tempTravel = Math.Max(Math.Min((accelTravelX - tempTravel), testAccelMaxTravel), testAccelMinTravel);
+ tempAccel = (accelSlope * tempTravel + accelOffset);
+ */
+ }
+
+ double elapsedDuration = testAccelEasingDuration * (tempAccel / testAccelMulti);
+
+ /*double getMultiDiff = (tempAccel - 1.0) / (testAccelMulti - 1.0);
+ //double tempinner = getMultiDiff * (getMultiDiff - 2.0);
+ //timeElapsed = (-testAccelEasingDuration * tempinner + 0.0);
+ //double currentAccelMultiTemp = -(testAccelMulti - 1.0) * tempinner + 1.0;
+ double tempinner = Math.Sin(getMultiDiff * (Math.PI / 2.0));
+ timeElapsed = testAccelEasingDuration * tempinner + 0.0;
+ double currentAccelMultiTemp = (testAccelMulti - 1.0) * tempinner + 1.0;
+ tempAccel = currentAccelMultiTemp;
+ */
+
+ if (elapsedDuration > 0.0 && (timeElapsed * 0.001) < elapsedDuration)
+ {
+ elapsedDiff = ((timeElapsed * 0.001) / elapsedDuration);
+ elapsedDiff = (1.0 - tempAccel) * (elapsedDiff * elapsedDiff * elapsedDiff) + tempAccel;
+ shiftX = elapsedDiff * shiftX;
+ }
+ else
+ {
+ // Easing time has ended. Reset values.
+ previousPointerX = smoothedPos.X;
+ accelHelperX = 0.0;
+ accelTravelX = 0.0;
+ deltaEasingTimeX.Stop();
+ //regionEasingX.Stop();
+ }
+ }
+ else
+ {
+ // Don't apply acceleration. Reset values.
+ previousPointerX = smoothedPos.X;
+ accelHelperX = 0.0;
+ accelTravelX = 0.0;
+ if (deltaEasingTimeX.IsRunning)
+ {
+ deltaEasingTimeX.Stop();
+ }
+ }
+
+ // If deltaY >= 0.1 and displacement is increasing then
+ // use acceleration multiplier.
+ if (absY > 0.0 && testDeltaAccel && !initialMouseMove && Math.Abs(previousPointerY - smoothedPos.Y) >= testAccelMinTravel &&
+ (smoothedPos.Y - previousPointerY >= 0.0) == (smoothedPos.Y >= 0.5))
+ {
+ double tempTravel = Math.Min(Math.Abs(previousPointerY - smoothedPos.Y), testAccelMaxTravel);
+ if (accelHelperY > 1.0)
+ {
+ // Already in acceleration mode. Add accel
+ // dead zone to travel.
+ //tempTravel = Math.Min(tempTravel + testAccelMinTravel, testAccelMaxTravel);
+ }
+
+ //double tempDist = Math.Min(tempTravel / 0.5, 1.0);
+ double tempDist = Math.Min(tempTravel, testAccelMaxTravel);
+
+ /*double currentAccelMultiTemp = (accelSlope * tempDist + accelOffset);
+ double getMultiDiff = (currentAccelMultiTemp - 1.0) / (testAccelMulti - 1.0);
+ //currentAccelMultiTemp = -(testAccelMulti - 1.0) / (getMultiDiff * (getMultiDiff - 2.0)) + 1.0;
+ currentAccelMultiTemp = (testAccelMulti - 1.0) / Math.Sin(getMultiDiff * (Math.PI / 2.0)) + 1.0;
+
+ shiftY = shiftY * currentAccelMultiTemp;
+ previousPointerY = smoothedPos.Y;
+ accelHelperY = currentAccelMultiTemp;
+ accelTravelY = tempTravel;
+ deltaEasingTimeY.Restart();
+ */
+
+ shiftY = shiftY * (accelSlope * tempDist + accelOffset);
+ previousPointerY = smoothedPos.Y;
+ accelHelperY = (accelSlope * tempDist + accelOffset);
+ accelTravelY = tempTravel;
+ deltaEasingTimeY.Restart();
+ }
+ else if (absY > 0.0 && testDeltaAccel && !initialMouseMove && testAccelEasingDuration > 0.00 &&
+ accelHelperY > 0.0 &&
+ Math.Abs(smoothedPos.Y - previousPointerY) < testAccelMinTravel &&
+ (previousPointerY >= 0.5) == (smoothedPos.Y >= 0.5))
+ {
+ double timeElapsed = deltaEasingTimeY.ElapsedMilliseconds;
+ double elapsedDiff = 1.0;
+ double tempAccel = accelHelperY;
+ double tempTravel = accelTravelY;
+
+ if ((smoothedPos.Y - previousPointerY >= 0.0) != (smoothedPos.Y >= 0.5))
+ {
+ // Travelling towards dead zone. Decrease acceleration and duration.
+ double minstop2 = Math.Min(testAccelMinTravel, tempTravel);
+ double tempmix2 = Math.Abs(smoothedPos.Y - previousPointerY);
+ tempmix2 = Math.Min(tempmix2, minstop2);
+
+ double tempmixslope = (testAccelMinTravel - tempTravel) / (minstop2);
+ double tempshitintercept = tempTravel;
+
+ double finalmanham = (tempmixslope * tempmix2 + tempshitintercept);
+ //tempAccel = finalmanham;
+ tempTravel = finalmanham;
+ tempAccel = (accelSlope * tempTravel + accelOffset);
+
+ /*tempTravel = Math.Min(Math.Abs(previousPointerY - smoothedPos.Y), testAccelMaxTravel);
+ tempTravel = Math.Max(Math.Min((accelTravelY - tempTravel), testAccelMaxTravel), testAccelMinTravel);
+ tempAccel = (accelSlope * tempTravel + accelOffset);
+ */
+ }
+
+ double elapsedDuration = testAccelEasingDuration * (tempAccel / testAccelMulti);
+
+ /*double getMultiDiff = (tempAccel - 1.0) / (testAccelMulti - 1.0);
+ //double tempinner = getMultiDiff * (getMultiDiff - 2.0);
+ //timeElapsed = -testAccelEasingDuration * tempinner + 0.0;
+ //double currentAccelMultiTemp = -(testAccelMulti - 1.0) * tempinner + 1.0;
+ double tempinner = Math.Sin(getMultiDiff * (Math.PI / 2.0));
+ timeElapsed = testAccelEasingDuration * tempinner + 0.0;
+ double currentAccelMultiTemp = (testAccelMulti - 1.0) * tempinner + 1.0;
+ tempAccel = currentAccelMultiTemp;
+ */
+
+ if (elapsedDuration > 0.0 && (timeElapsed * 0.001) < elapsedDuration)
+ {
+ elapsedDiff = ((timeElapsed * 0.001) / elapsedDuration);
+ elapsedDiff = (1.0 - tempAccel) * (elapsedDiff * elapsedDiff * elapsedDiff) + tempAccel;
+ shiftY = elapsedDiff * shiftY;
+ }
+ else
+ {
+ // Easing time has ended. Reset values.
+ previousPointerY = smoothedPos.Y;
+ accelHelperY = 0.0;
+ accelTravelY = 0.0;
+ deltaEasingTimeY.Stop();
+ }
+ }
+ else
+ {
+ // Don't apply acceleration. Reset values.
+ previousPointerY = smoothedPos.Y;
+ accelHelperY = 0.0;
+ accelTravelY = 0.0;
+ if (deltaEasingTimeY.IsRunning)
+ {
+ deltaEasingTimeY.Stop();
+ }
+ }
+
+ //double currentoffset = 0.037;
+ //double currentoffset = 0.0426;
+ double currentoffset = 0.09236;
+ mouseOffsetX = currentoffset * unitX;
+ mouseOffsetY = currentoffset * unitY;
+ // Find initial relative mouse speed
+ double mouseX = 0.0;
+ double mouseY = 0.0;
+ if (absX > 0.0)
+ {
+ mouseX = (fps_mouse_speed - mouseOffsetX) * shiftX + (mouseOffsetX * signshiftX);
+ }
+ else
+ {
+ remainderX = 0.0;
+ }
+
+ if (absY > 0.0)
+ {
+ mouseY = (fps_mouse_speed - mouseOffsetY) * shiftY + (mouseOffsetY * signshiftY);
+ }
+ else
+ {
+ remainderY = 0.0;
+ }
+
+ // Only apply remainder if both current displacement and
+ // remainder follow the same direction.
+ if ((remainderX > 0) == (mouseX > 0))
+ {
+ mouseX += remainderX;
+ }
+
+ // Only apply remainder if both current displacement and
+ // remainder follow the same direction.
+ if ((remainderY > 0) == (mouseY > 0))
+ {
+ mouseY += remainderY;
+ }
+
+ // Make sure relative mouse movement does not exceed 127 pixels.
+ if (Math.Abs(mouseX) > 127)
+ {
+ mouseX = (mouseX < 0) ? -127 : 127;
+ }
+
+ // Make sure relative mouse movement does not exceed 127 pixels.
+ if (Math.Abs(mouseY) > 127)
+ {
+ mouseY = (mouseY < 0) ? -127 : 127;
+ }
+
+ // Reset remainder values
+ remainderX = 0.0;
+ remainderY = 0.0;
+
+ // Round mouseX distance to zero and save remainder.
+ // Prefer over rounding to nearest.
+ if (mouseX > 0.0)
+ {
+ double temp = Math.Floor(mouseX);
+ remainderX = mouseX - temp;
+ mouseX = temp;
+ }
+ else if (mouseX < 0.0)
+ {
+ double temp = Math.Ceiling(mouseX);
+ remainderX = mouseX - temp;
+ mouseX = temp;
+ }
+
+ // Round mouseY distance to zero and save remainder.
+ // Prefer over rounding to nearest.
+ if (mouseY > 0.0)
+ {
+ double temp = Math.Floor(mouseY);
+ remainderY = mouseY - temp;
+ mouseY = temp;
+ }
+ else if (mouseY < 0.0)
+ {
+ double temp = Math.Ceiling(mouseY);
+ remainderY = mouseY - temp;
+ mouseY = temp;
+ }
+
+ //this.inputSimulator.Mouse.MoveMouseBy((int)(Settings.Default.fpsmouse_speed * shiftX), (int)(Settings.Default.fpsmouse_speed * shiftY));
+ // Need to double check if sync would happen if (0,0).
+ if (mouseX != 0.0 || mouseY != 0.0)
+ {
+ DS4Windows.InputMethods.MoveCursorBy((int)mouseX, (int)mouseY);
+ //this.inputSimulator.Mouse.MoveMouseBy((int)mouseX, (int)mouseY);
+ }
+
+ return true;
+ }
+ else
+ {
+ // Consider outside of IR range. Reset some values.
+ remainderX = 0.0;
+ remainderY = 0.0;
+
+ accelHelperX = 0.0;
+ accelHelperY = 0.0;
+ accelTravelX = 0.0;
+ accelTravelY = 0.0;
+
+ previousPointerX = 0.5;
+ previousPointerY = 0.5;
+
+ if (deltaEasingTimeX.IsRunning)
+ {
+ deltaEasingTimeX.Stop();
+ }
+
+ if (deltaEasingTimeY.IsRunning)
+ {
+ deltaEasingTimeY.Stop();
+ }
+
+ initialInReachStatus = true;
+
+ if (regionEasingX.IsRunning)
+ {
+ regionEasingX.Stop();
+ }
+ }
}
+
return false;
}
diff --git a/WiiTUIO/Properties/Resources.Designer.cs b/WiiTUIO/Properties/Resources.Designer.cs
index f6c5aed..6d00a61 100644
--- a/WiiTUIO/Properties/Resources.Designer.cs
+++ b/WiiTUIO/Properties/Resources.Designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:4.0.30319.18051
+// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
diff --git a/WiiTUIO/Properties/Settings.cs b/WiiTUIO/Properties/Settings.cs
index 003d6c8..f1f22bd 100644
--- a/WiiTUIO/Properties/Settings.cs
+++ b/WiiTUIO/Properties/Settings.cs
@@ -347,6 +347,111 @@ public int pointer_FPS
}
}
+ // Should delta acceleration be enabled.
+ private bool _test_deltaAccel = true;
+ public bool test_deltaAccel
+ {
+ get { return _test_deltaAccel; }
+ set
+ {
+ _test_deltaAccel = value;
+ OnPropertyChanged("test_deltaAccel");
+ }
+ }
+
+ // Maximum multiplier to use for delta acceleration.
+ private double _test_deltaAccelMulti = 4.0;
+ public double test_deltaAccelMulti
+ {
+ get { return _test_deltaAccelMulti; }
+ set
+ {
+ if (value >= 1.0 && value <= 20.0)
+ {
+ _test_deltaAccelMulti = value;
+ OnPropertyChanged("test_deltaAccelMulti");
+ }
+ }
+ }
+
+ // Minimum delta travel before delta acceleration is applied.
+ private double _test_deltaAccelMinTravel = 0.1;
+ public double test_deltaAccelMinTravel
+ {
+ get { return _test_deltaAccelMinTravel; }
+ set
+ {
+ if (value >= 0.01 && value <= 0.5)
+ {
+ _test_deltaAccelMinTravel = value;
+ OnPropertyChanged("test_deltaAccelMinTravel");
+ }
+ }
+ }
+
+ // Maximum duration that delta acceleration should be applied.
+ // Value is in seconds.
+ private double _test_deltaAccelEasingDuration = 0.05;
+ public double test_deltaAccelEasingDuration
+ {
+ get { return _test_deltaAccelEasingDuration; }
+ set
+ {
+ if (value >= 0.00 && value <= 10.0)
+ {
+ _test_deltaAccelEasingDuration = value;
+ OnPropertyChanged("test_deltaAccelEasingDuration");
+ }
+ }
+
+ }
+
+ // Maximum duration that easing is applied to upper acceleration
+ // region.
+ private double _test_regionEasingXDuration = 0.025;
+ public double test_regionEasingXDuration
+ {
+ get { return _test_regionEasingXDuration; }
+ set
+ {
+ if (value >= 0.00 && value <= 10.0)
+ {
+ _test_regionEasingXDuration = value;
+ OnPropertyChanged("test_regionEasingXDuration");
+ }
+ }
+ }
+
+ // Maximum delta travel before maximum delta acceleration is applied.
+ private double _test_deltaAccelMaxTravel = 0.5;
+ public double test_deltaAccelMaxTravel
+ {
+ get { return _test_deltaAccelMaxTravel; }
+ set
+ {
+ if (value >= 0.01 && value <= 0.5)
+ {
+ _test_deltaAccelMaxTravel = value;
+ OnPropertyChanged("test_deltaAccelMaxTravel");
+ }
+ }
+ }
+
+ private double _test_regionEasingXOffset = 0.8;
+ public double test_regionEasingXOffset
+ {
+ get { return _test_regionEasingXOffset; }
+ set
+ {
+ if (value >= 0.0 && value <= 1.0)
+ {
+ _test_regionEasingXOffset = value;
+ OnPropertyChanged("test_regionEasingXOffset");
+ }
+ }
+ }
+
+
private int _pointer_positionSmoothing = 3;
public int pointer_positionSmoothing
{
diff --git a/WiiTUIO/WiiTUIO.csproj b/WiiTUIO/WiiTUIO.csproj
index 25dc286..7d36e83 100644
--- a/WiiTUIO/WiiTUIO.csproj
+++ b/WiiTUIO/WiiTUIO.csproj
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WiiTUIO</RootNamespace>
<AssemblyName>Touchmote</AssemblyName>
- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
@@ -96,12 +96,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\bin\x64\Debug\</OutputPath>
- <Optimize>true</Optimize>
+ <Optimize>false</Optimize>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
+ <DefineConstants>TRACE;DEBUG</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>..\bin\x64\Release\</OutputPath>
@@ -209,6 +210,7 @@
<Compile Include="Output\CursorPositionHelper.cs" />
<Compile Include="Output\Handlers\HandlerFactory.cs" />
<Compile Include="Output\Handlers\ICursorHandler.cs" />
+ <Compile Include="Output\Handlers\InputMethods.cs" />
<Compile Include="Output\Handlers\IOutputHandler.cs" />
<Compile Include="Output\Handlers\IRumbleFeedback.cs" />
<Compile Include="Output\Handlers\IStickHandler.cs" />
@@ -404,6 +406,7 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
+ <None Include="app.config" />
<None Include="app.manifest">
<SubType>Designer</SubType>
</None>
@@ -488,10 +491,8 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
- <PostBuildEvent>copy "$(ProjectDir)VMultiDll_$(PlatformName).dll" "$(TargetDir)VMultiDll.dll" /Y
-xcopy "$(TargetDir)..\$(ConfigurationName)" "C:\Program Files\Touchmote" /H /Y
-cd "C:\Program Files\Touchmote"
-"C:\Program Files (x86)\Windows Kits\8.1\bin\$(PlatformName)\signtool.exe" sign /v /a /s ROOT /n Touchmote /t http://timestamp.verisign.com/scripts/timstamp.dll "C:\Program Files\Touchmote\Touchmote.exe"</PostBuildEvent>
+ <PostBuildEvent>
+ </PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
diff --git a/WiiTUIO/app.manifest b/WiiTUIO/app.manifest
index 81d3a74..2a0910b 100644
--- a/WiiTUIO/app.manifest
+++ b/WiiTUIO/app.manifest
@@ -16,7 +16,7 @@
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
- <requestedExecutionLevel level="requireAdministrator" uiAccess="true" />
+ <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<PermissionSet Unrestricted="true" ID="Custom" SameSite="site" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment