/// <summary> /// No checking to see if the deserialized controls match any definition /// </summary> public void DeSerialize(BinaryReader b) { _buttons.Clear(); int numButtons = b.ReadInt32(); for (int i = 0; i < numButtons; i++) { string k = b.ReadString(); float v = b.ReadSingle(); _buttons.Add(k, (int)v); } }
/// <summary> /// uses the bindings to latch our own logical button state from the source controller's button state (which are assumed to be the physical side of the binding). /// this will clobber any existing data (use OR_* or other functions to layer in additional input sources) /// </summary> public void LatchFromPhysical(IController controller) { foreach (var kvp in _bindings) { foreach (var boundBtn in kvp.Value) { if (_buttons[kvp.Key] == false && controller.IsPressed(boundBtn)) { _buttonStarts[kvp.Key] = _emulator.Frame; } } } _buttons.Clear(); foreach (var kvp in _bindings) { _buttons[kvp.Key] = false; foreach (var bound_button in kvp.Value) { if (controller.IsPressed(bound_button)) { _buttons[kvp.Key] = true; } } } }
/// <summary> /// uses the bindings to latch our own logical button state from the source controller's button state (which are assumed to be the physical side of the binding). /// this will clobber any existing data (use OR_* or other functions to layer in additional input sources) /// </summary> public void LatchFromPhysical(IController controller) { _buttons.Clear(); foreach (var kvp in _bindings) { _buttons[kvp.Key] = false; foreach (var bound_button in kvp.Value) { if (controller.IsPressed(bound_button)) { _buttons[kvp.Key] = true; } } } foreach (var kvp in _floatBinds) { var input = controller.GetFloat(kvp.Value.Value); string outkey = kvp.Key; if (_floatRanges.ContainsKey(outkey)) { _floatButtons[outkey] = input; } } // it's not sure where this should happen, so for backwards compatibility.. do it every time NormalizeFloats(controller); }
public void StartListeningForFloatEvents() { lock (_floatValues) { _floatDeltas.Clear(); _trackDeltas = true; } }
public void StartListeningForFloatEvents() { lock (FloatValues) { FloatDeltas.Clear(); trackdeltas = true; } }
public void StartListeningForAxisEvents() { lock (_axisValues) { _axisDeltas.Clear(); _trackDeltas = true; } }
/// <summary> /// uses the bindings to latch our own logical button state from the source controller's button state (which are assumed to be the physical side of the binding). /// this will clobber any existing data (use OR_* or other functions to layer in additional input sources) /// </summary> public void LatchFromPhysical(IController finalHostController) { _buttons.Clear(); foreach (var kvp in _bindings) { _buttons[kvp.Key] = false; foreach (var button in kvp.Value) { if (finalHostController.IsPressed(button)) { _buttons[kvp.Key] = true; } } } foreach (var kvp in _axisBindings) { // values from finalHostController are ints in -10000..10000 (or 0..10000), so scale to -1..1, using floats to keep fractional part var value = finalHostController.AxisValue(kvp.Value.Value) / 10000.0f; // apply deadzone (and scale diminished range back up to -1..1) var deadzone = kvp.Value.Deadzone; if (value < -deadzone) { value += deadzone; } else if (value < deadzone) { value = 0.0f; } else { value -= deadzone; } value /= 1.0f - deadzone; // scale by user-set multiplier (which is -2..2, therefore value is now in -2..2) value *= kvp.Value.Mult; // -1..1 -> -A..A (where A is the larger "side" of the range e.g. a range of 0..50, neutral=10 would give A=40, and thus a value in -40..40) var range = _axisRanges[kvp.Key]; value *= Math.Max(range.Neutral - range.Min, range.Max - range.Neutral); // shift the midpoint, so a value of 0 becomes range.Neutral (and, assuming >=1x multiplier, all values in range are reachable) value += range.Neutral; // finally, constrain to range _axes[kvp.Key] = ((int)value).ConstrainWithin(range.Range); } }
public static void ClearBindings() { _bindings.Clear(); }
public void ClearStarts() { _buttonStarts.Clear(); }
public void ClearStickyFloats() { _floatSet.Clear(); }
public void ClearStickyAxes() => _axisSet.Clear();
public void ClearStickies() { _boolPatterns.Clear(); _axisPatterns.Clear(); }
public void ClearStickies() { _boolPatterns.Clear(); _floatPatterns.Clear(); }
public void ClearStickyFloats() { _floatPatterns.Clear(); }
public void ClearStickies() { _stickySet.Clear(); buttonStarts.Clear(); lagStarts.Clear(); }
/// <summary> /// uses the bindings to latch our own logical button state from the source controller's button state (which are assumed to be the physical side of the binding). /// this will clobber any existing data (use OR_* or other functions to layer in additional input sources) /// </summary> public void LatchFromPhysical(IController controller) { _buttons.Clear(); foreach (var kvp in _bindings) { _buttons[kvp.Key] = false; foreach (var bound_button in kvp.Value) { if (controller[bound_button]) { _buttons[kvp.Key] = true; } } } foreach (var kvp in _floatBinds) { var input = controller.GetFloat(kvp.Value.Value); string outkey = kvp.Key; float multiplier = kvp.Value.Mult; float deadzone = kvp.Value.Deadzone; ControllerDefinition.FloatRange range; if (_floatRanges.TryGetValue(outkey, out range)) { // input range is assumed to be -10000,0,10000 // first, modify for deadzone { float absinput = Math.Abs(input); float zeropoint = deadzone * 10000.0f; if (absinput < zeropoint) { input = 0.0f; } else { absinput -= zeropoint; absinput *= 10000.0f; absinput /= 10000.0f - zeropoint; input = absinput * Math.Sign(input); } } var output = (input * multiplier + 10000.0f) * (range.Max - range.Min) / 20000.0f + range.Min; float lbound = Math.Min(range.Min, range.Max); float ubound = Math.Max(range.Min, range.Max); if (output < lbound) { output = lbound; } if (output > ubound) { output = ubound; } _floatButtons[outkey] = output; } } }