Skip to content

Commit

Permalink
修复造成HidIO崩溃的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanheiii committed Nov 15, 2022
1 parent 783c816 commit ab99947
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions MU3Input/IO/HidIO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class HidIO : IO

public HidIO()
{
data = new OutputData() { Buttons = new byte[10]};
data = new OutputData() { Buttons = new byte[10] };
Reconnect();
new Thread(PollThread).Start();
}
Expand Down Expand Up @@ -57,12 +57,16 @@ private unsafe void PollThread()
continue;
}

var temp = _inBuffer.ToStructure<OutputData>();

OutputData temp = new OutputData();
temp.Buttons = new ArraySegment<byte>(_inBuffer, 0, 10).ToArray();
temp.Lever = BitConverter.ToInt16(_inBuffer, 10);
temp.OptButtons = (OptButtons)_inBuffer[12];
temp.Aime.Scan = _inBuffer[13];
if (temp.Aime.Scan == 1)
{
temp.Aime.Mifare = Mifare.Create(new ArraySegment<byte>(_inBuffer, 14, 10).ToArray());
bool flag = true;
for(int i = 0; i < 10; i++)
for (int i = 0; i < 10; i++)
{
if (temp.Aime.Mifare.ID[i] != 255)
{
Expand All @@ -76,6 +80,12 @@ private unsafe void PollThread()
temp.Aime.Mifare = Mifare.Create(bytes);
}
}
if(temp.Aime.Scan == 2)
{
temp.Aime.Felica.IDm = BitConverter.ToUInt64(_inBuffer, 14);
temp.Aime.Felica.PMm = BitConverter.ToUInt64(_inBuffer, 22);
temp.Aime.Felica.SystemCode = BitConverter.ToUInt16(_inBuffer, 30);
}
data = temp;
}
}
Expand Down

0 comments on commit ab99947

Please sign in to comment.