private void AddNewMappingItem_Click(object sender, RoutedEventArgs e)
        {
            var newMappingItem = new GamepadMappingItem
            {
                Type = GamepadMappingItemType.Empty,
                ConvertAxis = false,
                InvertAxis = false
            };

            var newListViewItem = new ListViewItem
            {
                Content = newMappingItem,
                ContentTemplate = DataTemplateForMappingType(newMappingItem.Type)
            };

            ListViewMappingItems.Add(newListViewItem);
            MappingItemsListView.AlternationCount = ListViewMappingItems.Count + 1;
        }
示例#2
0
        private void UpdateAxis(double itemValue, GamepadMappingItem configForCurrentItem)
        {
            var value = NormalizeAxis(itemValue, configForCurrentItem.ConvertAxis ?? false);

            if (configForCurrentItem.InvertAxis ?? false)
            {
                value = InvertNormalizedAxis(value);
            }

            var axisSetStatus = NtStatus.Success;
            switch (configForCurrentItem.AxisType)
            {
                case AxisType.Rx:
                    axisSetStatus = _vGenWrapper.vbox_SetAxisRx(_config.GamepadId, (short) (value*short.MaxValue));
                    break;
                case AxisType.Ry:
                    axisSetStatus = _vGenWrapper.vbox_SetAxisRy(_config.GamepadId, (short) (value*short.MaxValue));
                    break;
                case AxisType.Lx:
                    axisSetStatus = _vGenWrapper.vbox_SetAxisLx(_config.GamepadId, (short) (value*short.MaxValue));
                    break;
                case AxisType.Ly:
                    axisSetStatus = _vGenWrapper.vbox_SetAxisLy(_config.GamepadId, (short) (value*short.MaxValue));
                    break;
                case AxisType.LTrigger:
                    axisSetStatus = _vGenWrapper.vbox_SetTriggerL(_config.GamepadId, (byte) (value*byte.MaxValue));
                    break;
                case AxisType.RTrigger:
                    axisSetStatus = _vGenWrapper.vbox_SetTriggerR(_config.GamepadId, (byte) (value*byte.MaxValue));
                    break;
            }

            if (axisSetStatus != NtStatus.Success)
            {
                Log($"Failed to set axis {configForCurrentItem.AxisType} (${axisSetStatus}). Gamepad {_config.GamepadId}");
            }
        }