private void ProcessDualSpeedAxis(GameControllerAxisMapping mapping, int stateValue, IProgress <GameControllerProgressArgs> progress)
 {
     if (mapping != null)
     {
         System.Diagnostics.Debug.Write($" {stateValue}");
         bool highspeed = (stateValue <= -9900 || stateValue >= 9900);
         bool reverse   = (stateValue <= -10);
         bool stop      = (stateValue > -10 && stateValue < 10);
         if (mapping.ReverseDirection)
         {
             System.Diagnostics.Debug.WriteLine("(Reversed direction)");
             reverse = !reverse;
         }
         GameControllerAxisCommandState history = _AxisCommandHistory.Where(h => h.Command == mapping.Command).FirstOrDefault();
         if (history == null)
         {
             if (!stop)
             {
                 // New command
                 _AxisCommandHistory.Add(new GameControllerAxisCommandState(mapping.Command, highspeed, reverse));
                 progress.Report(new GameControllerProgressArgs(GameControllerUpdateNotification.CommandDown, mapping.Command, reverse, highspeed));
             }
         }
         else
         {
             // See if command has changed
             if (stop)
             {
                 // Issue command up and remove history
                 progress.Report(new GameControllerProgressArgs(GameControllerUpdateNotification.CommandUp, mapping.Command, history.Reverse, history.Highspeed));
                 _AxisCommandHistory.Remove(history);
             }
             else if (history.Highspeed != highspeed || history.Reverse != reverse)
             {
                 // There has been a change of something so stop and restart
                 progress.Report(new GameControllerProgressArgs(GameControllerUpdateNotification.CommandUp, mapping.Command, history.Reverse, history.Highspeed));
                 history.Highspeed = highspeed;
                 history.Reverse   = reverse;
                 if (reverse)
                 {
                     System.Diagnostics.Debug.Write("(Reverse)");
                 }
                 progress.Report(new GameControllerProgressArgs(GameControllerUpdateNotification.CommandDown, mapping.Command, reverse, highspeed));
             }
         }
     }
 }
 private void ProcessAxis(GameControllerAxisMapping mapping, int stateValue, bool highspeed, IProgress <GameControllerProgressArgs> progress)
 {
     if (mapping != null)
     {
         bool reverse = (stateValue <= -10);
         bool stop    = (stateValue > -10 && stateValue < 10);
         if (mapping.ReverseDirection)
         {
             reverse = !reverse;
         }
         GameControllerAxisCommandState history = _AxisCommandHistory.Where(h => h.Command == mapping.Command).FirstOrDefault();
         if (history == null)
         {
             if (!stop)
             {
                 // New command
                 _AxisCommandHistory.Add(new GameControllerAxisCommandState(mapping.Command, highspeed, reverse));
                 progress.Report(new GameControllerProgressArgs(GameControllerUpdateNotification.CommandDown, mapping.Command, reverse, highspeed));
             }
         }
         else
         {
             // See if command has changed
             if (stop)
             {
                 // Issue command up and remove history
                 progress.Report(new GameControllerProgressArgs(GameControllerUpdateNotification.CommandUp, mapping.Command, false, false));
                 _AxisCommandHistory.Remove(history);
             }
             else if (history.Reverse != reverse)
             {
                 // There has been a change of something so stop and restart
                 progress.Report(new GameControllerProgressArgs(GameControllerUpdateNotification.CommandUp, mapping.Command, false, false));
                 history.Highspeed = highspeed;
                 history.Reverse   = reverse;
                 progress.Report(new GameControllerProgressArgs(GameControllerUpdateNotification.CommandDown, mapping.Command, highspeed, reverse));
             }
         }
     }
 }