Split up mouse wheel events to vertical and horizontal to allow finer control

pull/15/head
crumbl3d 6 years ago
parent 1b1fbc717c
commit 8c5d4debe2

@ -53,15 +53,9 @@ namespace AutoHotInterception.Helpers
public static ManagedWrapper.Stroke ButtonAndStateToStroke(int btn, int state)
{
var stroke = new ManagedWrapper.Stroke();
var bit = btn * 2;
if (state == 0)
bit += 1;
if (btn == 5)
{
// Mouse wheel
stroke.mouse.rolling = (short)(state * 120);
}
stroke.mouse.state = (ushort)(1 << bit);
var power = btn < 5 ? btn * 2 + (state == 0 ? 1 : 0) : btn + 5;
stroke.mouse.state = (ushort)(1 << power);
if (btn >= 5) stroke.mouse.rolling = (short)(state * 120);
return stroke;
}
@ -69,18 +63,20 @@ namespace AutoHotInterception.Helpers
{
int state = stroke.mouse.state;
ushort btn = 0;
while (state > 2)
{
state >>= 2;
btn++;
}
if (btn == 5)
if (state < 0x400)
{
state = stroke.mouse.rolling < 0 ? -1 : 1;
while (state > 2)
{
state >>= 2;
btn++;
}
state = 2 - state; // 1 = Pressed, 0 = Released
}
else
{
state = 2 - state;
if (state == 0x400) btn = 5; // Vertical mouse wheel
else if (state == 0x800) btn = 6; // Horizontal mouse wheel
state = stroke.mouse.rolling < 0 ? -1 : 1;
}
return new ButtonState {Button = btn, State = state};
}

@ -464,7 +464,7 @@ namespace AutoHotInterception
// Process Mice
for (var i = 11; i < 21; i++)
{
var isMontioredMouse = IsMonitoredDevice(i) == 1;
var isMonitoredMouse = IsMonitoredDevice(i) == 1;
var hasSubscription = false;
var hasContext = _contextCallbacks.ContainsKey(i);
@ -472,7 +472,7 @@ namespace AutoHotInterception
{
//Debug.WriteLine($"AHK| Mouse {i} seen - flags: {stroke.mouse.flags}, raw state: {stroke.mouse.state}");
var block = false;
if (isMontioredMouse)
if (isMonitoredMouse)
{
if (stroke.mouse.state != 0 && _mouseButtonMappings.ContainsKey(i))
{

@ -1,7 +1,7 @@
# AutoHotInterception
AutoHotInterception(AHI) allows you to execute AutoHotkey code in response to events from a *specific* keyboard or mouse, whilst (optionally) blocking the native functionality (ie stopping Windows from seeing that keyboard or mouse event).
In other words, you can use a key on a second (or third, or fourth..) keyboard to trigger AHK code, and that key will not be seen by applications. You can use the *same key* on multiple keyboards for individual actions.
In other words, you can use a key on a second (or third, or fourth...) keyboard to trigger AHK code, and that key will not be seen by applications. You can use the *same key* on multiple keyboards for individual actions.
Keyboard Keys, Mouse Buttons and Mouse movement (Both Relative and Absolute modes) are supported.
AHI uses the Interception driver by Francisco Lopez
@ -164,9 +164,10 @@ Where `button` is one of:
2: Middle Mouse
3: Side Button 1
4: Side Button 2
5: Mouse Wheel
5: Mouse Wheel (Vertical)
6: Mouse Wheel (Horizontal)
```
For Mouse Wheel events, the `<state>` parameter will be `1` for Wheel Up and `0` for Wheel Down
For Mouse Wheel events, the `<state>` parameter will be `1` for Wheel Up / Right and `-1` for Wheel Down / Left
Otherwise, usage is identical to `SubscribeKey`
@ -221,7 +222,7 @@ You can send clicks and other mouse button events with:
`Interception.SendMouseButtonEvent(<mouseId>, <button>, <state>)`
Where `button` is the button index, as used in `SubscribeMouseButton`
When Sending Mouse Wheel events, set `<state>` to `1` for Wheel Up and `-1` for Wheel Down.
When Sending Mouse Wheel events, set `<state>` to `1` for Wheel Up / Right and `-1` for Wheel Down / Left.
If you are working in Absolute mode (eg with a graphics tablet or light guns), you can send mouse button events at specific coordinates using:
`Interception.SendMouseButtonEventAbsolute(<mouseId>, <button>, <state>, <x>, <y>)`

Loading…
Cancel
Save