Fix Absolute Mode mouse movement

hotfix/absolute-mouse
Clive Galway 5 years ago
parent 2fe91b84b6
commit 3979fc9fc1

@ -655,25 +655,27 @@ namespace AutoHotInterception
}
}
// Process Relative Mouse Move
if ((stroke.mouse.flags & (ushort) ManagedWrapper.MouseFlag.MouseMoveRelative) == (ushort) ManagedWrapper.MouseFlag.MouseMoveRelative)
if (x != 0 || y != 0)
{
if (x != 0 || y != 0)
hasMove = true;
// Process Absolute Mouse Move
if ((stroke.mouse.flags & (ushort)ManagedWrapper.MouseFlag.MouseMoveAbsolute) == (ushort)ManagedWrapper.MouseFlag.MouseMoveAbsolute)
{
hasMove = true;
if (_mouseMoveRelativeMappings.ContainsKey(i))
if (_mouseMoveAbsoluteMappings.ContainsKey(i))
{
var mapping = _mouseMoveRelativeMappings[i];
var mapping = _mouseMoveAbsoluteMappings[i];
hasSubscription = true;
//var debugStr = $"AHK| Mouse stroke has relative move of {x}, {y}...";
//var debugStr = $"AHK| Mouse stroke has absolute move of {x}, {y}...";
if (mapping.Concurrent)
ThreadPool.QueueUserWorkItem(threadProc => mapping.Callback(x, y));
else if (_workerThreads.ContainsKey(i) && _workerThreads[i].ContainsKey(8))
_workerThreads[i][8]?.Actions.Add(() => mapping.Callback(x, y));
else if (_workerThreads.ContainsKey(i) && _workerThreads[i].ContainsKey(7))
_workerThreads[i][7]?.Actions.Add(() => mapping.Callback(x, y));
if (mapping.Block)
{
moveRemoved = true;
stroke.mouse.x = 0;
stroke.mouse.y = 0;
//debugStr += "Blocking";
}
else
@ -683,26 +685,26 @@ namespace AutoHotInterception
//Debug.WriteLine(debugStr);
}
}
}
// Process Absolute Mouse Move
else if ((stroke.mouse.flags & (ushort)ManagedWrapper.MouseFlag.MouseMoveAbsolute) == (ushort)ManagedWrapper.MouseFlag.MouseMoveAbsolute)
{
if (x != 0 || y != 0)
// Process Relative Mouse Move
//else if ((stroke.mouse.flags & (ushort) ManagedWrapper.MouseFlag.MouseMoveRelative) == (ushort) ManagedWrapper.MouseFlag.MouseMoveRelative) / flag is 0, so always true!
else
{
hasMove = true;
if (_mouseMoveAbsoluteMappings.ContainsKey(i))
if (_mouseMoveRelativeMappings.ContainsKey(i))
{
var mapping = _mouseMoveAbsoluteMappings[i];
var mapping = _mouseMoveRelativeMappings[i];
hasSubscription = true;
//var debugStr = $"AHK| Mouse stroke has absolute move of {x}, {y}...";
//var debugStr = $"AHK| Mouse stroke has relative move of {x}, {y}...";
if (mapping.Concurrent)
ThreadPool.QueueUserWorkItem(threadProc => mapping.Callback(x, y));
else if (_workerThreads.ContainsKey(i) && _workerThreads[i].ContainsKey(7))
_workerThreads[i][7]?.Actions.Add(() => mapping.Callback(x, y));
else if (_workerThreads.ContainsKey(i) && _workerThreads[i].ContainsKey(8))
_workerThreads[i][8]?.Actions.Add(() => mapping.Callback(x, y));
if (mapping.Block)
{
moveRemoved = true;
stroke.mouse.x = 0;
stroke.mouse.y = 0;
//debugStr += "Blocking";
}
else
@ -712,6 +714,7 @@ namespace AutoHotInterception
//Debug.WriteLine(debugStr);
}
}
}
// Forward on the stroke if required

@ -13,7 +13,9 @@ namespace TestApp
{
var im = new Manager();
var mouseHandle = "HID\\VID_046D&PID_C52B&REV_2407&MI_02&Qid_1028&WI_01&Class_00000004";
//var devs = im.GetDeviceList();
//var mouseHandle = "HID\\VID_046D&PID_C52B&REV_2407&MI_02&Qid_1028&WI_01&Class_00000004";
var mouseHandle = "HID\\VID_046D&PID_C00C&REV_0620"; // Logitech USB
var devId = im.GetMouseIdFromHandle(mouseHandle);
var counter = 0;
@ -40,9 +42,11 @@ namespace TestApp
Console.WriteLine(" Counter: " + mycounter);
counter = mycounter;
}));
im.SubscribeMouseMove(devId, true, new Action<int, int>((x, y) =>
{
Console.WriteLine($"Mouse Move: x: {x}, y: {y}");
}));
}
Console.ReadLine();
}
}
}

@ -7,8 +7,10 @@ namespace TestApp
{
private static void Main()
{
//var mt = new MouseTester();
var kt = new KeyboardTester();
var mt = new MouseTester();
//var kt = new KeyboardTester();
//var tt = new TabletTester();
Console.ReadLine();
}
}
}

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoHotInterception;
namespace TestApp
{
public class TabletTester
{
public TabletTester()
{
var im = new Manager();
var devId = im.GetMouseIdFromHandle("HID\\VID_0B57&PID_9091&REV_0101&Col01");
var counter = 0;
if (devId != 0)
{
Console.WriteLine($"Testing Absolute device with ID of {devId}");
im.SubscribeMouseButton(devId, 0, true, new Action<int>(value =>
{
Console.WriteLine("LButton Button Value: " + value);
}));
im.SubscribeMouseButton(devId, 1, true, new Action<int>(value =>
{
Console.WriteLine("RButton Button Value: " + value);
}));
im.SubscribeMouseButton(devId, 3, true, new Action<int>(value =>
{
Console.WriteLine("XButton1 Button Value: " + value);
}));
im.SubscribeMouseButton(devId, 4, true, new Action<int>(value =>
{
Console.WriteLine("XButton2 Button Value: " + value);
}));
im.SubscribeMouseButton(devId, 5, true, new Action<int>(value =>
{
Console.Write("WheelVertical Value: " + value);
var mycounter = counter;
mycounter++;
Console.WriteLine(" Counter: " + mycounter);
counter = mycounter;
}));
im.SubscribeMouseMoveAbsolute(devId, true, new Action<int, int>((x, y) =>
{
Console.WriteLine($"x: {x}, y: {y}");
}));
}
}
}
}

@ -46,6 +46,7 @@
<Compile Include="MouseTester.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TabletTester.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />

@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Deprecated
### Removed
### Fixed
- Absolute Mode mouse movement subscriptions now work again
## [0.4.4] - 2019-07-09
- Added SetState to allow toggling on/off of bindings

Loading…
Cancel
Save