The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

d/wmr: consolidate interface getters

Moving them into one function makes it simpler to add more HMDs.

authored by

Christoph Haag and committed by
Jakob Bornecrantz
96c09e06 09603144

+29 -41
+29 -41
src/xrt/drivers/wmr/wmr_prober.c
··· 40 40 */ 41 41 42 42 static bool 43 - check_and_get_interface_hp(struct xrt_prober_device *device, enum wmr_headset_type *out_hmd_type, int *out_interface) 43 + check_and_get_interface(struct xrt_prober_device *device, enum wmr_headset_type *out_hmd_type, int *out_interface) 44 44 { 45 - if (device->product_id != REVERB_G1_PID && device->product_id != REVERB_G2_PID) { 46 - return false; 47 - } 45 + switch (device->vendor_id) { 46 + case HP_VID: 47 + if (device->product_id != REVERB_G1_PID && device->product_id != REVERB_G2_PID) { 48 + return false; 49 + } 48 50 49 - if (device->product_id == REVERB_G1_PID) 50 - *out_hmd_type = WMR_HEADSET_REVERB_G1; 51 - else 52 - *out_hmd_type = WMR_HEADSET_REVERB_G2; 53 - *out_interface = 0; 51 + if (device->product_id == REVERB_G1_PID) 52 + *out_hmd_type = WMR_HEADSET_REVERB_G1; 53 + else 54 + *out_hmd_type = WMR_HEADSET_REVERB_G2; 54 55 55 - return true; 56 - } 56 + *out_interface = 0; 57 + return true; 57 58 58 - static bool 59 - check_and_get_interface_lenovo(struct xrt_prober_device *device, 60 - enum wmr_headset_type *out_hmd_type, 61 - int *out_interface) 62 - { 63 - if (device->product_id != EXPLORER_PID) { 64 - return false; 65 - } 66 - 67 - *out_hmd_type = WMR_HEADSET_LENOVO_EXPLORER; 68 - *out_interface = 0; 59 + case LENOVO_VID: 60 + if (device->product_id != EXPLORER_PID) { 61 + return false; 62 + } 69 63 70 - return true; 71 - } 64 + *out_hmd_type = WMR_HEADSET_LENOVO_EXPLORER; 65 + *out_interface = 0; 66 + return true; 72 67 73 - static bool 74 - check_and_get_interface_samsung(struct xrt_prober_device *device, 75 - enum wmr_headset_type *out_hmd_type, 76 - int *out_interface) 77 - { 78 - if (device->product_id != ODYSSEY_PID) { 79 - return false; 80 - } 68 + case SAMSUNG_VID: 69 + if (device->product_id != ODYSSEY_PID) { 70 + return false; 71 + } 81 72 82 - *out_hmd_type = WMR_HEADSET_SAMSUNG_800ZAA; 83 - *out_interface = 0; 73 + *out_hmd_type = WMR_HEADSET_SAMSUNG_800ZAA; 74 + *out_interface = 0; 75 + return true; 84 76 85 - return true; 77 + default: return false; 78 + } 86 79 } 87 80 88 81 static bool ··· 104 97 continue; 105 98 } 106 99 107 - switch (devices[i]->vendor_id) { 108 - case HP_VID: match = check_and_get_interface_hp(devices[i], out_hmd_type, &interface); break; 109 - case LENOVO_VID: match = check_and_get_interface_lenovo(devices[i], out_hmd_type, &interface); break; 110 - case SAMSUNG_VID: match = check_and_get_interface_samsung(devices[i], out_hmd_type, &interface); break; 111 - default: break; 112 - } 100 + match = check_and_get_interface(devices[i], out_hmd_type, &interface); 113 101 114 102 if (!match) { 115 103 continue;