コード例 #1
0
/**
 * @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;
}
コード例 #2
0
void SDL2EventHandler::setTextInputMode(bool m)
{
    if(m)
        SDL_StartTextInput();
    else
        SDL_StopTextInput();
}
コード例 #3
0
ファイル: Keyboard.cpp プロジェクト: MarcoLizza/love
void Keyboard::setTextInput(bool enable)
{
	if (enable)
		SDL_StartTextInput();
	else
		SDL_StopTextInput();
}
コード例 #4
0
ファイル: loop.cpp プロジェクト: mattsnippets1/boids
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);
}
コード例 #5
0
ファイル: InputEvent.cpp プロジェクト: Codex-NG/solarus
/**
 * \brief Quits the input event manager.
 */
void InputEvent::quit() {

  if (joystick != nullptr) {
    SDL_JoystickClose(joystick);
  }
  SDL_StopTextInput();
}
コード例 #6
0
void CSDL_Ext::stopTextInput()
{
	if (SDL_IsTextInputActive() == SDL_TRUE)
	{
		SDL_StopTextInput();
	}
}
コード例 #7
0
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
コード例 #8
0
ファイル: main.cpp プロジェクト: jaz303/coursework
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;
}
コード例 #9
0
	void StopTextInput(std::string* stream) {
		_stoppingstream = stream;
		if (_stoppingstream == _startingstream) {
			SDL_StopTextInput();
			_startingstream = nullptr;
		}
	}
コード例 #10
0
ファイル: textinput.c プロジェクト: wilkie/openomf
void textinput_focus(component *c, int focus) {
    if(focus) {
        SDL_StartTextInput();
    } else {
        SDL_StopTextInput();
    }
}
コード例 #11
0
ファイル: InputManager.cpp プロジェクト: venscn/Ryno-Engine
	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;
	}
コード例 #12
0
ファイル: Application.cpp プロジェクト: martin-macak/duel6r
	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);
			}
		}
	}
コード例 #13
0
ファイル: textbox.cpp プロジェクト: kiseitai2/Engine_Eureka
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();
        }
    }
}
コード例 #14
0
ファイル: in_sdl.c プロジェクト: aonorin/vkQuake
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();
}
コード例 #15
0
void ClientConsole::toggleConsole ()
{
	_active ^= true;
	if (_active)
		SDL_StartTextInput();
	else
		SDL_StopTextInput();
}
コード例 #16
0
ファイル: main_sdl.cpp プロジェクト: ilario/warzone2100
void StopTextInput()
{
	SDL_StopTextInput();	// disable text events
	CurrentKey = 0;
	memset(text, 0x0, sizeof(text));
	GetTextEvents = false;
	debug(LOG_INPUT, "SDL text events stopped");
}
コード例 #17
0
ファイル: GameState.cpp プロジェクト: IngussNeilands/glPortal
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();
  }
}
コード例 #18
0
ファイル: testime.c プロジェクト: albertz/sdl
void CleanupVideo()
{
    SDL_StopTextInput();
#ifdef HAVE_SDL_TTF
    TTF_CloseFont(font);
    TTF_Quit();
#endif
}
コード例 #19
0
ファイル: input_handler.cpp プロジェクト: wesulee/mr
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
	}
}
コード例 #20
0
ファイル: Game.cpp プロジェクト: jomoho/SDL_Framework
void Game::tearDown() {
    assets.freeAll();

	SDL_StopTextInput();
	TTF_Quit();

    delete map;
	delete platformSDL;
}
コード例 #21
0
void EventosInputTexto::desabilitar()
{
	habilitado = false;
	SDL_StopTextInput();

	pos_cursor = 0;
	tamanho_selecao = 0;
	str.clear();
}
コード例 #22
0
ファイル: sdl_input.cpp プロジェクト: Kangz/Unvanquished
/*
===============
IN_Shutdown
===============
*/
void IN_Shutdown() {
    SDL_StopTextInput();
    IN_DeactivateMouse(true);
    mouseAvailable = false;

    IN_ShutdownJoystick();

    window = nullptr;
}
コード例 #23
0
ファイル: window.cpp プロジェクト: aleksijuvani/polygonist
    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();
    }
コード例 #24
0
ファイル: i_input.c プロジェクト: Azarien/chocolate-doom
void I_StopTextInput(void)
{
    text_input_enabled = false;

    if (!vanilla_keyboard_mapping)
    {
        SDL_StopTextInput();
    }
}
コード例 #25
0
ファイル: st_name.c プロジェクト: drodin/neverball
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;
    }
}
コード例 #26
0
ファイル: testime.c プロジェクト: albertz/sdl
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);
}
コード例 #27
0
ファイル: SdlApp.cpp プロジェクト: yhnchang/yup
void SdlApp::shutdown()
{
	SDL_StopTextInput();

	if (mWindow != nullptr)
		SDL_DestroyWindow(mWindow);

	SDL_Quit();
}
コード例 #28
0
ファイル: ui.c プロジェクト: Nuos/crawler
void ui_console_toggle(bool enable)
{
	console_enabled = enable;
	if (console_enabled) {
		SDL_StartTextInput();
	} else {
		SDL_StopTextInput();
	}
}
コード例 #29
0
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;
}
コード例 #30
0
/*
===============
IN_Shutdown
===============
*/
void IN_Shutdown()
{
	SDL_StopTextInput();
	IN_SetMouseMode(MouseMode::SystemCursor);
	mouseAvailable = false;

	IN_ShutdownJoystick();

	window = nullptr;
}