gamepad buttons work again, except for 'fire' in menus (can't find why)
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3424 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -352,7 +352,7 @@ Widget* Screen::getLastWidget(ptr_vector<Widget>* within_vector)
|
||||
|
||||
#define MAX_VALUE 32768
|
||||
|
||||
void Screen::processAction(const int action, const unsigned int value)
|
||||
void Screen::processAction(const int action, const unsigned int value, Input::InputType type)
|
||||
{
|
||||
const bool pressedDown = value > MAX_VALUE*2/3;
|
||||
|
||||
@@ -470,6 +470,20 @@ void Screen::processAction(const int action, const unsigned int value)
|
||||
break;
|
||||
|
||||
case PA_FIRE:
|
||||
if(type == Input::IT_STICKBUTTON)
|
||||
{
|
||||
// simulate a 'enter' key press
|
||||
irr::SEvent::SKeyInput evt;
|
||||
evt.PressedDown = true;
|
||||
evt.Key = KEY_RETURN;
|
||||
irr::SEvent wrapper;
|
||||
wrapper.KeyInput = evt;
|
||||
wrapper.EventType = EET_KEY_INPUT_EVENT;
|
||||
GUIEngine::getDevice()->postEventFromUser(wrapper);
|
||||
|
||||
std::cout << "posting event to simulate 'enter'\n";
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "ptr_vector.hpp"
|
||||
|
||||
#include "input/input.hpp"
|
||||
#include <irrlicht.h>
|
||||
|
||||
using namespace irr;
|
||||
@@ -52,7 +52,7 @@ namespace GUIEngine
|
||||
void elementsWereDeleted(ptr_vector<Widget>* within_vector = NULL);
|
||||
|
||||
virtual bool OnEvent(const SEvent& event);
|
||||
void processAction(const int action, const unsigned int value);
|
||||
void processAction(const int action, const unsigned int value, Input::InputType type);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -361,7 +361,7 @@ void InputManager::input(Input::InputType type, int id0, int id1, int id2,
|
||||
m_timer_in_use = true;
|
||||
m_timer = 0.25;
|
||||
}
|
||||
GUIEngine::getCurrentScreen()->processAction(action, abs(value));
|
||||
GUIEngine::getCurrentScreen()->processAction(action, abs(value), type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -396,7 +396,7 @@ void InputManager::input(const SEvent& event)
|
||||
<< " 3=" << event.JoystickEvent.IsButtonPressed(2)
|
||||
<< " 4=" << event.JoystickEvent.IsButtonPressed(3) << std::endl;
|
||||
*/
|
||||
// Axes - FIXME, instead of checking all of them, ask the bindings which to poll
|
||||
// Axes - FIXME, instead of checking all of them, ask the bindings which ones to poll
|
||||
for(int axis_id=0; axis_id<SEvent::SJoystickEvent::NUMBER_OF_AXES ; axis_id++)
|
||||
{
|
||||
int value = event.JoystickEvent.Axis[axis_id];
|
||||
@@ -416,36 +416,13 @@ void InputManager::input(const SEvent& event)
|
||||
else
|
||||
input(Input::IT_STICKMOTION, event.JoystickEvent.Joystick, axis_id, Input::AD_POSITIVE, value);
|
||||
}
|
||||
|
||||
/*
|
||||
case SDL_JOYAXISMOTION:
|
||||
{
|
||||
const int value = ev.jaxis.value;
|
||||
|
||||
if(user_config->m_gamepad_debug)
|
||||
{
|
||||
printf("axis motion: which=%d axis=%d value=%d\n",
|
||||
ev.jaxis.which, ev.jaxis.axis, value);
|
||||
}
|
||||
|
||||
// FIXME - AD_NEGATIVE/AD_POSITIVE are probably useless since value contains that info too
|
||||
if(value < 0)
|
||||
input(Input::IT_STICKMOTION, ev.jaxis.which, ev.jaxis.axis, Input::AD_NEGATIVE, value);
|
||||
else
|
||||
input(Input::IT_STICKMOTION, ev.jaxis.which, ev.jaxis.axis, Input::AD_POSITIVE, value);
|
||||
}
|
||||
break;
|
||||
case SDL_JOYBUTTONUP:
|
||||
// See the SDL_JOYAXISMOTION case label because of !m_mode thingie.
|
||||
input(Input::IT_STICKBUTTON, ev.jbutton.which,
|
||||
ev.jbutton.button, 0, 0);
|
||||
break;
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
// See the SDL_JOYAXISMOTION case label because of !m_mode thingie.
|
||||
input(Input::IT_STICKBUTTON, ev.jbutton.which, ev.jbutton.button, 0, 32768);
|
||||
break;
|
||||
*/
|
||||
|
||||
// Buttons - FIXME, instead of checking all of them, ask the bindings which ones to poll
|
||||
for(int i=0; i<SEvent::SJoystickEvent::NUMBER_OF_BUTTONS; i++)
|
||||
{
|
||||
input(Input::IT_STICKBUTTON, event.JoystickEvent.Joystick, i, 0, event.JoystickEvent.IsButtonPressed(i) ? MAX_VALUE : 0);
|
||||
}
|
||||
|
||||
}
|
||||
else if(event.EventType == EET_KEY_INPUT_EVENT)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user