USB changes and updated de item list (#318)

* Update README.md

* Added USB functionality

* Updated readme

* Revert README.md changes

* Remove unnecessary lib dependencies

only directly referenced by injection project

* Minor clean

handle compiler/roslyn messages

* Update README.md

* added a null check and a usb-botbase-safe poke function

* Revert "Update README.md"

This reverts commit e106a62b0d.

* Created new de item list using https://github.com/berichan/NH_CreationEngine

Co-authored-by: Kurt <kaphotics@gmail.com>
This commit is contained in:
berichan 2020-06-29 12:31:22 +01:00 committed by GitHub
parent 93c78a15bf
commit f0eef1a0db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1655 additions and 1646 deletions

File diff suppressed because it is too large Load Diff

View File

@ -74,5 +74,13 @@ public static class SwitchCommand
/// <param name="count">Amount of bytes</param>
/// <returns>Encoded command bytes</returns>
public static byte[] PeekRaw(uint offset, int count) => Encode($"peek 0x{offset:X8} {count}", false);
/// <summary>
/// (Without return) Sends the Bot <see cref="data"/> to be written to <see cref="offset"/>.
/// </summary>
/// <param name="offset">Address of the data</param>
/// <param name="data">Data to write</param>
/// <returns>Encoded command bytes</returns>
public static byte[] PokeRaw(uint offset, byte[] data) => Encode($"poke 0x{offset:X8} 0x{string.Concat(data.Select(z => $"{z:X2}"))}", false);
}
}

View File

@ -78,7 +78,8 @@ public void Disconnect()
if (SwDevice.IsOpen)
{
IUsbDevice? wholeUsbDevice = SwDevice as IUsbDevice;
wholeUsbDevice?.ReleaseInterface(0);
if (wholeUsbDevice != null)
wholeUsbDevice?.ReleaseInterface(0);
SwDevice.Close();
}
}
@ -154,7 +155,7 @@ public void WriteBytes(byte[] data, uint offset)
{
lock (_sync)
{
SendInternal(SwitchCommand.Poke(offset, data));
SendInternal(SwitchCommand.PokeRaw(offset, data));
// give it time to push data back
Thread.Sleep((data.Length / 256) + 100);