Skip to content

Commit

Permalink
Fix index out of range when retrieving keyboard input
Browse files Browse the repository at this point in the history
  • Loading branch information
sabihoshi committed Apr 4, 2021
1 parent 315cd44 commit 74f0317
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion GenshinLyreMidiPlayer/GenshinLyreMidiPlayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<UseWPF>true</UseWPF>
<StartupObject>GenshinLyreMidiPlayer.App</StartupObject>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Version>1.3.0</Version>
<Version>1.3.1</Version>
<ApplicationIcon>item_windsong_lyre.ico</ApplicationIcon>
</PropertyGroup>

Expand Down
5 changes: 3 additions & 2 deletions GenshinLyreMidiPlayer/LyrePlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class LyrePlayer
public const string GenshinWindowName = "Genshin Impact";
private static readonly IInputSimulator Input = new InputSimulator();

private static readonly IReadOnlyList<int> LyreNotes = new List<int>
private static readonly List<int> LyreNotes = new List<int>
{
48, // C3
50, // D3
Expand Down Expand Up @@ -100,7 +100,8 @@ private static int TransposeNote(int noteId)

public static void PlayNote(int noteId, Keyboard.Layout selectedLayout)
{
var key = Keyboard.GetLayout(selectedLayout)[noteId];
var keyIndex = LyreNotes.IndexOf(noteId);
var key = Keyboard.GetLayout(selectedLayout)[keyIndex];
Input.Keyboard.KeyPress(key);
}

Expand Down

0 comments on commit 74f0317

Please sign in to comment.