[gnome-boxes/set-default-input-bus: 2/2] vm-configurator: Default to PS2 input bus



commit caafb767a36d82ff4bcfabad162ba8342a7cae44
Author: Felipe Borges <felipeborges gnome org>
Date:   Mon Dec 17 15:07:34 2018 +0100

    vm-configurator: Default to PS2 input bus
    
    Whenever the osinfo entry for the guest doesn't list a tablet
    device, we should default to PS2. When a tablet device is supported,
    the default input bus is set to USB.
    
    This is the same behavior of virt-manager. See
    https://github.com/virt-manager/virt-manager/blob/master/virtinst/devices/input.py#L40
    
    https://bugzilla.gnome.org/735768 Doesn't seem to be reproducible
    anymore.
    
    Related to #272

 src/vm-configurator.vala | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index 8e88b399..579909b5 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -433,26 +433,36 @@ private static void set_sound_config (Domain domain, InstallerMedia install_medi
     private static void set_tablet_config (Domain domain, InstallerMedia install_media) {
         var device = find_device_by_prop (install_media.supported_devices, DEVICE_PROP_NAME, "tablet");
         if (device != null) {
-            set_input_config (domain, DomainInputDeviceType.TABLET);
+            set_input_config (domain, DomainInputDeviceType.TABLET, install_media);
         }
     }
 
     private static void set_mouse_config (Domain domain, InstallerMedia install_media) {
-        set_input_config (domain, DomainInputDeviceType.MOUSE);
+        set_input_config (domain, DomainInputDeviceType.MOUSE, install_media);
     }
 
     private static void set_keyboard_config (Domain domain, InstallerMedia install_media) {
-        set_input_config (domain, DomainInputDeviceType.KEYBOARD);
+        set_input_config (domain, DomainInputDeviceType.KEYBOARD, install_media);
     }
 
-    private static void set_input_config (Domain domain, DomainInputDeviceType device_type) {
+    private static void set_input_config (Domain domain, DomainInputDeviceType device_type,
+                                          InstallerMedia install_media) {
         var input = new DomainInput ();
         input.set_device_type (device_type);
-        input.set_bus (DomainInputBus.USB);
+
+        var default_bus = get_default_input_bus (install_media);
+        input.set_bus (default_bus);
 
         domain.add_device (input);
     }
 
+    private static DomainInputBus get_default_input_bus (InstallerMedia install_media) {
+        if (find_device_by_prop (install_media.supported_devices, DEVICE_PROP_NAME, "tablet") != null)
+            return DomainInputBus.USB;
+
+        return DomainInputBus.PS2;
+    }
+
     private static StoragePermissions get_default_permissions () {
         var permissions = new StoragePermissions ();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]