|
From: Yoda-JM <yo...@us...> - 2010-09-12 12:17:43
|
Module: performous
Branch: master
Commit: ec94c0f808052f95afbe619c8096a7808eb83a12
Author: Vincent Le Ligeour <yo...@us...>
Date: Sun Sep 12 14:17:21 2010 +0200
Moved whammy bar to button mapping
---
game/guitargraph.cc | 13 ++++++++++++-
game/joystick.cc | 26 +++++++++++++++++++-------
game/joystick.hh | 3 ++-
3 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index dc4d9f2..5905161 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -334,8 +334,19 @@ void GuitarGraph::engine() {
if (ev.type == input::Event::PRESS) activateStarpower();
continue;
}
+ if (ev.button == input::WHAMMY_BUTTON) {
+ switch(ev.type) {
+ case input::Event::RELEASE:
+ m_whammy = (1.0 + 0.0 + 2.0*(rand()/double(RAND_MAX))) / 4.0;
+ break;
+ case input::Event::PRESS:
+ m_whammy = (1.0 + 1.0 + 2.0*(rand()/double(RAND_MAX))) / 4.0;
+ break;
+ default:
+ break;
+ }
+ }
if (ev.type == input::Event::RELEASE) endHold(ev.button, time);
- if (ev.type == input::Event::WHAMMY) m_whammy = (1.0 + ev.button + 2.0*(rand()/double(RAND_MAX))) / 4.0;
} else {
// Handle drum lefty-mode
if (m_leftymode.b() && ev.button > 0 && !menuOpen()) ev.button = m_pads - ev.button;
diff --git a/game/joystick.cc b/game/joystick.cc
index e408dd4..2691ae0 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -476,8 +476,8 @@ bool input::SDL::pushEvent(SDL_Event _e) {
break;
case SDLK_BACKSPACE:
if(!guitar) return false;
- event.type = input::Event::WHAMMY;
- button = 1;
+ event.type = input::Event::PRESS;
+ button = input::WHAMMY_BUTTON;
is_guitar_event = true;
break;
case SDLK_F6: case SDLK_6:
@@ -617,8 +617,8 @@ bool input::SDL::pushEvent(SDL_Event _e) {
return true;
case SDLK_BACKSPACE:
if(!guitar) return false;
- event.type = input::Event::WHAMMY;
- button = 0;
+ event.type = input::Event::RELEASE;
+ button = WHAMMY_BUTTON;
is_guitar_event = true;
break;
case SDLK_F6: case SDLK_6:
@@ -738,9 +738,10 @@ bool input::SDL::pushEvent(SDL_Event _e) {
if(!devices.find(joy_id)->second.assigned()) return false;
if (_e.jaxis.axis == 5 || _e.jaxis.axis == 6 || _e.jaxis.axis == 1) {
event.type = input::Event::PICK;
- } else if (_e.jaxis.axis == 2 || (devices.find(joy_id)->second.name() == "GUITAR_ROCKBAND_XB360"
- && _e.jaxis.axis == 4)) {
- event.type = input::Event::WHAMMY;
+ } else if (_e.jaxis.axis == 2 || (devices.find(joy_id)->second.name() == "GUITAR_ROCKBAND_XB360" && _e.jaxis.axis == 4)) {
+ // nothing to do here
+ } else if (devices.find(joy_id)->second.name() == "DRUMS_ROCKBAND_XB360" && _e.jaxis.axis == 3) { // <= WTF HERE !!!
+ // nothing to do here
} else {
return false;
}
@@ -759,6 +760,17 @@ bool input::SDL::pushEvent(SDL_Event _e) {
}
devices.find(joy_id)->second.addEvent(event);
break;
+ } else if (_e.jaxis.axis == 2 || (devices.find(joy_id)->second.name() == "GUITAR_ROCKBAND_XB360" && _e.jaxis.axis == 4)) {
+ event.button = input::WHAMMY_BUTTON;
+ if (_e.jaxis.value > 0) {
+ event.type = input::Event::PRESS;
+ event.pressed[event.button] = true;
+ } else {
+ event.type = input::Event::RELEASE;
+ event.pressed[event.button] = false;
+ }
+ devices.find(joy_id)->second.addEvent(event);
+ break;
}
// Direction
if(_e.jaxis.value > 0 ) { // down
diff --git a/game/joystick.hh b/game/joystick.hh
index a64ba72..9da0e0c 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -29,6 +29,7 @@ namespace input {
static const int BLUE_FRET_BUTTON = 3;
static const int ORANGE_FRET_BUTTON = 4;
static const int GODMODE_BUTTON = 5;
+ static const int WHAMMY_BUTTON = 6;
// Drums buttons
static const int KICK_BUTTON = 0;
static const int RED_TOM_BUTTON = 1;
@@ -50,7 +51,7 @@ namespace input {
static const int START_BUTTON = 9;
struct Event {
- enum Type { PRESS, RELEASE, PICK, WHAMMY };
+ enum Type { PRESS, RELEASE, PICK };
Type type;
int button; // Translated button number for press/release events. 0 for pick down, 1 for pick up (NOTE: these are NOT pick press/release events but rather different directions)
bool pressed[BUTTONS]; // All events tell the button state right after the event happened
|