/** * @brief Check call to SDL_StartTextInput and SDL_StopTextInput * * @sa http://wiki.libsdl.org/moin.cgi/SDL_StartTextInput * @sa http://wiki.libsdl.org/moin.cgi/SDL_StopTextInput */ int keyboard_startStopTextInput(void *arg) { /* Start-Stop */ SDL_StartTextInput(); SDLTest_AssertPass("Call to SDL_StartTextInput()"); SDL_StopTextInput(); SDLTest_AssertPass("Call to SDL_StopTextInput()"); /* Stop-Start */ SDL_StartTextInput(); SDLTest_AssertPass("Call to SDL_StartTextInput()"); /* Start-Start */ SDL_StartTextInput(); SDLTest_AssertPass("Call to SDL_StartTextInput()"); /* Stop-Stop */ SDL_StopTextInput(); SDLTest_AssertPass("Call to SDL_StopTextInput()"); SDL_StopTextInput(); SDLTest_AssertPass("Call to SDL_StopTextInput()"); return TEST_COMPLETED; }
void SDL2EventHandler::setTextInputMode(bool m) { if(m) SDL_StartTextInput(); else SDL_StopTextInput(); }
void Keyboard::setTextInput(bool enable) { if (enable) SDL_StartTextInput(); else SDL_StopTextInput(); }
Loop::Loop(const Renderer& renderer, Gui& gui) : mRenderer(renderer), mGui(gui), MAT_SIZE(Config::get().getValue("matrix_size")), PREGEN_BOIDS(Config::get().getValue("pregenerated_boids")), SEPARATION_DISTANCE(Config::get().getValue("separation_distance")), COHESION_DIVISOR(Config::get().getValue("cohesion_divisor")), ALIGNMENT_DIVISOR(Config::get().getValue("alignment_divisor")), GUI_WIDTH(Config::get().getValue("gui_width")), SCREEN_WIDTH(Config::get().getValue("screen_width")), SCREEN_HEIGHT(Config::get().getValue("screen_height")), mDataStructure(MAT_SIZE, PREGEN_BOIDS), mIsQuit(false), mIsLeftClickPressed(false), mIsRightClickPressed(false), mIsLeaderOn(false), mIsBoidVectorRendered(false), mIsDelaunayRendered(true), mIsDelaunayUpToDate(false), mTimeScale(1.0f), mFood(-10, -10), mPathFinish(GUI_WIDTH + 30.0f, 30.0f), mLeader(0), mObjectPlacement(0) { SDL_StopTextInput(); initializeGui(); updateBoidCounter(); mGui.updateElementContent(1, mBoidRules.changeParameter(mBoidRules.SEPARATION, .0f)); mGui.updateElementContent(2, mBoidRules.changeParameter(mBoidRules.COHESION, .0f)); mGui.updateElementContent(3, mBoidRules.changeParameter(mBoidRules.ALIGNMENT, .0f)); mGui.updateElementContent(4, mTimeScale * 100); }
/** * \brief Quits the input event manager. */ void InputEvent::quit() { if (joystick != nullptr) { SDL_JoystickClose(joystick); } SDL_StopTextInput(); }
void CSDL_Ext::stopTextInput() { if (SDL_IsTextInputActive() == SDL_TRUE) { SDL_StopTextInput(); } }
int main( int argc, char* args[] ) { //Start up SDL and create window if (!init()) { printf("Failed to initalize!\n"); }//end if else { //Load Media if (!loadMedia()) { printf("Failed to load media!\n"); }//end if else { // Main Loop Flag bool quit = false; //Event Handler SDL_Event e; //enable text input SDL_StartTextInput(); //While application is running while (!quit) { //Handle events on queue while (SDL_PollEvent(&e) != 0) { //User request quite if (e.type == SDL_QUIT) { quit = true; }//end if else if (e.type == SDL_TEXTINPUT) { int x = 0, y = 0; SDL_GetMouseState(&x, &y); handleKeys(e.text.text[0], x, y); } }//end while //Render quad render(); //Update screen SDL_GL_SwapWindow(gWindow); }//end main loop SDL_StopTextInput(); }//end else }//end if //Free resources and close SDL close(); system("pause"); return 0; }// end main func
int main(int argc, char* args[]) { if (!init(SCREEN_WIDTH, SCREEN_HEIGHT, "Lab 01", &gContext)) { fprintf(stderr, "Failed to initialize\n"); return 1; } gProgram = gl_compileShaderProgram(VERTEX_SHADER, FRAGMENT_SHADER); // gShape = shapes_makeTriangleStrip(); gShape = shapes_makeCircle(100, 0.4); glUseProgram(gProgram); SDL_Event e; SDL_StartTextInput(); while (!gContext.quit) { while(SDL_PollEvent(&e) != 0) { if (e.type == SDL_QUIT) { gContext.quit = true; } else if(e.type == SDL_TEXTINPUT) { int x = 0, y = 0; SDL_GetMouseState(&x, &y); handleKeys(e.text.text[0], x, y); } } render(); SDL_GL_SwapWindow(gContext.window); } SDL_StopTextInput(); shutdown(&gContext); return 0; }
void StopTextInput(std::string* stream) { _stoppingstream = stream; if (_stoppingstream == _startingstream) { SDL_StopTextInput(); _startingstream = nullptr; } }
void textinput_focus(component *c, int focus) { if(focus) { SDL_StartTextInput(); } else { SDL_StopTextInput(); } }
Input InputManager::get_input(){ static bool exit = false; frame_text.resize(0); SDL_Event evnt; SDL_StartTextInput(); //Will keep looping until there are no more events to process while (SDL_PollEvent(&evnt)) { switch (evnt.type) { case SDL_QUIT: return Input::EXIT_REQUEST; break; case SDL_MOUSEMOTION: set_mouse_coords((F32)evnt.motion.x, (F32)evnt.motion.y); break; case SDL_TEXTINPUT: frame_text += evnt.text.text; break; case SDL_KEYDOWN: key_press(evnt.key.keysym.sym , KEYBOARD); break; case SDL_KEYUP: key_release(evnt.key.keysym.sym , KEYBOARD); break; case SDL_MOUSEBUTTONDOWN: key_press(evnt.button.button , MOUSE); break; case SDL_MOUSEBUTTONUP: key_release(evnt.button.button , MOUSE); break; case SDL_JOYBUTTONDOWN: /* Handle Joystick Button Presses */ key_press(evnt.jbutton.button , CONTROLLER); break; case SDL_JOYBUTTONUP: /* Handle Joystick Button Presses */ key_release(evnt.jbutton.button , CONTROLLER); break; case SDL_JOYAXISMOTION: switch (evnt.jaxis.axis){ case 0: set_controller_axis_coord(&m_controller_LX_coords.x, evnt.jaxis.value); break; case 1: set_controller_axis_coord(&m_controller_LX_coords.y, evnt.jaxis.value); break; case 2: set_controller_axis_coord(&m_controller_RX_coords.x, evnt.jaxis.value); break; case 3: set_controller_axis_coord(&m_controller_RX_coords.y, evnt.jaxis.value); break; } } } SDL_StopTextInput(); if (is_key_pressed(SDLK_ESCAPE,KEYBOARD))exit = !exit; if(!exit)SDL_WarpMouseInWindow(m_window, WINDOW_WIDTH / 2.0f, WINDOW_HEIGHT / 2.0f); return Input::OK; }
void Application::keyEvent(Context& context, const KeyPressEvent& event) { input.setPressed(event.getCode(), event.isPressed()); if (event.isPressed()) { if (event.getCode() == SDLK_BACKQUOTE) { console.toggle(); if (console.isActive()) { SDL_StartTextInput(); } else if (context.is(*game)) { SDL_StopTextInput(); } } if (console.isActive()) { console.keyEvent(event.getCode(), event.getModifiers()); } else { context.keyEvent(event); } } }
void grabText(textbox *pTextbox, const SDL_Event& e) { if(pTextbox != NULL) { if(pTextbox->GetType() == "textbox") { SDL_StartTextInput(); do { //Loop until the text input events are done. if(SDL_PollEvent((SDL_Event*)&e)) { //check the input events switch(e.type) { case SDL_TEXTINPUT: if(e.text.text != "") { //If the text is not empty, we want to display it. pTextbox->changeMsg(pTextbox->GetText() + std::string(e.text.text), pTextbox->GetRenderer()); pTextbox->Draw(*pTextbox->GetRenderer()); } } } }while(e.key.keysym.scancode != SDL_SCANCODE_RETURN); SDL_StopTextInput(); } } }
void IN_Init (void) { textmode = Key_TextEntry(); if (textmode) SDL_StartTextInput(); else SDL_StopTextInput(); if (safemode || COM_CheckParm("-nomouse")) { no_mouse = true; /* discard all mouse events when input is deactivated */ IN_BeginIgnoringMouseEvents(); } Cvar_RegisterVariable(&in_debugkeys); Cvar_RegisterVariable(&joy_sensitivity_yaw); Cvar_RegisterVariable(&joy_sensitivity_pitch); Cvar_RegisterVariable(&joy_deadzone); Cvar_RegisterVariable(&joy_deadzone_trigger); Cvar_RegisterVariable(&joy_invert); Cvar_RegisterVariable(&joy_exponent); Cvar_RegisterVariable(&joy_swapmovelook); Cvar_RegisterVariable(&joy_enable); IN_Activate(); IN_StartupJoystick(); }
void ClientConsole::toggleConsole () { _active ^= true; if (_active) SDL_StartTextInput(); else SDL_StopTextInput(); }
void StopTextInput() { SDL_StopTextInput(); // disable text events CurrentKey = 0; memset(text, 0x0, sizeof(text)); GetTextEvents = false; debug(LOG_INPUT, "SDL text events stopped"); }
void GameState::handleTerminal(Game& game){ if (Input::isKeyDown(SDL_SCANCODE_F2)){ game.getWorld()->scene->player->getComponent<Player>().frozen = false; game.getWorld()->scene->terminal->enabled = false; SDL_StopTextInput(); game.getWorld()->stateFunctionStack.pop(); } }
void CleanupVideo() { SDL_StopTextInput(); #ifdef HAVE_SDL_TTF TTF_CloseFont(font); TTF_Quit(); #endif }
void InputHandler::stopTextInput() { if (textInputEnabled) { SDL_StopTextInput(); textInputEnabled = false; #if defined(DEBUG_IH_TEXT_INPUT) && DEBUG_IH_TEXT_INPUT DEBUG_BEGIN << DEBUG_IH_PREPEND << "TextInput DISABLED" << std::endl; #endif } }
void Game::tearDown() { assets.freeAll(); SDL_StopTextInput(); TTF_Quit(); delete map; delete platformSDL; }
void EventosInputTexto::desabilitar() { habilitado = false; SDL_StopTextInput(); pos_cursor = 0; tamanho_selecao = 0; str.clear(); }
/* =============== IN_Shutdown =============== */ void IN_Shutdown() { SDL_StopTextInput(); IN_DeactivateMouse(true); mouseAvailable = false; IN_ShutdownJoystick(); window = nullptr; }
void window::end_text_input() { if (not is_text_input_active()) { throw std::runtime_error("Tried to end text input while text input is not active."); } SDL_StopTextInput(); }
void I_StopTextInput(void) { text_input_enabled = false; if (!vanilla_keyboard_mapping) { SDL_StopTextInput(); } }
int name_click(int b, int d) { if (gui_click(b, d)) return st_buttn(config_get_d(CONFIG_JOYSTICK_BUTTON_A), 1); else { SDL_StopTextInput(); return 1; } }
void Redraw() { int w = 0, h = textRect.h; SDL_Rect cursorRect, underlineRect; SDL_FillRect(screen, &textRect, backColor); #ifdef HAVE_SDL_TTF if (strlen(text)) { RenderText(screen, font, text, textRect.x, textRect.y, textColor); TTF_SizeUTF8(font, text, &w, &h); } #endif markedRect.x = textRect.x + w; markedRect.w = textRect.w - w; if (markedRect.w < 0) { SDL_Flip(screen); // Stop text input because we cannot hold any more characters SDL_StopTextInput(); return; } else { SDL_StartTextInput(); } cursorRect = markedRect; cursorRect.w = 2; cursorRect.h = h; SDL_FillRect(screen, &markedRect, backColor); if (markedText) { #ifdef HAVE_SDL_TTF RenderText(screen, font, markedText, markedRect.x, markedRect.y, textColor); TTF_SizeUTF8(font, markedText, &w, &h); #endif underlineRect = markedRect; underlineRect.y += (h - 2); underlineRect.h = 2; underlineRect.w = w; cursorRect.x += w + 1; SDL_FillRect(screen, &underlineRect, lineColor); } SDL_FillRect(screen, &cursorRect, lineColor); SDL_Flip(screen); SDL_SetTextInputRect(&markedRect); }
void SdlApp::shutdown() { SDL_StopTextInput(); if (mWindow != nullptr) SDL_DestroyWindow(mWindow); SDL_Quit(); }
void ui_console_toggle(bool enable) { console_enabled = enable; if (console_enabled) { SDL_StartTextInput(); } else { SDL_StopTextInput(); } }
void SDL2InputBackend::stopTextInput() { if(m_textHandler) { if(!m_editText.empty()) { m_textHandler->editingText(std::string(), 0, 0); m_editText.clear(); } SDL_StopTextInput(); } m_textHandler = NULL; }
/* =============== IN_Shutdown =============== */ void IN_Shutdown() { SDL_StopTextInput(); IN_SetMouseMode(MouseMode::SystemCursor); mouseAvailable = false; IN_ShutdownJoystick(); window = nullptr; }