Hat support is now believed to be there
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8323 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
717213a303
commit
6346188a64
@ -65,12 +65,7 @@ irr::core::stringw DeviceConfig::getMappingIdString (const PlayerAction action)
|
||||
returnString += "stkbt_";
|
||||
returnString += id;
|
||||
break;
|
||||
|
||||
case Input::IT_STICKHAT:
|
||||
returnString += "stkht_";
|
||||
returnString += id;
|
||||
break;
|
||||
|
||||
|
||||
case Input::IT_MOUSEMOTION:
|
||||
returnString += "mousemo_";
|
||||
returnString += id;
|
||||
|
@ -48,6 +48,73 @@ EventHandler::~EventHandler()
|
||||
|
||||
bool EventHandler::OnEvent (const SEvent &event)
|
||||
{
|
||||
// TO DEBUG HATS (when you don't actually have a hat)
|
||||
/*
|
||||
if (event.EventType == EET_KEY_INPUT_EVENT)
|
||||
{
|
||||
if (event.KeyInput.Key == 'W')
|
||||
{
|
||||
printf("Sending hat up event %i\n", event.KeyInput.PressedDown);
|
||||
SEvent evt2;
|
||||
evt2.EventType = EET_JOYSTICK_INPUT_EVENT;
|
||||
for (int n=0; n<SEvent::SJoystickEvent::NUMBER_OF_AXES; n++)
|
||||
{
|
||||
evt2.JoystickEvent.Axis[n] = 0.0f;
|
||||
}
|
||||
evt2.JoystickEvent.ButtonStates = 0;
|
||||
evt2.JoystickEvent.Joystick = 0;
|
||||
evt2.JoystickEvent.POV = (event.KeyInput.PressedDown ? 0 : 65535); // 0 degrees
|
||||
OnEvent(evt2);
|
||||
return false;
|
||||
}
|
||||
else if (event.KeyInput.Key == 'D')
|
||||
{
|
||||
printf("Sending hat right event %i\n", event.KeyInput.PressedDown);
|
||||
SEvent evt2;
|
||||
evt2.EventType = EET_JOYSTICK_INPUT_EVENT;
|
||||
for (int n=0; n<SEvent::SJoystickEvent::NUMBER_OF_AXES; n++)
|
||||
{
|
||||
evt2.JoystickEvent.Axis[n] = 0.0f;
|
||||
}
|
||||
evt2.JoystickEvent.ButtonStates = 0;
|
||||
evt2.JoystickEvent.Joystick = 0;
|
||||
evt2.JoystickEvent.POV = (event.KeyInput.PressedDown ? 9000 : 65535); // 90 degrees
|
||||
OnEvent(evt2);
|
||||
return false;
|
||||
}
|
||||
else if (event.KeyInput.Key == 'S')
|
||||
{
|
||||
printf("Sending hat down event %i\n", event.KeyInput.PressedDown);
|
||||
SEvent evt2;
|
||||
evt2.EventType = EET_JOYSTICK_INPUT_EVENT;
|
||||
for (int n=0; n<SEvent::SJoystickEvent::NUMBER_OF_AXES; n++)
|
||||
{
|
||||
evt2.JoystickEvent.Axis[n] = 0.0f;
|
||||
}
|
||||
evt2.JoystickEvent.ButtonStates = 0;
|
||||
evt2.JoystickEvent.Joystick = 0;
|
||||
evt2.JoystickEvent.POV = (event.KeyInput.PressedDown ? 18000 : 65535); // 180 degrees
|
||||
OnEvent(evt2);
|
||||
return false;
|
||||
}
|
||||
else if (event.KeyInput.Key == 'A')
|
||||
{
|
||||
printf("Sending hat left event %i\n", event.KeyInput.PressedDown);
|
||||
SEvent evt2;
|
||||
evt2.EventType = EET_JOYSTICK_INPUT_EVENT;
|
||||
for (int n=0; n<SEvent::SJoystickEvent::NUMBER_OF_AXES; n++)
|
||||
{
|
||||
evt2.JoystickEvent.Axis[n] = 0.0f;
|
||||
}
|
||||
evt2.JoystickEvent.ButtonStates = 0;
|
||||
evt2.JoystickEvent.Joystick = 0;
|
||||
evt2.JoystickEvent.POV = (event.KeyInput.PressedDown ? 27000 : 65535); // 270 degrees
|
||||
OnEvent(evt2);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if (event.EventType == EET_GUI_EVENT)
|
||||
{
|
||||
return onGUIEvent(event) == EVENT_BLOCK;
|
||||
|
@ -248,18 +248,27 @@ irr::core::stringw Binding::getAsString() const
|
||||
|
||||
break;
|
||||
case Input::IT_STICKMOTION:
|
||||
//I18N: to appear in input configuration screen, for gamepad axes
|
||||
s = _("Axis %d %s", m_id, (m_dir == Input::AD_NEGATIVE) ? L"-" : L"+");
|
||||
|
||||
if (m_id == Input::HAT_H_ID)
|
||||
{
|
||||
//I18N: to appear in input configuration screen, for gamepad hats
|
||||
s = _("Gamepad hat %d", (m_dir == Input::AD_NEGATIVE ? L"0-" : L"0+"));
|
||||
}
|
||||
else if (m_id == Input::HAT_V_ID)
|
||||
{
|
||||
//I18N: to appear in input configuration screen, for gamepad hats
|
||||
s = _("Gamepad hat %d", (m_dir == Input::AD_NEGATIVE ? L"1-" : L"1+"));
|
||||
}
|
||||
else
|
||||
{
|
||||
//I18N: to appear in input configuration screen, for gamepad axes
|
||||
s = _("Axis %d %s", m_id, (m_dir == Input::AD_NEGATIVE) ? L"-" : L"+");
|
||||
}
|
||||
break;
|
||||
case Input::IT_STICKBUTTON:
|
||||
//I18N: to appear in input configuration screen, for gamepad buttons
|
||||
s = ( _("Gamepad button %d", m_id+1));
|
||||
break;
|
||||
case Input::IT_STICKHAT:
|
||||
//I18N: to appear in input configuration screen, for gamepad hats
|
||||
s = _("Gamepad hat %d", (m_id+1));
|
||||
break;
|
||||
case Input::IT_MOUSEBUTTON:
|
||||
break; case Input::IT_MOUSEBUTTON:
|
||||
//I18N: to appear in input configuration screen, for mouse (might not be used at all)
|
||||
s = _("Mouse button %d", (m_id+1));
|
||||
break;
|
||||
|
@ -338,7 +338,7 @@ bool DeviceManager::translateInput( Input::InputType type,
|
||||
PlayerAction* action /* out */ )
|
||||
{
|
||||
InputDevice *device = NULL;
|
||||
|
||||
|
||||
// If the input event matches a bind on an input device, get a pointer to the device
|
||||
switch (type)
|
||||
{
|
||||
|
@ -39,6 +39,9 @@ struct Input
|
||||
{
|
||||
static const int MAX_VALUE = 32768;
|
||||
|
||||
static const int HAT_H_ID = 100;
|
||||
static const int HAT_V_ID = 101;
|
||||
|
||||
enum AxisDirection
|
||||
{
|
||||
AD_NEGATIVE,
|
||||
@ -52,7 +55,7 @@ struct Input
|
||||
IT_KEYBOARD,
|
||||
IT_STICKMOTION,
|
||||
IT_STICKBUTTON,
|
||||
IT_STICKHAT,
|
||||
//IT_STICKHAT,
|
||||
IT_MOUSEMOTION,
|
||||
IT_MOUSEBUTTON
|
||||
};
|
||||
|
@ -159,7 +159,7 @@ bool GamePadDevice::processAndMapInput(Input::InputType type, const int id, cons
|
||||
|
||||
if (type == Input::IT_STICKMOTION)
|
||||
{
|
||||
if (id >= m_axis_count) return false; // this gamepad doesn't even have that many axes
|
||||
if (id >= m_axis_count && id != Input::HAT_H_ID && id != Input::HAT_V_ID) return false; // this gamepad doesn't even have that many axes
|
||||
|
||||
if (player != NULL)
|
||||
{
|
||||
|
@ -331,17 +331,6 @@ void InputManager::inputSensing(Input::InputType type, int deviceID, int button,
|
||||
break;
|
||||
}
|
||||
|
||||
case Input::IT_STICKHAT:
|
||||
if (value > Input::MAX_VALUE/2)
|
||||
{
|
||||
Input sensed_input;
|
||||
sensed_input.m_type = Input::IT_STICKHAT;
|
||||
sensed_input.m_device_id = deviceID;
|
||||
sensed_input.m_button_id = button;
|
||||
sensed_input.m_character = deviceID;
|
||||
OptionsScreenInput2::getInstance()->gotSensedInput(sensed_input);
|
||||
break;
|
||||
}
|
||||
case Input::IT_NONE:
|
||||
case Input::IT_MOUSEMOTION:
|
||||
case Input::IT_MOUSEBUTTON:
|
||||
@ -525,8 +514,7 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID, int button
|
||||
// early menus where we accept every input because players are not set-up yet
|
||||
if (m_master_player_only && player == NULL)
|
||||
{
|
||||
if (type == Input::IT_STICKMOTION || type == Input::IT_STICKBUTTON ||
|
||||
type == Input::IT_STICKHAT)
|
||||
if (type == Input::IT_STICKMOTION || type == Input::IT_STICKBUTTON)
|
||||
{
|
||||
GamePadDevice* gp = getDeviceList()->getGamePadFromIrrID(deviceID);
|
||||
|
||||
@ -621,9 +609,26 @@ EventPropagation InputManager::input(const SEvent& event)
|
||||
event.JoystickEvent.Joystick, axis_id, value);
|
||||
}
|
||||
|
||||
dispatchInput(Input::IT_STICKMOTION, event.JoystickEvent.Joystick, axis_id, Input::AD_NEUTRAL, value);
|
||||
dispatchInput(Input::IT_STICKMOTION, event.JoystickEvent.Joystick, axis_id,
|
||||
Input::AD_NEUTRAL, value);
|
||||
}
|
||||
|
||||
|
||||
if (event.JoystickEvent.POV == 65535)
|
||||
{
|
||||
dispatchInput(Input::IT_STICKMOTION, event.JoystickEvent.Joystick, Input::HAT_H_ID, Input::AD_NEUTRAL,
|
||||
0);
|
||||
dispatchInput(Input::IT_STICKMOTION, event.JoystickEvent.Joystick, Input::HAT_V_ID, Input::AD_NEUTRAL,
|
||||
0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// *0.017453925f is to convert degrees to radians
|
||||
dispatchInput(Input::IT_STICKMOTION, event.JoystickEvent.Joystick, Input::HAT_H_ID, Input::AD_NEUTRAL,
|
||||
cos(event.JoystickEvent.POV*0.017453925f/100.0f)*Input::MAX_VALUE);
|
||||
dispatchInput(Input::IT_STICKMOTION, event.JoystickEvent.Joystick, Input::HAT_V_ID, Input::AD_NEUTRAL,
|
||||
sin(event.JoystickEvent.POV*0.017453925f/100.0f)*Input::MAX_VALUE);
|
||||
}
|
||||
|
||||
GamePadDevice* gp = getDeviceList()->getGamePadFromIrrID(event.JoystickEvent.Joystick);
|
||||
|
||||
if (gp == NULL)
|
||||
|
@ -292,8 +292,7 @@ void OptionsScreenInput2::gotSensedInput(const Input& sensed_input)
|
||||
const bool keyboard = (m_config->getType() == DEVICE_CONFIG_TYPE_KEYBOARD &&
|
||||
sensed_input.m_type == Input::IT_KEYBOARD);
|
||||
const bool gamepad = (sensed_input.m_type == Input::IT_STICKMOTION ||
|
||||
sensed_input.m_type == Input::IT_STICKBUTTON ||
|
||||
sensed_input.m_type == Input::IT_STICKHAT) &&
|
||||
sensed_input.m_type == Input::IT_STICKBUTTON) &&
|
||||
m_config->getType() == DEVICE_CONFIG_TYPE_GAMEPAD;
|
||||
|
||||
if (keyboard)
|
||||
@ -332,10 +331,6 @@ void OptionsScreenInput2::gotSensedInput(const Input& sensed_input)
|
||||
{
|
||||
std::cout << "button " << sensed_input.m_button_id<< "\n\n";
|
||||
}
|
||||
else if (sensed_input.m_type == Input::IT_STICKHAT)
|
||||
{
|
||||
std::cout << "Hat " << sensed_input.m_button_id << "\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Sensed unknown gamepad event type??\n";
|
||||
|
Loading…
Reference in New Issue
Block a user