2 #include "nuklear_internal.h" 
   17     for (i = 0; i < NK_BUTTON_MAX; ++i)
 
   18         in->mouse.buttons[i].clicked = 0;
 
   20     in->keyboard.text_len = 0;
 
   21     in->mouse.scroll_delta = 
nk_vec2(0,0);
 
   22     in->mouse.prev.x = in->mouse.pos.x;
 
   23     in->mouse.prev.y = in->mouse.pos.y;
 
   24     in->mouse.delta.x = 0;
 
   25     in->mouse.delta.y = 0;
 
   26     for (i = 0; i < NK_KEY_MAX; i++)
 
   27         in->keyboard.keys[i].clicked = 0;
 
   38     if (in->mouse.ungrab) {
 
   39         in->mouse.grabbed = 0;
 
   51     in->mouse.pos.x = (float)x;
 
   52     in->mouse.pos.y = (float)y;
 
   53     in->mouse.delta.x = in->mouse.pos.x - in->mouse.prev.x;
 
   54     in->mouse.delta.y = in->mouse.pos.y - in->mouse.prev.y;
 
   63 #ifdef NK_KEYSTATE_BASED_INPUT 
   64     if (in->keyboard.keys[key].down != down)
 
   65         in->keyboard.keys[key].clicked++;
 
   67     in->keyboard.keys[key].clicked++;
 
   69     in->keyboard.keys[key].down = down;
 
   79     if (in->mouse.buttons[
id].down == down) 
return;
 
   81     btn = &in->mouse.buttons[id];
 
   82     btn->clicked_pos.x = (float)x;
 
   83     btn->clicked_pos.y = (float)y;
 
   88     in->mouse.delta.x = 0;
 
   89     in->mouse.delta.y = 0;
 
   90 #ifdef NK_BUTTON_TRIGGER_ON_RELEASE 
   91     if (down == 1 && 
id == NK_BUTTON_LEFT)
 
   93         in->mouse.down_pos.x = btn->clicked_pos.x;
 
   94         in->mouse.down_pos.y = btn->clicked_pos.y;
 
  103     ctx->input.mouse.scroll_delta.x += val.x;
 
  104     ctx->input.mouse.scroll_delta.y += val.y;
 
  118     if (len && ((in->keyboard.text_len + len) < NK_INPUT_MAX)) {
 
  119         nk_utf_encode(unicode, &in->keyboard.text[in->keyboard.text_len],
 
  120             NK_INPUT_MAX - in->keyboard.text_len);
 
  121         in->keyboard.text_len += len;
 
  143 nk_input_has_mouse_click(
const struct nk_input *i, 
enum nk_buttons 
id)
 
  146     if (!i) 
return nk_false;
 
  147     btn = &i->mouse.buttons[id];
 
  148     return (btn->clicked && btn->down == nk_false) ? nk_true : nk_false;
 
  151 nk_input_has_mouse_click_in_rect(
const struct nk_input *i, 
enum nk_buttons 
id,
 
  155     if (!i) 
return nk_false;
 
  156     btn = &i->mouse.buttons[id];
 
  157     if (!NK_INBOX(btn->clicked_pos.x,btn->clicked_pos.y,b.x,b.y,b.w,b.h))
 
  162 nk_input_has_mouse_click_in_button_rect(
const struct nk_input *i, 
enum nk_buttons 
id,
 
  166     if (!i) 
return nk_false;
 
  167     btn = &i->mouse.buttons[id];
 
  168 #ifdef NK_BUTTON_TRIGGER_ON_RELEASE 
  169     if (!NK_INBOX(btn->clicked_pos.x,btn->clicked_pos.y,b.x,b.y,b.w,b.h)
 
  170         || !NK_INBOX(i->mouse.down_pos.x,i->mouse.down_pos.y,b.x,b.y,b.w,b.h))
 
  172     if (!NK_INBOX(btn->clicked_pos.x,btn->clicked_pos.y,b.x,b.y,b.w,b.h))
 
  178 nk_input_has_mouse_click_down_in_rect(
const struct nk_input *i, 
enum nk_buttons 
id,
 
  179     struct nk_rect b, nk_bool down)
 
  182     if (!i) 
return nk_false;
 
  183     btn = &i->mouse.buttons[id];
 
  184     return nk_input_has_mouse_click_in_rect(i, 
id, b) && (btn->down == down);
 
  187 nk_input_is_mouse_click_in_rect(
const struct nk_input *i, 
enum nk_buttons 
id,
 
  191     if (!i) 
return nk_false;
 
  192     btn = &i->mouse.buttons[id];
 
  193     return (nk_input_has_mouse_click_down_in_rect(i, 
id, b, nk_false) &&
 
  194             btn->clicked) ? nk_true : nk_false;
 
  197 nk_input_is_mouse_click_down_in_rect(
const struct nk_input *i, 
enum nk_buttons 
id,
 
  198     struct nk_rect b, nk_bool down)
 
  201     if (!i) 
return nk_false;
 
  202     btn = &i->mouse.buttons[id];
 
  203     return (nk_input_has_mouse_click_down_in_rect(i, 
id, b, down) &&
 
  204             btn->clicked) ? nk_true : nk_false;
 
  207 nk_input_any_mouse_click_in_rect(
const struct nk_input *in, 
struct nk_rect b)
 
  210     for (i = 0; i < NK_BUTTON_MAX; ++i)
 
  211         down = down || nk_input_is_mouse_click_in_rect(in, (
enum nk_buttons)i, b);
 
  215 nk_input_is_mouse_hovering_rect(
const struct nk_input *i, 
struct nk_rect rect)
 
  217     if (!i) 
return nk_false;
 
  218     return NK_INBOX(i->mouse.pos.x, i->mouse.pos.y, rect.x, rect.y, rect.w, rect.h);
 
  221 nk_input_is_mouse_prev_hovering_rect(
const struct nk_input *i, 
struct nk_rect rect)
 
  223     if (!i) 
return nk_false;
 
  224     return NK_INBOX(i->mouse.prev.x, i->mouse.prev.y, rect.x, rect.y, rect.w, rect.h);
 
  227 nk_input_mouse_clicked(
const struct nk_input *i, 
enum nk_buttons 
id, 
struct nk_rect rect)
 
  229     if (!i) 
return nk_false;
 
  230     if (!nk_input_is_mouse_hovering_rect(i, rect)) 
return nk_false;
 
  231     return nk_input_is_mouse_click_in_rect(i, 
id, rect);
 
  234 nk_input_is_mouse_down(
const struct nk_input *i, 
enum nk_buttons 
id)
 
  236     if (!i) 
return nk_false;
 
  237     return i->mouse.buttons[id].down;
 
  240 nk_input_is_mouse_pressed(
const struct nk_input *i, 
enum nk_buttons 
id)
 
  243     if (!i) 
return nk_false;
 
  244     b = &i->mouse.buttons[id];
 
  245     if (b->down && b->clicked)
 
  250 nk_input_is_mouse_released(
const struct nk_input *i, 
enum nk_buttons 
id)
 
  252     if (!i) 
return nk_false;
 
  253     return (!i->mouse.buttons[
id].down && i->mouse.buttons[
id].clicked);
 
  256 nk_input_is_key_pressed(
const struct nk_input *i, 
enum nk_keys key)
 
  259     if (!i) 
return nk_false;
 
  260     k = &i->keyboard.keys[key];
 
  261     if ((k->down && k->clicked) || (!k->down && k->clicked >= 2))
 
  266 nk_input_is_key_released(
const struct nk_input *i, 
enum nk_keys key)
 
  269     if (!i) 
return nk_false;
 
  270     k = &i->keyboard.keys[key];
 
  271     if ((!k->down && k->clicked) || (k->down && k->clicked >= 2))
 
  276 nk_input_is_key_down(
const struct nk_input *i, 
enum nk_keys key)
 
  279     if (!i) 
return nk_false;
 
  280     k = &i->keyboard.keys[key];
 
  281     if (k->down) 
return nk_true;
 
main API and documentation file
 
NK_API void nk_input_end(struct nk_context *)
End the input mirroring process by resetting mouse grabbing state to ensure the mouse cursor is not g...
 
NK_API void nk_input_begin(struct nk_context *)
Begins the input mirroring process by resetting text, scroll mouse, previous mouse position and movem...
 
#define NK_UTF_SIZE
describes the number of bytes a glyph consists of
 
NK_API void nk_input_unicode(struct nk_context *, nk_rune)
Converts a unicode rune into UTF-8 and copies the result into an internal text buffer.
 
NK_API void nk_input_key(struct nk_context *, enum nk_keys, nk_bool down)
Mirrors the state of a specific key to nuklear.
 
NK_API void nk_input_button(struct nk_context *, enum nk_buttons, int x, int y, nk_bool down)
Mirrors the state of a specific mouse button to nuklear.
 
NK_API void nk_input_char(struct nk_context *, char)
Copies a single ASCII character into an internal text buffer.
 
NK_API void nk_input_scroll(struct nk_context *, struct nk_vec2 val)
Copies the last mouse scroll value to nuklear.
 
NK_API void nk_input_motion(struct nk_context *, int x, int y)
Mirrors current mouse position to nuklear.
 
NK_API void nk_input_glyph(struct nk_context *, const nk_glyph)
Converts an encoded unicode rune into UTF-8 and copies the result into an internal text buffer.