Skip to content

Commit

Permalink
0.05 Utilisation de anyButton
Browse files Browse the repository at this point in the history
  • Loading branch information
FLOBOY-France committed Jun 15, 2021
1 parent 790e516 commit 042283d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion GamePadToKeyboard/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<appSettings>
<add key="AppVersion" value="0.04" />
<add key="AppVersion" value="0.05" />
<add key="intervalleMS" value="500"/>
</appSettings>
</configuration>
34 changes: 18 additions & 16 deletions GamePadToKeyboard/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ class Program
{
static void Main(string[] args)
{
ButtonState previousState = ButtonState.Released;
//ButtonState previousState = ButtonState.Released;
bool previousStatePressed = false;
DateTime dtLastPressed = DateTime.Now;
int intervalleMS = int.Parse(ConfigurationManager.AppSettings["intervalleMS"]);
string AppVersion = ConfigurationManager.AppSettings["AppVersion"];

Console.WriteLine( (" ___ GamePadToKeyboard v" + AppVersion).PadRight(100, '_'));
Console.WriteLine("| A : Activation, B : Clear, Back : Sortie de l'application".PadRight(100) + "|");
//Console.WriteLine("| A : Activation, B : Clear, Back : Sortie de l'application".PadRight(100) + "|");
Console.WriteLine(("| Intervalle fixé à " + intervalleMS).PadRight(100) + "|");
int gamePadNumber = 0;

Expand All @@ -34,7 +35,8 @@ static void Main(string[] args)


GamePadState state = GamePad.GetState(gamePadNumber);
if (state.Buttons.A.Equals(ButtonState.Released) && previousState.Equals(ButtonState.Pressed))
// if (state.Buttons.A.Equals(ButtonState.Released) && previousState.Equals(ButtonState.Pressed))
if (!state.Buttons.IsAnyButtonPressed && previousStatePressed)
{

TimeSpan timeSpan = DateTime.Now - dtLastPressed;
Expand All @@ -43,27 +45,27 @@ static void Main(string[] args)
dtLastPressed = DateTime.Now;
KeyboardSender.SendReturn();
//KeyboardSender.SendKey(0x0D);
Console.WriteLine("On a relâché A, écart : " + timeSpan.TotalMilliseconds);
Console.WriteLine("On a relâché un bouton, écart : " + timeSpan.TotalMilliseconds);

}
else
{
Console.WriteLine("Non accepté : " + timeSpan.TotalMilliseconds + " < " + intervalleMS);
}
}
previousStatePressed = state.Buttons.IsAnyButtonPressed;
//else if (state.Buttons.B.Equals(ButtonState.Pressed))
// Console.Clear();
/*else if (state.Buttons.Back.Equals(ButtonState.Pressed))
{
Console.WriteLine("Êtes-vous sûr de vouloir sortir ? o/N");
string rep = Console.ReadLine();
if (rep.ToUpper().Equals("O"))
break;
}*/

else if (state.Buttons.B.Equals(ButtonState.Pressed))
Console.Clear();
else if (state.Buttons.Back.Equals(ButtonState.Pressed))
{
Console.WriteLine("Êtes-vous sûr de vouloir sortir ? o/N");
string rep = Console.ReadLine();
if (rep.ToUpper().Equals("O"))
break;
}

previousState = state.Buttons.A;
}
//previousState = state.Buttons.A;
}
}
}
}
Expand Down

0 comments on commit 042283d

Please sign in to comment.