Example #1
0
 public void ProcessHostGamepads(Action <string?, bool, ClientInputFocus> handleButton, Action <string?, int> handleAxis)
 {
     foreach (var pad in GamePad360.EnumerateDevices())
     {
         if (!pad.IsConnected)
         {
             continue;
         }
         for (int b = 0, n = pad.NumButtons; b < n; b++)
         {
             handleButton(pad.InputNamePrefix + pad.ButtonName(b), pad.Pressed(b), ClientInputFocus.Pad);
         }
         foreach (var(axisName, f) in pad.GetAxes())
         {
             handleAxis(pad.InputNamePrefix + axisName, (int)f);
         }
         _lastHapticsSnapshot.TryGetValue(pad.InputNamePrefix + "Left", out var leftStrength);
         _lastHapticsSnapshot.TryGetValue(pad.InputNamePrefix + "Right", out var rightStrength);
         pad.SetVibration(leftStrength, rightStrength);                 // values will be 0 if not found
     }
     foreach (var pad in GamePad.EnumerateDevices())
     {
         for (int b = 0, n = pad.NumButtons; b < n; b++)
         {
             handleButton(pad.InputNamePrefix + pad.ButtonName(b), pad.Pressed(b), ClientInputFocus.Pad);
         }
         foreach (var(axisName, f) in pad.GetAxes())
         {
             handleAxis(pad.InputNamePrefix + axisName, (int)f);
         }
     }
 }
Example #2
0
 public void ProcessHostGamepads(Action <string?, bool, ClientInputFocus> handleButton, Action <string?, int> handleAxis)
 {
     foreach (var pad in GamePad360.EnumerateDevices())
     {
         var inputNamePrefix = $"X{pad.PlayerNumber} ";
         for (int b = 0, n = pad.NumButtons; b < n; b++)
         {
             handleButton(inputNamePrefix + pad.ButtonName(b), pad.Pressed(b), ClientInputFocus.Pad);
         }
         foreach (var(axisName, f) in pad.GetAxes())
         {
             handleAxis(inputNamePrefix + axisName, (int)f);
         }
     }
     foreach (var pad in GamePad.EnumerateDevices())
     {
         var inputNamePrefix = $"J{pad.PlayerNumber} ";
         for (int b = 0, n = pad.NumButtons; b < n; b++)
         {
             handleButton(inputNamePrefix + pad.ButtonName(b), pad.Pressed(b), ClientInputFocus.Pad);
         }
         foreach (var(axisName, f) in pad.GetAxes())
         {
             handleAxis(inputNamePrefix + axisName, (int)f);
         }
     }
 }
Example #3
0
 public IReadOnlyDictionary <string, IReadOnlyCollection <string> > GetHapticsChannels()
 => GamePad360.EnumerateDevices().ToDictionary(pad => pad.InputNamePrefix, _ => XINPUT_HAPTIC_CHANNEL_NAMES);