From: <au...@us...> - 2009-03-29 18:43:42
|
Revision: 3312 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=3312&view=rev Author: auria Date: 2009-03-29 18:43:39 +0000 (Sun, 29 Mar 2009) Log Message: ----------- improved joystick code again Modified Paths: -------------- main/branches/irrlicht/src/input/device_manager.cpp main/branches/irrlicht/src/input/input_device.cpp main/branches/irrlicht/src/input/input_manager.cpp Modified: main/branches/irrlicht/src/input/device_manager.cpp =================================================================== --- main/branches/irrlicht/src/input/device_manager.cpp 2009-03-29 16:15:17 UTC (rev 3311) +++ main/branches/irrlicht/src/input/device_manager.cpp 2009-03-29 18:43:39 UTC (rev 3312) @@ -20,7 +20,6 @@ m_gamepad_amount = m_gamepads.size(); } -// TODO bool DeviceManager::mapInputToPlayerAndAction( Input::InputType type, int id0, int id1, int id2, int value, int* player /* out */, PlayerAction* action /* out */ ) { Modified: main/branches/irrlicht/src/input/input_device.cpp =================================================================== --- main/branches/irrlicht/src/input/input_device.cpp 2009-03-29 16:15:17 UTC (rev 3311) +++ main/branches/irrlicht/src/input/input_device.cpp 2009-03-29 18:43:39 UTC (rev 3312) @@ -84,14 +84,15 @@ void GamePadDevice::loadDefaults() { /* - TODO + TODO - joystic buttons m_bindings[PA_NITRO] m_bindings[PA_DRIFT] m_bindings[PA_RESCUE] m_bindings[PA_FIRE] m_bindings[PA_LOOK_BACK] */ - + // m_bindings[PA_NITRO].type = Input::IT_STICKBUTTON; + m_bindings[PA_ACCEL].type = Input::IT_STICKMOTION; m_bindings[PA_ACCEL].id = 1; m_bindings[PA_ACCEL].dir = Input::AD_NEGATIVE; @@ -118,6 +119,7 @@ Input(Input::IT_STICKMOTION, 0, 0, Input::AD_NEGATIVE)); set(GA_CURSOR_RIGHT, Input(Input::IT_STICKMOTION, 0, 0, Input::AD_POSITIVE)); + set(GA_CLEAR_MAPPING, Input(Input::IT_STICKBUTTON, 0, 2)); set(GA_ENTER, @@ -149,17 +151,17 @@ // set positive axis to 0 resetAxisDirection(axis, Input::AD_POSITIVE, player); - m_prevAxisDirections[axis] = Input::AD_NEGATIVE; } // going to positive from negative else if (value > 0 && m_prevAxisDirections[axis] == Input::AD_NEGATIVE) { // set negative axis to 0 resetAxisDirection(axis, Input::AD_NEGATIVE, player); - - m_prevAxisDirections[axis] = Input::AD_POSITIVE; } + if(value > 0) m_prevAxisDirections[axis] = Input::AD_POSITIVE; + else if(value < 0) m_prevAxisDirections[axis] = Input::AD_NEGATIVE; + // check if within deadzone if(value > -m_deadzone && value < m_deadzone) { Modified: main/branches/irrlicht/src/input/input_manager.cpp =================================================================== --- main/branches/irrlicht/src/input/input_manager.cpp 2009-03-29 16:15:17 UTC (rev 3311) +++ main/branches/irrlicht/src/input/input_manager.cpp 2009-03-29 18:43:39 UTC (rev 3312) @@ -373,7 +373,7 @@ #endif if (action_found) { - RaceManager::getWorld()->getLocalPlayerKart(player)->action(action, value); + RaceManager::getWorld()->getLocalPlayerKart(player)->action(action, abs(value)); } else if(type == Input::IT_KEYBOARD) { @@ -496,13 +496,16 @@ break; case SDL_JOYAXISMOTION: - if(user_config->m_gamepad_debug) + //const unsigned int value = ev.jaxis.value - 32768; + const int value = ev.jaxis.value;// - 32768*2; + + //if(user_config->m_gamepad_debug) { printf("axis motion: which=%d axis=%d value=%d\n", - ev.jaxis.which, ev.jaxis.axis, ev.jaxis.value); + ev.jaxis.which, ev.jaxis.axis, value); } - - if(ev.jaxis.value < 0) + + if(value < 0) { /* // TODO - bring back those weird axis tricks. would be cool if // they could happen inside the GamePadDevice class, for encapsulation @@ -511,7 +514,7 @@ input(Input::IT_STICKMOTION, !m_mode ? 0 : stickIndex, ev.jaxis.axis, Input::AD_POSITIVE, 0); } */ - input(Input::IT_STICKMOTION, ev.jaxis.which, ev.jaxis.axis, Input::AD_NEGATIVE, -ev.jaxis.value); + input(Input::IT_STICKMOTION, ev.jaxis.which, ev.jaxis.axis, Input::AD_NEGATIVE, value); //m_stick_infos[ev.jaxis.which]->m_prevAxisDirections[ev.jaxis.axis] = Input::AD_NEGATIVE; } else @@ -524,7 +527,7 @@ } */ // TODO - set stickIndex - input(Input::IT_STICKMOTION, ev.jaxis.which, ev.jaxis.axis, Input::AD_POSITIVE, ev.jaxis.value); + input(Input::IT_STICKMOTION, ev.jaxis.which, ev.jaxis.axis, Input::AD_POSITIVE, value); //m_stick_infos[ev.jaxis.which]->m_prevAxisDirections[ev.jaxis.axis] = Input::AD_POSITIVE; } @@ -589,7 +592,7 @@ */ // See the SDL_JOYAXISMOTION case label because of !m_mode thingie. - input(Input::IT_STICKBUTTON, !m_mode ? 0 : stickIndex, + input(Input::IT_STICKBUTTON, ev.jbutton.which, ev.jbutton.button, 0, 0); break; case SDL_JOYBUTTONDOWN: @@ -598,7 +601,7 @@ */ // See the SDL_JOYAXISMOTION case label because of !m_mode thingie. - input(Input::IT_STICKBUTTON, !m_mode ? 0 : stickIndex, + input(Input::IT_STICKBUTTON, ev.jbutton.which, ev.jbutton.button, 0, 32768); break; case SDL_USEREVENT: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |