Skip to content

Commit

Permalink
Added counter keys to be configurable as well
Browse files Browse the repository at this point in the history
  • Loading branch information
KoB-Kirito committed Jun 14, 2020
1 parent c3d4b56 commit 20a8b88
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions Program.vb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Module Program
.CountUpKey = ConsoleKey.PageUp,
.CountDownKey = ConsoleKey.PageDown,
.ResetKey = ConsoleKey.Delete,
.CounterKeys = {96, 97, 98, 99, 100, 101, 102, 103, 104, 105},
.CounterDefaultValue = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}
Dim tJson = JsonConvert.SerializeObject(tCfg, Formatting.Indented)
Expand Down Expand Up @@ -55,24 +56,13 @@ Module Program
End If
Next

Dim cKey() As Integer = {ConsoleKey.NumPad0,
ConsoleKey.NumPad1,
ConsoleKey.NumPad2,
ConsoleKey.NumPad3,
ConsoleKey.NumPad4,
ConsoleKey.NumPad5,
ConsoleKey.NumPad6,
ConsoleKey.NumPad7,
ConsoleKey.NumPad8,
ConsoleKey.NumPad9}

Dim cState(9) As Short
'Check keypresses forever
Do

'Fixes bug of states not resetting
For i = 0 To 9
cState(i) = GetAsyncKeyState(cKey(i))
cState(i) = GetAsyncKeyState(cfg.CounterKeys(i))
Next

'Count up
Expand All @@ -87,7 +77,7 @@ Module Program
End If

' Wait to only trigger once per keypress
While GetAsyncKeyState(COUNT_UP_KEY) AndAlso GetAsyncKeyState(cKey(i))
While GetAsyncKeyState(COUNT_UP_KEY) AndAlso GetAsyncKeyState(cfg.CounterKeys(i))
Threading.Thread.Sleep(15)
End While

Expand All @@ -108,7 +98,7 @@ Module Program
End If

' Wait to only trigger once per keypress
While GetAsyncKeyState(COUNT_DOWN_KEY) AndAlso GetAsyncKeyState(cKey(i))
While GetAsyncKeyState(COUNT_DOWN_KEY) AndAlso GetAsyncKeyState(cfg.CounterKeys(i))
Threading.Thread.Sleep(15)
End While

Expand All @@ -129,7 +119,7 @@ Module Program
End If

' Wait to only trigger once per keypress
While GetAsyncKeyState(RESET_KEY) AndAlso GetAsyncKeyState(cKey(i))
While GetAsyncKeyState(RESET_KEY) AndAlso GetAsyncKeyState(cfg.CounterKeys(i))
Threading.Thread.Sleep(15)
End While

Expand Down Expand Up @@ -195,5 +185,6 @@ Public Structure Config
Public CountDownKey2 As Integer
Public ResetKey As Integer
Public ResetKey2 As Integer
Public CounterKeys As Integer()
Public CounterDefaultValue As Integer()
End Structure

0 comments on commit 20a8b88

Please sign in to comment.