void text_callback(GLFWwindow *win, unsigned int codepoint) { nk_input_unicode(ctx, codepoint); }
NK_API int nk_headless_handle_event(void) { printf("nk_headless_handle_event\n"); return nk_true; #if 0 struct nk_context *ctx = &headless.ctx; if (evt->type == SDL_VIDEORESIZE) { /* Do nothing */ } else if (evt->type == SDL_KEYUP || evt->type == SDL_KEYDOWN) { /* key events */ int down = evt->type == SDL_KEYDOWN; SDLMod state = SDL_GetModState(); SDLKey sym = evt->key.keysym.sym; if (sym == SDLK_RSHIFT || sym == SDLK_LSHIFT) nk_input_key(ctx, NK_KEY_SHIFT, down); else if (sym == SDLK_DELETE) nk_input_key(ctx, NK_KEY_DEL, down); else if (sym == SDLK_RETURN) nk_input_key(ctx, NK_KEY_ENTER, down); else if (sym == SDLK_TAB) nk_input_key(ctx, NK_KEY_TAB, down); else if (sym == SDLK_LEFT) nk_input_key(ctx, NK_KEY_LEFT, down); else if (sym == SDLK_RIGHT) nk_input_key(ctx, NK_KEY_RIGHT, down); else if (sym == SDLK_BACKSPACE) nk_input_key(ctx, NK_KEY_BACKSPACE, down); else if (sym == SDLK_HOME) nk_input_key(ctx, NK_KEY_TEXT_START, down); else if (sym == SDLK_END) nk_input_key(ctx, NK_KEY_TEXT_END, down); else if (sym == SDLK_SPACE && !down) nk_input_char(ctx, ' '); else { if (sym == SDLK_c && state == SDLK_LCTRL) nk_input_key(ctx, NK_KEY_COPY, down); else if (sym == SDLK_v && state == SDLK_LCTRL) nk_input_key(ctx, NK_KEY_PASTE, down); else if (sym == SDLK_x && state == SDLK_LCTRL) nk_input_key(ctx, NK_KEY_CUT, down); else if (sym == SDLK_z && state == SDLK_LCTRL) nk_input_key(ctx, NK_KEY_TEXT_UNDO, down); else if (sym == SDLK_r && state == SDLK_LCTRL) nk_input_key(ctx, NK_KEY_TEXT_REDO, down); else if (sym == SDLK_LEFT && state == SDLK_LCTRL) nk_input_key(ctx, NK_KEY_TEXT_WORD_LEFT, down); else if (sym == SDLK_RIGHT && state == SDLK_LCTRL) nk_input_key(ctx, NK_KEY_TEXT_WORD_RIGHT, down); else if (sym == SDLK_b && state == SDLK_LCTRL) nk_input_key(ctx, NK_KEY_TEXT_LINE_START, down); else if (sym == SDLK_e && state == SDLK_LCTRL) nk_input_key(ctx, NK_KEY_TEXT_LINE_END, down); else if (!down) { /* This demo does not provide full unicode support since the default * sdl1.2 font only allows runes in range 0-255. But this demo * already is quite limited and not really meant for full blown Apps * anyway. So I think ASCII support for Debugging Tools should be enough */ if (sym >= SDLK_0 && sym <= SDLK_9) { nk_rune rune = '0' + sym - SDLK_0; nk_input_unicode(ctx, rune); } else if (sym >= SDLK_a && sym <= SDLK_z) { nk_rune rune = 'a' + sym - SDLK_a; rune = ((state == KMOD_LSHIFT) ? (nk_rune)nk_to_upper((int)rune):rune); nk_input_unicode(ctx, rune); } } } } else if (evt->type == SDL_MOUSEBUTTONDOWN || evt->type == SDL_MOUSEBUTTONUP) { /* mouse button */ int down = evt->type == SDL_MOUSEBUTTONDOWN; const int x = evt->button.x, y = evt->button.y; if (evt->button.button == SDL_BUTTON_LEFT) nk_input_button(ctx, NK_BUTTON_LEFT, x, y, down); if (evt->button.button == SDL_BUTTON_MIDDLE) nk_input_button(ctx, NK_BUTTON_MIDDLE, x, y, down); if (evt->button.button == SDL_BUTTON_RIGHT) nk_input_button(ctx, NK_BUTTON_RIGHT, x, y, down); if (evt->button.button == SDL_BUTTON_WHEELUP) nk_input_scroll(ctx, 1.0f); if (evt->button.button == SDL_BUTTON_WHEELDOWN) nk_input_scroll(ctx, -1.0f); } else if (evt->type == SDL_MOUSEMOTION) { nk_input_motion(ctx, evt->motion.x, evt->motion.y); } #endif }