mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-08-04 08:31:02 +00:00
[Win] Refactored UpdateAxes
This commit is contained in:
parent
354fc04614
commit
be575d4475
|
@ -320,20 +320,25 @@ namespace OpenTK.Platform.Windows
|
||||||
Array.Resize(ref DataBuffer, report_count);
|
Array.Resize(ref DataBuffer, report_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
UpdateAxes(rin, stick);
|
||||||
if (HidProtocol.GetData(HidProtocolReportType.Input,
|
UpdateButtons(rin, stick);
|
||||||
DataBuffer, ref size, PreparsedData,
|
return true;
|
||||||
new IntPtr((void*)&rin->Data.HID.RawData),
|
}
|
||||||
rin->Data.HID.Size) != HidProtocolStatus.Success)
|
}
|
||||||
{
|
|
||||||
Debug.Print("[WinRawJoystick] HidProtocol.GetData() failed with {0}",
|
|
||||||
Marshal.GetLastWin32Error());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
UpdateButtons(rin, stick);
|
HatPosition GetHatPosition(uint value, HidProtocolValueCaps caps)
|
||||||
|
{
|
||||||
|
if (caps.LogicalMax == 8)
|
||||||
|
return (HatPosition)value;
|
||||||
|
else
|
||||||
|
return HatPosition.Centered;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe void UpdateAxes(RawInput* rin, Device stick)
|
||||||
|
{
|
||||||
for (int i = 0; i < stick.AxisCaps.Count; i++)
|
for (int i = 0; i < stick.AxisCaps.Count; i++)
|
||||||
{
|
{
|
||||||
if (stick.AxisCaps[i].IsRange)
|
if (stick.AxisCaps[i].IsRange)
|
||||||
|
@ -374,20 +379,6 @@ namespace OpenTK.Platform.Windows
|
||||||
stick.SetAxis(page, usage, scaled_value);
|
stick.SetAxis(page, usage, scaled_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private HatPosition GetHatPosition(uint value, HidProtocolValueCaps caps)
|
|
||||||
{
|
|
||||||
if (caps.LogicalMax == 8)
|
|
||||||
return (HatPosition)value;
|
|
||||||
else
|
|
||||||
return HatPosition.Centered;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe void UpdateButtons(RawInput* rin, Device stick)
|
unsafe void UpdateButtons(RawInput* rin, Device stick)
|
||||||
|
@ -642,43 +633,6 @@ namespace OpenTK.Platform.Windows
|
||||||
return guid;
|
return guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UpdateAxes(Device stick, HidProtocolCaps caps, HidProtocolValueCaps[] axes, int axes_count, HidProtocolData[] data)
|
|
||||||
{
|
|
||||||
// Use the data indices in the axis and button caps arrays to
|
|
||||||
// access the data buffer we just filled.
|
|
||||||
for (int i = 0; i < axes_count; i++)
|
|
||||||
{
|
|
||||||
if (!axes[i].IsRange)
|
|
||||||
{
|
|
||||||
int index = axes[i].NotRange.DataIndex;
|
|
||||||
if (index < 0 || index >= caps.NumberInputValueCaps)
|
|
||||||
{
|
|
||||||
// Should never happen
|
|
||||||
Debug.Print("[WinRawJoystick] Error: DataIndex out of range");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data[index].DataIndex != i)
|
|
||||||
{
|
|
||||||
// Should also never happen
|
|
||||||
Debug.Print("[WinRawJoystick] DataIndex != index ({0} != {1})",
|
|
||||||
data[index].DataIndex, i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
short value = (short)HidHelper.ScaleValue(data[i].RawValue,
|
|
||||||
axes[i].LogicalMin, axes[i].LogicalMax,
|
|
||||||
short.MinValue, short.MaxValue);
|
|
||||||
|
|
||||||
stick.SetAxis(axes[i].UsagePage, axes[i].NotRange.Usage, value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Todo: fall back to HidProtocol.GetLinkCollectionNodes
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Device GetDevice(IntPtr handle)
|
Device GetDevice(IntPtr handle)
|
||||||
{
|
{
|
||||||
long hardware_id = handle.ToInt64();
|
long hardware_id = handle.ToInt64();
|
||||||
|
|
Loading…
Reference in a new issue