summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorGiancarlo Saraceni <ghsaraceni@yahoo.com>2017-06-06 02:12:02 -0700
committerShawn Hoffman <godisgovernment@gmail.com>2017-06-06 04:38:20 -0700
commitef84e19d5595dcb2b5571f3eb711285491b81ecd (patch)
tree095c658793b154463a58d514da5e765ea9eed11f /Source/Core
parent096399d3719769dde4004bcefec87a447fd32cf3 (diff)
Implement slider bar present on GHWT and GH5 controllers
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/WiimoteCommon/WiimoteReport.h2
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.cpp33
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.h2
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h3
-rw-r--r--Source/Core/DolphinWX/Input/GuitarInputConfigDiag.cpp14
5 files changed, 45 insertions, 9 deletions
diff --git a/Source/Core/Core/HW/WiimoteCommon/WiimoteReport.h b/Source/Core/Core/HW/WiimoteCommon/WiimoteReport.h
index cfcc11b102..64044046af 100644
--- a/Source/Core/Core/HW/WiimoteCommon/WiimoteReport.h
+++ b/Source/Core/Core/HW/WiimoteCommon/WiimoteReport.h
@@ -260,7 +260,7 @@ struct wm_guitar_extension
u8 sy : 6;
u8 pad2 : 2; // 1 on gh3, 0 on ghwt
- u8 tb : 5; // not used in gh3
+ u8 sb : 5; // not used in gh3
u8 pad3 : 3; // always 0
u8 whammy : 5;
diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.cpp b/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.cpp
index df06e23eac..73218cbed7 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.cpp
+++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.cpp
@@ -7,6 +7,8 @@
#include <array>
#include <cassert>
+#include <map>
+
#include "Common/Common.h"
#include "Common/CommonTypes.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
@@ -15,10 +17,22 @@
#include "InputCommon/ControllerEmu/ControlGroup/AnalogStick.h"
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
+#include "InputCommon/ControllerEmu/ControlGroup/Slider.h"
#include "InputCommon/ControllerEmu/ControlGroup/Triggers.h"
namespace WiimoteEmu
{
+static const std::map<const ControlState, const u8> s_slider_bar_control_codes{
+ // values determined using a PS3 Guitar Hero 5 controller, which maps the touchbar to Zr on
+ // Windows
+ {0.0, 0x0F}, // not touching
+ {-0.4375, 0x04}, // top fret
+ {-0.097656, 0x0A}, // second fret
+ {0.203125, 0x12}, // third fret
+ {0.578125, 0x17}, // fourth fret
+ {1.0, 0x1F} // bottom fret
+};
+
constexpr std::array<u8, 6> guitar_id{{0x00, 0x00, 0xa4, 0x20, 0x01, 0x03}};
constexpr std::array<u16, 5> guitar_fret_bitmasks{{
@@ -63,6 +77,9 @@ Guitar::Guitar(ExtensionReg& reg) : Attachment(_trans("Guitar"), reg)
groups.emplace_back(m_whammy = new ControllerEmu::Triggers(_trans("Whammy")));
m_whammy->controls.emplace_back(new ControllerEmu::Input(_trans("Bar")));
+ // slider bar
+ groups.emplace_back(m_slider_bar = new ControllerEmu::Slider(_trans("Slider Bar")));
+
// set up register
m_id = guitar_id;
}
@@ -83,8 +100,18 @@ void Guitar::GetState(u8* const data)
gdata->sy = static_cast<u8>((y * 0x1F) + 0x20);
}
- // TODO: touch bar, probably not
- gdata->tb = 0x0F; // not touched
+ // slider bar
+ if (m_slider_bar->controls[0]->control_ref->BoundCount())
+ {
+ ControlState slider_bar;
+ m_slider_bar->GetState(&slider_bar);
+ gdata->sb = s_slider_bar_control_codes.lower_bound(slider_bar)->second;
+ }
+ else
+ {
+ // if user has not mapped controls for slider bar, tell game it's untouched
+ gdata->sb = 0x0F;
+ }
// whammy bar
ControlState whammy;
@@ -125,6 +152,8 @@ ControllerEmu::ControlGroup* Guitar::GetGroup(GuitarGroup group)
return m_whammy;
case GuitarGroup::Stick:
return m_stick;
+ case GuitarGroup::SliderBar:
+ return m_slider_bar;
default:
assert(false);
return nullptr;
diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.h b/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.h
index 169818bff5..36fd809af8 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.h
+++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.h
@@ -12,6 +12,7 @@ class AnalogStick;
class Buttons;
class ControlGroup;
class Triggers;
+class Slider;
}
namespace WiimoteEmu
@@ -48,5 +49,6 @@ private:
ControllerEmu::Buttons* m_strum;
ControllerEmu::Triggers* m_whammy;
ControllerEmu::AnalogStick* m_stick;
+ ControllerEmu::Slider* m_slider_bar;
};
}
diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h
index c998aa7409..44ea750605 100644
--- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h
+++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h
@@ -91,7 +91,8 @@ enum class GuitarGroup
Frets,
Strum,
Whammy,
- Stick
+ Stick,
+ SliderBar
};
enum class DrumsGroup
diff --git a/Source/Core/DolphinWX/Input/GuitarInputConfigDiag.cpp b/Source/Core/DolphinWX/Input/GuitarInputConfigDiag.cpp
index aee2f5dedf..13f52fecb8 100644
--- a/Source/Core/DolphinWX/Input/GuitarInputConfigDiag.cpp
+++ b/Source/Core/DolphinWX/Input/GuitarInputConfigDiag.cpp
@@ -20,11 +20,15 @@ GuitarInputConfigDialog::GuitarInputConfigDialog(wxWindow* const parent, InputCo
Wiimote::GetGuitarGroup(port_num, WiimoteEmu::GuitarGroup::Buttons), this, this);
auto* const group_left_strum = new ControlGroupBox(
Wiimote::GetGuitarGroup(port_num, WiimoteEmu::GuitarGroup::Strum), this, this);
+ auto* const group_slider_bar = new ControlGroupBox(
+ Wiimote::GetGuitarGroup(port_num, WiimoteEmu::GuitarGroup::SliderBar), this, this);
- auto* const buttons_strum_sizer = new wxBoxSizer(wxVERTICAL);
- buttons_strum_sizer->Add(group_box_buttons, 0, wxEXPAND);
- buttons_strum_sizer->AddSpacer(space5);
- buttons_strum_sizer->Add(group_left_strum, 0, wxEXPAND);
+ auto* const buttons_strum_slider_bar_sizer = new wxBoxSizer(wxVERTICAL);
+ buttons_strum_slider_bar_sizer->Add(group_box_buttons, 0, wxEXPAND);
+ buttons_strum_slider_bar_sizer->AddSpacer(space5);
+ buttons_strum_slider_bar_sizer->Add(group_left_strum, 0, wxEXPAND);
+ buttons_strum_slider_bar_sizer->AddSpacer(space5);
+ buttons_strum_slider_bar_sizer->Add(group_slider_bar, 0, wxEXPAND);
auto* const group_box_frets = new ControlGroupBox(
Wiimote::GetGuitarGroup(port_num, WiimoteEmu::GuitarGroup::Frets), this, this);
@@ -41,7 +45,7 @@ GuitarInputConfigDialog::GuitarInputConfigDialog(wxWindow* const parent, InputCo
auto* const controls_sizer = new wxBoxSizer(wxHORIZONTAL);
controls_sizer->AddSpacer(space5);
- controls_sizer->Add(buttons_strum_sizer, 0, wxEXPAND);
+ controls_sizer->Add(buttons_strum_slider_bar_sizer, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(frets_whammy_sizer, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);