cleaned up old TuxKart crap left in input module (variables id0, id1, id2, whose meaning change from device to device... how brilliant)

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3553 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-05-30 18:57:25 +00:00
parent 83a731500c
commit dc84e15685
4 changed files with 25 additions and 33 deletions

View File

@ -394,15 +394,15 @@ namespace StateManager
if(sensedInput->type == Input::IT_KEYBOARD) if(sensedInput->type == Input::IT_KEYBOARD)
{ {
std::cout << "key " << Input::getInputAsString(Input::IT_KEYBOARD, sensedInput->id0) << std::endl; std::cout << "key " << Input::getInputAsString(Input::IT_KEYBOARD, sensedInput->btnID) << std::endl;
} }
else if(sensedInput->type == Input::IT_STICKMOTION) else if(sensedInput->type == Input::IT_STICKMOTION)
{ {
std::cout << "gamepad axis " << sensedInput->id0 << " " << sensedInput->id1 << " " << sensedInput->id2 << std::endl; std::cout << "gamepad " << sensedInput->deviceID << "axis " << sensedInput->btnID << " direction=" << sensedInput->axisDirection << std::endl;
} }
else if(sensedInput->type == Input::IT_STICKBUTTON) else if(sensedInput->type == Input::IT_STICKBUTTON)
{ {
std::cout << "gamepad button " << sensedInput->id0 << " " << sensedInput->id1 << " " << sensedInput->id2 << std::endl; std::cout << "gamepad " << sensedInput->deviceID << " button " << sensedInput->btnID << std::endl;
} }
getCurrentScreen()->dismissModalDialog(); getCurrentScreen()->dismissModalDialog();

View File

@ -79,7 +79,7 @@ void DeviceManager::add(GamePadDevice* d)
m_gamepad_amount = m_gamepads.size(); m_gamepad_amount = m_gamepads.size();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool DeviceManager::mapInputToPlayerAndAction( Input::InputType type, int id0, int id1, int id2, int value, bool DeviceManager::mapInputToPlayerAndAction( Input::InputType type, int deviceID, int btnID, int axisDir, int value,
int* player /* out */, PlayerAction* action /* out */ ) int* player /* out */, PlayerAction* action /* out */ )
{ {
// TODO - auto-detect player ID from device // TODO - auto-detect player ID from device
@ -89,7 +89,7 @@ bool DeviceManager::mapInputToPlayerAndAction( Input::InputType type, int id0, i
{ {
for(unsigned int n=0; n<m_keyboard_amount; n++) for(unsigned int n=0; n<m_keyboard_amount; n++)
{ {
if( m_keyboards[n].hasBinding(id0, action) ) return true; if( m_keyboards[n].hasBinding(btnID, action) ) return true;
} }
return false; return false;
} }
@ -99,12 +99,11 @@ bool DeviceManager::mapInputToPlayerAndAction( Input::InputType type, int id0, i
} }
else if(type == Input::IT_STICKBUTTON || type == Input::IT_STICKMOTION) else if(type == Input::IT_STICKBUTTON || type == Input::IT_STICKMOTION)
{ {
// std::cout << "stick motion, ID=" <<id0 << " axis=" << id1 << " value=" << value << std::endl;
for(unsigned int n=0; n<m_gamepad_amount; n++) for(unsigned int n=0; n<m_gamepad_amount; n++)
{ {
//std::cout << "checking gamepad #" << n << " out of " << m_gamepad_amount << std::endl; //std::cout << "checking gamepad #" << n << " out of " << m_gamepad_amount << std::endl;
if(m_gamepads[n].hasBinding(type, id1 /* axis or button */, value, *player, action /* out */) ) if(m_gamepads[n].hasBinding(type, btnID /* axis or button */, value, *player, action /* out */) )
{ {
//std::cout << "that's the one.\n"; //std::cout << "that's the one.\n";
return true; return true;

View File

@ -47,15 +47,12 @@ struct Input
static const int IT_LAST = IT_MOUSEBUTTON; static const int IT_LAST = IT_MOUSEBUTTON;
InputType type; InputType type;
int id0; // FIXME : give meaningful names to these variables... int deviceID;
int id1; int btnID; // or axis ID for gamepads axes
int id2; int axisDirection;
// Esoteric C++ feature alarm: structs are classes where the fields and
// methods are public by default. I just needed some convenient constructors
// for this struct.
Input() Input()
: type(IT_NONE), id0(0), id1(0), id2(0) : type(IT_NONE), deviceID(0), btnID(0), axisDirection(0)
{ {
// Nothing to do. // Nothing to do.
} }
@ -83,8 +80,8 @@ struct Input
* index should be zero. The binding will react to all joysticks connected * index should be zero. The binding will react to all joysticks connected
* to the system. * to the system.
*/ */
Input(InputType ntype, int nid0 , int nid1 = 0, int nid2= 0) Input(InputType ntype, int deviceID , int btnID = 0, int axisDirection= 0)
: type(ntype), id0(nid0), id1(nid1), id2(nid2) : type(ntype), deviceID(deviceID), btnID(btnID), axisDirection(axisDirection)
{ {
// Nothing to do. // Nothing to do.
} }

View File

@ -180,17 +180,13 @@ void InputManager::handleStaticAction(int key, int value)
* Note: It is the obligation of the called menu to switch of the sense mode. * Note: It is the obligation of the called menu to switch of the sense mode.
* *
*/ */
void InputManager::input(Input::InputType type, int id0, int id1, int id2, void InputManager::input(Input::InputType type, int deviceID, int btnID, int axisDirection, int value)
int value)
{ {
int player; int player;
PlayerAction action; PlayerAction action;
const bool action_found = m_device_manager->mapInputToPlayerAndAction( type, id0, id1, id2, value, &player, &action ); const bool action_found = m_device_manager->mapInputToPlayerAndAction( type, deviceID, btnID, axisDirection, value, &player, &action );
// std::cout << "Input code=" << id0 << " found=" << action_found << std::endl;
//GameAction ga = m_action_map->getEntry(type, id0, id1, id2);
// Act different in input sensing mode. // Act different in input sensing mode.
if (m_mode >= INPUT_SENSE_PREFER_AXIS && if (m_mode >= INPUT_SENSE_PREFER_AXIS &&
@ -223,9 +219,11 @@ void InputManager::input(Input::InputType type, int id0, int id1, int id2,
if(store_new) if(store_new)
{ {
m_sensed_input->type = type; m_sensed_input->type = type;
m_sensed_input->id0 = id0;
m_sensed_input->id1 = id1; m_sensed_input->deviceID = deviceID;
m_sensed_input->id2 = id2; m_sensed_input->btnID = btnID;
m_sensed_input->axisDirection = axisDirection;
m_max_sensed_input = abs(value); m_max_sensed_input = abs(value);
m_max_sensed_type = type; m_max_sensed_type = type;
} }
@ -236,10 +234,8 @@ void InputManager::input(Input::InputType type, int id0, int id1, int id2,
StateManager::gotSensedInput(m_sensed_input); StateManager::gotSensedInput(m_sensed_input);
} }
} }
} // if m_mode==INPUT_SENSE_PREFER_{AXIS,BUTTON} }
else else if (action_found)
if (action_found)
{ {
if(StateManager::isGameState()) if(StateManager::isGameState())
RaceManager::getWorld()->getLocalPlayerKart(player)->action(action, abs(value)); RaceManager::getWorld()->getLocalPlayerKart(player)->action(action, abs(value));
@ -267,7 +263,7 @@ void InputManager::input(Input::InputType type, int id0, int id1, int id2,
else if(type == Input::IT_KEYBOARD) else if(type == Input::IT_KEYBOARD)
{ {
// keyboard press not handled by device manager / bindings. Check static bindings... // keyboard press not handled by device manager / bindings. Check static bindings...
handleStaticAction( id0, value ); handleStaticAction( btnID, value );
} }
} // input } // input
@ -340,7 +336,7 @@ bool InputManager::input(const SEvent& event)
return true; return true;
} }
input(Input::IT_KEYBOARD, key, input(Input::IT_KEYBOARD, 0, key,
#ifdef HAVE_IRRLICHT #ifdef HAVE_IRRLICHT
// FIXME: not sure why this happens: with plib the unicode // FIXME: not sure why this happens: with plib the unicode
// value is 0. Since all values defined in user_config // value is 0. Since all values defined in user_config
@ -354,12 +350,12 @@ bool InputManager::input(const SEvent& event)
#else #else
ev.key.keysym.unicode, ev.key.keysym.unicode,
#endif #endif
0, MAX_VALUE); MAX_VALUE);
} }
else else
{ {
input(Input::IT_KEYBOARD, key, 0, 0, 0); input(Input::IT_KEYBOARD, 0, key, 0, 0);
} }
} }
#if 0 // in case we ever use mouse in-game... #if 0 // in case we ever use mouse in-game...