fill in x and y only if axes are valid

This commit is contained in:
Chris Sarbora 2024-12-31 11:30:49 -06:00
parent 4ff0665dc4
commit 62ac1f4eb6
No known key found for this signature in database
2 changed files with 11 additions and 7 deletions

View File

@ -901,11 +901,11 @@ bool sdlgameController::enum_controllers() {
m_ControlList[num_devs].buttons = jc.num_btns;
m_ControlList[num_devs].btnmask = 0;
m_ControlList[num_devs].flags =
CTF_X_AXIS | CTF_Y_AXIS | ((jc.axes_mask & JOYFLAG_ZVALID) ? CTF_Z_AXIS : 0) |
((jc.axes_mask & JOYFLAG_RVALID) ? CTF_R_AXIS : 0) | ((jc.axes_mask & JOYFLAG_UVALID) ? CTF_U_AXIS : 0) |
((jc.axes_mask & JOYFLAG_VVALID) ? CTF_V_AXIS : 0) | ((jc.axes_mask & JOYFLAG_POVVALID) ? CTF_POV : 0) |
((jc.axes_mask & JOYFLAG_POV2VALID) ? CTF_POV2 : 0) | ((jc.axes_mask & JOYFLAG_POV3VALID) ? CTF_POV3 : 0) |
((jc.axes_mask & JOYFLAG_POV4VALID) ? CTF_POV4 : 0);
((jc.axes_mask & JOYFLAG_XVALID) ? CTF_X_AXIS : 0) | ((jc.axes_mask & JOYFLAG_YVALID) ? CTF_Y_AXIS : 0) |
((jc.axes_mask & JOYFLAG_ZVALID) ? CTF_Z_AXIS : 0) | ((jc.axes_mask & JOYFLAG_RVALID) ? CTF_R_AXIS : 0) |
((jc.axes_mask & JOYFLAG_UVALID) ? CTF_U_AXIS : 0) | ((jc.axes_mask & JOYFLAG_VVALID) ? CTF_V_AXIS : 0) |
((jc.axes_mask & JOYFLAG_POVVALID) ? CTF_POV : 0) | ((jc.axes_mask & JOYFLAG_POV2VALID) ? CTF_POV2 : 0) |
((jc.axes_mask & JOYFLAG_POV3VALID) ? CTF_POV3 : 0) | ((jc.axes_mask & JOYFLAG_POV4VALID) ? CTF_POV4 : 0);
m_ControlList[num_devs].normalizer[0] = (jc.maxx - jc.minx) / 2.0f;
m_ControlList[num_devs].normalizer[1] = (jc.maxy - jc.miny) / 2.0f;
m_ControlList[num_devs].normalizer[2] = (jc.maxz - jc.minz) / 2.0f;

View File

@ -284,8 +284,12 @@ void joy_GetPos(tJoystick joy, tJoyPos *pos) {
uint32_t mask;
mask = Joysticks[joy].caps.axes_mask;
if (mask & JOYFLAG_XVALID) {
pos->x = SDL_JoystickGetAxis(stick, 0);
}
if (mask & JOYFLAG_YVALID) {
pos->y = SDL_JoystickGetAxis(stick, 1);
}
if (mask & JOYFLAG_ZVALID) {
pos->z = SDL_JoystickGetAxis(stick, 2);
}