From 7fba56f27b9170c24234e2fa040753b01b7d1156 Mon Sep 17 00:00:00 2001 From: Florin9doi Date: Sun, 14 Jul 2024 13:43:02 +0300 Subject: [PATCH] USB: Replace if/else with switch --- rpcs3/Emu/Cell/lv2/sys_usbd.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_usbd.cpp b/rpcs3/Emu/Cell/lv2/sys_usbd.cpp index 8787fece48..3c54bb0a91 100644 --- a/rpcs3/Emu/Cell/lv2/sys_usbd.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_usbd.cpp @@ -870,7 +870,9 @@ void connect_usb_controller(u8 index, input::product_type type) if (!already_connected) { - if (type == input::product_type::guncon_3) + switch (type) + { + case input::product_type::guncon_3: { if (!g_cfg_guncon3.load()) { @@ -881,8 +883,9 @@ void connect_usb_controller(u8 index, input::product_type type) std::shared_ptr dev = std::make_shared(index, usbh->get_new_location()); usbh->connect_usb_device(dev, true); usbh->pad_to_usb.emplace(index, std::pair(type, dev)); + break; } - if (type == input::product_type::top_shot_elite) + case input::product_type::top_shot_elite: { if (!g_cfg_topshotelite.load()) { @@ -893,8 +896,9 @@ void connect_usb_controller(u8 index, input::product_type type) std::shared_ptr dev = std::make_shared(index, usbh->get_new_location()); usbh->connect_usb_device(dev, true); usbh->pad_to_usb.emplace(index, std::pair(type, dev)); + break; } - if (type == input::product_type::top_shot_fearmaster) + case input::product_type::top_shot_fearmaster: { if (!g_cfg_topshotfearmaster.load()) { @@ -905,13 +909,18 @@ void connect_usb_controller(u8 index, input::product_type type) std::shared_ptr dev = std::make_shared(index, usbh->get_new_location()); usbh->connect_usb_device(dev, true); usbh->pad_to_usb.emplace(index, std::pair(type, dev)); + break; } - if (type == input::product_type::udraw_gametablet) + case input::product_type::udraw_gametablet: { sys_usbd.success("Adding emulated uDraw GameTablet (controller %d)", index); std::shared_ptr dev = std::make_shared(index, usbh->get_new_location()); usbh->connect_usb_device(dev, true); usbh->pad_to_usb.emplace(index, std::pair(type, dev)); + break; + } + default: + break; } } }