input: add keyboard and mouse input flags#217
Conversation
|
Add a demo case for this. |
| /** | ||
| * Set the keyboard output pointer. Called when a key is captured with NK_CONSOLE_INPUT_FLAG_KEYBOARD. | ||
| */ | ||
| NK_API void nk_console_input_set_keyboard_out(nk_console* widget, nk_rune* out_key); |
There was a problem hiding this comment.
Add a nk_console_input_set_gamepad_out()... Should take all int gamepad_number, int* out_gamepad_number, enum nk_gamepad_button* out_gamepad_button.
| * Use a bitwise OR of nk_console_input_flags values. | ||
| * Defaults to NK_CONSOLE_INPUT_FLAG_GAMEPAD. | ||
| */ | ||
| NK_API void nk_console_input_set_flags(nk_console* widget, nk_uint flags); |
There was a problem hiding this comment.
Looking to add some helper constructors...
- Add
nk_console_input_gamepad()that just calls nk_console_input() - Add
nk_console_input_key()that sets up the widget just for keyboard input - Add
nk_console_input_mouse()that sets up the widget just for mouse input
| NK_CONSOLE_INPUT_FLAG_GAMEPAD = (1 << 0), | ||
| NK_CONSOLE_INPUT_FLAG_KEYBOARD = (1 << 1), | ||
| NK_CONSOLE_INPUT_FLAG_MOUSE = (1 << 2), |
There was a problem hiding this comment.
Could use NK_FLAG() for NK_CONSOLE_INPUT_FLAG_GAMEPAD NK_CONSOLE_INPUT_FLAG_KEYBOARD and NK_CONSOLE_INPUT_FLAG_MOUSE
| ((nk_console_input_data*)widget->data)->out_key = out_key; | ||
| } | ||
|
|
||
| NK_API void nk_console_input_set_mouse_out(nk_console* widget, enum nk_buttons* out_mouse_button) { |
There was a problem hiding this comment.
Add a helper methods that will check whether or not the selected output is a key, mouse button, or gamepad input devive.
nk_console_input_is_mouse()
nk_console_input_is_key()
nk_console_input_is_gamepad()
| if (nk_input_is_mouse_released(&console->ctx->input, (enum nk_buttons)mi)) { | ||
| if (data->out_mouse_button != NULL) *data->out_mouse_button = (enum nk_buttons)mi; | ||
| nk_console_trigger_event(input, NK_CONSOLE_EVENT_CHANGED); | ||
| finished = nk_true; |
There was a problem hiding this comment.
Make sure the repesented key is presenteed nicely. Copy the nk_console_key_name() function over to nk_console_input_key_name(), and use it when rendering the widget.
| #define NK_CONSOLE_INPUT_H__ | ||
|
|
||
| /** | ||
| * Flags that control which input sources are accepted by an input widget. |
There was a problem hiding this comment.
In the doxygen docs of nk_console_input_flags, add @see nk_console_input()
Extends nk_console_input with nk_console_input_flags (NK_CONSOLE_INPUT_FLAG_GAMEPAD, _KEYBOARD, _MOUSE). New API: nk_console_input_set_flags(), nk_console_input_get_flags(), nk_console_input_set_keyboard_out(), nk_console_input_set_mouse_out(). The prompt text updates dynamically to reflect active sources; defaults to gamepad-only for backward compatibility. Fixes #16