Closed Ryzee119 closed 4 years ago
hi
Work fine, thanks.
Maybe you can add Axis, i create it working in game only (not use your function)
if (event.type == SDL_CONTROLLERAXISMOTION) { switch (event.caxis.axis) { case SDL_CONTROLLER_AXIS_LEFTX: case SDL_CONTROLLER_AXIS_RIGHTX: if (event.caxis.value < -16384) { left_key_pressed = 1; } else { left_key_pressed = 0; } if (event.caxis.value > 16384) { right_key_pressed = 1; } else { right_key_pressed = 0; } break; case SDL_CONTROLLER_AXIS_LEFTY: case SDL_CONTROLLER_AXIS_RIGHTY: if (event.caxis.value < -16384) { input_up_key_pressed = 1; } else { input_up_key_pressed = 0; } if (event.caxis.value > 16384) { down_key_pressed = 1; } else { down_key_pressed = 0; } break; } }
You can close gamepad and maybe SubSystem for better integration ?
void gamepad_shutdown() {
if (gamepad != NULL) {
SDL_GameControllerClose(gamepad );
}
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
}
thanks
Thanks :smile: I'll add the deinit for sure and see what the best way of integrating the axis code is. I should be able to use your code snippet or close to it
Hi Ryzee119, I'm currently working on controller support too. So I probably won't merge this PR. I'm refactoring the input handling a bit to get rid of key repeat and to implement controller mapping via the redefine menu.
No problem. Thanks for your work on this awesome game :)
I'll keep an eye out for future updates
I wrote a SDL_GameController backend for a port I am working on.
I appreciate there is probably many ways of doing this so will leave up to the author of this repo if they would like to merge or they had something else in mind. Happy to make changes if requested.
Benefits of this way:
gamecontroller_to_keyboard()
ininput.c
has been added to convert button events to SDL_Keycodes to integrate with the existing code base as much as possible.Current the mapping is as follows but happy to change based on feedback
What it doesn't do:
I have tested with my wired Xbox360 controller.
This will potentially close issue #12