dota-wheel/DotaWheel/DotaWheelHandler.cs

211 lines
7.5 KiB
C#
Raw Permalink Normal View History

2022-08-02 00:12:37 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WindowsInput;
using WindowsInput.Native;
namespace DotaWheel
{
class DotaWheelHandler : WheelHandler
{
private InputSimulator InputSimulator = new InputSimulator();
private bool Paused = false;
public DotaWheelHandler(int wheelIndex) : base(wheelIndex)
{
}
private void CheckPause(Wheel wheel)
{
Console.WriteLine("CheckPause");
if (wheel.ButtonPressed(Wheel.Button.OPTION))
{
Console.WriteLine("Option was pressed");
Paused = !Paused;
}
}
public override void Init()
{
// TODO: Make dota not recognise the steering wheel.
}
public override void Handle(Wheel wheel)
{
CheckPause(wheel);
if (!Paused)
{
LogitechGSDK.LogiSetOperatingRange(WheelIndex, 180);
LogitechGSDK.LogiPlayCarAirborne(WheelIndex);
// Mouse with wheel rotation for x and accelerator position for y
//InputSimulator.Mouse.MoveMouseTo(wheel.WheelPosition, wheel.AcceleratorPosition);
// Buttons are done by dota gamepad binds
/*
// Camera Buttons
// DPAD UP for W
HandleDpadButtonChange(
wheel,
Wheel.DpadButton.UP,
() => { InputSimulator.Keyboard.KeyDown(VirtualKeyCode.VK_W); },
() => { InputSimulator.Keyboard.KeyUp(VirtualKeyCode.VK_W); }
);
// DPAD DOWN for S
HandleDpadButtonChange(
wheel,
Wheel.DpadButton.DOWN,
() => { InputSimulator.Keyboard.KeyDown(VirtualKeyCode.VK_S); },
() => { InputSimulator.Keyboard.KeyUp(VirtualKeyCode.VK_S); }
);
// DPAD LEFT for A
HandleDpadButtonChange(
wheel,
Wheel.DpadButton.LEFT,
() => { InputSimulator.Keyboard.KeyDown(VirtualKeyCode.VK_A); },
() => { InputSimulator.Keyboard.KeyUp(VirtualKeyCode.VK_A); }
);
// DPAD RIGHT for D
HandleDpadButtonChange(
wheel,
Wheel.DpadButton.RIGHT,
() => { InputSimulator.Keyboard.KeyDown(VirtualKeyCode.VK_D); },
() => { InputSimulator.Keyboard.KeyUp(VirtualKeyCode.VK_D); }
);
*/
// Mouse Buttons
// RIGHT_PADDLE for Mouse Left Button
HandleButtonChange(
wheel,
Wheel.Button.RIGHT_PADDLE,
() => { InputSimulator.Mouse.LeftButtonDown(); },
() => { InputSimulator.Mouse.LeftButtonUp(); }
);
// LEFT_PADDLE for Mouse Right Button
HandleButtonChange(
wheel,
Wheel.Button.LEFT_PADDLE,
() => { InputSimulator.Mouse.RightButtonDown(); },
() => { InputSimulator.Mouse.RightButtonUp(); }
);
/*
// Ability Buttons
// L3 for 1
HandleButtonChange(
wheel,
Wheel.Button.L3,
() => { InputSimulator.Keyboard.KeyPress(VirtualKeyCode.VK_1); },
//() => { InputSimulator.Keyboard.KeyDown(VirtualKeyCode.VK_1); },
() => { InputSimulator.Keyboard.KeyUp(VirtualKeyCode.VK_1); }
);
// L2 for 2
HandleButtonChange(
wheel,
Wheel.Button.L2,
() => { InputSimulator.Keyboard.KeyDown(VirtualKeyCode.VK_2); },
() => { InputSimulator.Keyboard.KeyUp(VirtualKeyCode.VK_2); }
);
// R2 for 3
HandleButtonChange(
wheel,
Wheel.Button.R2,
() => { InputSimulator.Keyboard.KeyDown(VirtualKeyCode.VK_3); },
() => { InputSimulator.Keyboard.KeyUp(VirtualKeyCode.VK_3); }
);
// R3 for R
HandleButtonChange(
wheel,
Wheel.Button.R3,
() => { InputSimulator.Keyboard.KeyDown(VirtualKeyCode.VK_R); },
() => { InputSimulator.Keyboard.KeyUp(VirtualKeyCode.VK_R); }
);
// ROT_CENTER for 4
HandleButtonChange(
wheel,
Wheel.Button.ROT_CENTER,
() => { InputSimulator.Keyboard.KeyDown(VirtualKeyCode.VK_4); },
() => { InputSimulator.Keyboard.KeyUp(VirtualKeyCode.VK_4); }
);
// SHARE for 5
HandleButtonChange(
wheel,
Wheel.Button.SHARE,
() => { InputSimulator.Keyboard.KeyDown(VirtualKeyCode.VK_5); },
() => { InputSimulator.Keyboard.KeyUp(VirtualKeyCode.VK_5); }
);
// Item Buttons
// PLUS for Z
HandleButtonChange(
wheel,
Wheel.Button.PLUS,
() => { InputSimulator.Keyboard.KeyDown(VirtualKeyCode.VK_Z); },
() => { InputSimulator.Keyboard.KeyUp(VirtualKeyCode.VK_Z); }
);
// SQUARE for X
HandleButtonChange(
wheel,
Wheel.Button.SQUARE,
() => { InputSimulator.Keyboard.KeyDown(VirtualKeyCode.VK_X); },
() => { InputSimulator.Keyboard.KeyUp(VirtualKeyCode.VK_X); }
);
// TRIANGLE for C
HandleButtonChange(
wheel,
Wheel.Button.TRIANGLE,
() => { InputSimulator.Keyboard.KeyDown(VirtualKeyCode.VK_C); },
() => { InputSimulator.Keyboard.KeyUp(VirtualKeyCode.VK_C); }
);
// MINUS for V
HandleButtonChange(
wheel,
Wheel.Button.MINUS,
() => { InputSimulator.Keyboard.KeyDown(VirtualKeyCode.VK_V); },
() => { InputSimulator.Keyboard.KeyUp(VirtualKeyCode.VK_V); }
);
// X for B
HandleButtonChange(
wheel,
Wheel.Button.X,
() => { InputSimulator.Keyboard.KeyDown(VirtualKeyCode.VK_B); },
() => { InputSimulator.Keyboard.KeyUp(VirtualKeyCode.VK_B); }
);
// CIRCLE for N
HandleButtonChange(
wheel,
Wheel.Button.CIRCLE,
() => { InputSimulator.Keyboard.KeyDown(VirtualKeyCode.VK_N); },
() => { InputSimulator.Keyboard.KeyUp(VirtualKeyCode.VK_N); }
);
*/
}
}
}
}