Skip to content

Commit

Permalink
Fix wonky movements when using left stick on Vita #2
Browse files Browse the repository at this point in the history
  • Loading branch information
usineur committed Nov 17, 2019
1 parent 8447bc7 commit 1040967
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ if(SWITCH_LIBNX)
add_definitions(-D__SWITCH__)
add_custom_target(${CMAKE_PROJECT_NAME}.nro
DEPENDS ${CMAKE_PROJECT_NAME}
COMMAND nacptool --create "Heart of Darkness" "cyx, usineur" "0.2.0" ${CMAKE_PROJECT_NAME}.nacp
COMMAND nacptool --create "Heart of Darkness" "cyx, usineur" "0.2.2" ${CMAKE_PROJECT_NAME}.nacp
COMMAND elf2nro ${CMAKE_PROJECT_NAME} ${CMAKE_PROJECT_NAME}.nro --icon=${CMAKE_SOURCE_DIR}/res/icon.jpg --nacp=${CMAKE_PROJECT_NAME}.nacp
)
add_custom_target(nxlink
Expand Down
28 changes: 28 additions & 0 deletions system_sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

static const char *kIconBmp = "icon.bmp";

#ifdef __vita__
static bool axis[4]= { false, false, false, false };
#endif

static int _scalerMultiplier = 3;
static const Scaler *_scaler = &scaler_xbr;
static const float _gamma = 1.f;
Expand Down Expand Up @@ -496,25 +500,49 @@ void System_SDL2::processEvents() {
case SDL_CONTROLLER_AXIS_RIGHTX:
if (ev.caxis.value < -kJoystickCommitValue) {
pad.mask |= SYS_INP_LEFT;
#ifdef __vita__
axis[0] = true;
} else if (axis[0]) {
axis[0] = false;
#else
} else {
#endif
pad.mask &= ~SYS_INP_LEFT;
}
if (ev.caxis.value > kJoystickCommitValue) {
pad.mask |= SYS_INP_RIGHT;
#ifdef __vita__
axis[1] = true;
} else if (axis[1]) {
axis[1] = false;
#else
} else {
#endif
pad.mask &= ~SYS_INP_RIGHT;
}
break;
case SDL_CONTROLLER_AXIS_LEFTY:
case SDL_CONTROLLER_AXIS_RIGHTY:
if (ev.caxis.value < -kJoystickCommitValue) {
pad.mask |= SYS_INP_UP;
#ifdef __vita__
axis[2] = true;
} else if (axis[2]) {
axis[2] = false;
#else
} else {
#endif
pad.mask &= ~SYS_INP_UP;
}
if (ev.caxis.value > kJoystickCommitValue) {
pad.mask |= SYS_INP_DOWN;
#ifdef __vita__
axis[3] = true;
} else if (axis[3]) {
axis[3] = false;
#else
} else {
#endif
pad.mask &= ~SYS_INP_DOWN;
}
break;
Expand Down

0 comments on commit 1040967

Please sign in to comment.