You can subscribe to this list here.
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(25) |
Jul
(288) |
Aug
(119) |
Sep
(31) |
Oct
(59) |
Nov
(458) |
Dec
(359) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2010 |
Jan
(268) |
Feb
(26) |
Mar
(36) |
Apr
(48) |
May
(119) |
Jun
(37) |
Jul
(173) |
Aug
(429) |
Sep
(137) |
Oct
(156) |
Nov
(59) |
Dec
(45) |
| 2011 |
Jan
(398) |
Feb
(257) |
Mar
(49) |
Apr
(5) |
May
(34) |
Jun
(11) |
Jul
(38) |
Aug
(12) |
Sep
(1) |
Oct
(49) |
Nov
(5) |
Dec
(10) |
| 2012 |
Jan
(21) |
Feb
(32) |
Mar
(20) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(173) |
Aug
|
Sep
(25) |
Oct
(6) |
Nov
(44) |
Dec
|
|
From: knittl <kn...@us...> - 2009-08-03 08:40:18
|
Module: performous
Branch: master
Commit: bc182d9b09e50414410e820b7266e9af27adfe76
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Aug 1 15:42:22 2009 +0200
Added GH3/GH4 instrument matching
---
game/joystick.cc | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index a481551..fe7036b 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -125,8 +125,11 @@ void input::init() {
for (unsigned int i = 0 ; i < nbjoysticks ; ++i) {
input::sdl_devices[i] = SDL_JoystickOpen(i);
std::string name = SDL_JoystickName(i);
- if( name.find("Guitar Hero") != std::string::npos ) {
+ if( name.find("Guitar Hero3") != std::string::npos ) {
input::Private::devices[i] = input::Private::InputDevPrivate(input::Private::GUITAR_GH);
+ } else if( name.find("Guitar Hero4") != std::string::npos ) {
+ // here we can have both drumkit or guitar .... let say the drumkit
+ input::Private::devices[i] = input::Private::InputDevPrivate(input::Private::DRUM_GH);
} else if( name.find("Harmonix") != std::string::npos ) {
input::Private::devices[i] = input::Private::InputDevPrivate(input::Private::GUITAR_RB);
} else {
|
|
From: knittl <kn...@us...> - 2009-08-03 08:40:17
|
Module: performous
Branch: master
Commit: 9cac693cae7d7a12628ec96e6e793a2d1c4d0729
Author: Lasse Karkkainen <tro...@tr...>
Date: Sat Aug 1 16:40:18 2009 +0300
Started GuitarGraph conversion to new input framework.
Button mapping code added to joystick.cc.
---
game/guitargraph.cc | 19 +++++++++++++------
game/guitargraph.hh | 2 ++
game/joystick.cc | 14 ++++++++++++++
game/joystick.hh | 4 ++--
4 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 4520da3..30470bb 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -1,7 +1,5 @@
#include "guitargraph.hh"
-#include "joystick.hh"
-
namespace {
struct Diff { std::string name; int basepitch; } diffv[] = {
{ "Supaeasy", 0x3C },
@@ -21,12 +19,21 @@ namespace {
float a = clamp(1.0 - t / future); // Note: we want 1.0 alpha already at zero t.
return std::pow(a, 0.8); // Nicer curve
}
- bool fretPressed[5] = {};
- bool fretHit[5] = {};
- bool picked = false;
}
-GuitarGraph::GuitarGraph(Song const& song): m_song(song), m_button("button.svg"), m_tap("tap.svg"), m_pickValue(0.0, 5.0), m_drums(), m_instrument(), m_level(), m_text(getThemePath("sing_timetxt.svg"), config["graphic/text_lod"].f()), m_hammerReady(0.0, 2.0), m_score() {
+GuitarGraph::GuitarGraph(Song const& song, bool drums = false):
+ m_input(drums ? input::DRUMS : input::GUITAR),
+ m_song(song),
+ m_button("button.svg"),
+ m_tap("tap.svg"),
+ m_pickValue(0.0, 5.0),
+ m_drums(),
+ m_instrument(),
+ m_level(),
+ m_text(getThemePath("sing_timetxt.svg"), config["graphic/text_lod"].f()),
+ m_hammerReady(0.0, 2.0),
+ m_score()
+{
std::size_t tracks = m_song.tracks.size();
if (tracks == 0) throw std::runtime_error("No tracks");
m_necks.push_back(new Texture("guitarneck.svg"));
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
index aa27b88..73bce81 100644
--- a/game/guitargraph.hh
+++ b/game/guitargraph.hh
@@ -4,6 +4,7 @@
#include <boost/scoped_ptr.hpp>
#include "animvalue.hh"
#include "engine.hh"
+#include "joystick.hh"
#include "surface.hh"
#include "opengl_text.hh"
@@ -54,6 +55,7 @@ class GuitarGraph {
void draw(double time);
void engine(double time);
private:
+ InputDev m_input;
Song const& m_song;
Surface m_button;
Surface m_tap;
diff --git a/game/joystick.cc b/game/joystick.cc
index 226aa75..52f94bd 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -3,6 +3,20 @@
#include <boost/lexical_cast.hpp>
+enum TypeSDL {UNKNOWN, GUITAR_RB, DRUM_RB, GUITAR_GH, DRUM_GH, TYPESDL_N};
+static const int SDL_BUTTONS = 6;
+
+int buttonFromSDL(TypeSDL type, unsigned sdlButton) {
+ static const int inputmap[TYPESDL_N][SDL_BUTTONS] = {
+ { 2, 0, 1, 3, 4, 0 }, // Guitar Hero guitar
+ { 3, 4, 1, 2, 0, 4 }, // Guitar Hero drums
+ { 3, 0, 1, 2, 4, 0 }, // Rock Band guitar
+ { 3, 4, 1, 2, 0, 0 } // Rock Band drums
+ };
+ if (sdlButton > SDL_BUTTONS) return -1;
+ return inputmap[instrument][sdlButton];
+}
+
Joysticks joysticks;
Joystick::Joystick(Joystick::Type _type): m_type(_type) { }
diff --git a/game/joystick.hh b/game/joystick.hh
index 7262d02..d9574f4 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -70,7 +70,7 @@ extern Joysticks joysticks;
* New input management, superseed all joysticks stuffs
*/
namespace input {
- enum Type {UNKNOWN, GUITAR_RB, DRUM_RB, GUITAR_GH, DRUM_GH};
+ enum DevType { GUITAR, DRUMS };
static const std::size_t BUTTONS = 6;
@@ -122,7 +122,7 @@ namespace input {
// First gives a correct instrument type
// Then gives an unknown instrument type
// Finally throw an exception if only wrong (or none) instrument are available
- InputDev(input::Type) : m_device_id() {input::Private::devices[m_device_id].assign();};
+ InputDev(input::DevType) : m_device_id() {input::Private::devices[m_device_id].assign();};
~InputDev() {input::Private::devices[m_device_id].unassign();};
bool tryPoll(InputDevEvent& _e) {return input::Private::devices[m_device_id].tryPoll(_e);};
void addEvent(InputDevEvent _e) {input::Private::devices[m_device_id].addEvent(_e);};
|
|
From: knittl <kn...@us...> - 2009-08-03 08:40:16
|
Module: performous
Branch: master
Commit: 2fbfc307c4007f07cdef7160d3e685810fc4bd8d
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Aug 1 15:38:39 2009 +0200
Changed API .... again
---
game/joystick.cc | 8 ++++----
game/joystick.hh | 41 ++++++++++++++++++++++++++++++++---------
2 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index 8e7edd9..a481551 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -126,9 +126,9 @@ void input::init() {
input::sdl_devices[i] = SDL_JoystickOpen(i);
std::string name = SDL_JoystickName(i);
if( name.find("Guitar Hero") != std::string::npos ) {
- input::Private::devices[i] = input::Private::InputDevPrivate(input::GUITAR_GH);
+ input::Private::devices[i] = input::Private::InputDevPrivate(input::Private::GUITAR_GH);
} else if( name.find("Harmonix") != std::string::npos ) {
- input::Private::devices[i] = input::Private::InputDevPrivate(input::GUITAR_RB);
+ input::Private::devices[i] = input::Private::InputDevPrivate(input::Private::GUITAR_RB);
} else {
input::Private::devices[i] = input::Private::InputDevPrivate();
}
@@ -139,9 +139,9 @@ void input::init() {
init_devices();
// compatibility with old joystick stuffs
for (input::Private::InputDevs::iterator it = input::Private::devices.begin() ; it != input::Private::devices.end() ; ++it) {
- if( it->second.type() == GUITAR_GH || it->second.type() == DRUM_GH ) {
+ if( it->second.type() == Private::GUITAR_GH || it->second.type() == Private::DRUM_GH ) {
joysticks[it->first] = Joystick(Joystick::GUITARHERO);
- } else if( it->second.type() == GUITAR_GH || it->second.type() == DRUM_GH ) {
+ } else if( it->second.type() == Private::GUITAR_GH || it->second.type() == Private::DRUM_GH ) {
joysticks[it->first] = Joystick(Joystick::ROCKBAND);
} else {
joysticks[it->first] = Joystick();
diff --git a/game/joystick.hh b/game/joystick.hh
index 0177861..2dbbc1e 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -70,7 +70,7 @@ extern Joysticks joysticks;
* New input management, superseed all joysticks stuffs
*/
namespace input {
- enum Type {UNKNOWN, GUITAR_RB, DRUM_RB, GUITAR_GH, DRUM_GH};
+ enum Type {UNKNOWN, GUITAR ,DRUM};
static const std::size_t BUTTONS = 6;
@@ -87,9 +87,10 @@ namespace input {
};
namespace Private {
+ enum Type {UNKNOWN, GUITAR_RB, DRUM_RB, GUITAR_GH, DRUM_GH};
class InputDevPrivate {
public:
- InputDevPrivate(input::Type _type = input::UNKNOWN) : m_assigned(false), m_type(_type) {};
+ InputDevPrivate(input::Private::Type _type = input::Private::UNKNOWN) : m_assigned(false), m_type(_type) {};
bool tryPoll(InputDevEvent& _event) {
if( m_events.empty() ) return false;
_event = m_events.front();
@@ -109,13 +110,35 @@ namespace input {
void unassign() {m_assigned = false; clearEvents();};
bool assigned() {return m_assigned;};
bool pressed(int _button) {return m_pressed[_button];};
- input::Type type() {return m_type;};
- void setType(input::Type _type) {m_type=_type;init_devices();};
+ input::Private::Type type() {return m_type;};
+ bool type_match( input::Type _type) {
+ if( _type == input::UNKNOWN && m_type == input::Private::UNKNOWN ) {
+ return true;
+ } else if( _type == input::GUITAR &&
+ (m_type == input::Private::GUITAR_GH || m_type == input::Private::GUITAR_RB) ) {
+ return true;
+ } else if( _type == input::DRUM &&
+ (m_type == input::Private::DRUM_GH || m_type == input::Private::DRUM_RB) ) {
+ return true;
+ } else {
+ return false;
+ }
+ };
+ void setType(input::Type _type) {
+ if( _type == input::GUITAR ) {
+ m_type = input::Private::GUITAR_RB;
+ } else if( _type == input::DRUM ) {
+ m_type = input::Private::DRUM_RB;
+ } else {
+ m_type = input::Private::UNKNOWN;
+ }
+ init_devices();
+ };
private:
std::deque<InputDevEvent> m_events;
bool m_assigned;
bool m_pressed[BUTTONS];
- input::Type m_type;
+ input::Private::Type m_type;
};
typedef std::map<unsigned int,InputDevPrivate> InputDevs;
@@ -131,21 +154,21 @@ namespace input {
using namespace input::Private;
if( devices.size() == 0 ) throw std::runtime_error("No InputDev available");
for(InputDevs::iterator it = devices.begin() ; it != devices.end() ; ++it) {
- if( !it->second.assigned() && it->second.type() == _type ) {
+ if( !it->second.assigned() && it->second.type_match(_type) ) {
m_device_id = it->first;
it->second.assign();
return;
}
}
for(InputDevs::iterator it = devices.begin() ; it != devices.end() ; ++it) {
- if( !it->second.assigned() && it->second.type() == input::Type::UNKNOWN ) {
+ if( !it->second.assigned() && it->second.type_match(input::UNKNOWN) ) {
m_device_id = it->first;
- it->second.type(_type);
+ it->second.setType(_type);
it->second.assign();
return;
}
}
- throw std::runtime_error("No matching instrument available")
+ throw std::runtime_error("No matching instrument available");
};
~InputDev() {input::Private::devices[m_device_id].unassign();};
bool tryPoll(InputDevEvent& _e) {return input::Private::devices[m_device_id].tryPoll(_e);};
|
|
From: knittl <kn...@us...> - 2009-08-03 08:40:15
|
Module: performous
Branch: master
Commit: f387273d15defbfdcb4b9bd2c3226648de5a1831
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Aug 1 14:35:12 2009 +0200
Finished InputDevPrivate and add init event to have right button state at start
---
game/joystick.cc | 18 +++++++++++++-----
game/joystick.hh | 17 ++++++++++++++---
2 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index 7ab17e6..226aa75 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -104,8 +104,8 @@ void input::init() {
unsigned int nbjoysticks = SDL_NumJoysticks();
std::cout << "Detecting " << nbjoysticks << " joysticks..." << std::endl;
- for (unsigned int i = 0 ; i < nbjoysticks ; i++) {
- SDL_JoystickOpen(i);
+ for (unsigned int i = 0 ; i < nbjoysticks ; ++i) {
+ SDL_Joystick * joystick = SDL_JoystickOpen(i);
std::string name = SDL_JoystickName(i);
if( name.find("Guitar Hero") != std::string::npos ) {
input::Private::devices[i] = input::Private::InputDevPrivate(input::GUITAR_GH);
@@ -116,6 +116,17 @@ void input::init() {
}
std::cout << "Id: " << i << std::endl;
std::cout << " Name: " << name << std::endl;
+ // Here we should send an event to have correct state buttons
+ unsigned int num_buttons = SDL_JoystickNumButtons(joystick);
+ for( unsigned int j = 0 ; j < num_buttons ; ++j ) {
+ SDL_Event event;
+ event.type = SDL_JOYBUTTONDOWN;
+ event.jbutton.type = SDL_JOYBUTTONDOWN;
+ event.jbutton.which = i;
+ event.jbutton.button = j;
+ event.jbutton.state = SDL_PRESSED;
+ input::pushEvent(event);
+ }
}
// compatibility with old joystick stuffs
for (input::Private::InputDevs::iterator it = input::Private::devices.begin() ; it != input::Private::devices.end() ; ++it) {
@@ -143,19 +154,16 @@ bool input::pushEvent(SDL_Event _e) {
switch(_e.type) {
case SDL_JOYAXISMOTION:
joy_id = _e.jaxis.which;
- if( !devices[joy_id].assigned() ) break;
// do stuffs to devices[joy_id] events (PICK)
break;
case SDL_JOYHATMOTION:
joy_id = _e.jhat.which;
- if( !devices[joy_id].assigned() ) break;
// do stuffs to devices[joy_id] events (PICK)
break;
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
joy_id = _e.jbutton.which;
// do stuffs to devices[joy_id] states (BUTTONS)
- if( !devices[joy_id].assigned() ) break;
// do stuffs to devices[joy_id] events (BUTTONS)
break;
case SDL_JOYBALLMOTION:
diff --git a/game/joystick.hh b/game/joystick.hh
index bc42d6a..7262d02 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -86,9 +86,20 @@ namespace input {
class InputDevPrivate {
public:
InputDevPrivate(input::Type _type = input::UNKNOWN) : m_assigned(false), m_type(_type) {};
- bool tryPoll(InputDevEvent&) {return true;};
- // this will modify the m_pressed member
- void addEvent(InputDevEvent) {};
+ bool tryPoll(InputDevEvent& _event) {
+ if( m_events.empty() ) return false;
+ _event = m_events.front();
+ m_events.pop_front();
+ return true;
+ };
+ void addEvent(InputDevEvent _event) {
+ // only add event if the device is assigned
+ if( m_assigned ) m_events.push_back(_event);
+ // always keep track of button status
+ for( unsigned int i = 0 ; i < BUTTONS ; ++i ) {
+ m_pressed[i] = _event.pressed[i];
+ }
+ };
void clearEvents() {m_events.clear();};
void assign() {m_assigned = true;};
void unassign() {m_assigned = false; clearEvents();};
|
|
From: knittl <kn...@us...> - 2009-08-03 08:40:14
|
Module: performous
Branch: master
Commit: 09ca599cbbdc96fdcaed5269903b9172228f93cd
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Aug 1 15:20:21 2009 +0200
Added InputDev constructor
---
game/joystick.hh | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/game/joystick.hh b/game/joystick.hh
index 6b8d0ff..0177861 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -127,7 +127,26 @@ namespace input {
// First gives a correct instrument type
// Then gives an unknown instrument type
// Finally throw an exception if only wrong (or none) instrument are available
- InputDev(input::Type) : m_device_id() {input::Private::devices[m_device_id].assign();};
+ InputDev(input::Type _type) {
+ using namespace input::Private;
+ if( devices.size() == 0 ) throw std::runtime_error("No InputDev available");
+ for(InputDevs::iterator it = devices.begin() ; it != devices.end() ; ++it) {
+ if( !it->second.assigned() && it->second.type() == _type ) {
+ m_device_id = it->first;
+ it->second.assign();
+ return;
+ }
+ }
+ for(InputDevs::iterator it = devices.begin() ; it != devices.end() ; ++it) {
+ if( !it->second.assigned() && it->second.type() == input::Type::UNKNOWN ) {
+ m_device_id = it->first;
+ it->second.type(_type);
+ it->second.assign();
+ return;
+ }
+ }
+ throw std::runtime_error("No matching instrument available")
+ };
~InputDev() {input::Private::devices[m_device_id].unassign();};
bool tryPoll(InputDevEvent& _e) {return input::Private::devices[m_device_id].tryPoll(_e);};
void addEvent(InputDevEvent _e) {input::Private::devices[m_device_id].addEvent(_e);};
|
|
From: knittl <kn...@us...> - 2009-08-03 08:40:12
|
Module: performous
Branch: master
Commit: 659a9e44d603c3ac6f33f3c8a7e6f7bb4cd5d58d
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Aug 1 15:03:02 2009 +0200
Added some init stuffs when changing instrument type
---
game/joystick.cc | 33 +++++++++++++++++++++------------
game/joystick.hh | 5 +++++
2 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index 226aa75..8e7edd9 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -98,6 +98,24 @@ void Joystick::clearEvents() {
* New input management, superseed all joysticks stuffs
*/
input::Private::InputDevs input::Private::devices;
+input::SDL_devices input::sdl_devices;
+
+void input::init_devices() {
+ for (input::Private::InputDevs::iterator it = input::Private::devices.begin() ; it != input::Private::devices.end() ; ++it) {
+ unsigned int id = it->first;
+ if( it->second.assigned() ) continue;
+ unsigned int num_buttons = SDL_JoystickNumButtons(input::sdl_devices[id]);
+ for( unsigned int i = 0 ; i < num_buttons ; ++i ) {
+ SDL_Event event;
+ event.type = SDL_JOYBUTTONDOWN;
+ event.jbutton.type = SDL_JOYBUTTONDOWN;
+ event.jbutton.which = id;
+ event.jbutton.button = i;
+ event.jbutton.state = SDL_PRESSED;
+ input::pushEvent(event);
+ }
+ }
+}
void input::init() {
// new stuffs
@@ -105,7 +123,7 @@ void input::init() {
std::cout << "Detecting " << nbjoysticks << " joysticks..." << std::endl;
for (unsigned int i = 0 ; i < nbjoysticks ; ++i) {
- SDL_Joystick * joystick = SDL_JoystickOpen(i);
+ input::sdl_devices[i] = SDL_JoystickOpen(i);
std::string name = SDL_JoystickName(i);
if( name.find("Guitar Hero") != std::string::npos ) {
input::Private::devices[i] = input::Private::InputDevPrivate(input::GUITAR_GH);
@@ -116,18 +134,9 @@ void input::init() {
}
std::cout << "Id: " << i << std::endl;
std::cout << " Name: " << name << std::endl;
- // Here we should send an event to have correct state buttons
- unsigned int num_buttons = SDL_JoystickNumButtons(joystick);
- for( unsigned int j = 0 ; j < num_buttons ; ++j ) {
- SDL_Event event;
- event.type = SDL_JOYBUTTONDOWN;
- event.jbutton.type = SDL_JOYBUTTONDOWN;
- event.jbutton.which = i;
- event.jbutton.button = j;
- event.jbutton.state = SDL_PRESSED;
- input::pushEvent(event);
- }
}
+ // Here we should send an event to have correct state buttons
+ init_devices();
// compatibility with old joystick stuffs
for (input::Private::InputDevs::iterator it = input::Private::devices.begin() ; it != input::Private::devices.end() ; ++it) {
if( it->second.type() == GUITAR_GH || it->second.type() == DRUM_GH ) {
diff --git a/game/joystick.hh b/game/joystick.hh
index 7262d02..6b8d0ff 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -74,6 +74,10 @@ namespace input {
static const std::size_t BUTTONS = 6;
+ typedef std::map<unsigned int,SDL_Joystick*> SDL_devices;
+ extern SDL_devices sdl_devices;
+ void init_devices();
+
struct InputDevEvent {
enum Type { PRESS, RELEASE, PICK };
Type type;
@@ -106,6 +110,7 @@ namespace input {
bool assigned() {return m_assigned;};
bool pressed(int _button) {return m_pressed[_button];};
input::Type type() {return m_type;};
+ void setType(input::Type _type) {m_type=_type;init_devices();};
private:
std::deque<InputDevEvent> m_events;
bool m_assigned;
|
|
From: knittl <kn...@us...> - 2009-08-03 08:40:09
|
Module: performous
Branch: master
Commit: a6e4540d55d7509db31e5959e530f8f13bd15930
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Aug 1 14:09:51 2009 +0200
Merged toward a good InputDev implementation
---
game/joystick.cc | 29 +++++++++++++++++++++++++----
game/joystick.hh | 2 +-
game/main.cc | 1 +
3 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index 804c48e..7ab17e6 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -130,9 +130,7 @@ void input::init() {
}
void input::clear() {
// new stuffs
- for (input::Private::InputDevs::iterator it = input::Private::devices.begin() ; it != input::Private::devices.end() ; ++it) {
- it->second.clearEvents();
- }
+ // nothing to do here
// compatibility with old joystick stuffs
for(Joysticks::iterator it = joysticks.begin() ; it != joysticks.end() ; ++it ) {
it->second.clearEvents();
@@ -140,7 +138,30 @@ void input::clear() {
}
bool input::pushEvent(SDL_Event _e) {
// new stuffs
- // TODO
+ int joy_id;
+ using namespace input::Private;
+ switch(_e.type) {
+ case SDL_JOYAXISMOTION:
+ joy_id = _e.jaxis.which;
+ if( !devices[joy_id].assigned() ) break;
+ // do stuffs to devices[joy_id] events (PICK)
+ break;
+ case SDL_JOYHATMOTION:
+ joy_id = _e.jhat.which;
+ if( !devices[joy_id].assigned() ) break;
+ // do stuffs to devices[joy_id] events (PICK)
+ break;
+ case SDL_JOYBUTTONDOWN:
+ case SDL_JOYBUTTONUP:
+ joy_id = _e.jbutton.which;
+ // do stuffs to devices[joy_id] states (BUTTONS)
+ if( !devices[joy_id].assigned() ) break;
+ // do stuffs to devices[joy_id] events (BUTTONS)
+ break;
+ case SDL_JOYBALLMOTION:
+ default:
+ return false;
+ }
// compatibility with old joystick stuffs
switch(_e.type) {
case SDL_JOYAXISMOTION:
diff --git a/game/joystick.hh b/game/joystick.hh
index b62bc55..bc42d6a 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -91,7 +91,7 @@ namespace input {
void addEvent(InputDevEvent) {};
void clearEvents() {m_events.clear();};
void assign() {m_assigned = true;};
- void unassign() {m_assigned = false;};
+ void unassign() {m_assigned = false; clearEvents();};
bool assigned() {return m_assigned;};
bool pressed(int _button) {return m_pressed[_button];};
input::Type type() {return m_type;};
diff --git a/game/main.cc b/game/main.cc
index df9cc97..815142e 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -40,6 +40,7 @@ static void checkEvents_SDL(ScreenManager& sm, Window& window) {
static bool esc = false;
SDL_Event event;
// Clear input event first
+ // FIXME: onlyrequired for old Joystick compatibility
input::clear();
while(SDL_PollEvent(&event) == 1) {
// catch input event first
|
|
From: knittl <kn...@us...> - 2009-08-03 08:40:03
|
Module: performous
Branch: master
Commit: 376141d58e60d6913c44a84b13e7957766c8bf4e
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Aug 1 13:01:46 2009 +0200
Added a new stable InputDev version
---
game/joystick.cc | 77 +++++++++++++++++-------------------------------------
game/joystick.hh | 22 +++------------
2 files changed, 29 insertions(+), 70 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index 213284d..804c48e 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -5,61 +5,14 @@
Joysticks joysticks;
-Joystick::Joystick(unsigned int _id): m_id(_id) {
- if( getName().find("Guitar Hero") != std::string::npos ) {
- m_type = Joystick::GUITARHERO;
- } else if( getName().find("Harmonix") != std::string::npos ) {
- m_type = Joystick::ROCKBAND;
- } else {
- m_type = Joystick::UNKNOWN;
- }
-};
+Joystick::Joystick(Joystick::Type _type): m_type(_type) { }
+
Joystick::~Joystick() {
- // Do it another way :/
- //if(SDL_JoystickOpened(m_id)) SDL_JoystickClose(m_joystick);
-};
-std::string Joystick::getName() const {
- return std::string(SDL_JoystickName(m_id));
};
+
Joystick::Type Joystick::getType() const {
return m_type;
}
-bool Joystick::buttonState(unsigned char _button_id) const {
- return (SDL_JoystickGetButton(m_joystick, _button_id) != 0);
-};
-JoystickEvent::HatDirection Joystick::hat(unsigned char _hat_id) const {
- unsigned char direction = SDL_JoystickGetHat(m_joystick, _hat_id);
- switch(direction) {
- case SDL_HAT_LEFTUP:
- return JoystickEvent::LEFT_UP;
- case SDL_HAT_LEFT:
- return JoystickEvent::LEFT;
- case SDL_HAT_LEFTDOWN:
- return JoystickEvent::LEFT_DOWN;
- case SDL_HAT_UP:
- return JoystickEvent::UP;
- case SDL_HAT_CENTERED:
- return JoystickEvent::CENTERED;
- case SDL_HAT_DOWN:
- return JoystickEvent::DOWN;
- case SDL_HAT_RIGHTUP:
- return JoystickEvent::RIGHT_UP;
- case SDL_HAT_RIGHT:
- return JoystickEvent::RIGHT;
- case SDL_HAT_RIGHTDOWN:
- return JoystickEvent::RIGHT_DOWN;
- }
- // we should not go here
- return JoystickEvent::CENTERED;
-};
-short Joystick::axis(unsigned char _axis_id) const {
- return SDL_JoystickGetAxis(m_joystick, _axis_id);
-};
-std::pair<int, int> Joystick::ball(int _ball_id) const {
- int dx, dy;
- SDL_JoystickGetBall(m_joystick, _ball_id, &dx,&dy);
- return std::pair<int,int>(dx,dy);
-};
void Joystick::addEvent(SDL_JoyAxisEvent event) {
JoystickEvent joy_event(JoystickEvent::AXIS_MOTION);
@@ -69,6 +22,7 @@ void Joystick::addEvent(SDL_JoyAxisEvent event) {
m_events.push_back(joy_event);
}
+
void Joystick::addEvent(SDL_JoyBallEvent event) {
JoystickEvent joy_event(JoystickEvent::BALL_MOTION);
@@ -78,6 +32,7 @@ void Joystick::addEvent(SDL_JoyBallEvent event) {
m_events.push_back(joy_event);
}
+
void Joystick::addEvent(SDL_JoyHatEvent event) {
JoystickEvent joy_event(JoystickEvent::HAT_MOTION);
@@ -117,6 +72,7 @@ void Joystick::addEvent(SDL_JoyHatEvent event) {
m_events.push_back(joy_event);
}
+
void Joystick::addEvent(SDL_JoyButtonEvent event) {
JoystickEvent joy_event((event.type == SDL_JOYBUTTONDOWN) ? JoystickEvent::BUTTON_DOWN : JoystickEvent::BUTTON_UP);
@@ -124,6 +80,7 @@ void Joystick::addEvent(SDL_JoyButtonEvent event) {
joy_event.button_state = event.state;
m_events.push_back(joy_event);
+
}
bool Joystick::tryPollEvent(JoystickEvent& _event) {
if( m_events.empty() ) return false;
@@ -132,6 +89,7 @@ bool Joystick::tryPollEvent(JoystickEvent& _event) {
m_events.pop_front();
return true;
}
+
void Joystick::clearEvents() {
m_events.clear();
}
@@ -148,13 +106,26 @@ void input::init() {
for (unsigned int i = 0 ; i < nbjoysticks ; i++) {
SDL_JoystickOpen(i);
- input::Private::devices[i] = input::Private::InputDevPrivate();
+ std::string name = SDL_JoystickName(i);
+ if( name.find("Guitar Hero") != std::string::npos ) {
+ input::Private::devices[i] = input::Private::InputDevPrivate(input::GUITAR_GH);
+ } else if( name.find("Harmonix") != std::string::npos ) {
+ input::Private::devices[i] = input::Private::InputDevPrivate(input::GUITAR_RB);
+ } else {
+ input::Private::devices[i] = input::Private::InputDevPrivate();
+ }
std::cout << "Id: " << i << std::endl;
- std::cout << " Name: " << SDL_JoystickName(i) << std::endl;
+ std::cout << " Name: " << name << std::endl;
}
// compatibility with old joystick stuffs
for (input::Private::InputDevs::iterator it = input::Private::devices.begin() ; it != input::Private::devices.end() ; ++it) {
- joysticks[it->first] = Joystick(it->first);
+ if( it->second.type() == GUITAR_GH || it->second.type() == DRUM_GH ) {
+ joysticks[it->first] = Joystick(Joystick::GUITARHERO);
+ } else if( it->second.type() == GUITAR_GH || it->second.type() == DRUM_GH ) {
+ joysticks[it->first] = Joystick(Joystick::ROCKBAND);
+ } else {
+ joysticks[it->first] = Joystick();
+ }
}
}
void input::clear() {
diff --git a/game/joystick.hh b/game/joystick.hh
index 3e75435..8901241 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -41,14 +41,11 @@ class JoystickEvent {
class Joystick {
public:
enum Type {UNKNOWN, GUITARHERO, ROCKBAND};
- Joystick() {};
- /// create joystick object with given id
- Joystick(unsigned int _id);
+ /// create joystick object
+ Joystick(Joystick::Type _type = Joystick::UNKNOWN);
~Joystick();
/// Return joystick Type
Joystick::Type getType() const;
- /// get name of joystick
- std::string getName() const;
/// add an even from an SDL_JoyAxisEvent
void addEvent(SDL_JoyAxisEvent event);
/// add an even from an SDL_JoyBallEvent
@@ -61,18 +58,8 @@ class Joystick {
bool tryPollEvent(JoystickEvent& _event);
/// clear all the events
void clearEvents();
- /// returns button state (true if pressed, else false)
- bool buttonState(unsigned char _button_id) const;
- /// returns hi-hat state
- JoystickEvent::HatDirection hat(unsigned char _hat_id) const;
- /// returns axis state
- short axis(unsigned char _axis_id) const;
- /// returns ball state
- std::pair<int, int> ball(int _ball_id) const;
private:
- SDL_Joystick * m_joystick;
std::deque<JoystickEvent> m_events;
- unsigned int m_id;
Type m_type;
};
@@ -83,7 +70,7 @@ extern Joysticks joysticks;
* New input management, superseed all joysticks stuffs
*/
namespace input {
- enum Type {UNKNOWN, GUITAR, DRUM};
+ enum Type {UNKNOWN, GUITAR_RB, DRUM_RB, GUITAR_GH, DRUM_GH};
static const std::size_t BUTTONS = 6;
@@ -98,7 +85,7 @@ namespace input {
namespace Private {
class InputDevPrivate {
public:
- InputDevPrivate() : m_assigned(false), m_type(input::UNKNOWN) {};
+ InputDevPrivate(input::Type _type = input::UNKNOWN) : m_assigned(false), m_type(_type) {};
bool tryPoll(InputDevEvent&) {return true;};
void addEvent(InputDevEvent) {};
void clearEvents() {m_events.clear();};
@@ -107,6 +94,7 @@ namespace input {
void assign() {m_assigned = true;};
void unassign() {m_assigned = false;};
bool assigned() {return m_assigned;};
+ input::Type type() {return m_type;};
private:
std::deque<InputDevEvent> m_events;
bool m_assigned;
|
|
From: knittl <kn...@us...> - 2009-08-03 08:40:01
|
Module: performous
Branch: master
Commit: 68c975c9cb77eb8049caabe8e10089f50779dd56
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Aug 1 13:32:51 2009 +0200
Changed clear event position
---
game/joystick.hh | 1 +
game/main.cc | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/game/joystick.hh b/game/joystick.hh
index 0450cd8..b62bc55 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -87,6 +87,7 @@ namespace input {
public:
InputDevPrivate(input::Type _type = input::UNKNOWN) : m_assigned(false), m_type(_type) {};
bool tryPoll(InputDevEvent&) {return true;};
+ // this will modify the m_pressed member
void addEvent(InputDevEvent) {};
void clearEvents() {m_events.clear();};
void assign() {m_assigned = true;};
diff --git a/game/main.cc b/game/main.cc
index e5578f5..df9cc97 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -39,6 +39,8 @@ static void checkEvents_SDL(ScreenManager& sm, Window& window) {
}
static bool esc = false;
SDL_Event event;
+ // Clear input event first
+ input::clear();
while(SDL_PollEvent(&event) == 1) {
// catch input event first
if(!input::pushEvent(event)) {
@@ -81,7 +83,6 @@ static void checkEvents_SDL(ScreenManager& sm, Window& window) {
case GL_OUT_OF_MEMORY: std::cerr << "OpenGL error: invalid enum" << std::endl; break;
}
}
- input::clear();
if( config["graphic/fullscreen"].b() != window.getFullscreen() )
window.setFullscreen(config["graphic/fullscreen"].b());
}
|
|
From: knittl <kn...@us...> - 2009-08-03 08:39:59
|
Module: performous
Branch: master
Commit: 95c1aaa3caab99be5098b7758dcf90698511cce3
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Aug 1 13:25:30 2009 +0200
Fixed API
---
game/joystick.hh | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/game/joystick.hh b/game/joystick.hh
index 8901241..0450cd8 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -89,15 +89,15 @@ namespace input {
bool tryPoll(InputDevEvent&) {return true;};
void addEvent(InputDevEvent) {};
void clearEvents() {m_events.clear();};
- bool status(InputDevEvent::Type) {return false;}; // for buttons
- short value(InputDevEvent::Type) {return 0;}; // for axis
void assign() {m_assigned = true;};
void unassign() {m_assigned = false;};
bool assigned() {return m_assigned;};
+ bool pressed(int _button) {return m_pressed[_button];};
input::Type type() {return m_type;};
private:
std::deque<InputDevEvent> m_events;
bool m_assigned;
+ bool m_pressed[BUTTONS];
input::Type m_type;
};
@@ -107,14 +107,14 @@ namespace input {
class InputDev {
public:
- // Throw an exception if none is available
+ // First gives a correct instrument type
+ // Then gives an unknown instrument type
+ // Finally throw an exception if only wrong (or none) instrument are available
InputDev(input::Type) : m_device_id() {input::Private::devices[m_device_id].assign();};
~InputDev() {input::Private::devices[m_device_id].unassign();};
bool tryPoll(InputDevEvent& _e) {return input::Private::devices[m_device_id].tryPoll(_e);};
void addEvent(InputDevEvent _e) {input::Private::devices[m_device_id].addEvent(_e);};
- bool status(InputDevEvent::Type _t) {return input::Private::devices[m_device_id].status(_t);}; // for buttons
- short value(InputDevEvent::Type _t) {return input::Private::devices[m_device_id].value(_t);}; // for axis
- bool pressed[BUTTONS]; // Current state
+ bool pressed(int _button) {return input::Private::devices[m_device_id].pressed(_button);}; // Current state
private:
unsigned int m_device_id; // should be some kind of reference
};
|
|
From: knittl <kn...@us...> - 2009-08-03 08:39:58
|
Module: performous
Branch: master
Commit: a194165a0895eac4a2b99f9486ea47331621e207
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Aug 1 12:40:57 2009 +0200
Started new input device implementation (keeping joystick api compatibility)
Fixed manpage section
---
docs/CMakeLists.txt | 6 ++--
game/joystick.cc | 71 +++++++++++++++++++++++++++++++++-----------------
game/joystick.hh | 13 ++++-----
game/main.cc | 70 ++++++++++++++++++++-----------------------------
game/video_driver.cc | 6 +---
5 files changed, 87 insertions(+), 79 deletions(-)
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
index 4b99915..0a4269d 100644
--- a/docs/CMakeLists.txt
+++ b/docs/CMakeLists.txt
@@ -5,19 +5,19 @@ if(UNIX)
mark_as_advanced(HELP2MAN)
mark_as_advanced(GZIP)
if(HELP2MAN AND GZIP)
- set(MANFILE ${CMAKE_CURRENT_BINARY_DIR}/performous.1.gz)
+ set(MANFILE ${CMAKE_CURRENT_BINARY_DIR}/performous.6.gz)
set(H2MFILE ${CMAKE_CURRENT_SOURCE_DIR}/performous.h2m)
set(PERFORMOUS_EXEC ${CMAKE_BINARY_DIR}/game/performous)
add_custom_command(
OUTPUT ${MANFILE}
- COMMAND ${HELP2MAN} ${PERFORMOUS_EXEC} -i ${H2MFILE} -N | ${GZIP} > ${MANFILE}
+ COMMAND ${HELP2MAN} ${PERFORMOUS_EXEC} -s 6 -i ${H2MFILE} -N | ${GZIP} > ${MANFILE}
MAIN_DEPENDENCY ${H2MFILE}
DEPENDENCY ${PERFORMOUS_EXEC}
COMMENT "Building Performous man page"
VERBATIM
)
add_custom_target(manpage ALL DEPENDS ${MANFILE})
- install(FILES ${MANFILE} DESTINATION share/man/man1)
+ install(FILES ${MANFILE} DESTINATION share/man/man6)
else(HELP2MAN AND GZIP)
message("WARNING: Can't locate help2man or gzip; man pages will not be generated")
endif(HELP2MAN AND GZIP)
diff --git a/game/joystick.cc b/game/joystick.cc
index c030705..213284d 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -6,7 +6,6 @@
Joysticks joysticks;
Joystick::Joystick(unsigned int _id): m_id(_id) {
- m_joystick = SDL_JoystickOpen(m_id);
if( getName().find("Guitar Hero") != std::string::npos ) {
m_type = Joystick::GUITARHERO;
} else if( getName().find("Harmonix") != std::string::npos ) {
@@ -25,18 +24,6 @@ std::string Joystick::getName() const {
Joystick::Type Joystick::getType() const {
return m_type;
}
-std::string Joystick::getDescription() const {
- std::string desc;
- desc += "axes: ";
- desc += boost::lexical_cast<std::string>(SDL_JoystickNumAxes(m_joystick));
- desc += ", buttons: ";
- desc += boost::lexical_cast<std::string>(SDL_JoystickNumButtons(m_joystick));
- desc += ", balls: ";
- desc += boost::lexical_cast<std::string>(SDL_JoystickNumBalls(m_joystick));
- desc += ", hats: ";
- desc += boost::lexical_cast<std::string>(SDL_JoystickNumHats(m_joystick));
- return desc;
-};
bool Joystick::buttonState(unsigned char _button_id) const {
return (SDL_JoystickGetButton(m_joystick, _button_id) != 0);
};
@@ -149,21 +136,57 @@ void Joystick::clearEvents() {
m_events.clear();
}
-void joysticks_init() {
+/**
+ * New input management, superseed all joysticks stuffs
+ */
+input::Private::InputDevs input::Private::devices;
+
+void input::init() {
+ // new stuffs
unsigned int nbjoysticks = SDL_NumJoysticks();
std::cout << "Detecting " << nbjoysticks << " joysticks..." << std::endl;
for (unsigned int i = 0 ; i < nbjoysticks ; i++) {
- joysticks[i] = Joystick(i);
+ SDL_JoystickOpen(i);
+ input::Private::devices[i] = input::Private::InputDevPrivate();
std::cout << "Id: " << i << std::endl;
- std::cout << " Name: " << joysticks[i].getName() << std::endl;
- std::cout << " Description: " << joysticks[i].getDescription() << std::endl;
+ std::cout << " Name: " << SDL_JoystickName(i) << std::endl;
+ }
+ // compatibility with old joystick stuffs
+ for (input::Private::InputDevs::iterator it = input::Private::devices.begin() ; it != input::Private::devices.end() ; ++it) {
+ joysticks[it->first] = Joystick(it->first);
}
}
-
-/**
- * New input management, superseed all joysticks stuffs
- */
-void input::init() {}
-input::InputDev& input::assign(input::Type) {}
-bool input::pushEvent(SDL_Event) {return false;}
+void input::clear() {
+ // new stuffs
+ for (input::Private::InputDevs::iterator it = input::Private::devices.begin() ; it != input::Private::devices.end() ; ++it) {
+ it->second.clearEvents();
+ }
+ // compatibility with old joystick stuffs
+ for(Joysticks::iterator it = joysticks.begin() ; it != joysticks.end() ; ++it ) {
+ it->second.clearEvents();
+ }
+}
+bool input::pushEvent(SDL_Event _e) {
+ // new stuffs
+ // TODO
+ // compatibility with old joystick stuffs
+ switch(_e.type) {
+ case SDL_JOYAXISMOTION:
+ joysticks[_e.jaxis.which].addEvent(_e.jaxis);
+ break;
+ case SDL_JOYBALLMOTION:
+ joysticks[_e.jball.which].addEvent(_e.jball);
+ break;
+ case SDL_JOYHATMOTION:
+ joysticks[_e.jhat.which].addEvent(_e.jhat);
+ break;
+ case SDL_JOYBUTTONDOWN:
+ case SDL_JOYBUTTONUP:
+ joysticks[_e.jbutton.which].addEvent(_e.jbutton);
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
diff --git a/game/joystick.hh b/game/joystick.hh
index 1cbfa55..3e75435 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -11,8 +11,6 @@
#define PS3_DRUM_CONTROLLER_XXX 4
#define PS3_DRUM_CONTROLLER_ORANGE 5
-void joysticks_init();
-
class JoystickEvent {
public:
enum Type {BUTTON_DOWN, BUTTON_UP, HAT_MOTION, AXIS_MOTION, BALL_MOTION};
@@ -51,8 +49,6 @@ class Joystick {
Joystick::Type getType() const;
/// get name of joystick
std::string getName() const;
- /// get longer description of joystick
- std::string getDescription() const;
/// add an even from an SDL_JoyAxisEvent
void addEvent(SDL_JoyAxisEvent event);
/// add an even from an SDL_JoyBallEvent
@@ -102,15 +98,17 @@ namespace input {
namespace Private {
class InputDevPrivate {
public:
- InputDevPrivate() : m_assigned(false) {};
+ InputDevPrivate() : m_assigned(false), m_type(input::UNKNOWN) {};
bool tryPoll(InputDevEvent&) {return true;};
void addEvent(InputDevEvent) {};
+ void clearEvents() {m_events.clear();};
bool status(InputDevEvent::Type) {return false;}; // for buttons
short value(InputDevEvent::Type) {return 0;}; // for axis
void assign() {m_assigned = true;};
void unassign() {m_assigned = false;};
bool assigned() {return m_assigned;};
private:
+ std::deque<InputDevEvent> m_events;
bool m_assigned;
input::Type m_type;
};
@@ -121,6 +119,7 @@ namespace input {
class InputDev {
public:
+ // Throw an exception if none is available
InputDev(input::Type) : m_device_id() {input::Private::devices[m_device_id].assign();};
~InputDev() {input::Private::devices[m_device_id].unassign();};
bool tryPoll(InputDevEvent& _e) {return input::Private::devices[m_device_id].tryPoll(_e);};
@@ -134,8 +133,8 @@ namespace input {
// Initialize all event stuffs
void init();
- // Throw an exception if none is available
- InputDev& assign(input::Type);
+ // clear all event stuffs
+ void clear();
// Returns true if event is taken, feed an InputDev by transforming SDL_Event into InputDevEvent
bool pushEvent(SDL_Event);
};
diff --git a/game/main.cc b/game/main.cc
index cd05a20..e5578f5 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -40,46 +40,36 @@ static void checkEvents_SDL(ScreenManager& sm, Window& window) {
static bool esc = false;
SDL_Event event;
while(SDL_PollEvent(&event) == 1) {
- switch(event.type) {
- case SDL_QUIT:
- sm.finished();
- break;
- case SDL_VIDEORESIZE:
- window.resize(event.resize.w, event.resize.h);
- break;
- case SDL_JOYAXISMOTION:
- joysticks[event.jaxis.which].addEvent(event.jaxis);
- break;
- case SDL_JOYBALLMOTION:
- joysticks[event.jball.which].addEvent(event.jball);
- break;
- case SDL_JOYHATMOTION:
- joysticks[event.jhat.which].addEvent(event.jhat);
- break;
- case SDL_JOYBUTTONDOWN:
- case SDL_JOYBUTTONUP:
- joysticks[event.jbutton.which].addEvent(event.jbutton);
- break;
- case SDL_KEYUP:
- if (event.key.keysym.sym == SDLK_ESCAPE) esc = false;
- break;
- case SDL_KEYDOWN:
- int keypressed = event.key.keysym.sym;
- SDLMod modifier = event.key.keysym.mod;
- // Workaround for key repeat on escape
- if (keypressed == SDLK_ESCAPE) {
- if (esc) return;
- esc = true;
- }
- if (keypressed == SDLK_RETURN && modifier & KMOD_ALT ) {
- config["graphic/fullscreen"].b() = !config["graphic/fullscreen"].b();
- continue; // Already handled here...
- }
- if (keypressed == SDLK_F4 && modifier & KMOD_ALT) {
+ // catch input event first
+ if(!input::pushEvent(event)) {
+ switch(event.type) {
+ case SDL_QUIT:
sm.finished();
- continue; // Already handled here...
+ break;
+ case SDL_VIDEORESIZE:
+ window.resize(event.resize.w, event.resize.h);
+ break;
+ case SDL_KEYUP:
+ if (event.key.keysym.sym == SDLK_ESCAPE) esc = false;
+ break;
+ case SDL_KEYDOWN:
+ int keypressed = event.key.keysym.sym;
+ SDLMod modifier = event.key.keysym.mod;
+ // Workaround for key repeat on escape
+ if (keypressed == SDLK_ESCAPE) {
+ if (esc) return;
+ esc = true;
+ }
+ if (keypressed == SDLK_RETURN && modifier & KMOD_ALT ) {
+ config["graphic/fullscreen"].b() = !config["graphic/fullscreen"].b();
+ continue; // Already handled here...
+ }
+ if (keypressed == SDLK_F4 && modifier & KMOD_ALT) {
+ sm.finished();
+ continue; // Already handled here...
+ }
+ break;
}
- break;
}
sm.getCurrentScreen()->manageEvent(event);
switch(glGetError()) {
@@ -91,9 +81,7 @@ static void checkEvents_SDL(ScreenManager& sm, Window& window) {
case GL_OUT_OF_MEMORY: std::cerr << "OpenGL error: invalid enum" << std::endl; break;
}
}
- for(Joysticks::iterator it = joysticks.begin() ; it != joysticks.end() ; ++it ) {
- it->second.clearEvents();
- }
+ input::clear();
if( config["graphic/fullscreen"].b() != window.getFullscreen() )
window.setFullscreen(config["graphic/fullscreen"].b());
}
diff --git a/game/video_driver.cc b/game/video_driver.cc
index c93b955..b1edfe2 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -29,12 +29,10 @@ Window::Window(unsigned int width, unsigned int height, int fs, unsigned int fs_
SDL_ShowCursor(SDL_DISABLE);
SDL_EnableUNICODE(SDL_ENABLE);
SDL_EnableKeyRepeat(80, 80);
- joysticks_init();
+ input::init();
}
-Window::~Window() {
- joysticks.clear();
-}
+Window::~Window() { }
void Window::blank() {
glClear(GL_COLOR_BUFFER_BIT);
|
|
From: knittl <kn...@us...> - 2009-08-03 08:39:55
|
Module: performous Branch: master Commit: 4b80466f6680c00831b8a834cce7181add00bdb6 Author: Lasse Karkkainen <tro...@tr...> Date: Sat Aug 1 12:57:50 2009 +0300 Document InputDev button numbers. --- docs/instruments.txt | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/docs/instruments.txt b/docs/instruments.txt index d8cbb23..65bdeea 100644 --- a/docs/instruments.txt +++ b/docs/instruments.txt @@ -68,3 +68,22 @@ Ex: A5- => SDL axis 4 with negative value BEND: A3+ PICK DOWN: A6+ PICK UP: A6- + + +Performous InputDev button numbers +---------------------------------- + +drums: +0 = kick +1 = red +2 = yellow +3 = blue +4 = green (also orange of GHWT drums) + +guitar: +0 = green +1 = red +2 = yellow +3 = blue +4 = orange + |
|
From: knittl <kn...@us...> - 2009-08-03 08:39:53
|
Module: performous
Branch: master
Commit: 768f19b467b2c036041d8f995f123717539339ae
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Aug 1 11:34:51 2009 +0200
Added some Input Event stuffs
---
game/joystick.cc | 1 +
game/joystick.hh | 27 +++++++++++++++++----------
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index 9ed995d..c030705 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -164,5 +164,6 @@ void joysticks_init() {
/**
* New input management, superseed all joysticks stuffs
*/
+void input::init() {}
input::InputDev& input::assign(input::Type) {}
bool input::pushEvent(SDL_Event) {return false;}
diff --git a/game/joystick.hh b/game/joystick.hh
index 11659a1..c0c25ef 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -90,20 +90,24 @@ namespace input {
enum Type {UNKNOWN, GUITAR, DRUM};
struct InputDevEvent {
- enum Type {GREEN, RED, YELLOW, BLUE, ORANGE, KICK, PICK, WHAMMY};
+ enum Type {GREEN, RED, YELLOW, BLUE, ORANGE, KICK, PICK, WHAMMY, TYPE_SIZE};
Type type;
- bool pressed; // for buttons
- short value; // for axis
+ bool pressed[TYPE_SIZE]; // for buttons
+ short value[TYPE_SIZE]; // for axis
+
};
namespace Private {
class InputDevPrivate {
public:
- InputDevPrivate() {};
+ InputDevPrivate() : m_assigned(false) {};
bool tryPoll(InputDevEvent&) {return true;};
void addEvent(InputDevEvent) {};
bool status(InputDevEvent::Type) {return false;}; // for buttons
short value(InputDevEvent::Type) {return 0;}; // for axis
+ void assign() {m_assigned = true;};
+ void unassign() {m_assigned = false;};
+ bool assigned() {return m_assigned;};
private:
bool m_assigned;
input::Type m_type;
@@ -115,15 +119,18 @@ namespace input {
class InputDev {
public:
- InputDev(input::Private::InputDevPrivate& _device):m_device(_device) {};
- bool tryPoll(InputDevEvent& _e) {return m_device.tryPoll(_e);};
- void addEvent(InputDevEvent _e) {m_device.addEvent(_e);};
- bool status(InputDevEvent::Type _t) {return m_device.status(_t);}; // for buttons
- short value(InputDevEvent::Type _t) {return m_device.value(_t);}; // for axis
+ InputDev(input::Type) : m_device_id() {input::Private::devices[m_device_id].assign();};
+ ~InputDev() {input::Private::devices[m_device_id].unassign();};
+ bool tryPoll(InputDevEvent& _e) {return input::Private::devices[m_device_id].tryPoll(_e);};
+ void addEvent(InputDevEvent _e) {input::Private::devices[m_device_id].addEvent(_e);};
+ bool status(InputDevEvent::Type _t) {return input::Private::devices[m_device_id].status(_t);}; // for buttons
+ short value(InputDevEvent::Type _t) {return input::Private::devices[m_device_id].value(_t);}; // for axis
private:
- input::Private::InputDevPrivate& m_device;
+ unsigned int m_device_id; // should be some kind of reference
};
+ // Initialize all event stuffs
+ void init();
// Throw an exception if none is available
InputDev& assign(input::Type);
// Returns true if event is taken, feed an InputDev by transforming SDL_Event into InputDevEvent
|
|
From: knittl <kn...@us...> - 2009-08-03 08:39:53
|
Module: performous
Branch: master
Commit: ca3b30cbeed6be14dd2959af91112e361f7920c9
Author: Lasse Karkkainen <tro...@tr...>
Date: Sat Aug 1 12:48:17 2009 +0300
Drafting InputDev API.
---
game/joystick.hh | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/game/joystick.hh b/game/joystick.hh
index c0c25ef..1cbfa55 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -89,12 +89,14 @@ extern Joysticks joysticks;
namespace input {
enum Type {UNKNOWN, GUITAR, DRUM};
+ static const std::size_t BUTTONS = 6;
+
struct InputDevEvent {
- enum Type {GREEN, RED, YELLOW, BLUE, ORANGE, KICK, PICK, WHAMMY, TYPE_SIZE};
+ enum Type { PRESS, RELEASE, PICK };
Type type;
- bool pressed[TYPE_SIZE]; // for buttons
- short value[TYPE_SIZE]; // for axis
-
+ 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
+ // More stuff later, when it is actually used
};
namespace Private {
@@ -125,6 +127,7 @@ namespace input {
void addEvent(InputDevEvent _e) {input::Private::devices[m_device_id].addEvent(_e);};
bool status(InputDevEvent::Type _t) {return input::Private::devices[m_device_id].status(_t);}; // for buttons
short value(InputDevEvent::Type _t) {return input::Private::devices[m_device_id].value(_t);}; // for axis
+ bool pressed[BUTTONS]; // Current state
private:
unsigned int m_device_id; // should be some kind of reference
};
|
|
From: knittl <kn...@us...> - 2009-08-03 08:39:50
|
Module: performous
Branch: master
Commit: 5242395bd81f9ebd0228b03892f50caec9037de4
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Aug 1 11:16:53 2009 +0200
New API for event
---
game/joystick.cc | 2 +-
game/joystick.hh | 35 ++++++++++++++++++++++++-----------
2 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index 5693be7..9ed995d 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -164,5 +164,5 @@ void joysticks_init() {
/**
* New input management, superseed all joysticks stuffs
*/
-void input::assign(InputDev&, input::Type) {}
+input::InputDev& input::assign(input::Type) {}
bool input::pushEvent(SDL_Event) {return false;}
diff --git a/game/joystick.hh b/game/joystick.hh
index 2f18fc6..11659a1 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -95,24 +95,37 @@ namespace input {
bool pressed; // for buttons
short value; // for axis
};
+
+ namespace Private {
+ class InputDevPrivate {
+ public:
+ InputDevPrivate() {};
+ bool tryPoll(InputDevEvent&) {return true;};
+ void addEvent(InputDevEvent) {};
+ bool status(InputDevEvent::Type) {return false;}; // for buttons
+ short value(InputDevEvent::Type) {return 0;}; // for axis
+ private:
+ bool m_assigned;
+ input::Type m_type;
+ };
+
+ typedef std::map<unsigned int,InputDevPrivate> InputDevs;
+ extern InputDevs devices;
+ }
class InputDev {
public:
- InputDev() {};
- bool tryPoll(InputDevEvent&) {return true;};
- void addEvent(InputDevEvent) {};
- bool status(InputDevEvent::Type) {return false;}; // for buttons
- short value(InputDevEvent::Type) {return 0;}; // for axis
+ InputDev(input::Private::InputDevPrivate& _device):m_device(_device) {};
+ bool tryPoll(InputDevEvent& _e) {return m_device.tryPoll(_e);};
+ void addEvent(InputDevEvent _e) {m_device.addEvent(_e);};
+ bool status(InputDevEvent::Type _t) {return m_device.status(_t);}; // for buttons
+ short value(InputDevEvent::Type _t) {return m_device.value(_t);}; // for axis
private:
- bool m_assigned;
- input::Type m_type;
+ input::Private::InputDevPrivate& m_device;
};
- typedef std::map<unsigned int,InputDev> InputDevs;
- extern InputDevs devices;
-
// Throw an exception if none is available
- void assign(InputDev&, input::Type);
+ InputDev& assign(input::Type);
// Returns true if event is taken, feed an InputDev by transforming SDL_Event into InputDevEvent
bool pushEvent(SDL_Event);
};
|
|
From: knittl <kn...@us...> - 2009-08-03 08:39:48
|
Module: performous
Branch: master
Commit: b13e8fd4d7f1779f6bd823a838e430c657430ddd
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Aug 1 10:56:49 2009 +0200
Added new input device API
---
game/joystick.cc | 6 ++++++
game/joystick.hh | 44 ++++++++++++++++++++++++++++++++------------
2 files changed, 38 insertions(+), 12 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index 21bdcb6..5693be7 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -160,3 +160,9 @@ void joysticks_init() {
std::cout << " Description: " << joysticks[i].getDescription() << std::endl;
}
}
+
+/**
+ * New input management, superseed all joysticks stuffs
+ */
+void input::assign(InputDev&, input::Type) {}
+bool input::pushEvent(SDL_Event) {return false;}
diff --git a/game/joystick.hh b/game/joystick.hh
index 1dc5201..2f18fc6 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -83,17 +83,37 @@ class Joystick {
typedef std::map<unsigned int,Joystick> Joysticks;
extern Joysticks joysticks;
-class InputDevEvent {
- public:
- InputDevEvent() {};
-};
+/**
+ * New input management, superseed all joysticks stuffs
+ */
+namespace input {
+ enum Type {UNKNOWN, GUITAR, DRUM};
-class InputDev {
- public:
- InputDev() {};
- bool tryPoll(InputDevEvent& _event) {(void)_event;return true;};
- bool fret(unsigned int _id) {(void)_id;return false;};
- // reserved for feeding the device with event
- void addEvent(SDL_JoyButtonEvent _event) {(void)_event;};
- private:
+ struct InputDevEvent {
+ enum Type {GREEN, RED, YELLOW, BLUE, ORANGE, KICK, PICK, WHAMMY};
+ Type type;
+ bool pressed; // for buttons
+ short value; // for axis
+ };
+
+ class InputDev {
+ public:
+ InputDev() {};
+ bool tryPoll(InputDevEvent&) {return true;};
+ void addEvent(InputDevEvent) {};
+ bool status(InputDevEvent::Type) {return false;}; // for buttons
+ short value(InputDevEvent::Type) {return 0;}; // for axis
+ private:
+ bool m_assigned;
+ input::Type m_type;
+ };
+
+ typedef std::map<unsigned int,InputDev> InputDevs;
+ extern InputDevs devices;
+
+ // Throw an exception if none is available
+ void assign(InputDev&, input::Type);
+ // Returns true if event is taken, feed an InputDev by transforming SDL_Event into InputDevEvent
+ bool pushEvent(SDL_Event);
};
+
|
|
From: knittl <kn...@us...> - 2009-08-03 08:39:47
|
Module: performous Branch: master Commit: 75f8cf567d81ec30ee8896cb38993b851c85c171 Author: Lasse Karkkainen <tro...@tr...> Date: Sat Aug 1 10:47:50 2009 +0300 Most stuff rewritten with chords. Drums still use old logic. Visuals for tappable notes. Almost perfect hammering logic. --- game/guitargraph.cc | 165 ++++++++++++++++++++++-------------------------- game/guitargraph.hh | 30 +++++++-- themes/default/tap.svg | 114 +++++++++++++++++++++++++++++++++ 3 files changed, 214 insertions(+), 95 deletions(-) |
|
From: knittl <kn...@us...> - 2009-08-03 08:39:45
|
Module: performous
Branch: master
Commit: b01db5d540f8ebe69e6680cf53143efdfedb8401
Author: Lasse Karkkainen <tro...@tr...>
Date: Fri Jul 31 23:23:40 2009 +0300
Making chords.
---
game/guitargraph.cc | 41 +++++++++++++++++++++++++++++++++++++++++
game/guitargraph.hh | 8 ++++++--
2 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 098030d..9d847b3 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -332,3 +332,44 @@ void GuitarGraph::drawBar(double time, float h) {
glVertex2f(2.5f, time2y(time - h));
}
+void GuitarGraph::updateChords() {
+ m_chords.clear();
+ Durations::size_type pos[5] = {}, size[5] = {};
+ Durations const* durations[5] = {};
+ for (int fret = 0; fret < 5; ++fret) {
+ NoteMap const& nm = m_song.tracks[m_instrument].nm;
+ int basepitch = diffv[m_level].basepitch;
+ NoteMap::const_iterator it = nm.find(basepitch + fret);
+ if (it == nm.end()) continue;
+ durations[fret] = &it->second;
+ }
+ while (true) {
+ // Find the earliest
+ double t = getInf();
+ for (int fret = 0; fret < 5; ++fret) {
+ if (pos[fret] == size[fret]) continue;
+ Durations const& dur = *durations[fret];
+ t = std::min(t, dur[pos[fret]].begin);
+ }
+ // Quit processing if none were left
+ if (t == getInf()) break;
+ // Construct a chord
+ Chord c;
+ c.begin = t;
+ for (int fret = 0; fret < 5; ++fret) {
+ if (pos[fret] == size[fret]) continue;
+ Durations const& dur = *durations[fret];
+ Duration const& d = dur[pos[fret]++];
+ if (d.begin > t) continue;
+ c.fret[fret] = true;
+ c.dur[fret] = &d;
+ ++c.polyphony;
+ }
+ if (c.polyphony == 1) {
+ c.tappable = true;
+ if (m_chords.empty() || m_chords.back() == c) c.tappable = false;
+ }
+ m_chords.push_back(c);
+ }
+}
+
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
index eb79a25..a7ce016 100644
--- a/game/guitargraph.hh
+++ b/game/guitargraph.hh
@@ -13,10 +13,14 @@ struct Chord {
double begin;
bool fret[5];
Duration const* dur[5];
- bool chord;
+ int polyphony;
bool tappable;
bool tapped;
int tapScore;
+ Chord(): begin(), polyphony(), tappable(), tapped(), tapScore() {
+ std::fill(fret, fret + 5, false);
+ std::fill(dur, dur + 5, static_cast<Duration const*>(NULL));
+ }
};
static inline bool operator==(Chord const& a, Chord const& b) {
@@ -53,7 +57,7 @@ class GuitarGraph {
void difficultyAuto();
bool difficulty(Difficulty level);
SvgTxtTheme m_text;
- void updateChords() {}
+ void updateChords();
std::vector<Chord> m_chords;
typedef std::map<Duration const*, int> NoteStatus;
NoteStatus m_notes;
|
|
From: knittl <kn...@us...> - 2009-08-03 08:39:44
|
Module: performous
Branch: master
Commit: cbeff9c5671d3570ff3cd562c89fda03a03efc16
Author: Vincent Le Ligeour <yo...@us...>
Date: Fri Jul 31 19:58:13 2009 +0200
Fixed GHWT drumkit button mapping
---
game/guitargraph.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 3788cdc..098030d 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -47,7 +47,7 @@ void GuitarGraph::inputProcess() {
if (b >= 6) continue;
static const int inputmap[][6] = {
{ 2, 0, 1, 3, 4, 0 }, // Guitar Hero guitar
- { 0, 0, 0, 0, 0, 0 }, // Guitar Hero drums (FIXME)
+ { 3, 4, 1, 2, 0, 4 }, // Guitar Hero drums
{ 3, 0, 1, 2, 4, 0 }, // Rock Band guitar
{ 3, 4, 1, 2, 0, 0 } // Rock Band drums
};
|
|
From: knittl <kn...@us...> - 2009-08-03 08:39:43
|
Module: performous
Branch: master
Commit: baf0f4fd8d057af44707e6d451347e7eda4b357b
Author: Lasse Karkkainen <tro...@tr...>
Date: Fri Jul 31 20:09:20 2009 +0300
New instrument button mapping.
---
game/guitargraph.cc | 21 ++++++++++-----------
1 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 987e5d9..3788cdc 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -44,17 +44,15 @@ void GuitarGraph::inputProcess() {
if (ev.type == JoystickEvent::AXIS_MOTION && ev.axis_id == 5 && ev.axis_value != 0) picked = true;
if (ev.type != JoystickEvent::BUTTON_DOWN && ev.type != JoystickEvent::BUTTON_UP) continue;
unsigned b = ev.button_id;
- if (b >= 5) continue;
- static const int gh[] = { 2, 0, 1, 3, 4 };
- static const int rb[] = { 3, 0, 1, 2, 4 };
- int button = (it->second.getType() == Joystick::ROCKBAND ? rb : gh)[b];
- if (m_drums) {
- if (button == 0) button = 4;
- else if (button == 4) button = 0;
- if (ev.type == JoystickEvent::BUTTON_DOWN) {
- if (button == 0) m_pickValue.setValue(1.0);
- }
- }
+ if (b >= 6) continue;
+ static const int inputmap[][6] = {
+ { 2, 0, 1, 3, 4, 0 }, // Guitar Hero guitar
+ { 0, 0, 0, 0, 0, 0 }, // Guitar Hero drums (FIXME)
+ { 3, 0, 1, 2, 4, 0 }, // Rock Band guitar
+ { 3, 4, 1, 2, 0, 0 } // Rock Band drums
+ };
+ int instrument = 2 * (it->second.getType() == Joystick::ROCKBAND) + m_drums;
+ int button = inputmap[instrument][b];
fretPressed[button] = (ev.type == JoystickEvent::BUTTON_DOWN);
if (fretPressed[button]) fretHit[button] = true;
}
@@ -62,6 +60,7 @@ void GuitarGraph::inputProcess() {
}
void GuitarGraph::engine(double time) {
+ if (m_drums && fretHit[0]) m_pickValue.setValue(1.0);
if (time < -0.5) {
if (picked) {
if (fretPressed[4]) {
|
|
From: knittl <kn...@us...> - 2009-08-03 08:39:40
|
Module: performous Branch: master Commit: a7c6f3f5e2f1e3643cd6d57e814637fc77dbf2ed Author: Lasse Karkkainen <tro...@tr...> Date: Fri Jul 31 19:12:35 2009 +0300 New drumboard. --- themes/default/drumneck.svg | 261 +++++++++++++++++++++++++++++++++++-------- 1 files changed, 212 insertions(+), 49 deletions(-) |
|
From: knittl <kn...@us...> - 2009-08-03 08:39:39
|
Module: performous Branch: master Commit: 1c8e8e2cb70b3027e9799a8ad50f929ba7378018 Author: Lasse Karkkainen <tro...@tr...> Date: Fri Jul 31 18:36:48 2009 +0300 Merge branch 'master' of ssh://tronic@performous.git.sourceforge.net/gitroot/performous --- |
|
From: knittl <kn...@us...> - 2009-08-03 08:39:37
|
Module: performous
Branch: master
Commit: 77a31d239c1388f2bc0ddce6cec900025d49233a
Author: Lasse Karkkainen <tro...@tr...>
Date: Fri Jul 31 13:21:04 2009 +0300
Initial work on the chord-based guitar engine.
---
game/guitargraph.cc | 1 +
game/guitargraph.hh | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index fe43bbb..987e5d9 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -202,6 +202,7 @@ bool GuitarGraph::difficulty(Difficulty level) {
for (int fret = 0; fret < 5; ++fret) if (nm.find(basepitch + fret) == nm.end()) ++fail;
if (fail == 5) return false;
m_level = level;
+ updateChords();
return true;
}
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
index 32bb160..eb79a25 100644
--- a/game/guitargraph.hh
+++ b/game/guitargraph.hh
@@ -9,6 +9,20 @@
class Song;
+struct Chord {
+ double begin;
+ bool fret[5];
+ Duration const* dur[5];
+ bool chord;
+ bool tappable;
+ bool tapped;
+ int tapScore;
+};
+
+static inline bool operator==(Chord const& a, Chord const& b) {
+ return std::equal(a.fret, a.fret + 5, b.fret);
+}
+
/// handles drawing of notes and waves
class GuitarGraph {
public:
@@ -39,6 +53,8 @@ class GuitarGraph {
void difficultyAuto();
bool difficulty(Difficulty level);
SvgTxtTheme m_text;
+ void updateChords() {}
+ std::vector<Chord> m_chords;
typedef std::map<Duration const*, int> NoteStatus;
NoteStatus m_notes;
bool m_hammerReady;
|
|
From: knittl <kn...@us...> - 2009-08-03 08:39:36
|
Module: performous
Branch: master
Commit: 9f92443635116d999b6361a433be7044bb16fdd7
Author: Lasse Karkkainen <tro...@tr...>
Date: Fri Jul 31 09:28:17 2009 +0300
Basic hammering support, not very good, but code needs cleanup now.
---
game/guitargraph.cc | 69 ++++++++++++++++++++++++++++++++++-----------------
game/guitargraph.hh | 1 +
2 files changed, 47 insertions(+), 23 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 8d32158..fe43bbb 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -26,7 +26,7 @@ namespace {
bool picked = false;
}
-GuitarGraph::GuitarGraph(Song const& song): m_song(song), m_button("button.svg"), m_pickValue(0.0, 5.0), m_drums(), m_instrument(), m_level(), m_text(getThemePath("sing_timetxt.svg"), config["graphic/text_lod"].f()), m_score() {
+GuitarGraph::GuitarGraph(Song const& song): m_song(song), m_button("button.svg"), m_pickValue(0.0, 5.0), m_drums(), m_instrument(), m_level(), m_text(getThemePath("sing_timetxt.svg"), config["graphic/text_lod"].f()), m_hammerReady(), m_score() {
std::size_t tracks = m_song.tracks.size();
if (tracks == 0) throw std::runtime_error("No tracks");
m_necks.push_back(new Texture("guitarneck.svg"));
@@ -103,14 +103,24 @@ void GuitarGraph::engine(double time) {
if (tolerance < 0.1) m_score += 15;
if (tolerance < 0.05) m_score += 15;
if (tolerance < 0.03) m_score += 5;
- m_notes[d] = 1;
+ m_notes[d] = 2;
}
if (m_score < 0) m_score = 0;
return;
}
- if (!picked) return; // TODO: hammering etc. later, remove this
+ int hammerFret = -1;
+ if (!picked) {
+ if (!m_hammerReady) return;
+ // Check if exactly one fret is hammered
+ for (int fret = 0; fret < 5; ++fret) {
+ if (!fretHit[fret]) continue;
+ if (hammerFret != -1) return;
+ hammerFret = fret;
+ }
+ if (hammerFret == -1) return;
+ }
m_pickValue.setValue(1.0);
- for (NoteStatus::iterator it = m_notes.begin(); it != m_notes.end(); ++it) if (it->second == 1) it->second = 2;
+ // FIXME: Replace with hold code for (NoteStatus::iterator it = m_notes.begin(); it != m_notes.end(); ++it) if (it->second == 1) it->second = 2;
Duration const* dIt[5] = {};
double begin = getNaN();
double tolerance = 0.2;
@@ -141,26 +151,39 @@ void GuitarGraph::engine(double time) {
need[fret] = true;
++count;
}
- bool shadowed = (count == 1); // If the chord only requires one fret, frets on the left side of that are "shadowed" (ignored)
- bool fail = false;
- for (int fret = 0; fret < 5 && !fail; ++fret) {
- if (need[fret] && !fretPressed[fret]) { fail = true; break; } // Fret missing
- if (need[fret]) shadowed = false;
- if (!shadowed && fretPressed[fret] && !need[fret]) { fail = true; break; } // Pressing non-shadowed fret that is not needed
- }
- if (fail) {
- m_score -= 100.0;
- if (m_score < 0) m_score = 0;
- } else {
- // Successful pick, mark and score it so
- for (int fret = 0; fret < 5; ++fret) {
- if (!need[fret]) continue;
- m_notes[dIt[fret]] = 1;
- m_score += 15;
- if (tolerance < 0.1) m_score += 15;
- if (tolerance < 0.05) m_score += 15;
- if (tolerance < 0.03) m_score += 5;
+ m_hammerReady = false;
+ if (picked) {
+ // Regular pick handling
+ bool shadowed = (count == 1); // If the chord only requires one fret, frets on the left side of that are "shadowed" (ignored)
+ bool fail = false;
+ for (int fret = 0; fret < 5 && !fail; ++fret) {
+ if (need[fret] && !fretPressed[fret]) { fail = true; break; } // Fret missing
+ if (need[fret]) shadowed = false;
+ if (!shadowed && fretPressed[fret] && !need[fret]) { fail = true; break; } // Pressing non-shadowed fret that is not needed
}
+ if (fail) {
+ m_score -= 100.0;
+ if (m_score < 0) m_score = 0;
+ } else {
+ // Successful pick, mark and score it so
+ for (int fret = 0; fret < 5; ++fret) {
+ if (!need[fret]) continue;
+ m_notes[dIt[fret]] = 2;
+ m_score += 15;
+ if (tolerance < 0.1) m_score += 15;
+ if (tolerance < 0.05) m_score += 15;
+ if (tolerance < 0.03) m_score += 5;
+ }
+ m_hammerReady = true;
+ }
+ } else {
+ // Hammering
+ if (count != 1 || !need[hammerFret] || tolerance > 0.1) return;
+ m_notes[dIt[hammerFret]] = 1;
+ m_score += 30;
+ if (tolerance < 0.05) m_score += 15;
+ if (tolerance < 0.03) m_score += 5;
+ m_hammerReady = true;
}
}
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
index 17b37c4..32bb160 100644
--- a/game/guitargraph.hh
+++ b/game/guitargraph.hh
@@ -41,6 +41,7 @@ class GuitarGraph {
SvgTxtTheme m_text;
typedef std::map<Duration const*, int> NoteStatus;
NoteStatus m_notes;
+ bool m_hammerReady;
int m_score;
};
|
|
From: knittl <kn...@us...> - 2009-08-03 08:39:35
|
Module: performous
Branch: master
Commit: f2898c5e6ed13a80377043d161c2a7ba7c4f2be8
Author: Lasse Karkkainen <tro...@tr...>
Date: Fri Jul 31 07:49:25 2009 +0300
Increase GF compatibility.
---
game/guitargraph.cc | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index fe172b9..8d32158 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -17,7 +17,10 @@ namespace {
const float texCoordStep = -0.5f; // Two beat lines per neck texture => 0.5 tex units per beat
// Note: t is difference from playback time so it must be in range [past, future]
float time2y(float t) { return -timescale * (t - past) / (future - past); }
- float time2a(float t) { return 1.0f - t / future; } // Note: we want 1.0 alpha already at zero t.
+ float time2a(float t) {
+ float a = clamp(1.0 - t / future); // Note: we want 1.0 alpha already at zero t.
+ return std::pow(a, 0.8); // Nicer curve
+ }
bool fretPressed[5] = {};
bool fretHit[5] = {};
bool picked = false;
|