/// <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)); }
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); }