66 lines
1.7 KiB
C#
66 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DotaWheel
|
|
{
|
|
abstract class WheelHandler
|
|
{
|
|
protected readonly int WheelIndex;
|
|
|
|
protected WheelHandler(int wheelIndex)
|
|
{
|
|
WheelIndex = wheelIndex;
|
|
}
|
|
|
|
protected void HandleButtonChange(Wheel wheel, Wheel.Button button, Action pressedFunc, Action releasedFunc)
|
|
{
|
|
if (wheel.ButtonPressed(button))
|
|
{
|
|
pressedFunc();
|
|
}
|
|
if (wheel.ButtonReleased(button))
|
|
{
|
|
releasedFunc();
|
|
}
|
|
}
|
|
|
|
protected void HandleDpadButtonChange(Wheel wheel, Wheel.DpadButton dpadButton, Action pressedFunc, Action releasedFunc)
|
|
{
|
|
if (wheel.DpadButtonPressed(dpadButton))
|
|
{
|
|
pressedFunc();
|
|
}
|
|
if (wheel.DpadButtonReleased(dpadButton))
|
|
{
|
|
releasedFunc();
|
|
}
|
|
}
|
|
|
|
protected void HandleScalarInputPseudoButtonChanged(
|
|
Wheel wheel,
|
|
Wheel.ScalarInput scalarInput,
|
|
Action pressedFunc,
|
|
Action releasedFunc,
|
|
uint threshold,
|
|
bool positiveDown = false
|
|
)
|
|
{
|
|
if (wheel.ScalarInputPressed(scalarInput, threshold, positiveDown))
|
|
{
|
|
pressedFunc();
|
|
}
|
|
if (wheel.ScalarInputReleased(scalarInput, threshold, positiveDown))
|
|
{
|
|
releasedFunc();
|
|
}
|
|
}
|
|
|
|
public abstract void Init();
|
|
|
|
public abstract void Handle(Wheel wheel);
|
|
}
|
|
}
|