Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #604 from magcius/wip/emu-cleanup-2
Start cleaning up the input interface
  • Loading branch information
lioncash committed Jul 15, 2014
2 parents 01cd90d + ff918df commit ebd0299
Show file tree
Hide file tree
Showing 41 changed files with 767 additions and 1,632 deletions.
16 changes: 16 additions & 0 deletions Source/Core/Core/ConfigManager.cpp
Expand Up @@ -150,6 +150,7 @@ void SConfig::SaveSettings()
SaveCoreSettings(ini);
SaveMovieSettings(ini);
SaveDSPSettings(ini);
SaveInputSettings(ini);
SaveFifoPlayerSettings(ini);

ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX));
Expand Down Expand Up @@ -329,6 +330,13 @@ void SConfig::SaveDSPSettings(IniFile& ini)
dsp->Set("CaptureLog", m_DSPCaptureLog);
}

void SConfig::SaveInputSettings(IniFile& ini)
{
IniFile::Section* input = ini.GetOrCreateSection("Input");

input->Set("BackgroundInput", m_BackgroundInput);
}

void SConfig::SaveFifoPlayerSettings(IniFile& ini)
{
IniFile::Section* fifoplayer = ini.GetOrCreateSection("FifoPlayer");
Expand All @@ -350,6 +358,7 @@ void SConfig::LoadSettings()
LoadCoreSettings(ini);
LoadMovieSettings(ini);
LoadDSPSettings(ini);
LoadInputSettings(ini);
LoadFifoPlayerSettings(ini);

m_SYSCONF = new SysConf();
Expand Down Expand Up @@ -556,6 +565,13 @@ void SConfig::LoadDSPSettings(IniFile& ini)
dsp->Get("CaptureLog", &m_DSPCaptureLog, false);
}

void SConfig::LoadInputSettings(IniFile& ini)
{
IniFile::Section* input = ini.GetOrCreateSection("Input");

input->Get("BackgroundInput", &m_BackgroundInput, false);
}

void SConfig::LoadFifoPlayerSettings(IniFile& ini)
{
IniFile::Section* fifoplayer = ini.GetOrCreateSection("FifoPlayer");
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/Core/ConfigManager.h
Expand Up @@ -97,6 +97,9 @@ struct SConfig : NonCopyable
int m_Volume;
std::string sBackend;

// Input settings
bool m_BackgroundInput;

SysConf* m_SYSCONF;

// save settings
Expand All @@ -122,6 +125,7 @@ struct SConfig : NonCopyable
void SaveGameListSettings(IniFile& ini);
void SaveCoreSettings(IniFile& ini);
void SaveDSPSettings(IniFile& ini);
void SaveInputSettings(IniFile& ini);
void SaveMovieSettings(IniFile& ini);
void SaveFifoPlayerSettings(IniFile& ini);

Expand All @@ -132,6 +136,7 @@ struct SConfig : NonCopyable
void LoadGameListSettings(IniFile& ini);
void LoadCoreSettings(IniFile& ini);
void LoadDSPSettings(IniFile& ini);
void LoadInputSettings(IniFile& ini);
void LoadMovieSettings(IniFile& ini);
void LoadFifoPlayerSettings(IniFile& ini);

Expand Down
3 changes: 1 addition & 2 deletions Source/Core/Core/Core.vcxproj
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
Expand Down Expand Up @@ -357,7 +357,6 @@
<ClInclude Include="HW\WiimoteEmu\Attachment\Turntable.h" />
<ClInclude Include="HW\WiimoteEmu\Encryption.h" />
<ClInclude Include="HW\WiimoteEmu\MatrixMath.h" />
<ClInclude Include="HW\WiimoteEmu\UDPTLayer.h" />
<ClInclude Include="HW\WiimoteEmu\WiimoteEmu.h" />
<ClInclude Include="HW\WiimoteEmu\WiimoteHid.h" />
<ClInclude Include="HW\WiimoteReal\WiimoteReal.h" />
Expand Down
5 changes: 1 addition & 4 deletions Source/Core/Core/Core.vcxproj.filters
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="ActionReplay">
Expand Down Expand Up @@ -1005,9 +1005,6 @@
<ClInclude Include="HW\WiimoteEmu\MatrixMath.h">
<Filter>HW %28Flipper/Hollywood%29\Wiimote\Emu</Filter>
</ClInclude>
<ClInclude Include="HW\WiimoteEmu\UDPTLayer.h">
<Filter>HW %28Flipper/Hollywood%29\Wiimote\Emu</Filter>
</ClInclude>
<ClInclude Include="HW\WiimoteEmu\WiimoteEmu.h">
<Filter>HW %28Flipper/Hollywood%29\Wiimote\Emu</Filter>
</ClInclude>
Expand Down
64 changes: 28 additions & 36 deletions Source/Core/Core/HW/GCPadEmu.cpp
Expand Up @@ -79,7 +79,7 @@ GCPad::GCPad(const unsigned int index) : m_index(index)

// options
groups.emplace_back(m_options = new ControlGroup(_trans("Options")));
m_options->settings.emplace_back(new ControlGroup::Setting(_trans("Background Input"), false));
m_options->settings.emplace_back(new ControlGroup::BackgroundInputSetting(_trans("Background Input")));
}

std::string GCPad::GetName() const
Expand All @@ -89,34 +89,31 @@ std::string GCPad::GetName() const

void GCPad::GetInput(GCPadStatus* const pad)
{
// if window has focus or background input enabled
if (Host_RendererHasFocus() || m_options[0].settings[0]->value)
{
// buttons
m_buttons->GetState(&pad->button, button_bitmasks);

// set analog A/B analog to full or w/e, prolly not needed
if (pad->button & PAD_BUTTON_A) pad->analogA = 0xFF;
if (pad->button & PAD_BUTTON_B) pad->analogB = 0xFF;

// dpad
m_dpad->GetState(&pad->button, dpad_bitmasks);

// sticks
m_main_stick->GetState(&pad->stickX, &pad->stickY, 0x80, 127);
m_c_stick->GetState(&pad->substickX, &pad->substickY, 0x80, 127);

// triggers
m_triggers->GetState(&pad->button, trigger_bitmasks, &pad->triggerLeft, 0xFF);
}
else
{
// center sticks
pad->stickX = 0x80;
pad->stickY = 0x80;
pad->substickX = 0x80;
pad->substickY = 0x80;
}
double x, y, triggers[2];

// buttons
m_buttons->GetState(&pad->button, button_bitmasks);

// set analog A/B analog to full or w/e, prolly not needed
if (pad->button & PAD_BUTTON_A) pad->analogA = 0xFF;
if (pad->button & PAD_BUTTON_B) pad->analogB = 0xFF;

// dpad
m_dpad->GetState(&pad->button, dpad_bitmasks);

// sticks
m_main_stick->GetState(&x, &y);
pad->stickX = 0x7F + (x * 0x80);
pad->stickY = 0x7F + (y * 0x80);

m_c_stick->GetState(&x, &y);
pad->substickX = 0x7F + (x * 0x80);
pad->substickY = 0x7F + (y * 0x80);

// triggers
m_triggers->GetState(&pad->button, trigger_bitmasks, triggers);
pad->triggerLeft = triggers[0] * 0xFF;
pad->triggerRight = triggers[1] * 0xFF;
}

void GCPad::SetMotor(const u8 on)
Expand All @@ -126,17 +123,12 @@ void GCPad::SetMotor(const u8 on)
if (state < 0.5)
force = -force;

// only rumble if window has focus or background input is enabled
if (Host_RendererHasFocus() || m_options[0].settings[0]->value)
m_rumble->controls[0]->control_ref->State(force);
else
m_rumble->controls[0]->control_ref->State(0);
m_rumble->controls[0]->control_ref->State(force);
}

void GCPad::SetOutput(const u8 on)
{
// only rumble if window has focus or background input is enabled
m_rumble->controls[0]->control_ref->State(on && (Host_RendererHasFocus() || m_options[0].settings[0]->value));
m_rumble->controls[0]->control_ref->State(on);
}

void GCPad::LoadDefaults(const ControllerInterface& ciface)
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/HW/WiimoteEmu/Attachment/Attachment.cpp
Expand Up @@ -42,7 +42,7 @@ void Attachment::Reset()

}

void ControllerEmu::Extension::GetState(u8* const data, const bool focus)
void ControllerEmu::Extension::GetState(u8* const data)
{
((WiimoteEmu::Attachment*)attachments[active_extension].get())->GetState(data, focus);
((WiimoteEmu::Attachment*)attachments[active_extension].get())->GetState(data);
}
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/WiimoteEmu/Attachment/Attachment.h
Expand Up @@ -15,7 +15,7 @@ class Attachment : public ControllerEmu
public:
Attachment(const char* const _name, WiimoteEmu::ExtensionReg& _reg);

virtual void GetState(u8* const data, const bool focus = true) {}
virtual void GetState(u8* const data) {}
void Reset();
std::string GetName() const override;

Expand Down
51 changes: 28 additions & 23 deletions Source/Core/Core/HW/WiimoteEmu/Attachment/Classic.cpp
Expand Up @@ -80,7 +80,7 @@ Classic::Classic(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Classic"),
memcpy(&id, classic_id, sizeof(classic_id));
}

void Classic::GetState(u8* const data, const bool focus)
void Classic::GetState(u8* const data)
{
wm_classic_extension* const ccdata = (wm_classic_extension*)data;
ccdata->bt = 0;
Expand All @@ -89,42 +89,47 @@ void Classic::GetState(u8* const data, const bool focus)

// left stick
{
u8 x, y;
m_left_stick->GetState(&x, &y, 0x20, focus ? 0x1F /*0x15*/ : 0);
double x, y;
m_left_stick->GetState(&x, &y);

ccdata->lx = x;
ccdata->ly = y;
ccdata->lx = (x * 0x1F) + 0x20;
ccdata->ly = (y * 0x1F) + 0x20;
}

// right stick
{
u8 x, y;
m_right_stick->GetState(&x, &y, 0x10, focus ? 0x0F /*0x0C*/ : 0);
double x, y;
u8 x_, y_;
m_right_stick->GetState(&x, &y);

ccdata->rx1 = x;
ccdata->rx2 = x >> 1;
ccdata->rx3 = x >> 3;
ccdata->ry = y;
x_ = (x * 0x1F) + 0x20;
y_ = (y * 0x1F) + 0x20;

ccdata->rx1 = x_;
ccdata->rx2 = x_ >> 1;
ccdata->rx3 = x_ >> 3;
ccdata->ry = y_;
}

//triggers
{
u8 trigs[2];
m_triggers->GetState(&ccdata->bt, classic_trigger_bitmasks, trigs, focus ? 0x1F : 0);
double trigs[2] = { 0, 0 };
u8 lt, rt;
m_triggers->GetState(&ccdata->bt, classic_trigger_bitmasks, trigs);

ccdata->lt1 = trigs[0];
ccdata->lt2 = trigs[0] >> 3;
ccdata->rt = trigs[1];
}
lt = trigs[0] * 0x1F;
rt = trigs[1] * 0x1F;

if (focus)
{
// buttons
m_buttons->GetState(&ccdata->bt, classic_button_bitmasks);
// dpad
m_dpad->GetState(&ccdata->bt, classic_dpad_bitmasks);
ccdata->lt1 = lt;
ccdata->lt2 = lt >> 3;
ccdata->rt = rt;
}

// buttons
m_buttons->GetState(&ccdata->bt, classic_button_bitmasks);
// dpad
m_dpad->GetState(&ccdata->bt, classic_dpad_bitmasks);

// flip button bits
ccdata->bt ^= 0xFFFF;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/WiimoteEmu/Attachment/Classic.h
Expand Up @@ -13,7 +13,7 @@ class Classic : public Attachment
{
public:
Classic(WiimoteEmu::ExtensionReg& _reg);
void GetState(u8* const data, const bool focus) override;
void GetState(u8* const data) override;

enum
{
Expand Down
21 changes: 9 additions & 12 deletions Source/Core/Core/HW/WiimoteEmu/Attachment/Drums.cpp
Expand Up @@ -51,7 +51,7 @@ Drums::Drums(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Drums"), _reg)
memcpy(&id, drums_id, sizeof(drums_id));
}

void Drums::GetState(u8* const data, const bool focus)
void Drums::GetState(u8* const data)
{
wm_drums_extension* const ddata = (wm_drums_extension*)data;
ddata->bt = 0;
Expand All @@ -60,24 +60,21 @@ void Drums::GetState(u8* const data, const bool focus)

// stick
{
u8 x, y;
m_stick->GetState(&x, &y, 0x20, focus ? 0x1F /*0x15*/ : 0);
double x, y;
m_stick->GetState(&x, &y);

ddata->sx = x;
ddata->sy = y;
ddata->sx = (x * 0x1F) + 0x20;
ddata->sx = (y * 0x1F) + 0x20;
}

// TODO: softness maybe
data[2] = 0xFF;
data[3] = 0xFF;

if (focus)
{
// buttons
m_buttons->GetState(&ddata->bt, drum_button_bitmasks);
// pads
m_pads->GetState(&ddata->bt, drum_pad_bitmasks);
}
// buttons
m_buttons->GetState(&ddata->bt, drum_button_bitmasks);
// pads
m_pads->GetState(&ddata->bt, drum_pad_bitmasks);

// flip button bits
ddata->bt ^= 0xFFFF;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/WiimoteEmu/Attachment/Drums.h
Expand Up @@ -13,7 +13,7 @@ class Drums : public Attachment
{
public:
Drums(WiimoteEmu::ExtensionReg& _reg);
void GetState(u8* const data, const bool focus) override;
void GetState(u8* const data) override;

enum
{
Expand Down
31 changes: 14 additions & 17 deletions Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.cpp
Expand Up @@ -64,7 +64,7 @@ Guitar::Guitar(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Guitar"), _r
memcpy(&id, guitar_id, sizeof(guitar_id));
}

void Guitar::GetState(u8* const data, const bool focus)
void Guitar::GetState(u8* const data)
{
wm_guitar_extension* const gdata = (wm_guitar_extension*)data;
gdata->bt = 0;
Expand All @@ -73,30 +73,27 @@ void Guitar::GetState(u8* const data, const bool focus)

// stick
{
u8 x, y;
m_stick->GetState(&x, &y, 0x20, focus ? 0x1F /*0x15*/ : 0);
double x, y;
m_stick->GetState(&x, &y);

gdata->sx = x;
gdata->sy = y;
gdata->sx = (x * 0x1F) + 0x20;
gdata->sy = (y * 0x1F) + 0x20;
}

// TODO: touch bar, probably not
gdata->tb = 0x0F; // not touched

// whammy bar
u8 whammy;
m_whammy->GetState(&whammy, 0x1F);
gdata->whammy = whammy;
double whammy;
m_whammy->GetState(&whammy);
gdata->whammy = whammy * 0x1F;

if (focus)
{
// buttons
m_buttons->GetState(&gdata->bt, guitar_button_bitmasks);
// frets
m_frets->GetState(&gdata->bt, guitar_fret_bitmasks);
// strum
m_strum->GetState(&gdata->bt, guitar_strum_bitmasks);
}
// buttons
m_buttons->GetState(&gdata->bt, guitar_button_bitmasks);
// frets
m_frets->GetState(&gdata->bt, guitar_fret_bitmasks);
// strum
m_strum->GetState(&gdata->bt, guitar_strum_bitmasks);

// flip button bits
gdata->bt ^= 0xFFFF;
Expand Down

0 comments on commit ebd0299

Please sign in to comment.