Mercurial > repos > blastem
comparison 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 |
comparison
equal
deleted
inserted
replaced
2317:e836cf11783b | 2318:1c7329ac7f3f |
---|---|
21 #include <SDL_opengles2.h> | 21 #include <SDL_opengles2.h> |
22 #else | 22 #else |
23 #include <GL/glew.h> | 23 #include <GL/glew.h> |
24 #endif | 24 #endif |
25 #endif | 25 #endif |
26 #include "../render_sdl.h" | |
26 #include "../render.h" | 27 #include "../render.h" |
28 #include "../controller_info.h" | |
27 | 29 |
28 | 30 |
29 NK_API struct nk_context* nk_sdl_init(SDL_Window *win); | 31 NK_API struct nk_context* nk_sdl_init(SDL_Window *win); |
30 NK_API void nk_sdl_font_stash_begin(struct nk_font_atlas **atlas); | 32 NK_API void nk_sdl_font_stash_begin(struct nk_font_atlas **atlas); |
31 NK_API void nk_sdl_font_stash_end(void); | 33 NK_API void nk_sdl_font_stash_end(void); |
430 } else if (evt->cbutton.button == SDL_CONTROLLER_BUTTON_A || evt->cbutton.button == SDL_CONTROLLER_BUTTON_START) { | 432 } else if (evt->cbutton.button == SDL_CONTROLLER_BUTTON_A || evt->cbutton.button == SDL_CONTROLLER_BUTTON_START) { |
431 nk_input_key(ctx, NK_KEY_ENTER, down); | 433 nk_input_key(ctx, NK_KEY_ENTER, down); |
432 } | 434 } |
433 } else if (evt->type == SDL_CONTROLLERAXISMOTION) { | 435 } else if (evt->type == SDL_CONTROLLERAXISMOTION) { |
434 if (evt->caxis.axis == SDL_CONTROLLER_AXIS_LEFTY || evt->caxis.axis == SDL_CONTROLLER_AXIS_RIGHTY) { | 436 if (evt->caxis.axis == SDL_CONTROLLER_AXIS_LEFTY || evt->caxis.axis == SDL_CONTROLLER_AXIS_RIGHTY) { |
435 int down = abs(evt->caxis.value) > 2000; | 437 int joystick = render_find_joystick_index(evt->caxis.which); |
438 controller_info info = get_controller_info(joystick); | |
439 int down = abs(evt->caxis.value) > info.stick_deadzone; | |
436 if (evt->caxis.value >= 0) { | 440 if (evt->caxis.value >= 0) { |
437 if (ctx->input.keyboard.keys[NK_KEY_UP].down) { | 441 if (ctx->input.keyboard.keys[NK_KEY_UP].down) { |
438 nk_input_key(ctx, NK_KEY_UP, 0); | 442 nk_input_key(ctx, NK_KEY_UP, 0); |
439 } | 443 } |
440 nk_input_key(ctx, NK_KEY_DOWN, down); | 444 nk_input_key(ctx, NK_KEY_DOWN, down); |