Mercurial > repos > blastem
diff nuklear_ui/nuklear_sdl_gles2.h @ 2318:1c7329ac7f3f
Make UI respect stick deadzone
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 02 Apr 2023 23:36:30 -0700 |
parents | 523ab225815b |
children | 568c1c22f3e3 |
line wrap: on
line diff
--- a/nuklear_ui/nuklear_sdl_gles2.h Sun Apr 02 23:21:39 2023 -0700 +++ b/nuklear_ui/nuklear_sdl_gles2.h Sun Apr 02 23:36:30 2023 -0700 @@ -23,7 +23,9 @@ #include <GL/glew.h> #endif #endif +#include "../render_sdl.h" #include "../render.h" +#include "../controller_info.h" NK_API struct nk_context* nk_sdl_init(SDL_Window *win); @@ -432,7 +434,9 @@ } } else if (evt->type == SDL_CONTROLLERAXISMOTION) { if (evt->caxis.axis == SDL_CONTROLLER_AXIS_LEFTY || evt->caxis.axis == SDL_CONTROLLER_AXIS_RIGHTY) { - int down = abs(evt->caxis.value) > 2000; + int joystick = render_find_joystick_index(evt->caxis.which); + controller_info info = get_controller_info(joystick); + int down = abs(evt->caxis.value) > info.stick_deadzone; if (evt->caxis.value >= 0) { if (ctx->input.keyboard.keys[NK_KEY_UP].down) { nk_input_key(ctx, NK_KEY_UP, 0);