USB: Top Shot Fearmaster device emulation

This commit is contained in:
Florin9doi 2024-07-02 00:08:10 +03:00 committed by Megamouse
parent 088b594fa8
commit 33d2b27b91
15 changed files with 593 additions and 5 deletions

View file

@ -6,6 +6,7 @@
#include "Emu/Io/ghltar_config.h"
#include "Emu/Io/guncon3_config.h"
#include "Emu/Io/topshotelite_config.h"
#include "Emu/Io/topshotfearmaster_config.h"
#include "Emu/Io/turntable_config.h"
#include "Emu/Io/usio_config.h"
#include "util/asm.hpp"
@ -95,6 +96,10 @@ emulated_pad_settings_dialog::emulated_pad_settings_dialog(pad_type type, QWidge
setWindowTitle(tr("Configure Emulated Top Shot Elite"));
add_tabs<topshotelite_btn>(tabs);
break;
case emulated_pad_settings_dialog::pad_type::topshotfearmaster:
setWindowTitle(tr("Configure Emulated Top Shot Fearmaster"));
add_tabs<topshotfearmaster_btn>(tabs);
break;
}
v_layout->addWidget(tabs);
@ -139,6 +144,9 @@ void emulated_pad_settings_dialog::add_tabs(QTabWidget* tabs)
case pad_type::topshotelite:
players = g_cfg_topshotelite.players.size();
break;
case pad_type::topshotfearmaster:
players = g_cfg_topshotfearmaster.players.size();
break;
}
m_combos.resize(players);
@ -166,7 +174,7 @@ void emulated_pad_settings_dialog::add_tabs(QTabWidget* tabs)
combo->setItemData(index, i, button_role::emulated_button);
}
if constexpr (std::is_same_v<T, guncon3_btn> || std::is_same_v<T, topshotelite_btn>)
if constexpr (std::is_same_v<T, guncon3_btn> || std::is_same_v<T, topshotelite_btn> || std::is_same_v<T, topshotfearmaster_btn>)
{
for (int p = static_cast<int>(pad_button::mouse_button_1); p <= static_cast<int>(pad_button::mouse_button_8); p++)
{
@ -202,6 +210,9 @@ void emulated_pad_settings_dialog::add_tabs(QTabWidget* tabs)
case pad_type::topshotelite:
saved_btn_id = ::at32(g_cfg_topshotelite.players, player)->get_pad_button(static_cast<topshotelite_btn>(id));
break;
case pad_type::topshotfearmaster:
saved_btn_id = ::at32(g_cfg_topshotfearmaster.players, player)->get_pad_button(static_cast<topshotfearmaster_btn>(id));
break;
}
combo->setCurrentIndex(combo->findData(static_cast<int>(saved_btn_id)));
@ -240,6 +251,9 @@ void emulated_pad_settings_dialog::add_tabs(QTabWidget* tabs)
case pad_type::topshotelite:
::at32(g_cfg_topshotelite.players, player)->set_button(static_cast<topshotelite_btn>(id), btn_id);
break;
case pad_type::topshotfearmaster:
::at32(g_cfg_topshotfearmaster.players, player)->set_button(static_cast<topshotfearmaster_btn>(id), btn_id);
break;
}
});
@ -306,6 +320,12 @@ void emulated_pad_settings_dialog::load_config()
cfg_log.notice("Could not load topshotelite config. Using defaults.");
}
break;
case emulated_pad_settings_dialog::pad_type::topshotfearmaster:
if (!g_cfg_topshotfearmaster.load())
{
cfg_log.notice("Could not load topshotfearmaster config. Using defaults.");
}
break;
}
}
@ -334,6 +354,9 @@ void emulated_pad_settings_dialog::save_config()
case emulated_pad_settings_dialog::pad_type::topshotelite:
g_cfg_topshotelite.save();
break;
case emulated_pad_settings_dialog::pad_type::topshotfearmaster:
g_cfg_topshotfearmaster.save();
break;
}
}
@ -362,6 +385,9 @@ void emulated_pad_settings_dialog::reset_config()
case emulated_pad_settings_dialog::pad_type::topshotelite:
g_cfg_topshotelite.from_default();
break;
case emulated_pad_settings_dialog::pad_type::topshotfearmaster:
g_cfg_topshotfearmaster.from_default();
break;
}
for (usz player = 0; player < m_combos.size(); player++)
@ -399,6 +425,9 @@ void emulated_pad_settings_dialog::reset_config()
case pad_type::topshotelite:
def_btn_id = ::at32(g_cfg_topshotelite.players, player)->default_pad_button(static_cast<topshotelite_btn>(data.toInt()));
break;
case pad_type::topshotfearmaster:
def_btn_id = ::at32(g_cfg_topshotfearmaster.players, player)->default_pad_button(static_cast<topshotfearmaster_btn>(data.toInt()));
break;
}
combo->setCurrentIndex(combo->findData(static_cast<int>(def_btn_id)));