analog sticks works better now

This commit is contained in:
georgemoralis 2024-06-17 14:33:03 +03:00
parent 91e6d35e89
commit b17a57cb3d
1 changed files with 41 additions and 9 deletions

View File

@ -132,42 +132,74 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
break; break;
case SDLK_a: case SDLK_a:
axis = Input::Axis::LeftX; axis = Input::Axis::LeftX;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += -127; axisvalue += -127;
} else {
axisvalue = 0;
}
ax = Input::GetAxis(-0x80, 0x80, axisvalue); ax = Input::GetAxis(-0x80, 0x80, axisvalue);
break; break;
case SDLK_d: case SDLK_d:
axis = Input::Axis::LeftX; axis = Input::Axis::LeftX;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += 127; axisvalue += 127;
} else {
axisvalue = 0;
}
ax = Input::GetAxis(-0x80, 0x80, axisvalue); ax = Input::GetAxis(-0x80, 0x80, axisvalue);
break; break;
case SDLK_w: case SDLK_w:
axis = Input::Axis::LeftY; axis = Input::Axis::LeftY;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += -127; axisvalue += -127;
} else {
axisvalue = 0;
}
ax = Input::GetAxis(-0x80, 0x80, axisvalue); ax = Input::GetAxis(-0x80, 0x80, axisvalue);
break; break;
case SDLK_s: case SDLK_s:
axis = Input::Axis::LeftY; axis = Input::Axis::LeftY;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += 127; axisvalue += 127;
} else {
axisvalue = 0;
}
ax = Input::GetAxis(-0x80, 0x80, axisvalue); ax = Input::GetAxis(-0x80, 0x80, axisvalue);
break; break;
case SDLK_j: case SDLK_j:
axis = Input::Axis::RightX; axis = Input::Axis::RightX;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += -127; axisvalue += -127;
} else {
axisvalue = 0;
}
ax = Input::GetAxis(-0x80, 0x80, axisvalue); ax = Input::GetAxis(-0x80, 0x80, axisvalue);
break; break;
case SDLK_l: case SDLK_l:
axis = Input::Axis::RightX; axis = Input::Axis::RightX;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += 127; axisvalue += 127;
} else {
axisvalue = 0;
}
ax = Input::GetAxis(-0x80, 0x80, axisvalue); ax = Input::GetAxis(-0x80, 0x80, axisvalue);
break; break;
case SDLK_i: case SDLK_i:
axis = Input::Axis::RightY; axis = Input::Axis::RightY;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += -127; axisvalue += -127;
} else {
axisvalue = 0;
}
ax = Input::GetAxis(-0x80, 0x80, axisvalue); ax = Input::GetAxis(-0x80, 0x80, axisvalue);
break; break;
case SDLK_k: case SDLK_k:
axis = Input::Axis::RightY; axis = Input::Axis::RightY;
if (event->type == SDL_EVENT_KEY_DOWN) {
axisvalue += 127; axisvalue += 127;
} else {
axisvalue = 0;
}
ax = Input::GetAxis(-0x80, 0x80, axisvalue); ax = Input::GetAxis(-0x80, 0x80, axisvalue);
break; break;
default: default:
@ -176,7 +208,7 @@ void WindowSDL::onKeyPress(const SDL_Event* event) {
if (button != 0) { if (button != 0) {
controller->CheckButton(0, button, event->type == SDL_EVENT_KEY_DOWN); controller->CheckButton(0, button, event->type == SDL_EVENT_KEY_DOWN);
} }
if (axis != Input::Axis::AxisMax&& event->type == SDL_EVENT_KEY_DOWN) { if (axis != Input::Axis::AxisMax) {
controller->Axis(0, axis, ax); controller->Axis(0, axis, ax);
} }
} }