|
From: knittl <kn...@us...> - 2009-08-03 08:40:29
|
Module: performous
Branch: master
Commit: 0efcf1019bcf5894ec080561be767ca5d69ecf55
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Aug 1 16:20:34 2009 +0200
Fixed compilation errors
Moved practice screen to new intrument management
---
game/joystick.cc | 2 ++
game/screen_practice.cc | 27 +++++++++++++++------------
game/screen_practice.hh | 2 ++
3 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index d23e04a..9a8f6fb 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -3,6 +3,7 @@
#include <boost/lexical_cast.hpp>
+/*
enum TypeSDL {UNKNOWN, GUITAR_RB, DRUM_RB, GUITAR_GH, DRUM_GH, TYPESDL_N};
static const unsigned SDL_BUTTONS = 6;
@@ -16,6 +17,7 @@ int buttonFromSDL(TypeSDL type, unsigned sdlButton) {
if (sdlButton > SDL_BUTTONS) return -1;
return inputmap[type][sdlButton];
}
+*/
/*
diff --git a/game/screen_practice.cc b/game/screen_practice.cc
index 7cd3339..38543d7 100644
--- a/game/screen_practice.cc
+++ b/game/screen_practice.cc
@@ -1,7 +1,6 @@
#include "screen_practice.hh"
#include "util.hh"
-#include "joystick.hh"
#include "configuration.hh"
ScreenPractice::ScreenPractice(std::string const& name, Audio& audio, Capture& capture):
@@ -17,11 +16,13 @@ void ScreenPractice::enter() {
m_vumeters.push_back(b = new ProgressBar(getThemePath("vumeter_bg.svg"), getThemePath("vumeter_fg.svg"), ProgressBar::VERTICAL, 0.136, 0.023));
b->dimensions.screenBottom().left(-0.4 + i * 0.2).fixedWidth(0.04);
}
+ drums.reset(new input::InputDev(input::DRUMS));
}
void ScreenPractice::exit() {
m_vumeters.clear();
theme.reset();
+ drums.reset();
}
void ScreenPractice::manageEvent(SDL_Event event) {
@@ -40,27 +41,29 @@ void ScreenPractice::manageEvent(SDL_Event event) {
break;
}
}
- JoystickEvent joy_event;
- for(Joysticks::iterator it = joysticks.begin() ; it != joysticks.end() ; ++it ) {
- if( it->second.tryPollEvent(joy_event) && joy_event.type == JoystickEvent::BUTTON_DOWN) {
- switch(joy_event.button_id) {
- case PS3_DRUM_CONTROLLER_RED: // Snare drum
+ input::Event input_event;
+ while( drums->tryPollEvent(input_event) ) {
+ if(input_event.type == input::Event::PRESS) {
+ switch(input_event.button) {
+ case 0:
+ m_audio.playMusic(getDataPath("sounds/drum_bass.ogg"));
+ break;
+ case 1:
m_audio.playMusic(getDataPath("sounds/drum_snare.ogg"));
break;
- case PS3_DRUM_CONTROLLER_BLUE: // Tom 1
+ case 2:
m_audio.playMusic(getDataPath("sounds/drum_tom1.ogg"));
break;
- case PS3_DRUM_CONTROLLER_GREEN: // Tom 2
+ case 3:
m_audio.playMusic(getDataPath("sounds/drum_tom2.ogg"));
break;
- case PS3_DRUM_CONTROLLER_YELLOW: // Hi hat
+ case 4:
m_audio.playMusic(getDataPath("sounds/drum_hi-hat.ogg"));
break;
- case PS3_DRUM_CONTROLLER_ORANGE: // crash cymbal
+ case 5:
m_audio.playMusic(getDataPath("sounds/drum_cymbal.ogg"));
break;
- case PS3_DRUM_CONTROLLER_XXX: // Drum bass
- m_audio.playMusic(getDataPath("sounds/drum_bass.ogg"));
+ default:
break;
}
}
diff --git a/game/screen_practice.hh b/game/screen_practice.hh
index 1816055..84d60e2 100644
--- a/game/screen_practice.hh
+++ b/game/screen_practice.hh
@@ -7,6 +7,7 @@
#include "theme.hh"
#include "opengl_text.hh"
#include "progressbar.hh"
+#include "joystick.hh"
/// screen for practice mode
class ScreenPractice : public Screen {
@@ -26,6 +27,7 @@ class ScreenPractice : public Screen {
Capture& m_capture;
boost::ptr_vector<ProgressBar> m_vumeters;
boost::scoped_ptr<ThemePractice> theme;
+ boost::scoped_ptr<input::InputDev> drums;
};
#endif
|