using System.Diagnostics;
namespace StgSharp.Graphic.Input
{
public static class HidHelper
{
///
/// Translates a generic HID usage value to a specific joystick axis for the specified .
///
/// The HID usage page.
/// The generic usage value.
/// An that maps the HID usage value to a joystick axis.
public static int TranslateJoystickAxis(HidPage page, int usage)
{
switch (page)
{
case HidPage.GenericDesktop:
switch ((HidGenericDesktopUsage)usage)
{
case HidGenericDesktopUsage.X:
return 0;
case HidGenericDesktopUsage.Y:
return 1;
case HidGenericDesktopUsage.Z:
return 2;
case HidGenericDesktopUsage.RotationZ:
return 3;
case HidGenericDesktopUsage.RotationX:
return 4;
case HidGenericDesktopUsage.RotationY:
return 5;
case HidGenericDesktopUsage.Slider:
return 6;
case HidGenericDesktopUsage.Dial:
return 7;
case HidGenericDesktopUsage.Wheel:
return 8;
}
break;
case HidPage.Simulation:
switch ((HidSimulationUsage)usage)
{
case HidSimulationUsage.Rudder:
return 9;
case HidSimulationUsage.Throttle:
return 10;
}
break;
}
Debug.Print($"[Input] Unknown axis with HID page/usage {page}/{usage}");
return 0;
}
}
}