예제 #1
0
 protected InputEnumerator(IPluginProvision p)
     : base(p)
 {
     this.ControllerLayout =
         JsonConvert.DeserializeObject <ControllerLayout>(File.ReadAllText(p.ResourceDirectory.GetFiles()
                                                                           .First(f => f.Name == "layout.json").FullName));
 }
 /// <summary>
 /// Gets default mappings for a real device to a virtual device
 /// </summary>
 /// <param name="realDevice">The button layout of the real controller device</param>
 /// <param name="virtualDevice">The button layout of the defined controller device</param>
 /// <returns></returns>
 public static IControllerElementMappings GetDefaultMappings(IControllerLayout realDevice,
                                                             IControllerLayout virtualDevice)
 {
     return(realDevice.Layout.Keyboard == null
         ? ControllerElementMappings.GetDefaultDeviceMappings(realDevice, virtualDevice)
         : ControllerElementMappings.GetDefaultKeyboardMappings(realDevice, virtualDevice));
 }
예제 #3
0
 public InputDevice(InputApi deviceApi, ILowLevelInputDevice deviceInfo, IControllerLayout deviceLayout)
 {
     this.DeviceId       = deviceLayout.LayoutId;
     this.ControllerName = deviceLayout.FriendlyName;
     this.DeviceApi      = deviceApi;
     this.DeviceInfo     = deviceInfo;
     this.DeviceLayout   = deviceLayout;
 }
예제 #4
0
        protected InputEnumerator(IPluginProvision p)
            : base(p)
        {
            var file = p.ResourceDirectory.OpenFile("layout.json");

            this.ControllerLayout =
                JsonConvert.DeserializeObject <ControllerLayout>(file.ReadAllText());
        }
예제 #5
0
 public EmulatedController(int portIndex,
                           IInputDevice physicalDevice,
                           IControllerLayout targetLayout,
                           IControllerElementMappings layoutMapping)
 {
     this.PortIndex      = portIndex;
     this.PhysicalDevice = physicalDevice;
     this.TargetLayout   = targetLayout;
     this.LayoutMapping  = layoutMapping;
 }
 /// <summary>
 /// Initializes a<see cref= "ControllerElementMappingProfile" /> from an <see cref="IDeviceLayoutMapping"/>,
 /// that includes only mappings that are assignable to the provided layout.
 /// </summary>
 /// <param name="deviceName">The name of the physical device for this set of mappings.</param>
 /// <param name="controller">The controller layout to assign device mappings to.</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,
                                        IControllerLayout controller, InputDriver driver, int vendor,
                                        IDeviceLayoutMapping mapping, Guid profileGuid)
     : this(deviceName, controller.ControllerID, driver, vendor, profileGuid)
 {
     foreach (var(controllerElement, _) in controller.Layout)
     {
         if (mapping[controllerElement] == DeviceCapability.None)
         {
             continue;
         }
         this.Add(new ControllerElementMapping(controllerElement, mapping[controllerElement]));
     }
 }
        private static IControllerElementMappings GetDefaultDeviceMappings(IControllerLayout realDevice,
                                                                           IControllerLayout virtualDevice)
        {
            var mappedElements = from element in virtualDevice.Layout
                                 select new MappedControllerElement(element.Key,
                                                                    realDevice.Layout[element.Key] != null ? element.Key : ControllerElement.NoElement);

            var elementCollection = new ControllerElementMappings(realDevice.LayoutId, virtualDevice.LayoutId);

            foreach (var element in mappedElements)
            {
                elementCollection.Add(element);
            }

            return(elementCollection);
        }
        private static IControllerElementMappings GetDefaultKeyboardMappings(IControllerLayout realKeyboard,
                                                                             IControllerLayout virtualDevice)
        {
            var mappedElements = from element in virtualDevice.Layout
                                 select new MappedControllerElement(element.Key,
                                                                    ControllerElementMappings.DefaultKeyboardMappings.ContainsKey(element.Key)
                        ? ControllerElementMappings.DefaultKeyboardMappings[element.Key]
                        : ControllerElement.KeyNone);
            var elementCollection = new ControllerElementMappings(realKeyboard.LayoutId, virtualDevice.LayoutId);

            foreach (var element in mappedElements)
            {
                elementCollection.Add(element);
            }

            return(elementCollection);
        }
 /// <summary>
 /// Initializes a<see cref= "ControllerElementMappingProfile" /> from an <see cref="IDeviceLayoutMapping"/>,
 /// that includes only mappings that are assignable to the provided layout.
 /// </summary>
 /// <param name="deviceName">The name of the physical device for this set of mappings.</param>
 /// <param name="controller">The controller layout to assign device mappings to.</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>
 public ControllerElementMappingProfile(string deviceName,
                                        IControllerLayout controller, InputDriver driver, int vendor,
                                        IDeviceLayoutMapping mapping)
     : this(deviceName, controller, driver, vendor, mapping, Guid.NewGuid())
 {
 }