示例#1
0
 private void storeButtonMap(ApplicationDataContainer container, HIDButtonMap buttonMap)
 {
     container.Values.Clear();
     foreach (var entry in buttonMap)
     {
         container.Values[((int)entry.Key).ToString()] = entry.Value.ToCompositeValue();
     }
 }
示例#2
0
 private void restoreButtonMap(ApplicationDataContainer container, HIDButtonMap buttonMap)
 {
     foreach (var entry in container.Values)
     {
         ApplicationDataCompositeValue value = entry.Value as ApplicationDataCompositeValue;
         HIDMapping mapping = HIDMappingExtensions.FromCompositeValue(value);
         buttonMap[(Button)(int.Parse(entry.Key.ToString()))] = mapping;
     }
 }
示例#3
0
 private void ProcessInputForMap(HidInputReport report, HIDButtonMap buttonMap, ref ButtonStates newState)
 {
     foreach (var mappingItem in buttonMap)
     {
         HIDMapping mapping = mappingItem.Value;
         if (mapping.IsNumeric)
         {
             HidNumericControl control = report.GetNumericControl(mapping.UsagePage, mapping.UsageId);
             ushort            value   = (ushort)control.Value;
             if (!this.CheckDeadzone(control.ControlDescription, control))
             {
                 continue;
             }
             if (mapping.UsagePage == 0x01 && mapping.UsageId == 0x39)
             {
                 // dpad
                 if ((mapping.Direction == DPadDirection.Down && value >= 3 && value <= 5) ||
                     (mapping.Direction == DPadDirection.Left && value >= 5 && value <= 7) ||
                     (mapping.Direction == DPadDirection.Up && (value == 7 || value == 0 || value == 1)) ||
                     (mapping.Direction == DPadDirection.Right && value >= 1 && value <= 3)
                     )
                 {
                     this.setButtonState(mappingItem.Key, ref newState);
                 }
             }
             else
             {
                 // axis
                 ushort center = NumericCenters[mapping.UsagePage];
                 if ((value < center && mapping.Sign < 0) ||
                     (value > center && mapping.Sign > 0))
                 {
                     this.setButtonState(mappingItem.Key, ref newState);
                 }
             }
         }
         else
         {
             HidBooleanControl control = report.GetBooleanControl(mapping.UsagePage, mapping.UsageId);
             if (control.IsActive)
             {
                 this.setButtonState(mappingItem.Key, ref newState);
             }
         }
     }
 }
示例#4
0
        public HIDInputChannel(DeviceInformation deviceInfo, HidDevice device)
        {
            this.currentDevice      = device;
            this.deviceInfo         = deviceInfo;
            this.state              = new ControllerState();
            this.resources          = new ResourceLoader();
            this.mapping            = new HIDButtonMap();
            this.mappingAlternative = new HIDButtonMap();
            this.axisString         = this.resources.GetString("hidAxisDescription");
            this.hidDPadUp          = this.resources.GetString("hidDpadUp");
            this.hidDPadLeft        = this.resources.GetString("hidDpadLeft");
            this.hidDPadRight       = this.resources.GetString("hidDpadRight");
            this.hidDPadDown        = this.resources.GetString("hidDpadDown");

            this.getNumericControlDescs();

            this.RestoreLayout();

            this.currentDevice.InputReportReceived += CurrentDevice_InputReportReceived;
        }