more cleanup

This commit is contained in:
Anon 2016-07-30 09:59:26 -05:00
parent 7c6c5a4327
commit 3f497f0426
5 changed files with 12 additions and 10 deletions

View File

@ -125,7 +125,7 @@ void Config::SaveValues() {
qt_config->beginGroup("Controls"); qt_config->beginGroup("Controls");
for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) { for (int i = 0; i < Settings::NativeInput::NUM_INPUTS; ++i) {
qt_config->setValue(QString::fromStdString(Settings::NativeInput::Mapping[i]), qt_config->setValue(QString::fromStdString(Settings::NativeInput::Mapping[i]),
QString::fromStdString(Settings::values.input_mappings[Settings::NativeInput::All[i]].Save())); QString::fromStdString(Settings::values.input_mappings[Settings::NativeInput::All[i]].toString()));
} }
qt_config->setValue("pad_circle_modifier_scale", (double)Settings::values.pad_circle_modifier_scale); qt_config->setValue("pad_circle_modifier_scale", (double)Settings::values.pad_circle_modifier_scale);
qt_config->endGroup(); qt_config->endGroup();

View File

@ -91,7 +91,7 @@ namespace Settings {
bool operator==(const InputDeviceMapping& rhs) const { bool operator==(const InputDeviceMapping& rhs) const {
return (this->device == rhs.device) && (this->framework == rhs.framework) && (this->number == rhs.number); return (this->device == rhs.device) && (this->framework == rhs.framework) && (this->number == rhs.number);
} }
std::string Save() { std::string toString() {
std::string result = ""; std::string result = "";
if (this->framework == DeviceFramework::Qt) if (this->framework == DeviceFramework::Qt)
result = "Qt"; result = "Qt";

View File

@ -19,8 +19,8 @@ namespace InputCore {
static int tick_event; static int tick_event;
Service::HID::PadState pad_state; Service::HID::PadState pad_state;
std::tuple<s16, s16> circle_pad = { 0,0 }; std::tuple<s16, s16> circle_pad = { 0,0 };
shared_ptr<Keyboard> main_keyboard; /// Instance of main keyboard device. Always initialized regardless of settings. shared_ptr<Keyboard> main_keyboard;
vector<shared_ptr<IDevice>> devices; ///Devices that are handling input for the game vector<shared_ptr<IDevice>> devices; ///< Devices that are handling input for the game
static void InputTickCallback(u64, int cycles_late) { static void InputTickCallback(u64, int cycles_late) {
for (auto& device : devices) for (auto& device : devices)
@ -42,7 +42,6 @@ namespace InputCore {
devices.clear(); devices.clear();
} }
///Parse the settings to initialize necessary devices to handle input
vector<shared_ptr<IDevice>> InputCore::ParseSettings() { vector<shared_ptr<IDevice>> InputCore::ParseSettings() {
vector<shared_ptr<IDevice>> devices; vector<shared_ptr<IDevice>> devices;
vector<Settings::InputDeviceMapping> uniqueMappings; //unique mappings from settings file, used to init devices. vector<Settings::InputDeviceMapping> uniqueMappings; //unique mappings from settings file, used to init devices.
@ -91,13 +90,13 @@ namespace InputCore {
input->InitDevice(mapping.number, keyMapping); input->InitDevice(mapping.number, keyMapping);
} }
//init keyboard, if it hasn't already
if (main_keyboard == nullptr) if (main_keyboard == nullptr)
main_keyboard = std::make_shared<Keyboard>(); main_keyboard = std::make_shared<Keyboard>();
return devices; return devices;
} }
///Helper method to check if device has already been initialized from the mapping.
bool InputCore::CheckIfMappingExists(vector<Settings::InputDeviceMapping> uniqueMapping, Settings::InputDeviceMapping mappingToCheck) { bool InputCore::CheckIfMappingExists(vector<Settings::InputDeviceMapping> uniqueMapping, Settings::InputDeviceMapping mappingToCheck) {
for (auto& mapping : uniqueMapping) { for (auto& mapping : uniqueMapping) {
if (mapping == mappingToCheck) if (mapping == mappingToCheck)
@ -105,4 +104,4 @@ namespace InputCore {
} }
return false; return false;
} }
} }

View File

@ -16,11 +16,14 @@ namespace InputCore {
extern Service::HID::PadState pad_state; extern Service::HID::PadState pad_state;
extern std::tuple<s16, s16> circle_pad; extern std::tuple<s16, s16> circle_pad;
extern std::shared_ptr<Keyboard> main_keyboard; extern std::shared_ptr<Keyboard> main_keyboard; ///< Instance of main keyboard device. Always initialized regardless of settings.
void Init(); void Init();
void Shutdown(); void Shutdown();
///Read settings to initialize devices
std::vector<std::shared_ptr<IDevice>> ParseSettings(); std::vector<std::shared_ptr<IDevice>> ParseSettings();
///Helper method to check if device was already initialized
bool CheckIfMappingExists(std::vector<Settings::InputDeviceMapping> uniqueMapping, Settings::InputDeviceMapping mappingToCheck); bool CheckIfMappingExists(std::vector<Settings::InputDeviceMapping> uniqueMapping, Settings::InputDeviceMapping mappingToCheck);
} // namespace }

View File

@ -60,4 +60,4 @@ namespace KeyMap {
} }
} }
} }
} }