void AddSystemDeviceProfile( UnityInputDeviceProfile deviceProfile ) { if (deviceProfile.IsSupportedOnThisPlatform) { systemDeviceProfiles.Add( deviceProfile ); } }
void Initialize( UnityInputDeviceProfile profile, int joystickId ) { Profile = profile; Meta = Profile.Meta; var analogMappingCount = Profile.AnalogCount; for (int i = 0; i < analogMappingCount; i++) { var analogMapping = Profile.AnalogMappings[i]; var analogControl = AddControl( analogMapping.Target, analogMapping.Handle ); analogControl.Sensitivity = Profile.Sensitivity; analogControl.UpperDeadZone = Profile.UpperDeadZone; analogControl.LowerDeadZone = Profile.LowerDeadZone; } var buttonMappingCount = Profile.ButtonCount; for (int i = 0; i < buttonMappingCount; i++) { var buttonMapping = Profile.ButtonMappings[i]; AddControl( buttonMapping.Target, buttonMapping.Handle ); } JoystickId = joystickId; if (joystickId != 0) { SortOrder = 100 + joystickId; Meta += " [id: " + joystickId + "]"; } }
void AttachKeyboardDeviceWithConfig( UnityInputDeviceProfile config ) { if (keyboardDevicesAttached) { return; } var keyboardDevice = new UnityInputDevice( config ); AttachDevice( keyboardDevice ); keyboardDevicesAttached = true; }
public UnityInputDevice( UnityInputDeviceProfile profile, int joystickId = 0 ) : base(profile.Name, profile.AnalogMappings.Length, profile.ButtonMappings.Length) { Profile = profile; Meta = Profile.Meta; foreach (var analogMapping in Profile.AnalogMappings) { AddAnalogControl( analogMapping.Target, analogMapping.Handle ); } foreach (var buttonMapping in Profile.ButtonMappings) { AddButtonControl( buttonMapping.Target, buttonMapping.Handle ); } JoystickId = joystickId; if (joystickId != 0) { Meta += " [id: " + joystickId + "]"; } }
public bool IsConfiguredWith( UnityInputDeviceProfile deviceProfile, int joystickId ) { return Profile == deviceProfile && JoystickId == joystickId; }
public UnityInputDevice( UnityInputDeviceProfile profile ) : base( profile.Name ) { Initialize( profile, 0 ); }
public UnityInputDevice( UnityInputDeviceProfile profile, int joystickId ) : base( profile.Name ) { Initialize( profile, joystickId ); }
void Initialize( UnityInputDeviceProfile profile, int joystickId ) { Profile = profile; Meta = Profile.Meta; foreach (var analogMapping in Profile.AnalogMappings) { AddAnalogControl( analogMapping.Target, analogMapping.Handle ); } foreach (var buttonMapping in Profile.ButtonMappings) { AddButtonControl( buttonMapping.Target, buttonMapping.Handle ); } JoystickId = joystickId; if (joystickId != 0) { SortOrder = 100 + joystickId; Meta += " [id: " + joystickId + "]"; } }
public UnityInputDevice( UnityInputDeviceProfile profile ) : base(profile.Name, profile.AnalogMappings.Length, profile.ButtonMappings.Length) { Initialize( profile, 0 ); }
void DetectAttachedJoystickDevice(int unityJoystickId, string unityJoystickName) { if (unityJoystickName == "WIRED CONTROLLER" || unityJoystickName == " WIRED CONTROLLER") { // Ignore Steam controller for now. return; } if (unityJoystickName.IndexOf("webcam", StringComparison.OrdinalIgnoreCase) != -1) { // Unity thinks some webcams are joysticks. >_< return; } // PS4 controller works properly as of Unity 4.5 if (InputManager.UnityVersion <= new VersionInfo(4, 5)) { if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXWebPlayer) { if (unityJoystickName == "Unknown Wireless Controller") { // Ignore PS4 controller in Bluetooth mode on Mac since it connects but does nothing. return; } } } var matchedDeviceProfile = deviceProfiles.Find(config => config.HasJoystickName(unityJoystickName)); if (matchedDeviceProfile == null) { matchedDeviceProfile = deviceProfiles.Find(config => config.HasLastResortRegex(unityJoystickName)); } UnityInputDeviceProfile deviceProfile = null; if (matchedDeviceProfile == null) { deviceProfile = new UnityUnknownDeviceProfile(unityJoystickName); deviceProfiles.Add(deviceProfile); } else { deviceProfile = matchedDeviceProfile; } int deviceCount = devices.Count; for (int i = 0; i < deviceCount; i++) { var device = devices[i]; var unityDevice = device as UnityInputDevice; if (unityDevice != null && unityDevice.IsConfiguredWith(deviceProfile, unityJoystickId)) { Logger.LogInfo("Device \"" + unityJoystickName + "\" is already configured with " + deviceProfile.Name); return; } } if (!deviceProfile.IsHidden) { var joystickDevice = new UnityInputDevice(deviceProfile, unityJoystickId); AttachDevice(joystickDevice); if (matchedDeviceProfile == null) { Logger.LogWarning("Device " + unityJoystickId + " with name \"" + unityJoystickName + "\" does not match any known profiles."); } else { Logger.LogInfo("Device " + unityJoystickId + " matched profile " + deviceProfile.GetType().Name + " (" + deviceProfile.Name + ")"); } } else { Logger.LogInfo("Device " + unityJoystickId + " matching profile " + deviceProfile.GetType().Name + " (" + deviceProfile.Name + ")" + " is hidden and will not be attached."); } }
public UnityInputDevice(UnityInputDeviceProfile profile) : base(profile.Name, profile.AnalogMappings.Length, profile.ButtonMappings.Length) { Initialize(profile, 0); }
public bool IsConfiguredWith(UnityInputDeviceProfile deviceProfile, int joystickId) { return(Profile == deviceProfile && JoystickId == joystickId); }
public UnityInputDevice(UnityInputDeviceProfile profile) : base(profile.Name) { Initialize(profile, 0); }
public UnityInputDevice(UnityInputDeviceProfile profile, int joystickId) : base(profile.Name) { Initialize(profile, joystickId); }