|
From: Tapio V. <aa...@us...> - 2010-01-12 13:29:35
|
Module: performous
Branch: master
Commit: b7dfe92e62699b4671fa27d777b0dd39acdef2d1
Author: Tapio Vierros <tap...@gm...>
Date: Tue Jan 12 15:28:11 2010 +0200
Added GH X-plorer guitar mapping. Needs testing.
---
data/schema.xml | 2 +-
game/joystick.cc | 24 ++++++++++++++++++------
game/joystick.hh | 4 ++--
3 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/data/schema.xml b/data/schema.xml
index fed2106..a7312ea 100644
--- a/data/schema.xml
+++ b/data/schema.xml
@@ -85,7 +85,7 @@ to save the current settings to XML.
</locale>
</entry>
<entry name="game/instruments" type="string_list">
- <!-- Should be SDL_ID:{GUITAR_GUITARHERO|GUITAR_ROCKBAND|DRUMS_GUITARHERO|DRUMS_ROCKBAND|DRUMS_MIDI|DANCEPAD_GENERIC}
+ <!-- Should be SDL_ID:{GUITAR_GUITARHERO|GUITAR_GUITARHERO_XPLORER|GUITAR_ROCKBAND|DRUMS_GUITARHERO|DRUMS_ROCKBAND|DRUMS_MIDI|DANCEPAD_GENERIC}
example:
<stringvalue>0:GUITAR_GUITARHERO</stringvalue>
-->
diff --git a/game/joystick.cc b/game/joystick.cc
index a4b1afa..77f3401 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -38,9 +38,10 @@ void input::MidiDrums::process() {
static const unsigned SDL_BUTTONS = 10;
int input::buttonFromSDL(input::Private::Type _type, unsigned int _sdl_button) {
- static const int inputmap[5][SDL_BUTTONS] = {
+ static const int inputmap[6][SDL_BUTTONS] = {
//G R Y B O S // for guitars (S=starpower)
{ 2, 0, 1, 3, 4, 5, -1, -1, 8, 9 }, // Guitar Hero guitar
+ { 0, 1, 3, 2, 4,-1, 8, 9,-1,-1 }, // Guitar Hero X-plorer guitar
{ 3, 0, 1, 2, 4, 5, -1, -1, 8, 9 }, // Rock Band guitar
//K R Y B G O // for drums
{ 3, 4, 1, 2, 0, 4, -1, -1, 8, 9 }, // Guitar Hero drums
@@ -52,14 +53,16 @@ int input::buttonFromSDL(input::Private::Type _type, unsigned int _sdl_button) {
switch(_type) {
case input::Private::GUITAR_GH:
return inputmap[0][_sdl_button];
- case input::Private::GUITAR_RB:
+ case input::Private::GUITAR_GH_XPLORER:
return inputmap[1][_sdl_button];
- case input::Private::DRUMS_GH:
+ case input::Private::GUITAR_RB:
return inputmap[2][_sdl_button];
- case input::Private::DRUMS_RB:
+ case input::Private::DRUMS_GH:
return inputmap[3][_sdl_button];
- case input::Private::DANCEPAD_GENERIC:
+ case input::Private::DRUMS_RB:
return inputmap[4][_sdl_button];
+ case input::Private::DANCEPAD_GENERIC:
+ return inputmap[5][_sdl_button];
default:
return -1;
}
@@ -177,7 +180,8 @@ void input::SDL::init() {
std::map<unsigned int, input::Private::Type> forced_type;
using namespace boost::spirit::classic;
- rule<> type = str_p("GUITAR_GUITARHERO") | "GUITAR_ROCKBAND" | "DRUMS_GUITARHERO" | "DRUMS_ROCKBAND" | "DRUMS_MIDI" | "DANCEPAD_GENERIC";
+ rule<> type = str_p("GUITAR_GUITARHERO") | "GUITAR_ROCKBAND" | "GUITAR_GUITARHERO_XPLORER"
+ | "DRUMS_GUITARHERO" | "DRUMS_ROCKBAND" | "DRUMS_MIDI" | "DANCEPAD_GENERIC";
rule<> entry = uint_p[assign_a(sdl_id)] >> ":" >> (type)[assign_a(instrument_type)];
ConfigItem::StringList const& instruments = config["game/instruments"].sl();
@@ -188,6 +192,8 @@ void input::SDL::init() {
} else {
if (instrument_type == "GUITAR_GUITARHERO") {
forced_type[sdl_id] = input::Private::GUITAR_GH;
+ } else if (instrument_type == "GUITAR_GUITARHERO_XPLORER") {
+ forced_type[sdl_id] = input::Private::GUITAR_GH_XPLORER;
} else if (instrument_type == "DRUMS_GUITARHERO") {
forced_type[sdl_id] = input::Private::DRUMS_GH;
} else if (instrument_type == "GUITAR_ROCKBAND") {
@@ -223,6 +229,9 @@ void input::SDL::init() {
case input::Private::GUITAR_GH:
std::cout << " Detected as: Guitar Hero Guitar (forced)" << std::endl;
break;
+ case input::Private::GUITAR_GH_XPLORER:
+ std::cout << " Detected as: Guitar Hero Guitar X-plorer (forced)" << std::endl;
+ break;
case input::Private::DRUMS_GH:
std::cout << " Detected as: Guitar Hero Drums (forced)" << std::endl;
break;
@@ -243,6 +252,9 @@ void input::SDL::init() {
} else if( name.find("Guitar Hero3") != std::string::npos ) {
std::cout << " Detected as: Guitar Hero Guitar" << std::endl;
input::Private::devices[i] = input::Private::InputDevPrivate(input::Private::GUITAR_GH);
+ } else if( name.find("Guitar Hero X-plorer") != std::string::npos ) {
+ std::cout << " Detected as: Guitar Hero Guitar X-plorer" << std::endl;
+ input::Private::devices[i] = input::Private::InputDevPrivate(input::Private::GUITAR_GH_XPLORER);
} else if( name.find("Guitar Hero4") != std::string::npos ) {
// here we can have both drumkit or guitar .... let say the drumkit
std::cout << " Detected as: Guitar Hero Drums (guessed)" << std::endl;
diff --git a/game/joystick.hh b/game/joystick.hh
index a7ddb7f..20a2188 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -32,7 +32,7 @@ namespace input {
};
namespace Private {
- enum Type { GUITAR_RB, DRUMS_RB, GUITAR_GH, DRUMS_GH, DRUMS_MIDI, DANCEPAD_GENERIC };
+ enum Type { GUITAR_RB, DRUMS_RB, GUITAR_GH, GUITAR_GH_XPLORER, DRUMS_GH, DRUMS_MIDI, DANCEPAD_GENERIC };
static unsigned int KEYBOARD_ID = UINT_MAX;
static unsigned int KEYBOARD_ID2 = KEYBOARD_ID-1;
static unsigned int KEYBOARD_ID3 = KEYBOARD_ID-2; // Three ids needed for keyboard guitar/drumkit/dancepad
@@ -79,7 +79,7 @@ namespace input {
input::Private::Type type() {return m_type;};
bool type_match( input::DevType _type) {
if( _type == input::GUITAR &&
- (m_type == input::Private::GUITAR_GH || m_type == input::Private::GUITAR_RB) ) {
+ (m_type == input::Private::GUITAR_GH || m_type == input::Private::GUITAR_GH_XPLORER || m_type == input::Private::GUITAR_RB) ) {
return true;
}
else if( _type == input::DRUMS &&
|