All PrimeHack settings implemented and should update correctly. Changed title and forced portable.

This commit is contained in:
SirMangler 2019-10-18 16:13:02 +01:00
parent 3dd22b9755
commit fa04cad490
13 changed files with 64 additions and 84 deletions

View File

@ -18,7 +18,7 @@ namespace Common
#define BUILD_TYPE_STR "" #define BUILD_TYPE_STR ""
#endif #endif
const std::string scm_rev_str = "Dolphin " const std::string scm_rev_str = "PrimeHack (v0.3.0) "
#if !SCM_IS_MASTER #if !SCM_IS_MASTER
"[" SCM_BRANCH_STR "] " "[" SCM_BRANCH_STR "] "
#endif #endif

View File

@ -23,6 +23,8 @@
#include "InputCommon/ControllerInterface/ControllerInterface.h" #include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/InputConfig.h" #include "InputCommon/InputConfig.h"
#include "Core/PrimeHack/HackConfig.h"
// Limit the amount of wiimote connect requests, when a button is pressed in disconnected state // Limit the amount of wiimote connect requests, when a button is pressed in disconnected state
static std::array<u8, MAX_BBMOTES> s_last_connect_request_counter; static std::array<u8, MAX_BBMOTES> s_last_connect_request_counter;
@ -141,6 +143,8 @@ void LoadConfig()
{ {
s_config.LoadConfig(false); s_config.LoadConfig(false);
s_last_connect_request_counter.fill(0); s_last_connect_request_counter.fill(0);
prime::UpdateHackSettings();
} }
void Resume() void Resume()
@ -220,6 +224,13 @@ bool CheckBeam(int beamcount)
return wiimote->CheckBeamCtrl(beamcount); return wiimote->CheckBeamCtrl(beamcount);
} }
std::tuple<double, double, double, bool, bool> PrimeSettings()
{
WiimoteEmu::Wiimote* wiimote = static_cast<WiimoteEmu::Wiimote*>(s_config.GetController(0));
return wiimote->GetPrimeSettings();
}
// This function is called periodically by the Core to update Wiimote state. // This function is called periodically by the Core to update Wiimote state.
void Update(int number, bool connected) void Update(int number, bool connected)
{ {

View File

@ -10,6 +10,8 @@
#include "Common/Common.h" #include "Common/Common.h"
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include <tuple>
class InputConfig; class InputConfig;
class PointerWrap; class PointerWrap;
@ -89,6 +91,8 @@ ControllerEmu::ControlGroup* GetTaTaConGroup(int number, WiimoteEmu::TaTaConGrou
bool CheckVisor(int visor_count); bool CheckVisor(int visor_count);
bool CheckBeam(int beam_count); bool CheckBeam(int beam_count);
std::tuple<double, double, double, bool, bool> PrimeSettings();
void ControlChannel(int number, u16 channel_id, const void* data, u32 size); void ControlChannel(int number, u16 channel_id, const void* data, u32 size);
void InterruptChannel(int number, u16 channel_id, const void* data, u32 size); void InterruptChannel(int number, u16 channel_id, const void* data, u32 size);
bool ButtonPressed(int number); bool ButtonPressed(int number);

View File

@ -49,6 +49,8 @@
#include "InputCommon/ControllerEmu/ControlGroup/PrimeHackButtons.h" #include "InputCommon/ControllerEmu/ControlGroup/PrimeHackButtons.h"
#include "InputCommon/ControllerEmu/ControlGroup/PrimeHackMisc.h" #include "InputCommon/ControllerEmu/ControlGroup/PrimeHackMisc.h"
#include "Core/PrimeHack/HackConfig.h"
namespace WiimoteEmu namespace WiimoteEmu
{ {
using namespace WiimoteCommon; using namespace WiimoteCommon;
@ -662,6 +664,15 @@ bool Wiimote::CheckBeamCtrl(int beamcount)
return m_primehack_beams->controls[beamcount].get()->control_ref->State() > 0.5; return m_primehack_beams->controls[beamcount].get()->control_ref->State() > 0.5;
} }
std::tuple<double, double, double, bool, bool> Wiimote::GetPrimeSettings()
{
std::tuple t = std::make_tuple(m_primehack_camera_sensitivity.GetValue(),
m_primehack_cursor_sensitivity.GetValue(), m_primehack_fieldofview.GetValue(),
m_primehack_invert_x.GetValue(), m_primehack_invert_y.GetValue());
return t;
}
void Wiimote::LoadDefaults(const ControllerInterface& ciface) void Wiimote::LoadDefaults(const ControllerInterface& ciface)
{ {

View File

@ -130,6 +130,7 @@ public:
bool CheckVisorCtrl(int visor_count); bool CheckVisorCtrl(int visor_count);
bool CheckBeamCtrl(int beam_count); bool CheckBeamCtrl(int beam_count);
std::tuple <double, double, double, bool, bool> GetPrimeSettings();
void Reset(); void Reset();

View File

@ -39,75 +39,6 @@ void InitializeHack(std::string const& mkb_device_name, std::string const& mkb_d
device_name = mkb_device_name; device_name = mkb_device_name;
device_source = mkb_device_source; device_source = mkb_device_source;
IniFile cfg_file;
cfg_file.Load(config_path, true);
if (!cfg_file.GetIfExists<float>("mouse", "sensitivity", &sensitivity))
{
auto* section = cfg_file.GetOrCreateSection("mouse");
section->Set("sensitivity", 15.f);
sensitivity = 15.f;
}
if (!cfg_file.GetIfExists<float>("mouse", "cursor_sensitivity", &cursor_sensitivity))
{
auto* section = cfg_file.GetOrCreateSection("mouse");
section->Set("cursor_sensitivity", 15.f);
cursor_sensitivity = 15.f;
}
if (!cfg_file.GetIfExists<float>("misc", "fov", &camera_fov))
{
auto* section = cfg_file.GetOrCreateSection("misc");
section->Set("fov", 60.f);
camera_fov = 60.f;
}
if (!cfg_file.GetIfExists<bool>("misc", "inverted_y", &inverted_y))
{
auto* section = cfg_file.GetOrCreateSection("misc");
section->Set("inverted_y", false);
inverted_y = false;
}
if (!cfg_file.GetIfExists<bool>("misc", "inverted_x", &inverted_x))
{
auto* section = cfg_file.GetOrCreateSection("misc");
section->Set("inverted_x", false);
inverted_x = false;
}
control_list.resize(8);
for (int i = 0; i < 4; i++)
{
std::string control = std::string("index_") + std::to_string(i);
std::string control_expr;
if (!cfg_file.GetIfExists<std::string>("beam", control.c_str(), &control_expr))
{
auto* section = cfg_file.GetOrCreateSection("beam");
section->Set(control.c_str(), beam_binds[i]);
control_expr = beam_binds[i];
}
control_list[i] = std::make_unique<InputReference>();
control_list[i]->UpdateReference(
g_controller_interface,
ciface::Core::DeviceQualifier(mkb_device_source.c_str(), 0, mkb_device_name.c_str()));
control_list[i]->SetExpression(control_expr);
if (!cfg_file.GetIfExists<std::string>("visor", control.c_str(), &control_expr))
{
auto* section = cfg_file.GetOrCreateSection("visor");
section->Set(control.c_str(), visor_binds[i]);
control_expr = visor_binds[i];
}
control_list[i + 4] = std::make_unique<InputReference>();
control_list[i + 4]->SetExpression(control_expr);
control_list[i + 4]->UpdateReference(
g_controller_interface,
ciface::Core::DeviceQualifier(mkb_device_source.c_str(), 0, mkb_device_name.c_str()));
}
cfg_file.Save(config_path);
} }
void RefreshControlDevices() void RefreshControlDevices()
@ -178,10 +109,26 @@ bool CheckBeamCtl(int beam_num)
bool CheckVisorCtl(int visor_num) bool CheckVisorCtl(int visor_num)
{ {
//return control_list[visor_num + 4]->State() > 0.5; // return control_list[visor_num + 4]->State() > 0.5;
return Wiimote::CheckVisor(visor_num); return Wiimote::CheckVisor(visor_num);
} }
void UpdateHackSettings()
{
std::tuple<double, double, double, bool, bool> t = Wiimote::PrimeSettings();
double camera = std::get<0>(t);
double cursor = std::get<1>(t);
double fov = std::get<2>(t);
bool invertx = std::get<3>(t);
bool inverty = std::get<4>(t);
SetSensitivity((float)camera);
SetCursorSensitivity((float)cursor);
SetFov((float)fov);
SetInvertedX(invertx);
SetInvertedY(inverty);
}
std::vector<std::unique_ptr<ControlReference>>& GetMutableControls() std::vector<std::unique_ptr<ControlReference>>& GetMutableControls()
{ {
return control_list; return control_list;

View File

@ -17,6 +17,7 @@ namespace prime
void LoadStateFromIni(); void LoadStateFromIni();
bool CheckBeamCtl(int beam_num); bool CheckBeamCtl(int beam_num);
bool CheckVisorCtl(int visor_num); bool CheckVisorCtl(int visor_num);
void UpdateHackSettings();
float GetSensitivity(); float GetSensitivity();
void SetSensitivity(float sensitivity); void SetSensitivity(float sensitivity);

View File

@ -18,6 +18,8 @@
#include "InputCommon/ControllerEmu/ControlGroup/Attachments.h" #include "InputCommon/ControllerEmu/ControlGroup/Attachments.h"
#include "InputCommon/InputConfig.h" #include "InputCommon/InputConfig.h"
#include "Core/PrimeHack/HackConfig.h"
PrimeHackEmuGeneral::PrimeHackEmuGeneral(MappingWindow* window, WiimoteEmuExtension* extension) PrimeHackEmuGeneral::PrimeHackEmuGeneral(MappingWindow* window, WiimoteEmuExtension* extension)
: MappingWidget(window), m_extension_widget(extension) : MappingWidget(window), m_extension_widget(extension)
{ {
@ -64,17 +66,22 @@ void PrimeHackEmuGeneral::OnAttachmentChanged(int extension)
void PrimeHackEmuGeneral::ConfigChanged() void PrimeHackEmuGeneral::ConfigChanged()
{ {
prime::UpdateHackSettings();
} }
void PrimeHackEmuGeneral::LoadSettings() void PrimeHackEmuGeneral::LoadSettings()
{ {
Wiimote::LoadConfig(); Wiimote::LoadConfig();
prime::UpdateHackSettings();
} }
void PrimeHackEmuGeneral::SaveSettings() void PrimeHackEmuGeneral::SaveSettings()
{ {
Wiimote::GetConfig()->SaveConfig(); Wiimote::GetConfig()->SaveConfig();
prime::UpdateHackSettings();
} }
InputConfig* PrimeHackEmuGeneral::GetConfig() InputConfig* PrimeHackEmuGeneral::GetConfig()

View File

@ -24,6 +24,8 @@ private:
void OnAttachmentChanged(int index); void OnAttachmentChanged(int index);
void ConfigChanged(); void ConfigChanged();
void UpdateHackSettings();
// Extensions // Extensions
QComboBox* m_extension_combo; QComboBox* m_extension_combo;

View File

@ -16,6 +16,8 @@
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h" #include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h" #include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "Core/PrimeHack/HackConfig.h"
namespace ControllerEmu namespace ControllerEmu
{ {
static std::recursive_mutex s_get_state_mutex; static std::recursive_mutex s_get_state_mutex;

View File

@ -99,6 +99,7 @@ void ControllerInterface::RefreshDevices()
#ifdef CIFACE_USE_WIN32 #ifdef CIFACE_USE_WIN32
ciface::Win32::PopulateDevices(m_wsi.render_surface); ciface::Win32::PopulateDevices(m_wsi.render_surface);
prime::InitializeHack("Keyboard Mouse", "DInput"); prime::InitializeHack("Keyboard Mouse", "DInput");
#endif #endif
#ifdef CIFACE_USE_XLIB #ifdef CIFACE_USE_XLIB

View File

@ -18,6 +18,8 @@
#include "InputCommon/InputConfig.h" #include "InputCommon/InputConfig.h"
#include "InputCommon/InputProfile.h" #include "InputCommon/InputProfile.h"
#include "Core/PrimeHack/HackConfig.h"
InputConfig::InputConfig(const std::string& ini_name, const std::string& gui_name, InputConfig::InputConfig(const std::string& ini_name, const std::string& gui_name,
const std::string& profile_name) const std::string& profile_name)
: m_ini_name(ini_name), m_gui_name(gui_name), m_profile_name(profile_name) : m_ini_name(ini_name), m_gui_name(gui_name), m_profile_name(profile_name)
@ -138,6 +140,7 @@ bool InputConfig::LoadConfig(bool isGC)
{ {
m_controllers[0]->LoadDefaults(g_controller_interface); m_controllers[0]->LoadDefaults(g_controller_interface);
m_controllers[0]->UpdateReferences(g_controller_interface); m_controllers[0]->UpdateReferences(g_controller_interface);
return false; return false;
} }
} }

View File

@ -232,18 +232,8 @@ void SetUserDirectory(const std::string& custom_path)
local = local || File::Exists(File::GetExeDirectory() + DIR_SEP "portable.txt"); local = local || File::Exists(File::GetExeDirectory() + DIR_SEP "portable.txt");
// Get Program Files path in case we need it. // Get Program Files path in case we need it.
TCHAR my_documents[MAX_PATH];
bool my_documents_found = SUCCEEDED(
SHGetFolderPath(nullptr, CSIDL_MYDOCUMENTS, nullptr, SHGFP_TYPE_CURRENT, my_documents));
if (local) // Case 1-2 user_path = File::GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP;
user_path = File::GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP;
else if (configPath[0]) // Case 3
user_path = TStrToUTF8(configPath);
else if (my_documents_found) // Case 4
user_path = TStrToUTF8(my_documents) + DIR_SEP "Dolphin Emulator" DIR_SEP;
else // Case 5
user_path = File::GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP;
// Prettify the path: it will be displayed in some places, we don't want a mix // Prettify the path: it will be displayed in some places, we don't want a mix
// of \ and /. // of \ and /.
@ -254,7 +244,7 @@ void SetUserDirectory(const std::string& custom_path)
user_path += DIR_SEP; user_path += DIR_SEP;
#else #else
if (File::IsDirectory(ROOT_DIR DIR_SEP USERDATA_DIR)) if (File::Exists(ROOT_DIR DIR_SEP USERDATA_DIR))
{ {
user_path = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP; user_path = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP;
} }