/* =============== IN_Init =============== */ void IN_Init( void *windowData ) { int appState; if( !SDL_WasInit( SDL_INIT_VIDEO ) ) { Com_Error( ERR_FATAL, "IN_Init called before SDL_Init( SDL_INIT_VIDEO )" ); return; } SDL_window = (SDL_Window *)windowData; Com_DPrintf( "\n------- Input Initialization -------\n" ); in_keyboardDebug = Cvar_Get( "in_keyboardDebug", "0", CVAR_ARCHIVE ); // mouse variables in_mouse = Cvar_Get( "in_mouse", "1", CVAR_ARCHIVE ); in_nograb = Cvar_Get( "in_nograb", "0", CVAR_ARCHIVE ); in_joystick = Cvar_Get( "in_joystick", "0", CVAR_ARCHIVE|CVAR_LATCH ); in_joystickThreshold = Cvar_Get( "joy_threshold", "0.15", CVAR_ARCHIVE ); SDL_StartTextInput( ); mouseAvailable = ( in_mouse->value != 0 ); IN_DeactivateMouse( ); appState = SDL_GetWindowFlags( SDL_window ); Cvar_SetValue( "com_unfocused", !( appState & SDL_WINDOW_INPUT_FOCUS ) ); Cvar_SetValue( "com_minimized", appState & SDL_WINDOW_MINIMIZED ); IN_InitJoystick( ); Com_DPrintf( "------------------------------------\n" ); }
/** * @brief Called when the node got the focus */ void uiTextEntryNode::onFocusGained (uiNode_t* node) { assert(editedCvar == nullptr); /* skip '*cvar ' */ const char* cvarRef = "*cvar:"; editedCvar = Cvar_GetOrCreate(&((const char*)node->text)[strlen(cvarRef)]); assert(editedCvar); Q_strncpyz(cvarValueBackup, editedCvar->string, sizeof(cvarValueBackup)); isAborted = false; EXTRADATA(node).cursorPosition = UTF8_strlen(editedCvar->string); #if SDL_VERSION_ATLEAST(2,0,0) SDL_StartTextInput(); vec2_t pos; UI_GetNodeAbsPos(node, pos); SDL_Rect r = {static_cast<int>(pos[0]), static_cast<int>(pos[1]), static_cast<int>(node->box.size[0]), static_cast<int>(node->box.size[1])}; SDL_SetTextInputRect(&r); #else #ifdef ANDROID char buf[MAX_CVAR_EDITING_LENGTH]; Q_strncpyz(buf, editedCvar->string, sizeof(buf)); SDL_ANDROID_GetScreenKeyboardTextInput(buf, sizeof(buf)); Cvar_ForceSet(editedCvar->name, buf); UI_TextEntryNodeValidateEdition(node); UI_RemoveFocus(); #endif #endif }
static void InitSDL() { #if OS_LINUX // In fullscreen mode when SDL is compiled with DGA support, the mouse // sensitivity often appears to be unusably wrong (typically too low). // (This seems to be reported almost exclusively on Ubuntu, but can be // reproduced on Gentoo after explicitly enabling DGA.) // Disabling the DGA mouse appears to fix that problem, and doesn't // have any obvious negative effects. setenv("SDL_VIDEO_X11_DGAMOUSE", "0", 0); #endif if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE) < 0) { LOGERROR(L"SDL library initialization failed: %hs", SDL_GetError()); throw PSERROR_System_SDLInitFailed(); } atexit(SDL_Quit); #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_StartTextInput(); #else SDL_EnableUNICODE(1); #endif }
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 SDL2EventHandler::setTextInputMode(bool m) { if(m) SDL_StartTextInput(); else SDL_StopTextInput(); }
void CSDL_Ext::startTextInput(SDL_Rect * where) { if (SDL_IsTextInputActive() == SDL_FALSE) { SDL_StartTextInput(); } SDL_SetTextInputRect(where); }
void j1Input::StartTextInput(SDL_Rect* rect) { text_input = true; SDL_StartTextInput(); if(rect != NULL) SDL_SetTextInputRect(rect); }
void j1Input::StartInput(p2SString edit_input, int pos) { SDL_StartTextInput(); //so it can have lots of input boxes input_text = edit_input; cursor_pos = pos; enable_input = true; }
void ClientConsole::toggleConsole () { _active ^= true; if (_active) SDL_StartTextInput(); else SDL_StopTextInput(); }
void Connect::onEnter() { SDL_StartTextInput(); name = "Type Opponents Hostname ..."; server->setText(font, name, 100); server->setPosition(1920 / 2, 500, Center); }
/** * \brief Initializes the input event manager. */ void InputEvent::initialize() { // Initialize text events. SDL_StartTextInput(); // Initialize the joypad. set_joypad_enabled(true); }
void TextBox::OnFocusAcquired() { assert(SDL_IsTextInputActive() == SDL_FALSE); m_caret.StartAnimation(); SetBorderColor(SDLColor(64, 64, 128, 0)); auto loc = GetLocation(); SDL_SetTextInputRect(&loc); SDL_StartTextInput(); }
void ui_console_toggle(bool enable) { console_enabled = enable; if (console_enabled) { SDL_StartTextInput(); } else { SDL_StopTextInput(); } }
void InputHandler::startTextInput() { if (!textInputEnabled) { SDL_StartTextInput(); textInputEnabled = true; #if defined(DEBUG_IH_TEXT_INPUT) && DEBUG_IH_TEXT_INPUT DEBUG_BEGIN << DEBUG_IH_PREPEND << "TextInput ENABLED" << std::endl; #endif } }
void EventosInputTexto::habilitar() { SDL_StartTextInput(); habilitado = true; pos_cursor = 0; tamanho_selecao = 0; str.clear(); }
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 IN_Init(void) { int appState; if (!SDL_WasInit(SDL_INIT_VIDEO)) { Com_Error(ERR_FATAL, "IN_Init called before SDL_Init( SDL_INIT_VIDEO )"); return; } mainScreen = (SDL_Window *)GLimp_MainWindow(); Com_DPrintf("\n------- Input Initialization -------\n"); in_keyboardDebug = Cvar_Get("in_keyboardDebug", "0", CVAR_TEMP); // mouse variables in_mouse = Cvar_Get("in_mouse", "1", CVAR_ARCHIVE); if (in_mouse->integer == 2) { Com_Printf("Trying to emulate non raw input\n"); if (!SDL_SetHintWithPriority(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "1", SDL_HINT_OVERRIDE)) { Com_Printf(S_COLOR_RED "Failed to set the hint"); } } else { SDL_SetHintWithPriority(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "0", SDL_HINT_OVERRIDE); } in_nograb = Cvar_Get("in_nograb", "0", CVAR_ARCHIVE); in_joystick = Cvar_Get("in_joystick", "0", CVAR_ARCHIVE | CVAR_LATCH); in_joystickThreshold = Cvar_Get("joy_threshold", "0.15", CVAR_ARCHIVE); SDL_StartTextInput(); mouseAvailable = (in_mouse->value != 0); IN_DeactivateMouse(); appState = SDL_GetWindowFlags(mainScreen); Cvar_SetValue("com_unfocused", !((appState & SDL_WINDOW_INPUT_FOCUS) && (appState & SDL_WINDOW_MOUSE_FOCUS))); Cvar_SetValue("com_minimized", appState & SDL_WINDOW_MINIMIZED); IN_InitKeyLockStates(); // FIXME: Joystick initialization crashes some Windows and Mac OS X clients (see SDL #2833) //IN_InitJoystick(); #ifdef DISABLE_DINGY IN_EnableDingFilter(); #endif Com_DPrintf("------------------------------------\n"); }
int main(int argc, char *argv[]) { SDL_Window *window; SDL_Event event; int done; /* Initialize SDL */ if (SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError()); return (1); } /* Set 640x480 video mode */ window = SDL_CreateWindow("CheckKeys Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, 0); if (!window) { fprintf(stderr, "Couldn't create 640x480 window: %s\n", SDL_GetError()); quit(2); } #if __IPHONEOS__ /* Creating the context creates the view, which we need to show keyboard */ SDL_GL_CreateContext(window); #endif SDL_StartTextInput(); /* Watch keystrokes */ done = 0; while (!done) { /* Check for events */ SDL_WaitEvent(&event); switch (event.type) { case SDL_KEYDOWN: case SDL_KEYUP: PrintKey(&event.key.keysym, event.key.state, event.key.repeat); break; case SDL_TEXTINPUT: PrintText(event.text.text); break; case SDL_MOUSEBUTTONDOWN: /* Any button press quits the app... */ case SDL_QUIT: done = 1; break; default: break; } } SDL_Quit(); return (0); }
void Menu::beforeStart(Context* prevContext) { SDL_ShowCursor(SDL_ENABLE); SDL_StartTextInput(); rebuildTable(); if (playMusic) { menuTrack.play(false); } }
BEGIN_NAMESPACE_YUP bool SdlApp::init() { if (!App::init()) return false; SDL_StartTextInput(); return true; }
/** * Get any keys that are currently being typed. Output in Aski. * If phone, pops up keyboard if not already up. If nothing is being typed, * returns 0. */ uint8_t jl_ct_typing_get(jlgr_t *jlgr) { if(!SDL_IsTextInputActive()) SDL_StartTextInput(); uint8_t rtn = jlgr->main.ct.text_input[jlgr->main.ct.read_cursor]; if(jl_ct_key_pressed(jlgr, SDL_SCANCODE_BACKSPACE) == 1) return '\b'; if(jl_ct_key_pressed(jlgr, SDL_SCANCODE_DELETE) == 1) return '\02'; if(jl_ct_key_pressed(jlgr, SDL_SCANCODE_RETURN) == 1) return '\n'; if(!rtn) return 0; jlgr->main.ct.read_cursor++; return rtn; }
void I_StartTextInput(int x1, int y1, int x2, int y2) { text_input_enabled = true; if (!vanilla_keyboard_mapping) { // SDL2-TODO: SDL_SetTextInputRect(...); SDL_StartTextInput(); } }
int main( int argc, char* args[] ) { //Start up SDL and create window if( !init() ) { printf( "Failed to initialize!\n" ); } 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 requests quit if( e.type == SDL_QUIT ) { quit = true; } //Handle keypress with current mouse position else if( e.type == SDL_TEXTINPUT ) { int x = 0, y = 0; SDL_GetMouseState( &x, &y ); handleKeys( e.text.text[ 0 ], x, y ); } } //Render quad render(); //Update screen SDL_GL_SwapWindow( gWindow ); SDL_Delay(20); } //Disable text input SDL_StopTextInput(); } //Free resources and close SDL Quit(); return 0; }
/** * Call string_input_win / ui_element_input::input_filter and filter the entries list interactively */ std::string uimenu::inputfilter() { std::string identifier = ""; // @todo: uimenu.filter_identifier ? mvwprintz(window, w_height - 1, 2, border_color, "< "); mvwprintz(window, w_height - 1, w_width - 3, border_color, " >"); /* //debatable merit std::string origfilter = filter; int origselected = selected; int origfselected = fselected; int origvshift = vshift; */ string_input_popup popup; popup.text( filter ) .max_length( 256 ) .window( window, 4, w_height - 1, w_width - 4 ) .identifier( identifier ); input_event event; #ifdef __ANDROID__ if( get_option<bool>( "ANDROID_AUTO_KEYBOARD" ) ) { SDL_StartTextInput(); } #endif do { // filter=filter_input->query(filter, false); filter = popup.query_string( false ); event = popup.context().get_raw_input(); // key = filter_input->keypress; if ( event.get_first_input() != KEY_ESCAPE ) { if( !scrollby( scroll_amount_from_key( event.get_first_input() ) ) ) { filterlist(); } show(); } } while(event.get_first_input() != '\n' && event.get_first_input() != KEY_ESCAPE); if ( event.get_first_input() == KEY_ESCAPE ) { /* //perhaps as an option filter = origfilter; selected = origselected; fselected = origfselected; vshift = origvshift; */ filterlist(); } wattron(window, border_color); for( int i = 1; i < w_width - 1; i++ ) { mvwaddch(window, w_height - 1, i, LINE_OXOX); } wattroff(window, border_color); return filter; }
int main( int argc, char* args[] ) { //Start up SDL and create window if( !init() ) { printf( "Failed to initialize!\n" ); } else { //Load media if( !loadMedia() ) { printf( "Unable to load media!\n" ); return 2; } //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 requests quit if( e.type == SDL_QUIT ) { quit = true; } } //Render quad render(); //Update screen SDL_GL_SwapWindow( gWindow ); } //Disable text input SDL_StopTextInput(); } //Free resources and close SDL close(); return 0; }
void StartTextInput() { if (!GetTextEvents) { SDL_StartTextInput(); // enable text events memset(text, 0x0, sizeof(text)); CurrentKey = 0; GetTextEvents = true; debug(LOG_INPUT, "SDL text events started"); } }
void Gosu::Input::setTextInput(TextInput* textInput) { if (pimpl->textInput && textInput == NULL) { SDL_StopTextInput(); } else if (pimpl->textInput == NULL && textInput) { SDL_StartTextInput(); } pimpl->textInput = textInput; }
void CConsole::ToggleVisible() { m_bToggle = true; m_bVisible = !m_bVisible; // TODO: this should be based on input focus, not visibility if (m_bVisible) SDL_StartTextInput(); else SDL_StopTextInput(); }
void Messages::dialog::input() { canceled = false; if( filtering ) { filter.query( false ); if( filter.confirmed() || filter.canceled() ) { filtering = false; } if( !filter.canceled() ) { const std::string &new_filter_str = filter.text(); if( new_filter_str != filter_str ) { filter_str = new_filter_str; do_filter( filter_str ); } } else { filter.text( filter_str ); } } else { const std::string &action = ctxt.handle_input(); if( action == "DOWN" && offset + max_lines < folded_filtered.size() ) { ++offset; } else if( action == "UP" && offset > 0 ) { --offset; } else if( action == "PAGE_DOWN" ) { if( offset + max_lines * 2 <= folded_filtered.size() ) { offset += max_lines; } else if( max_lines <= folded_filtered.size() ) { offset = folded_filtered.size() - max_lines; } else { offset = 0; } } else if( action == "PAGE_UP" ) { if( offset >= max_lines ) { offset -= max_lines; } else { offset = 0; } } else if( action == "FILTER" ) { filtering = true; #if defined(__ANDROID__) if( get_option<bool>( "ANDROID_AUTO_KEYBOARD" ) ) { SDL_StartTextInput(); } #endif } else if( action == "RESET_FILTER" ) { filter_str.clear(); filter.text( filter_str ); do_filter( filter_str ); } else if( action == "QUIT" ) { canceled = true; } } }
void System::showVirtualKeyboard(int flags) { jnipp::Method<void, int> setKeyboardOptions(m_NidroidClass, "setKeyboardOptions", "(I)V"); setKeyboardOptions(m_Nidroid, flags); SDL_StartTextInput(); }