public async Task DeleteControllerEventAsync(ControllerEvent controllerEvent)
 {
     using (await _lock.LockAsync())
     {
         await _databaseConnection.DeleteAsync(controllerEvent, true);
     }
 }
Пример #2
0
        public async Task <ControllerAction> AddOrUpdateControllerActionAsync(ControllerEvent controllerEvent, string deviceId, int channel, bool isInvert, ControllerButtonType buttonType, ControllerAxisCharacteristic axisCharacteristic, int maxOutputPercent, int axisDeadZonePercent)
        {
            using (await _asyncLock.LockAsync())
            {
                var controllerAction = controllerEvent.ControllerActions.FirstOrDefault(ca => ca.DeviceId == deviceId && ca.Channel == channel);
                if (controllerAction != null)
                {
                    controllerAction.IsInvert            = isInvert;
                    controllerAction.ButtonType          = buttonType;
                    controllerAction.AxisCharacteristic  = axisCharacteristic;
                    controllerAction.MaxOutputPercent    = maxOutputPercent;
                    controllerAction.AxisDeadZonePercent = axisDeadZonePercent;
                    await _creationRepository.UpdateControllerActionAsync(controllerAction);
                }
                else
                {
                    controllerAction = new ControllerAction
                    {
                        DeviceId            = deviceId,
                        Channel             = channel,
                        IsInvert            = isInvert,
                        ButtonType          = buttonType,
                        AxisCharacteristic  = axisCharacteristic,
                        MaxOutputPercent    = maxOutputPercent,
                        AxisDeadZonePercent = axisDeadZonePercent
                    };
                    await _creationRepository.InsertControllerActionAsync(controllerEvent, controllerAction);
                }

                return(controllerAction);
            }
        }
 public async Task UpdateControllerEventAsync(ControllerEvent controllerEvent)
 {
     using (await _lock.LockAsync())
     {
         await _databaseConnection.UpdateAsync(controllerEvent);
     }
 }
Пример #4
0
 public async Task DeleteControllerEventAsync(ControllerEvent controllerEvent)
 {
     using (await _asyncLock.LockAsync())
     {
         var parent = controllerEvent.ControllerProfile;
         await _creationRepository.DeleteControllerEventAsync(controllerEvent);
         parent.ControllerEvents.Remove(controllerEvent);
     }
 }
Пример #5
0
        public async Task<ControllerEvent> AddOrGetControllerEventAsync(ControllerProfile controllerProfile, GameControllerEventType eventType, string eventCode)
        {
            using (await _asyncLock.LockAsync())
            {
                var controllerEvent = controllerProfile.ControllerEvents.FirstOrDefault(ce => ce.EventType == eventType && ce.EventCode == eventCode);
                if (controllerEvent == null)
                {
                    controllerEvent = new ControllerEvent { EventType = eventType, EventCode = eventCode };
                    await _creationRepository.InsertControllerEventAsync(controllerProfile, controllerEvent);
                }

                return controllerEvent;
            }
        }
Пример #6
0
        private async Task InsertControllerEventAsync(ControllerEvent controllerEvent)
        {
            await _databaseConnection.InsertAsync(controllerEvent);

            // insert all available action as well as it's present for an event when it's imported only
            if (controllerEvent.ControllerActions.Any())
            {
                foreach (var controllerAction in controllerEvent.ControllerActions)
                {
                    await _databaseConnection.InsertAsync(controllerAction);
                }
                await _databaseConnection.UpdateWithChildrenAsync(controllerEvent);
            }
        }
        public async Task InsertControllerActionAsync(ControllerEvent controllerEvent, ControllerAction controllerAction)
        {
            using (await _lock.LockAsync())
            {
                await _databaseConnection.InsertAsync(controllerAction);

                if (controllerEvent.ControllerActions == null)
                {
                    controllerEvent.ControllerActions = new ObservableCollection <ControllerAction>();
                }

                controllerEvent.ControllerActions.Add(controllerAction);
                await _databaseConnection.UpdateWithChildrenAsync(controllerEvent);
            }
        }
Пример #8
0
        public async Task<ControllerAction> AddOrUpdateControllerActionAsync(
            ControllerEvent controllerEvent,
            string deviceId,
            int channel,
            bool isInvert,
            ControllerButtonType buttonType,
            ControllerAxisType axisType,
            ControllerAxisCharacteristic axisCharacteristic,
            int maxOutputPercent,
            int axisActiveZonePercent,
            int axisDeadZonePercent,
            ChannelOutputType channelOutputType,
            int maxServoAngle,
            int servoBaseAngle,
            int stepperAngle,
            string sequenceName)
        {
            using (await _asyncLock.LockAsync())
            {
                var controllerAction = controllerEvent.ControllerActions.FirstOrDefault(ca => ca.DeviceId == deviceId && ca.Channel == channel);
                if (controllerAction != null)
                {
                    controllerAction.IsInvert = isInvert;
                    controllerAction.ButtonType = buttonType;
                    controllerAction.AxisType = axisType;
                    controllerAction.AxisCharacteristic = axisCharacteristic;
                    controllerAction.MaxOutputPercent = maxOutputPercent;
                    controllerAction.AxisActiveZonePercent = axisActiveZonePercent;
                    controllerAction.AxisDeadZonePercent = axisDeadZonePercent;
                    controllerAction.ChannelOutputType = channelOutputType;
                    controllerAction.MaxServoAngle = maxServoAngle;
                    controllerAction.ServoBaseAngle = servoBaseAngle;
                    controllerAction.StepperAngle = stepperAngle;
                    controllerAction.SequenceName = sequenceName;
                    await _creationRepository.UpdateControllerActionAsync(controllerAction);
                }
                else
                {
                    controllerAction = new ControllerAction
                    {
                        DeviceId = deviceId,
                        Channel = channel,
                        IsInvert = isInvert,
                        ButtonType = buttonType,
                        AxisType = axisType,
                        AxisCharacteristic = axisCharacteristic,
                        MaxOutputPercent = maxOutputPercent,
                        AxisActiveZonePercent = axisActiveZonePercent,
                        AxisDeadZonePercent = axisDeadZonePercent,
                        ChannelOutputType = channelOutputType,
                        MaxServoAngle = maxServoAngle,
                        ServoBaseAngle = servoBaseAngle,
                        StepperAngle = stepperAngle,
                        SequenceName = sequenceName
                    };
                    await _creationRepository.InsertControllerActionAsync(controllerEvent, controllerAction);
                }

                return controllerAction;
            }
        }
Пример #9
0
        public async Task InsertControllerEventAsync(ControllerProfile controllerProfile, ControllerEvent controllerEvent)
        {
            using (await _lock.LockAsync())
            {
                await InsertControllerEventAsync(controllerEvent);

                if (controllerProfile.ControllerEvents == null)
                {
                    controllerProfile.ControllerEvents = new ObservableCollection <ControllerEvent>();
                }

                controllerProfile.ControllerEvents.Add(controllerEvent);
                await _databaseConnection.UpdateWithChildrenAsync(controllerProfile);
            }
        }