|
From: Matti K. <mpk...@us...> - 2009-12-10 18:09:09
|
Module: performous
Branch: dance
Commit: 452ca0e577ab2a4bfb51f5429848283c8e6322f1
Author: Matti Kemppainen <mpk...@us...>
Date: Thu Dec 10 20:08:44 2009 +0200
USB dancepad
---
game/dancegraph.cc | 2 +-
game/joystick.cc | 16 +++++++++++++---
game/joystick.hh | 19 ++++++++++++++-----
3 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index b0ab6cb..021cf26 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -41,7 +41,7 @@ DanceGraph::DanceGraph(Audio& audio, Song const& song):
m_level(BEGINNER),
m_audio(audio),
m_song(song),
- m_input(input::GUITAR), // TODO: to be replaced by DANCEPAD
+ m_input(input::DANCEPAD), // TODO: to be replaced by DANCEPAD
m_arrows(getThemePath("arrows.svg")),
m_arrows_cursor(getThemePath("arrows_cursor.svg")),
m_arrows_hold(getThemePath("arrows_hold.svg")),
diff --git a/game/joystick.cc b/game/joystick.cc
index 3b0e42e..0430630 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -23,16 +23,18 @@ void input::MidiDrums::process() {
}
#endif
-static const unsigned SDL_BUTTONS = 6;
+static const unsigned SDL_BUTTONS = 10;
int buttonFromSDL(input::Private::Type _type, unsigned int _sdl_button) {
- static const int inputmap[4][SDL_BUTTONS] = {
+ static const int inputmap[5][SDL_BUTTONS] = {
//G R Y B O // for guitars
{ 2, 0, 1, 3, 4, -1 }, // Guitar Hero guitar
{ 3, 0, 1, 2, 4, -1 }, // Rock Band guitar
//K R Y B G O // for drums
{ 3, 4, 1, 2, 0, 4 }, // Guitar Hero drums
- { 3, 4, 1, 2, 0, -1 } // Rock Band drums
+ { 3, 4, 1, 2, 0, -1 }, // Rock Band drums
+ // Left Down Up Right DownL DownR UpL UpR Enter Select
+ { 0, 2, 1, 3 } /* 4, 5, 6, 7, 8, 9 } */ // generic dance pad
};
if( _sdl_button >= SDL_BUTTONS ) return -1;
switch(_type) {
@@ -44,6 +46,8 @@ int buttonFromSDL(input::Private::Type _type, unsigned int _sdl_button) {
return inputmap[2][_sdl_button];
case input::Private::DRUMS_RB:
return inputmap[3][_sdl_button];
+ case input::Private::DANCEPAD_GENERIC:
+ return inputmap[4][_sdl_button];
default:
return -1;
}
@@ -140,6 +144,9 @@ void input::SDL::init() {
case input::Private::DRUMS_MIDI:
std::cout << " Detected as: MIDI Drums (forced)" << std::endl;
break;
+ case input::Private::DANCEPAD_GENERIC:
+ std::cout << " Detected as: Generic dance pad" << std::endl;
+ break;
}
input::Private::devices[i] = input::Private::InputDevPrivate(forced_type[i]);
} else if( name.find("Guitar Hero3") != std::string::npos ) {
@@ -158,6 +165,9 @@ void input::SDL::init() {
} else if( name.find("Harmonix Drum kit") != std::string::npos ) {
std::cout << " Detected as: RockBand Drums" << std::endl;
input::Private::devices[i] = input::Private::InputDevPrivate(input::Private::DRUMS_RB);
+ } else if( name.find("RedOctane USB Pad") != std::string::npos ) {
+ std::cout << " Detected as: Generic Dance Pad" << std::endl;
+ input::Private::devices[i] = input::Private::InputDevPrivate(input::Private::DANCEPAD_GENERIC);
} else {
std::cout << " Detected as: Unknwown (please report the name, assuming Guitar Hero Drums)" << std::endl;
input::Private::devices[i] = input::Private::InputDevPrivate(input::Private::DRUMS_GH);
diff --git a/game/joystick.hh b/game/joystick.hh
index ea59fc8..538186d 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -18,7 +18,7 @@
namespace input {
enum DevType { GUITAR, DRUMS, DANCEPAD };
- static const std::size_t BUTTONS = 6;
+ static const std::size_t BUTTONS = 10;
struct Event {
enum Type { PRESS, RELEASE, PICK, WHAMMY };
@@ -30,7 +30,7 @@ namespace input {
};
namespace Private {
- enum Type {GUITAR_RB, DRUMS_RB, GUITAR_GH, DRUMS_GH, DRUMS_MIDI};
+ enum Type { GUITAR_RB, DRUMS_RB, GUITAR_GH, DRUMS_GH, DRUMS_MIDI, DANCEPAD_GENERIC };
static unsigned int KEYBOARD_ID = UINT_MAX;
class InputDevPrivate {
public:
@@ -76,10 +76,17 @@ namespace input {
if( _type == input::GUITAR &&
(m_type == input::Private::GUITAR_GH || m_type == input::Private::GUITAR_RB) ) {
return true;
- } else if( _type == input::DRUMS &&
+ }
+ else if( _type == input::DRUMS &&
(m_type == input::Private::DRUMS_GH || m_type == input::Private::DRUMS_RB || m_type == input::Private::DRUMS_MIDI) ) {
return true;
- } else {
+ }
+ else if( _type == input::DANCEPAD && (m_type == input::Private::DANCEPAD_GENERIC
+ || m_type == input::Private::GUITAR_GH // for keyboard controlling
+ )) {
+ return true;
+ }
+ else {
return false;
}
};
@@ -105,6 +112,8 @@ namespace input {
std::cout << "Request acquiring DRUM" << std::endl;
if( _type == input::GUITAR )
std::cout << "Request acquiring GUITAR" << std::endl;
+ if( _type == input::DANCEPAD )
+ std::cout << "Request acquiring DANCEPAD" << std::endl;
if( devices.size() == 0 ) throw std::runtime_error("No InputDev available");
for(InputDevs::iterator it = devices.begin() ; it != devices.end() ; ++it) {
if( it->first == input::Private::KEYBOARD_ID && !config["game/keyboard_guitar"].b()) continue;
@@ -115,7 +124,7 @@ namespace input {
return;
}
}
- std::cout << "Not Found" << std::endl;
+ std::cout << "No InputDev was found!" << std::endl;
throw std::runtime_error("No matching instrument available");
};
~InputDev() {
|