Skip to content

Commit

Permalink
Vita: dpad works now if analog=off, gas on right stick if analog=on
Browse files Browse the repository at this point in the history
  • Loading branch information
rsn8887 committed Mar 23, 2018
1 parent d9f98ce commit b9f4e11
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 7 deletions.
46 changes: 39 additions & 7 deletions src/main/sdl2/input.cpp
Expand Up @@ -40,6 +40,13 @@ void Input::init(int pad_id, int* key_config, int* pad_config, int analog, int*
}

a_wheel = CENTRE;

#ifdef __vita__
dpad_up = false;
dpad_down = false;
dpad_left = false;
dpad_right = false;
#endif
}

void Input::close()
Expand Down Expand Up @@ -157,8 +164,15 @@ void Input::handle_joy_axis(SDL_JoyAxisEvent* evt)
// Neural
if ( (value > -DIGITAL_DEAD ) && (value < DIGITAL_DEAD ) )
{
#ifdef __vita__
if (!dpad_left)
keys[LEFT] = false;
if (!dpad_right)
keys[RIGHT] = false;
#else
keys[LEFT] = false;
keys[RIGHT] = false;
#endif
}
else if (value < 0)
{
Expand All @@ -175,8 +189,15 @@ void Input::handle_joy_axis(SDL_JoyAxisEvent* evt)
// Neural
if ( (value > -DIGITAL_DEAD ) && (value < DIGITAL_DEAD ) )
{
#ifdef __vita__
if (!dpad_up)
keys[UP] = false;
if (!dpad_down)
keys[DOWN] = false;
#else
keys[UP] = false;
keys[DOWN] = false;
#endif
}
else if (value < 0)
{
Expand Down Expand Up @@ -220,7 +241,11 @@ void Input::handle_joy_axis(SDL_JoyAxisEvent* evt)
a_wheel = adjusted;
}
// Accelerator and Brake [Combined Axis]
#ifdef __vita__
else if (evt->axis == axis[2])
#else
else if (axis[1] == axis[2] && (evt->axis == axis[1] || evt->axis == axis[2]))
#endif
{
// Accelerator
if (value < -pedals_dead)
Expand All @@ -245,6 +270,7 @@ void Input::handle_joy_axis(SDL_JoyAxisEvent* evt)
a_brake = 0;
}
}
#ifndef __vita__
// Accelerator [Single Axis]
else if (evt->axis == axis[1])
{
Expand All @@ -261,6 +287,7 @@ void Input::handle_joy_axis(SDL_JoyAxisEvent* evt)
adjusted += (adjusted >> 2);
a_brake = adjusted;
}
#endif
}
}

Expand Down Expand Up @@ -305,17 +332,22 @@ void Input::handle_joy(const uint8_t button, const bool is_pressed)
#ifdef __vita__
//map dpad to digital directions to allow menu control
//even when analog wheel is enabled
if (button == 6)
if (button == 6) {
dpad_down = is_pressed;
keys[DOWN] = is_pressed;

if (button == 7)
}
if (button == 7) {
dpad_left = is_pressed;
keys[LEFT] = is_pressed;

if (button == 8)
}
if (button == 8) {
dpad_up = is_pressed;
keys[UP] = is_pressed;

if (button == 9)
}
if (button == 9) {
dpad_right = is_pressed;
keys[RIGHT] = is_pressed;
}
#endif

}
8 changes: 8 additions & 0 deletions src/main/sdl2/input.hpp
Expand Up @@ -92,6 +92,14 @@ class Input

void handle_key(const int, const bool);
void handle_joy(const uint8_t, const bool);

#ifdef __vita__
// dpad wins over joystick
bool dpad_up;
bool dpad_down;
bool dpad_left;
bool dpad_right;
#endif
};

extern Input input;

0 comments on commit b9f4e11

Please sign in to comment.