////REVIEW: the descriptor may come from anywhere; method assumes we get passed some state we actually own ////REVIEW: this mutates the state of the current instance but also mutates the shared ActionMap; that's bad public bool BindControl(InputControlDescriptor descriptor, InputControl control, bool restrictToExistingDevices) { bool existingDevice = false; for (int i = 0; i < m_DeviceStates.Count; i++) { if (control.provider == m_DeviceStates[i].controlProvider) { existingDevice = true; break; } } if (!existingDevice) { if (restrictToExistingDevices) { return(false); } deviceStates.Add(new InputState(control.provider, new List <int>() { control.index })); } descriptor.controlIndex = control.index; descriptor.deviceType = control.provider.GetType(); m_ControlScheme.customized = true; RefreshBindings(); return(true); }
public static string GetDeviceControlName(InputControlDescriptor source) { string[] names = GetDeviceControlNames(source.deviceType); if (source.controlIndex < 0 || source.controlIndex >= names.Length) { return("None"); } return(names[source.controlIndex]); }
public static string GetDeviceControlName(DeviceSlot deviceSlot, InputControlDescriptor source) { if (deviceSlot != null) { string[] names = GetDeviceControlNames(deviceSlot.type); if (source.controlIndex >= 0 && source.controlIndex < names.Length) { return(names[source.controlIndex]); } } return("None"); }
////REVIEW: the descriptor may come from anywhere; method assumes we get passed some state we actually own ////REVIEW: this mutates the state of the current instance but also mutates the shared ActionMap; that's bad public bool BindControl(InputControlDescriptor descriptor, InputControl control, bool restrictToExistingDevices) { bool existingDevice = false; for (int i = 0; i < m_DeviceStates.Count; i++) { if (control.provider == m_DeviceStates[i].controlProvider) { existingDevice = true; break; } } if (!existingDevice) { if (restrictToExistingDevices) { return(false); } deviceStates.Add(new InputState(control.provider, new List <int>() { control.index })); } descriptor.controlIndex = control.index; var inputDevice = control.provider as InputDevice; if (inputDevice == null) { Debug.LogError(string.Format("The InputControlProvider must be an InputDevice, but it is a {0}", control.provider.GetType())); return(false); } int key = m_ControlScheme.GetDeviceKey(inputDevice); if (key == DeviceSlot.kInvalidKey) { Debug.LogError(string.Format("Could not find key for InputDevice type {0}", inputDevice.GetType())); return(false); } descriptor.deviceKey = key; m_ControlScheme.customized = true; RefreshBindings(); return(true); }
private string GetSourceName(InputControlDescriptor source) { var deviceState = GetDeviceStateForDeviceSlot(m_ControlScheme.GetDeviceSlot(source.deviceKey)); return(deviceState.controlProvider.GetControlData(source.controlIndex).name); }
private float GetSourceValue(InputControlDescriptor source) { var deviceState = GetDeviceStateForDeviceSlot(m_ControlScheme.GetDeviceSlot(source.deviceKey)); return(deviceState.GetCurrentValue(source.controlIndex)); }
public static string GetDeviceName(InputControlDescriptor source) { return((Type)source.deviceType == null ? "No-Device" : source.deviceType.Name); }
public ButtonAxisSource(InputControlDescriptor negative, InputControlDescriptor positive) { this.negative = negative; this.positive = positive; }