mirror of
https://github.com/AloUltraExt/sm64ex-alo.git
synced 2025-01-23 16:15:36 -05:00
Controller changes
Merge wii u controller changes Fix rawkey 3ds controller warning Fix controller left stick ranges (from sm64-port)
This commit is contained in:
parent
f0de0c620b
commit
0bc91aadc8
4 changed files with 60 additions and 5 deletions
|
@ -91,7 +91,7 @@ static void controller_3ds_read(OSContPad *pad)
|
|||
pad->stick_y = pos.dy / 2;
|
||||
}
|
||||
|
||||
static void controller_3ds_rawkey(void)
|
||||
static u32 controller_3ds_rawkey(void)
|
||||
{
|
||||
return VK_INVALID;
|
||||
}
|
||||
|
|
|
@ -227,17 +227,31 @@ static void controller_sdl_read(OSContPad *pad) {
|
|||
uint32_t magnitude_sq = (uint32_t)(leftx * leftx) + (uint32_t)(lefty * lefty);
|
||||
uint32_t stickDeadzoneActual = configStickDeadzone * DEADZONE_STEP;
|
||||
if (magnitude_sq > (uint32_t)(stickDeadzoneActual * stickDeadzoneActual)) {
|
||||
#if 0 // not used but leaving just in case
|
||||
pad->stick_x = leftx / 0x100;
|
||||
int stick_y = -lefty / 0x100;
|
||||
pad->stick_y = stick_y == 128 ? 127 : stick_y;
|
||||
#else
|
||||
// Game expects stick coordinates within -80..80
|
||||
// 32768 / 409 = ~80
|
||||
pad->stick_x = leftx / 409;
|
||||
pad->stick_y = -lefty / 409;
|
||||
#endif
|
||||
}
|
||||
|
||||
magnitude_sq = (uint32_t)(rightx * rightx) + (uint32_t)(righty * righty);
|
||||
stickDeadzoneActual = configStickDeadzone * DEADZONE_STEP;
|
||||
if (magnitude_sq > (uint32_t)(stickDeadzoneActual * stickDeadzoneActual)) {
|
||||
#if 0 // not used but leaving just in case
|
||||
pad->ext_stick_x = rightx / 0x100;
|
||||
int stick_y = -righty / 0x100;
|
||||
pad->ext_stick_y = stick_y == 128 ? 127 : stick_y;
|
||||
#else
|
||||
// Game expects stick coordinates within -80..80
|
||||
// 32768 / 409 = ~80
|
||||
pad->ext_stick_x = rightx / 409;
|
||||
pad->ext_stick_y = -righty / 409;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -255,17 +255,31 @@ static void controller_sdl_read(OSContPad *pad) {
|
|||
uint32_t magnitude_sq = (uint32_t)(leftx * leftx) + (uint32_t)(lefty * lefty);
|
||||
uint32_t stickDeadzoneActual = configStickDeadzone * DEADZONE_STEP;
|
||||
if (magnitude_sq > (uint32_t)(stickDeadzoneActual * stickDeadzoneActual)) {
|
||||
#if 0 // not used but leaving just in case
|
||||
pad->stick_x = leftx / 0x100;
|
||||
int stick_y = -lefty / 0x100;
|
||||
pad->stick_y = stick_y == 128 ? 127 : stick_y;
|
||||
#else
|
||||
// Game expects stick coordinates within -80..80
|
||||
// 32768 / 409 = ~80
|
||||
pad->stick_x = leftx / 409;
|
||||
pad->stick_y = -lefty / 409;
|
||||
#endif
|
||||
}
|
||||
|
||||
magnitude_sq = (uint32_t)(rightx * rightx) + (uint32_t)(righty * righty);
|
||||
stickDeadzoneActual = configStickDeadzone * DEADZONE_STEP;
|
||||
if (magnitude_sq > (uint32_t)(stickDeadzoneActual * stickDeadzoneActual)) {
|
||||
#if 0 // not used but leaving just in case
|
||||
pad->ext_stick_x = rightx / 0x100;
|
||||
int stick_y = -righty / 0x100;
|
||||
pad->ext_stick_y = stick_y == 128 ? 127 : stick_y;
|
||||
#else
|
||||
// Game expects stick coordinates within -80..80
|
||||
// 32768 / 409 = ~80
|
||||
pad->ext_stick_x = rightx / 409;
|
||||
pad->ext_stick_y = -righty / 409;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
#include "controller_api.h"
|
||||
#include "../configfile.h"
|
||||
|
||||
int16_t rightx;
|
||||
int16_t righty;
|
||||
|
||||
extern void KPADShutdown();
|
||||
|
||||
struct WiiUKeymap {
|
||||
|
@ -86,6 +89,13 @@ static void read_vpad(OSContPad *pad) {
|
|||
if (status.leftStick.y != 0) {
|
||||
pad->stick_y = (s8) round(status.leftStick.y * 80);
|
||||
}
|
||||
|
||||
if (status.rightStick.x != 0) {
|
||||
rightx = (int16_t) round(status.rightStick.x * 32767);
|
||||
}
|
||||
if (status.rightStick.y != 0) {
|
||||
righty = (int16_t) round(status.rightStick.y * 32767);
|
||||
}
|
||||
}
|
||||
|
||||
static void read_wpad(OSContPad* pad) {
|
||||
|
@ -122,25 +132,29 @@ static void read_wpad(OSContPad* pad) {
|
|||
|
||||
uint32_t wm = status.hold;
|
||||
KPADVec2D stick;
|
||||
KPADVec2D rStick;
|
||||
|
||||
bool gamepadStickNotSet = pad->stick_x == 0 && pad->stick_y == 0;
|
||||
bool gamepadRightStickNotSet = rightx == 0 && righty == 0;
|
||||
|
||||
if (status.extensionType == WPAD_EXT_NUNCHUK || status.extensionType == WPAD_EXT_MPLUS_NUNCHUK) {
|
||||
uint32_t ext = status.nunchuck.hold;
|
||||
stick = status.nunchuck.stick;
|
||||
rStick = (KPADVec2D) {0.0, 0.0};
|
||||
|
||||
if (wm & WPAD_BUTTON_A) pad->button |= A_BUTTON;
|
||||
if (wm & WPAD_BUTTON_B) pad->button |= B_BUTTON;
|
||||
if (wm & WPAD_BUTTON_PLUS) pad->button |= START_BUTTON;
|
||||
if (wm & WPAD_BUTTON_UP) pad->button |= U_CBUTTONS;
|
||||
if (wm & WPAD_BUTTON_DOWN) pad->button |= D_CBUTTONS;
|
||||
if (wm & WPAD_BUTTON_LEFT) pad->button |= L_CBUTTONS;
|
||||
if (wm & WPAD_BUTTON_RIGHT) pad->button |= R_CBUTTONS;
|
||||
if (wm & WPAD_BUTTON_UP) { pad->button |= U_CBUTTONS; rStick.y += 1.0; }
|
||||
if (wm & WPAD_BUTTON_DOWN) { pad->button |= D_CBUTTONS; rStick.y -= 1.0; }
|
||||
if (wm & WPAD_BUTTON_LEFT) { pad->button |= L_CBUTTONS; rStick.x -= 1.0; }
|
||||
if (wm & WPAD_BUTTON_RIGHT) { pad->button |= R_CBUTTONS; rStick.x += 1.0; }
|
||||
if (ext & WPAD_NUNCHUK_BUTTON_C) pad->button |= R_TRIG;
|
||||
if (ext & WPAD_NUNCHUK_BUTTON_Z) pad->button |= Z_TRIG;
|
||||
} else if (status.extensionType == WPAD_EXT_CLASSIC || status.extensionType == WPAD_EXT_MPLUS_CLASSIC) {
|
||||
uint32_t ext = status.classic.hold;
|
||||
stick = status.classic.leftStick;
|
||||
rStick = status.classic.rightStick;
|
||||
for (size_t i = 0; i < num_buttons; i++) {
|
||||
if (ext & map[i].classicButton) {
|
||||
pad->button |= map[i].n64Button;
|
||||
|
@ -153,6 +167,7 @@ static void read_wpad(OSContPad* pad) {
|
|||
} else if (status.extensionType == WPAD_EXT_PRO_CONTROLLER) {
|
||||
uint32_t ext = status.pro.hold;
|
||||
stick = status.pro.leftStick;
|
||||
rStick = status.pro.rightStick;
|
||||
for (size_t i = 0; i < num_buttons; i++) {
|
||||
if (ext & map[i].proButton) {
|
||||
pad->button |= map[i].n64Button;
|
||||
|
@ -173,12 +188,24 @@ static void read_wpad(OSContPad* pad) {
|
|||
pad->stick_y = (s8) round(stick.y * 80);
|
||||
}
|
||||
}
|
||||
|
||||
if (gamepadRightStickNotSet) {
|
||||
if (rStick.x != 0) {
|
||||
rightx = (int16_t) round(rStick.x * 32767);
|
||||
}
|
||||
if (rStick.y != 0) {
|
||||
righty = (int16_t) round(rStick.y * 32767);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void controller_wiiu_read(OSContPad* pad) {
|
||||
pad->stick_x = 0;
|
||||
pad->stick_y = 0;
|
||||
|
||||
rightx = 0;
|
||||
righty = 0;
|
||||
|
||||
read_vpad(pad);
|
||||
read_wpad(pad);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue