Skip to content

Commit

Permalink
Patch release [v1.5.1.0]
Browse files Browse the repository at this point in the history
- Fixed bug with keys not being created some of the time
  • Loading branch information
o7q committed May 8, 2023
1 parent b26f793 commit 7e4cd04
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 43 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
~ v1.5.1.0
- Fixed bug with keys not being created some of the time

~ v1.5.0.0
- Added controller support
- Added an option to modify font settings
Expand Down
2 changes: 1 addition & 1 deletion src/Keystrokes/Includes/Data/Storage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Keystrokes.Data
{
public static class Storage
{
public static string VERSION = "v1.5.0";
public static string VERSION = "v1.5.1";
public static List<Form> keys = new List<Form>();
}
}
86 changes: 44 additions & 42 deletions src/Keystrokes/keymaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,59 @@ private void createKeyButton_Click(object sender, EventArgs e)
createKeyButton.Text = "Press a key...";

allowKeyCreation = true;
allowControllerCreation = true;

// configure and start ControllerRefresh timer
controllerPing.Elapsed += new ElapsedEventHandler(ControllerRefresh);
controllerPing.Interval = 1;
controllerPing.Enabled = true;
}

private void createKeyButton_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
allowControllerCreation = false;

// prevent user from making a new key if the create button was not pressed
if (allowKeyCreation == false)
return;

// get and process key code
Keys keyCode = e.KeyCode;
KeysConverter converter = new KeysConverter();
Keys key = (Keys)converter.ConvertFrom(keyCode.ToString());
string hexValue = ((int)key).ToString("X2");

// configure key text
keyData_.keyText = keyTextTextbox.Text == "" ? keyCode.ToString() : keyTextTextbox.Text;

// fix keytext with proper keys
for (int i = 0; i < keyTextFixes.Length; i += 2)
if (keyData_.keyText == keyTextFixes[i + 1])
keyData_.keyText = keyTextFixes[i];

// configure key code identities
keyData_.keyCode = hexValue;
keyData_.isControllerKey = false;

// finalize
FinalizeKeyFields();
Directory.CreateDirectory("Keystrokes\\presets\\" + keyData_.presetName + "\\assets");

// display key with keyData_ settings
key newKey = new key(keyData_);
newKey.Show();
// add key to child list
keys.Add(newKey);

// lock create button
allowKeyCreation = false;
}

bool allowControllerCreation = false;
private void ControllerRefresh(object source, ElapsedEventArgs e)
{
// return if keys are not allowed to be created
if (allowKeyCreation == false)
if (allowKeyCreation == false || allowControllerCreation == false)
return;

// get pressed controller button information
Expand All @@ -199,6 +241,7 @@ private void ControllerRefresh(object source, ElapsedEventArgs e)

// disable ControllerRefresh
controllerPing.Enabled = false;
allowControllerCreation = false;

Invoke((MethodInvoker)delegate
{
Expand All @@ -213,47 +256,6 @@ private void ControllerRefresh(object source, ElapsedEventArgs e)
// add key to child list
keys.Add(newKey);
});

// lock create button
allowKeyCreation = false;
}

private void createKeyButton_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
{
// prevent user from making a new key if the create button was not pressed
if (allowKeyCreation == false)
return;

// get and process key code
Keys keyCode = e.KeyCode;
KeysConverter converter = new KeysConverter();
Keys key = (Keys)converter.ConvertFrom(keyCode.ToString());
string hexValue = ((int)key).ToString("X2");

// configure key text
keyData_.keyText = keyTextTextbox.Text == "" ? keyCode.ToString() : keyTextTextbox.Text;

// fix keytext with proper keys
for (int i = 0; i < keyTextFixes.Length; i += 2)
if (keyData_.keyText == keyTextFixes[i + 1])
keyData_.keyText = keyTextFixes[i];

// configure key code identities
keyData_.keyCode = hexValue;
keyData_.isControllerKey = false;

// finalize
FinalizeKeyFields();
Directory.CreateDirectory("Keystrokes\\presets\\" + keyData_.presetName + "\\assets");

// display key with keyData_ settings
key newKey = new key(keyData_);
newKey.Show();
// add key to child list
keys.Add(newKey);

// lock create button
allowKeyCreation = false;
}

private void FinalizeKeyFields()
Expand Down

0 comments on commit 7e4cd04

Please sign in to comment.