Fix context mode

Mouse
evilC 7 years ago
parent d7ac2f9f3a
commit c862ab93c9

@ -167,6 +167,24 @@ public class InterceptionWrapper : IDisposable
return true; return true;
} }
public bool SetMouseContextCallback(int vid, int pid, dynamic callback)
{
SetFilterState(false);
var id = 0;
if (vid != 0 && pid != 0)
{
id = GetMouseId(vid, pid);
}
if (id == 0) return false;
_contextCallbacks[id] = callback;
_filteredDevices[id] = true;
SetFilterState(true);
SetThreadState(true);
return true;
}
public int GetKeyboardId(int vid, int pid) public int GetKeyboardId(int vid, int pid)
{ {
return GetDeviceId(false, vid, pid); return GetDeviceId(false, vid, pid);
@ -267,13 +285,13 @@ public class InterceptionWrapper : IDisposable
} }
mapping.Callback(1 - state); mapping.Callback(1 - state);
} }
// If this key had no subscriptions, but Context Mode is set for this keyboard... }
// ... then set the Context before sending the key // If this key had no subscriptions, but Context Mode is set for this keyboard...
if (!hasSubscription && hasContext) // ... then set the Context before sending the key
{ if (!hasSubscription && hasContext)
// Set Context {
_contextCallbacks[i](1); // Set Context
} _contextCallbacks[i](1);
} }
// If the key was not blocked by Subscription Mode, then send it now // If the key was not blocked by Subscription Mode, then send it now
if (!block) if (!block)
@ -338,10 +356,23 @@ public class InterceptionWrapper : IDisposable
mapping.Callback(stroke.mouse.x, stroke.mouse.y); mapping.Callback(stroke.mouse.x, stroke.mouse.y);
} }
} }
// If this key had no subscriptions, but Context Mode is set for this mouse...
// ... then set the Context before sending the button
if (!hasSubscription && hasContext)
{
// Set Context
_contextCallbacks[i](1);
}
if (!(block)) if (!(block))
{ {
Send(_deviceContext, i, ref stroke, 1); Send(_deviceContext, i, ref stroke, 1);
} }
// If we are processing Context Mode, then Unset the context variable after sending the button
if (!hasSubscription && hasContext)
{
// Unset Context
_contextCallbacks[i](0);
}
} }
} }
Thread.Sleep(10); Thread.Sleep(10);

Loading…
Cancel
Save