|
From: Yoda-JM <yo...@us...> - 2009-08-13 21:31:35
|
Module: performous
Branch: master
Commit: 3ef0d3add973fec5a743d3abfa6788dc303c69ef
Author: Vincent Le Ligeour <yo...@us...>
Date: Thu Aug 13 23:29:39 2009 +0200
Fixed joystick/keyboard config
---
game/joystick.cc | 16 ++++++----------
game/joystick.hh | 2 ++
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index f9cdcca..7a89245 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -163,14 +163,10 @@ void input::SDL::init() {
// Here we should send an event to have correct state buttons
init_devices();
// Adding keyboard instrument
- if( config["game/keyboard_guitar"].b() ) {
- std::cout << "Id: " << UINT_MAX << std::endl;
- std::cout << " Name: Keyboard (emulated guitar)" << std::endl;
- input::SDL::sdl_devices[UINT_MAX] = NULL;
- input::Private::devices[UINT_MAX] = input::Private::InputDevPrivate(input::Private::GUITAR_GH);
- } else {
- std::cout << "Keyboard as guitar disable" << std::endl;
- }
+ std::cout << "Id: " << input::Private::KEYBOARD_ID << std::endl;
+ std::cout << " Name: Keyboard (emulated guitar): " << (config["game/keyboard_guitar"].b() ? "disabled":"enabled") << std::endl;
+ input::SDL::sdl_devices[input::Private::KEYBOARD_ID] = NULL;
+ input::Private::devices[input::Private::KEYBOARD_ID] = input::Private::InputDevPrivate(input::Private::GUITAR_GH);
}
bool input::SDL::pushEvent(SDL_Event _e) {
@@ -184,7 +180,7 @@ bool input::SDL::pushEvent(SDL_Event _e) {
case SDL_KEYDOWN: {
if( !config["game/keyboard_guitar"].b() ) return false;
int button = 0;
- joy_id = UINT_MAX;
+ joy_id = input::Private::KEYBOARD_ID;
if(!devices[joy_id].assigned()) return false;
switch(_e.key.keysym.sym) {
case SDLK_RETURN:
@@ -233,7 +229,7 @@ bool input::SDL::pushEvent(SDL_Event _e) {
case SDL_KEYUP: {
if( !config["game/keyboard_guitar"].b() ) return false;
int button = 0;
- joy_id = UINT_MAX;
+ joy_id = input::Private::KEYBOARD_ID;
if(!devices[joy_id].assigned()) return false;
switch(_e.key.keysym.sym) {
case SDLK_RETURN: pickPressed[0] = false; return true;
diff --git a/game/joystick.hh b/game/joystick.hh
index e7260f7..3d51591 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -19,6 +19,7 @@ namespace input {
namespace Private {
enum Type {GUITAR_RB, DRUMS_RB, GUITAR_GH, DRUMS_GH};
+ static unsigned int KEYBOARD_ID = UINT_MAX;
class InputDevPrivate {
public:
InputDevPrivate() : m_assigned(false), m_type(input::Private::DRUMS_GH) {
@@ -94,6 +95,7 @@ namespace input {
std::cout << "Request acquiring GUITAR" << 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;
if( !it->second.assigned() && it->second.type_match(_type) ) {
std::cout << "Found @" << it->first << std::endl;
m_device_id = it->first;
|