Exemplo n.º 1
0
        public InputBindings(
            InputSourceMapping <TAction> initialMapping,
            IObservable <InputSettings> inputSettingChanges,
            IImmutableDictionary <InputDefaults, InputSourceMapping <TAction> > defaultMappings)
        {
            _defaultMappings    = defaultMappings;
            _usesDefaultMapping = false;
            foreach (var defaultMapping in defaultMappings.Values)
            {
                if (initialMapping.Equals(defaultMapping))
                {
                    _usesDefaultMapping = true;
                }
            }

            _inputMappings = new BehaviorSubject <InputSourceMapping <TAction> >(initialMapping);
            _inputMappings.Subscribe(mapping => {
                _currentMapping = mapping;
            });
            _activeControllerId      = null;
            _activeControllerUpdates = new BehaviorSubject <JoystickActivator.Controller?>(null);

            _actionMap = _inputMappings.CombineLatest(
                _activeControllerUpdates,
                inputSettingChanges.DistinctUntilChanged(EqualityComparer <InputSettings> .Default),
                (mapping, controller, settings) => {
                var controllerId = controller.HasValue ? controller.Value.Id : null;
                return(new ActionMapConfig <TAction> {
                    InputMapping = mapping,
                    ControllerId = controllerId,
                    InputSettings = settings
                });
            });
        }
Exemplo n.º 2
0
            public static ControllerPeripheral GetPeripheral(ControllerId id, InputSettings inputSettings)
            {
                InputMap <InputSource, ButtonState> buttons;
                InputMap <InputSource, float>       axes;

                if (id is ControllerId.Unity)
                {
                    var controllerId = id as ControllerId.Unity;
                    buttons = Buttons(controllerId.Id);
                    axes    = PolarizedAxes(controllerId.Id)
                              .Adapt(Adapters.Deadzone(inputSettings.JoystickDeadzone));
                }
                else if (id is ControllerId.XInput)
                {
                    var controllerId = id as ControllerId.XInput;
                    buttons = XInputButtons(controllerId.Id);
                    axes    = PolarizedXInputAxes(controllerId.Id);
                }
                else
                {
                    buttons = InputMap <InputSource, ButtonState> .Empty;
                    axes    = InputMap <InputSource, float> .Empty;
                }
                return(new ControllerPeripheral(buttons, axes));
            }
Exemplo n.º 3
0
        public static NpadIdType GetNpadIdTypeFromIndex(ControllerId index)
        {
            switch (index)
            {
            case ControllerId.ControllerPlayer1:  return(NpadIdType.Player1);

            case ControllerId.ControllerPlayer2:  return(NpadIdType.Player2);

            case ControllerId.ControllerPlayer3:  return(NpadIdType.Player3);

            case ControllerId.ControllerPlayer4:  return(NpadIdType.Player4);

            case ControllerId.ControllerPlayer5:  return(NpadIdType.Player5);

            case ControllerId.ControllerPlayer6:  return(NpadIdType.Player6);

            case ControllerId.ControllerPlayer7:  return(NpadIdType.Player7);

            case ControllerId.ControllerPlayer8:  return(NpadIdType.Player8);

            case ControllerId.ControllerHandheld: return(NpadIdType.Handheld);

            case ControllerId.ControllerUnknown:  return(NpadIdType.Unknown);

            default: throw new ArgumentOutOfRangeException(nameof(index));
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the Device class.
 /// </summary>
 /// <param name="friendlyName">The friendly name of the device.</param>
 /// <param name="activationTime">The UTC time at which the device was
 /// activated</param>
 /// <param name="culture">The language culture setting on the device.
 /// For eg: "en-US"</param>
 /// <param name="deviceDescription">The device description.</param>
 /// <param name="deviceSoftwareVersion">The version number of the
 /// software running on the device.</param>
 /// <param name="deviceConfigurationStatus">The current configuration
 /// status of the device. Possible values include: 'Complete',
 /// 'Pending'</param>
 /// <param name="targetIqn">The target IQN.</param>
 /// <param name="modelDescription">The device model.</param>
 /// <param name="status">The current status of the device. Possible
 /// values include: 'Unknown', 'Online', 'Offline', 'Deactivated',
 /// 'RequiresAttention', 'MaintenanceMode', 'Creating', 'Provisioning',
 /// 'Deactivating', 'Deleted', 'ReadyToSetup'</param>
 /// <param name="serialNumber">The serial number.</param>
 /// <param name="deviceType">The type of the device. Possible values
 /// include: 'Invalid', 'Series8000VirtualAppliance',
 /// 'Series8000PhysicalAppliance'</param>
 /// <param name="activeController">The identifier of the active
 /// controller of the device. Possible values include: 'Unknown',
 /// 'None', 'Controller0', 'Controller1'</param>
 /// <param name="friendlySoftwareVersion">The device friendly software
 /// version.</param>
 /// <param name="id">The path ID that uniquely identifies the
 /// object.</param>
 /// <param name="name">The name of the object.</param>
 /// <param name="type">The hierarchical type of the object.</param>
 /// <param name="kind">The Kind of the object. Currently only
 /// Series8000 is supported. Possible values include:
 /// 'Series8000'</param>
 /// <param name="friendlySoftwareName">The friendly name of the
 /// software running on the device.</param>
 /// <param name="availableLocalStorageInBytes">The storage in bytes
 /// that is available locally on the device.</param>
 /// <param name="availableTieredStorageInBytes">The storage in bytes
 /// that is available on the device for tiered volumes.</param>
 /// <param name="provisionedTieredStorageInBytes">The storage in bytes
 /// that has been provisioned on the device for tiered volumes.</param>
 /// <param name="provisionedLocalStorageInBytes">The storage in bytes
 /// used for locally pinned volumes on the device (including additional
 /// local reservation).</param>
 /// <param name="provisionedVolumeSizeInBytes">Total capacity in bytes
 /// of tiered and locally pinned volumes on the device</param>
 /// <param name="usingStorageInBytes">The storage in bytes that is
 /// currently being used on the device, including both local and
 /// cloud.</param>
 /// <param name="totalTieredStorageInBytes">The total tiered storage
 /// available on the device in bytes.</param>
 /// <param name="agentGroupVersion">The device agent group
 /// version.</param>
 /// <param name="networkInterfaceCardCount">The number of network
 /// interface cards</param>
 /// <param name="deviceLocation">The location of the virtual
 /// appliance.</param>
 /// <param name="virtualMachineApiType">The virtual machine API type.
 /// Possible values include: 'Classic', 'Arm'</param>
 /// <param name="details">The additional device details regarding the
 /// end point count and volume container count.</param>
 /// <param name="rolloverDetails">The additional device details for the
 /// service data encryption key rollover.</param>
 public Device(string friendlyName, System.DateTime activationTime, string culture, string deviceDescription, string deviceSoftwareVersion, DeviceConfigurationStatus deviceConfigurationStatus, string targetIqn, string modelDescription, DeviceStatus status, string serialNumber, DeviceType deviceType, ControllerId activeController, string friendlySoftwareVersion, string id = default(string), string name = default(string), string type = default(string), Kind?kind = default(Kind?), string friendlySoftwareName = default(string), long?availableLocalStorageInBytes = default(long?), long?availableTieredStorageInBytes = default(long?), long?provisionedTieredStorageInBytes = default(long?), long?provisionedLocalStorageInBytes = default(long?), long?provisionedVolumeSizeInBytes = default(long?), long?usingStorageInBytes = default(long?), long?totalTieredStorageInBytes = default(long?), int?agentGroupVersion = default(int?), int?networkInterfaceCardCount = default(int?), string deviceLocation = default(string), VirtualMachineApiType?virtualMachineApiType = default(VirtualMachineApiType?), DeviceDetails details = default(DeviceDetails), DeviceRolloverDetails rolloverDetails = default(DeviceRolloverDetails))
     : base(id, name, type, kind)
 {
     FriendlyName              = friendlyName;
     ActivationTime            = activationTime;
     Culture                   = culture;
     DeviceDescription         = deviceDescription;
     DeviceSoftwareVersion     = deviceSoftwareVersion;
     FriendlySoftwareName      = friendlySoftwareName;
     DeviceConfigurationStatus = deviceConfigurationStatus;
     TargetIqn                 = targetIqn;
     ModelDescription          = modelDescription;
     Status                          = status;
     SerialNumber                    = serialNumber;
     DeviceType                      = deviceType;
     ActiveController                = activeController;
     FriendlySoftwareVersion         = friendlySoftwareVersion;
     AvailableLocalStorageInBytes    = availableLocalStorageInBytes;
     AvailableTieredStorageInBytes   = availableTieredStorageInBytes;
     ProvisionedTieredStorageInBytes = provisionedTieredStorageInBytes;
     ProvisionedLocalStorageInBytes  = provisionedLocalStorageInBytes;
     ProvisionedVolumeSizeInBytes    = provisionedVolumeSizeInBytes;
     UsingStorageInBytes             = usingStorageInBytes;
     TotalTieredStorageInBytes       = totalTieredStorageInBytes;
     AgentGroupVersion               = agentGroupVersion;
     NetworkInterfaceCardCount       = networkInterfaceCardCount;
     DeviceLocation                  = deviceLocation;
     VirtualMachineApiType           = virtualMachineApiType;
     Details                         = details;
     RolloverDetails                 = rolloverDetails;
 }
Exemplo n.º 5
0
 public KeyboardControlInfo(ControllerId controllerId, ControlInfo controlInfo, int keyCode)
 {
     Guard.NotNull(controllerId, nameof(controllerId));
     ControlInfo = Guard.NotNull(controlInfo, nameof(controlInfo));
     ControlId   = new ControlId(controllerId, controlInfo.Name);
     KeyCode     = keyCode;
 }
Exemplo n.º 6
0
        public void SetPort(PlatformId platform, int portNumber, ControllerId controller,
                            Guid deviceInstanceGuid, InputDriver instanceDriver, Guid inputProfile, string emulatorName)
        {
            using var context = new DatabaseContext(Options.Options);
            var entity = context.PortDeviceEntries
                         .Find(emulatorName, platform, portNumber);

            if (entity != null)
            {
                entity.ProfileGuid          = inputProfile;
                entity.InstanceGuid         = deviceInstanceGuid;
                entity.ControllerID         = controller;
                entity.Driver               = instanceDriver;
                context.Entry(entity).State = EntityState.Modified;
            }
            else
            {
                var newEntity = new PortDeviceEntryModel()
                {
                    ProfileGuid      = inputProfile,
                    InstanceGuid     = deviceInstanceGuid,
                    ControllerID     = controller,
                    Driver           = instanceDriver,
                    OrchestratorName = emulatorName,
                    PlatformID       = platform,
                    PortIndex        = portNumber
                };
                context.PortDeviceEntries.Add(newEntity);
            }
            context.SaveChanges();
        }
Exemplo n.º 7
0
 public Controller(ControllerType controllerType, ControllerId id, Maybe <UnityInputDeviceProfile> deviceProfile, string name)
 {
     ControllerType = controllerType;
     Id             = id;
     DeviceProfile  = deviceProfile;
     Name           = name;
 }
Exemplo n.º 8
0
        public XInputControlSet(ControllerId controllerId)
        {
            _controllerId = Guard.NotNull(controllerId, nameof(controllerId));

            ButtonControls = new[]
            {
                Button("up", XInputApi.XINPUT_GAMEPAD_DPAD_UP),
                Button("down", XInputApi.XINPUT_GAMEPAD_DPAD_DOWN),
                Button("left", XInputApi.XINPUT_GAMEPAD_DPAD_LEFT),
                Button("right", XInputApi.XINPUT_GAMEPAD_DPAD_RIGHT),
                Button("start", XInputApi.XINPUT_GAMEPAD_START),
                Button("back", XInputApi.XINPUT_GAMEPAD_BACK),
                Button("leftThumb", XInputApi.XINPUT_GAMEPAD_LEFT_THUMB),
                Button("rightThumb", XInputApi.XINPUT_GAMEPAD_RIGHT_THUMB),
                Button("leftShoulder", XInputApi.XINPUT_GAMEPAD_LEFT_SHOULDER),
                Button("rightShoulder", XInputApi.XINPUT_GAMEPAD_RIGHT_SHOULDER),
                Button("a", XInputApi.XINPUT_GAMEPAD_A),
                Button("b", XInputApi.XINPUT_GAMEPAD_B),
                Button("x", XInputApi.XINPUT_GAMEPAD_X),
                Button("y", XInputApi.XINPUT_GAMEPAD_Y)
            };

            LeftTriggerControl  = Trigger("leftTrigger");
            RightTriggerControl = Trigger("rightTrigger");
            LeftThumbXControl   = Thumb("leftThumbX");
            LeftThumbYControl   = Thumb("leftThumbY");
            RightThumbXControl  = Thumb("rightThumbX");
            RightThumbYControl  = Thumb("rightThumbY");
        }
 /// <summary>
 /// Initializes a new instance of the ControllerPowerStateChangeRequest
 /// class.
 /// </summary>
 /// <param name="action">The power state that the request is expecting
 /// for the controller of the device. Possible values include: 'Start',
 /// 'Restart', 'Shutdown'</param>
 /// <param name="activeController">The active controller that the
 /// request is expecting on the device. Possible values include:
 /// 'Unknown', 'None', 'Controller0', 'Controller1'</param>
 /// <param name="controller0State">The controller 0's status that the
 /// request is expecting on the device. Possible values include:
 /// 'NotPresent', 'PoweredOff', 'Ok', 'Recovering', 'Warning',
 /// 'Failure'</param>
 /// <param name="controller1State">The controller 1's status that the
 /// request is expecting on the device. Possible values include:
 /// 'NotPresent', 'PoweredOff', 'Ok', 'Recovering', 'Warning',
 /// 'Failure'</param>
 /// <param name="id">The path ID that uniquely identifies the
 /// object.</param>
 /// <param name="name">The name of the object.</param>
 /// <param name="type">The hierarchical type of the object.</param>
 /// <param name="kind">The Kind of the object. Currently only
 /// Series8000 is supported. Possible values include:
 /// 'Series8000'</param>
 public ControllerPowerStateChangeRequest(ControllerPowerStateAction action, ControllerId activeController, ControllerStatus controller0State, ControllerStatus controller1State, string id = default(string), string name = default(string), string type = default(string), Kind?kind = default(Kind?))
     : base(id, name, type, kind)
 {
     Action           = action;
     ActiveController = activeController;
     Controller0State = controller0State;
     Controller1State = controller1State;
 }
        public IControllerElementMappings?GetMappings(ControllerId controllerId, string deviceId, string profileName)
        {
            using var context = new DatabaseContext(this.Options.Options);
            var mappings = context.ControllerElementMappings
                           .Include(p => p.MappedElements)
                           .SingleOrDefault(p => p.ControllerID == controllerId &&
                                            p.DeviceID == deviceId && p.ProfileName == profileName);

            return(mappings?.AsControllerElementMappings());
        }
 public ControllerElementMappingProfile(string deviceName,
                                        ControllerId controllerId, InputDriver driver, int vendor, Guid profileGuid)
 {
     this.DeviceName         = deviceName;
     this.ControllerID       = controllerId;
     this.DriverType         = driver;
     this.VendorID           = vendor;
     this.controllerElements = new Dictionary <ControllerElement, ControllerElementMapping>();
     this.ProfileGuid        = profileGuid;
 }
 /// <summary>
 /// Initializes a <see cref="ControllerElementMappingProfile"/> from an <see cref="IDeviceLayoutMapping"/>,
 /// that includes all mappings from the default layout.
 /// </summary>
 /// <param name="deviceName">The name of the physical device for this set of mappings.</param>
 /// <param name="controllerId">The Stone <see cref="ControllerID"/> this mapping is intended for.</param>
 /// <param name="driver">The <see cref="InputDriver"/> of the device instance for this set of mappings.</param>
 /// <param name="vendor">The vendor ID of the physical device for this set of mappings.</param>
 /// <param name="mapping">The device layout mapping provided by the device enumerator.</param>
 /// <param name="profileGuid">The <see cref="Guid"/> of this mapping profile.</param>
 public ControllerElementMappingProfile(string deviceName,
                                        ControllerId controllerId, InputDriver driver, int vendor,
                                        IDeviceLayoutMapping mapping, Guid profileGuid)
     : this(deviceName, controllerId, driver, vendor, profileGuid)
 {
     foreach (var controllerElement in mapping)
     {
         this.Add(controllerElement);
     }
 }
Exemplo n.º 13
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked {
         var hashCode = Brokers?.GetHashCode() ?? 0;
         hashCode = (hashCode * 397) ^ (ControllerId?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ClusterId?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Topics?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
Exemplo n.º 14
0
	public void SetControllerLEDColor (ControllerId controllerId, Color color, float resetColorAfterTime = -1)
	{
		if(Application.platform != RuntimePlatform.OSXEditor) return;

		GetControllerById(controllerId).SetLED(color);
		GetControllerById(controllerId).Controller.SetLED(color);

		if(resetColorAfterTime != -1){
			StartCoroutine(ResetColorAfterShortTime(controllerId));
		}
	}
Exemplo n.º 15
0
	public void SetControllerRumble (ControllerId controllerId, float rumbleIntensity, float rumbleDuration = 0.7f)
	{
		if(Application.platform != RuntimePlatform.OSXEditor) return;
		
		if(rumbleDuration != -1)
		{
			GetControllerById(controllerId).Controller.LongerRumble(rumbleIntensity, rumbleDuration);
		} 
		else{
			GetControllerById(controllerId).Controller.SetRumble(rumbleIntensity);
		}
	}
        public IEnumerable <IControllerElementMappings> GetMappings(ControllerId controllerId, string deviceId)
        {
            using var context = new DatabaseContext(this.Options.Options);
            var mappings = context.ControllerElementMappings
                           .Include(p => p.MappedElements)
                           .Where(p => p.ControllerID == controllerId &&
                                  p.DeviceID == deviceId)
                           .Select(m => m.AsControllerElementMappings())
                           .ToList();

            return(mappings);
        }
Exemplo n.º 17
0
        public IEnumerable <(string profileName, Guid profileGuid)> GetProfileNames(ControllerId controllerId, InputDriver driverType, string deviceName, int vendorId)
        {
            using var context = new DatabaseContext(this.Options.Options);
            var retrievedMappings = context.ControllerElementMappings
                                    .Where(p => p.ControllerID == controllerId &&
                                           p.DriverType == driverType &&
                                           p.DeviceName == deviceName &&
                                           p.VendorID == vendorId)
                                    .ToList()
                                    .Select(p => (p.ProfileName, p.ProfileID));

            return(retrievedMappings);
        }
Exemplo n.º 18
0
 private static MappedControllerElementModel AsModel(this IMappedControllerElement @this,
                                                     ControllerId controllerId,
                                                     string deviceId,
                                                     string profileName)
 {
     return(new MappedControllerElementModel
     {
         LayoutElement = @this.LayoutElement,
         DeviceElement = @this.DeviceElement,
         ProfileName = profileName,
         ControllerID = controllerId,
         DeviceID = deviceId
     });
 }
Exemplo n.º 19
0
        public void DeleteMappings(ControllerId controllerId, string deviceName, int vendorId)
        {
            using var context = new DatabaseContext(this.Options.Options);
            var retrievedMappings = context.ControllerElementMappings
                                    .Where(p => p.ControllerID == controllerId &&
                                           p.DeviceName == deviceName &&
                                           p.VendorID == vendorId);

            foreach (var retrievedMapping in retrievedMappings)
            {
                context.Entry(retrievedMapping).State = EntityState.Deleted;
            }

            context.SaveChanges();
        }
        public void DeleteMappings(ControllerId controllerId, string deviceId, string profileName)
        {
            using var context = new DatabaseContext(this.Options.Options);
            var retrievedMappings = context.ControllerElementMappings
                                    .Include(p => p.MappedElements)
                                    .SingleOrDefault(p => p.ControllerID == controllerId &&
                                                     p.DeviceID == deviceId && p.ProfileName == profileName);

            if (retrievedMappings != null)
            {
                context.Entry(retrievedMappings).State = EntityState.Deleted;
            }

            context.SaveChanges();
        }
        /// <summary>
        /// Changes the power state of the controller.
        /// </summary>
        private void ChangeControllerPowerState(string deviceName, string hardwareComponentGroupName,
                                                ControllerId activeController, ControllerPowerStateAction controllerAction)
        {
            ControllerPowerStateChangeRequest powerChangeRequest = new ControllerPowerStateChangeRequest();

            powerChangeRequest.ActiveController = activeController;
            powerChangeRequest.Controller0State = ControllerStatus.Ok;
            powerChangeRequest.Controller1State = ControllerStatus.NotPresent;
            powerChangeRequest.Action           = controllerAction;

            this.Client.HardwareComponentGroups.ChangeControllerPowerState(
                deviceName,
                hardwareComponentGroupName,
                powerChangeRequest,
                this.ResourceGroupName,
                this.ManagerName);
        }
Exemplo n.º 22
0
        internal static string ToSerializedValue(this ControllerId value)
        {
            switch (value)
            {
            case ControllerId.Unknown:
                return("Unknown");

            case ControllerId.None:
                return("None");

            case ControllerId.Controller0:
                return("Controller0");

            case ControllerId.Controller1:
                return("Controller1");
            }
            return(null);
        }
Exemplo n.º 23
0
        public void InitializePrimaryController(ControllerStatus controllerType)
        {
            ControllerId controllerId = controllerType == ControllerStatus.Handheld ?
                                        ControllerId.ControllerHandheld : ControllerId.ControllerPlayer1;

            if (controllerType == ControllerStatus.ProController)
            {
                PrimaryController = new ProController(_device, NpadColor.Black, NpadColor.Black);
            }
            else
            {
                PrimaryController = new NpadController(controllerType,
                                                       _device,
                                                       (NpadColor.BodyNeonRed, NpadColor.BodyNeonRed),
                                                       (NpadColor.ButtonsNeonBlue, NpadColor.ButtonsNeonBlue));
            }

            PrimaryController.Connect(controllerId);
        }
Exemplo n.º 24
0
        // GetNpadIrCameraHandle(u32) -> nn::irsensor::IrCameraHandle
        public ResultCode GetNpadIrCameraHandle(ServiceCtx context)
        {
            NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32();

            if (npadIdType > NpadIdType.Player8 &&
                npadIdType != NpadIdType.Unknown &&
                npadIdType != NpadIdType.Handheld)
            {
                return(ResultCode.NpadIdOutOfRange);
            }

            ControllerId irCameraHandle = HidUtils.GetIndexFromNpadIdType(npadIdType);

            context.ResponseData.Write((int)irCameraHandle);

            // NOTE: If the irCameraHandle pointer is null this error is returned, Doesn't occur in our case.
            //       return ResultCode.HandlePointerIsNull;

            return(ResultCode.Success);
        }
Exemplo n.º 25
0
        public Ps3ControlSet(ControllerId controllerId)
        {
            _controllerId = Guard.NotNull(controllerId, nameof(controllerId));

            _controls = new[]
            {
                Analog("leftStickX", 1),
                Analog("leftStickY", 2),
                Analog("rightStickX", 3),
                Analog("rightStickY", 4),
                DPad("up", dPadValue: 0),
                DPad("right", dPadValue: 2),
                DPad("down", dPadValue: 4),
                DPad("left", dPadValue: 6),
                DigitalButton("triangle", 5, bit: 4),
                DigitalButton("circle", 5, bit: 5),
                DigitalButton("cross", 5, bit: 6),
                DigitalButton("square", 5, bit: 7),
                DigitalButton("select", 6, bit: 0),
                DigitalButton("leftStickButton", 6, bit: 1),
                DigitalButton("rightStickButton", 6, bit: 2),
                DigitalButton("start", 6, bit: 3),
                DigitalButton("l2", 6, bit: 4),
                DigitalButton("r2", 6, bit: 5),
                DigitalButton("l1", 6, bit: 6),
                DigitalButton("r1", 6, bit: 7),
                PsButton("ps", 7),
                AnalogButton("l2Analog", 8),
                AnalogButton("r2Analog", 9),
                AnalogButton("upAnalog", 10),
                AnalogButton("rightAnalog", 11),
                AnalogButton("downAnalog", 12),
                AnalogButton("leftAnalog", 13),
                AnalogButton("l1Analog", 14),
                AnalogButton("r1Analog", 15),
                AnalogButton("triangleAnalog", 16),
                AnalogButton("circleAnalog", 17),
                AnalogButton("crossAnalog", 18),
                AnalogButton("squareAnalog", 19)
            };
        }
Exemplo n.º 26
0
        public override void Connect(ControllerId controllerId)
        {
            ControllerColorDescription singleColorDesc =
                ControllerColorDescription.ColorDescriptionColorsNonexistent;

            ControllerColorDescription splitColorDesc = 0;

            ConnectionState = ControllerConnectionState.ControllerStateConnected | ControllerConnectionState.ControllerStateWired;

            Initialize(false,
                       (0, 0),
                       (0, 0),
                       singleColorDesc,
                       splitColorDesc,
                       _bodyColor,
                       _buttonColor);

            base.Connect(controllerId);

            SetLayout(ControllerLayouts.ProController);
        }
Exemplo n.º 27
0
        public void SetController(INESInput input, ControllerId controllerId)
        {
            ControllerChangedArgs args;

            switch (controllerId)
            {
            case ControllerId.Controller1:
                this.Controller1 = input;
                break;

            case ControllerId.Controller2:
                this.Controller2 = input;
                break;
            }

            args = input == null
                ? new ControllerChangedArgs(null, wasInserted: false, controllerId: controllerId)
                : new ControllerChangedArgs(input, wasInserted: true, controllerId: controllerId);

            this.ControllerChanged?.Invoke(this, args);
        }
Exemplo n.º 28
0
        public VJoyControlSet(ControllerId controllerId)
        {
            _controllerId = Guard.NotNull(controllerId, nameof(controllerId));

            _controls = new List <VJoyControl>
            {
                Axis("axisX", s => s.AxisX),
                Axis("axisY", s => s.AxisY),
                Axis("axisZ", s => s.AxisZ),
                Axis("axisRX", s => s.AxisXRot),
                Axis("axisRY", s => s.AxisYRot),
                Axis("axisRZ", s => s.AxisZRot),
                Axis("slider", s => s.Slider),
                Axis("dial", s => s.Dial)
            };

            _controls.AddRange(Enumerable.Range(0, 32).Select(i => Button($"button{i + 1}", s => s.Buttons, i)));

            _controlDictionary = new Dictionary <string, VJoyControl>();
            foreach (var control in _controls)
            {
                _controlDictionary.Add(control.ControlId.Name, control);
            }
        }
Exemplo n.º 29
0
        public static InputMap <InputSource, ButtonState> CreateCandidateInputMap(
            ControllerId controllerId   = null,
            float joystickAxisThreshold = 0.7f,
            float mouseAxisThreshold    = 30f)
        {
            var inputMap = ImperoCore.MergeAll(
                Adapters.MergeButtons,
                Peripherals.Keyboard,
                Peripherals.Mouse.Buttons,
                Peripherals.Mouse.PolarizedAxes
                .Adapt(Adapters.Axis2Button(mouseAxisThreshold)));

            if (controllerId != null)
            {
                var peripheral = Peripherals.Controller.GetPeripheral(controllerId, InputSettings.Default);
                inputMap = ImperoCore.MergeAll(
                    Adapters.MergeButtons,
                    inputMap,
                    peripheral.Buttons,
                    peripheral.Axes.Adapt(Adapters.Axis2Button(joystickAxisThreshold)));
            }

            return(inputMap);
        }
Exemplo n.º 30
0
 public ControllerChangedArgs(INESInput controller, bool wasInserted, ControllerId controllerId)
 {
     this.Controller   = controller;
     this.WasInserted  = wasInserted;
     this.ControllerId = controllerId;
 }
Exemplo n.º 31
0
 public void SetPort(IEmulatorOrchestrator orchestrator, PlatformId platform, int portNumber,
                     ControllerId controller, Guid deviceInstanceGuid, InputDriver instanceDriver, Guid inputProfile)
 => this.SetPort(platform, portNumber, controller, deviceInstanceGuid, instanceDriver, inputProfile, orchestrator.Name);
Exemplo n.º 32
0
	private MoveController GetControllerById(ControllerId id){
		return this.Controllers.Find(x => x.Controller.ControllerId == id);
	}
 /// <summary>
 /// Initializes a <see cref="ControllerElementMappingProfile"/> from an <see cref="IDeviceLayoutMapping"/>,
 /// that includes all mappings from the default layout.
 /// </summary>
 /// <param name="deviceName">The name of the physical device for this set of mappings.</param>
 /// <param name="controllerId">The Stone <see cref="ControllerID"/> this mapping is intended for.</param>
 /// <param name="driver">The <see cref="InputDriver"/> of the device instance for this set of mappings.</param>
 /// <param name="vendor">The vendor ID of the physical device for this set of mappings.</param>
 /// <param name="mapping">The device layout mapping provided by the device enumerator.</param>
 /// <param name="profileGuid">The <see cref="Guid"/> of this mapping profile.</param>
 public ControllerElementMappingProfile(string deviceName,
                                        ControllerId controllerId, InputDriver driver, int vendor,
                                        IDeviceLayoutMapping mapping)
     : this(deviceName, controllerId, driver, vendor, mapping, Guid.NewGuid())
 {
 }
Exemplo n.º 34
0
	private void OnControllerGestureHandler(ControllerId id, EventType gesture){
		if(OnGesture != null){
			OnGesture(new PSMoveEvent() { EventType = gesture, ControllerId = id, Controller = GetControllerById(id)});
		}
	}
Exemplo n.º 35
0
	private IEnumerator ResetColorAfterShortTime(ControllerId id){
		yield return new WaitForSeconds(0.7f);
		GetControllerById(id).SetLED(Color.white);
		GetControllerById(id).Controller.SetLED(Color.white);
	}
Exemplo n.º 36
0
	public void StopControllerRumble(ControllerId controllerId){
		if(Application.platform != RuntimePlatform.OSXEditor) return;
		
		GetControllerById(controllerId).Controller.StopConstantRumbleIfActive();
	}