Skip to content

Commit

Permalink
Move ControlDown to SDL2_FNAPlatform
Browse files Browse the repository at this point in the history
  • Loading branch information
flibitijibibo committed Jan 1, 2024
1 parent 1c0f0ad commit 3c02a81
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
22 changes: 15 additions & 7 deletions src/FNAPlatform/SDL2_FNAPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ internal static class SDL2_FNAPlatform

#endregion

#region Keyboard State

// Used for special copy-paste text input
private static bool LeftControlDown = false;
private static bool RightControlDown = false;

#endregion

#region Init/Exit Methods

public static string ProgramInit(LaunchParameters args)
Expand Down Expand Up @@ -956,11 +964,11 @@ ref bool textInputSuppress
Keys key = ToXNAKey(ref evt.key.keysym);
if (key == Keys.LeftControl)
{
Keyboard.LeftControlDown = true;
LeftControlDown = true;
}
else if (key == Keys.RightControl)
{
Keyboard.RightControlDown = true;
RightControlDown = true;
}

if (evt.key.repeat == 0)
Expand All @@ -971,7 +979,7 @@ ref bool textInputSuppress
textInputControlDown[textIndex] = true;
TextInputEXT.OnTextInput(FNAPlatform.TextInputCharacters[textIndex]);
}
else if ((Keyboard.LeftControlDown || Keyboard.RightControlDown)
else if ((LeftControlDown || RightControlDown)
&& key == Keys.V)
{
textInputControlDown[6] = true;
Expand All @@ -986,7 +994,7 @@ ref bool textInputSuppress
{
TextInputEXT.OnTextInput(FNAPlatform.TextInputCharacters[textIndex]);
}
else if ((Keyboard.LeftControlDown || Keyboard.RightControlDown)
else if ((LeftControlDown || RightControlDown)
&& key == Keys.V)
{
TextInputEXT.OnTextInput(FNAPlatform.TextInputCharacters[6]);
Expand All @@ -999,19 +1007,19 @@ ref bool textInputSuppress

if (key == Keys.LeftControl)
{
Keyboard.LeftControlDown = false;
LeftControlDown = false;
}
else if (key == Keys.RightControl)
{
Keyboard.RightControlDown = false;
RightControlDown = false;
}

int value;
if (FNAPlatform.TextInputBindings.TryGetValue(key, out value))
{
textInputControlDown[value] = false;
}
else if (((!Keyboard.LeftControlDown && !Keyboard.RightControlDown) && textInputControlDown[6])
else if (((!LeftControlDown && !RightControlDown) && textInputControlDown[6])
|| key == Keys.V)
{
textInputControlDown[6] = false;
Expand Down
8 changes: 0 additions & 8 deletions src/Input/Keyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ public static Keys GetKeyFromScancodeEXT(Keys scancode)

#endregion

#region Internal Static Variables

// Used for special copy-paste text input
internal static bool LeftControlDown = false;
internal static bool RightControlDown = false;

#endregion

#region Private Static Variables

private static List<Keys> activeKeys = new List<Keys>();
Expand Down

0 comments on commit 3c02a81

Please sign in to comment.