Skip to content

Commit

Permalink
(Hopefully) Fix device type being stuck on unknown and inputs sometim…
Browse files Browse the repository at this point in the history
…es not registering
  • Loading branch information
TheNathannator committed Feb 15, 2023
1 parent 0cd85a2 commit ad47b0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions Nintroller/Nintroller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -698,9 +698,9 @@ private void ParseReport(byte[] report)
break;

case ReadReportType.Extension_B:
_readType = ReadReportType.Unknown;
if (report.Length < 6)
{
_readType = ReadReportType.Unknown;
Log("Report length not long enough for Extension_B");
return;
}
Expand Down Expand Up @@ -1142,7 +1142,7 @@ private void ParseReport(byte[] report)
case InputReport.BtnsIRExt:
case InputReport.BtnsAccIRExt:
case InputReport.ExtOnly:
if (_state != null)
if (_state != null && _currentType != ControllerType.Unknown)
{
_state.Update(report);
var arg = new NintrollerStateEventArgs(_currentType, _state, BatteryLevel);
Expand All @@ -1156,7 +1156,9 @@ private void ParseReport(byte[] report)
Debug.WriteLine("State Update Exception: " + ex.ToString());
}
}
else if (_statusType != StatusType.DiscoverExtension)
else if (_statusType != StatusType.DiscoverExtension &&
_readType != ReadReportType.Extension_A &&
_readType != ReadReportType.Extension_B)
{
Log("State is null! Requesting status");
_currentType = ControllerType.Unknown;
Expand Down Expand Up @@ -1389,6 +1391,9 @@ public void StopReading()
{
_reading = false;
_connected = false;
_ackType = AcknowledgementType.NA;
_statusType = StatusType.Unknown;
_readType = ReadReportType.Unknown;
}

#endregion
Expand Down
2 changes: 1 addition & 1 deletion WiitarThing/Components/DeviceControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ void device_ExtensionChange(object sender, NintrollerExtensionEventArgs e)
Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background,
new Action(() =>
{
UpdateIcon(DeviceType);
RefreshState();
}
));
}
Expand Down

0 comments on commit ad47b0e

Please sign in to comment.