Exemplo n.º 1
0
/**
 * Simulate press or release of a key corresponding to given character
 */
void Keymap_SimulateCharacter(char asckey, bool press)
{
	SDL_Keysym sdlkey;

	sdlkey.mod = KMOD_NONE;
	sdlkey.scancode = 0;
	if (isupper(asckey)) {
		if (press) {
			sdlkey.sym = SDLK_LSHIFT;
			Keymap_KeyDown(&sdlkey);
		}
		sdlkey.sym = tolower(asckey);
		sdlkey.mod = KMOD_LSHIFT;
	} else {
		sdlkey.sym = asckey;
	}
	if (press) {
		Keymap_KeyDown(&sdlkey);
	} else {
		Keymap_KeyUp(&sdlkey);
		if (isupper(asckey)) {
			sdlkey.sym = SDLK_LSHIFT;
			Keymap_KeyUp(&sdlkey);
		}
	}
}
Exemplo n.º 2
0
void Process_key()
{
    int i;

    for(i=0; i<320; i++)
        Key_Sate[i]=input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0,i) ? 0x80: 0;

    if(memcmp( Key_Sate,old_Key_Sate , sizeof(Key_Sate) ) )
        for(i=0; i<320; i++)
            if(Key_Sate[i] && Key_Sate[i]!=old_Key_Sate[i]  )
            {

                if(i==RETROK_RALT) {
                    //KBMOD=-KBMOD;
                    //printf("Modifier pressed %d \n",KBMOD);
                    continue;
                }

                Keymap_KeyDown(i);

            }
            else if ( !Key_Sate[i] && Key_Sate[i]!=old_Key_Sate[i]  )
            {

                if(i==RETROK_RALT) {
                    //KBMOD=-KBMOD;
                    //printf("Modifier pressed %d \n",KBMOD);
                    continue;
                }

                Keymap_KeyUp(i);

            }

    memcpy(old_Key_Sate,Key_Sate , sizeof(Key_Sate) );

}
Exemplo n.º 3
0
/**
 * Debounce any PC key held down if running with key repeat disabled.
 * This is called each ST frame, so keys get held down for one VBL which
 * is enough for 68000 code to scan.
 */
void Keymap_DebounceAllKeys(void)
{
	SDLKey key;
	char STScanCode;
	SDL_keysym tmpKeySym;

	/* Return if we aren't in fast forward or have not disabled key repeat */
	if ((ConfigureParams.System.bFastForward == false)
	        || (!ConfigureParams.Keyboard.bDisableKeyRepeat))
	{
		return;
	}

	tmpKeySym.mod = KMOD_NONE;

	/* Now run through each PC key looking for ones held down */
	for (key = SDLK_FIRST; key < SDLK_LAST; key++)
	{
		/* Is key held? */
		if (Keyboard.KeyStates[key])
		{
			tmpKeySym.sym = key;
			tmpKeySym.scancode = 0;

			/* Get scan code */
			STScanCode = Keymap_RemapKeyToSTScanCode(&tmpKeySym);
			if (STScanCode != (char)-1)
			{
				/* Does this require de-bouncing? */
				if (Keymap_DebounceSTKey(STScanCode))
					Keymap_KeyUp(&tmpKeySym);
			}
		}
	}

}
Exemplo n.º 4
0
Arquivo: main.c Projeto: jsdf/previous
/**
 * SDL message handler.
 * Here we process the SDL events (keyboard, mouse, ...) and map it to
 * Atari IKBD events.
 */
void Main_EventHandler(void)
{
	bool bContinueProcessing;
	SDL_Event event;
	int events;
	int remotepause;

	do
	{
		bContinueProcessing = false;

		/* check remote process control */
		remotepause = Control_CheckUpdates();

		if ( bEmulationActive || remotepause )
		{
			events = SDL_PollEvent(&event);
		}
		else
		{
			ShortCut_ActKey();
			/* last (shortcut) event activated emulation? */
			if ( bEmulationActive )
				break;
			events = SDL_WaitEvent(&event);
		}
		if (!events)
		{
			/* no events -> if emulation is active or
			 * user is quitting -> return from function.
			 */
			continue;
		}
		switch (event.type)
		{

		 case SDL_QUIT:
			Main_RequestQuit();
			break;
			
		 case SDL_MOUSEMOTION:               /* Read/Update internal mouse position */
			Main_HandleMouseMotion(&event);
			bContinueProcessing = false;
			break;

		 case SDL_MOUSEBUTTONDOWN:
			if (event.button.button == SDL_BUTTON_LEFT)
			{
				if (ConfigureParams.Mouse.bEnableAutoGrab && !bGrabMouse) {
					bGrabMouse = true;        /* Toggle flag */

					/* If we are in windowed mode, toggle the mouse cursor mode now: */
					if (!bInFullScreen)
					{
						SDL_SetRelativeMouseMode(SDL_TRUE);
                        SDL_SetWindowGrab(sdlWindow, SDL_TRUE);
						Main_SetTitle(MOUSE_LOCK_MSG);
					}
				}
                
                Keymap_MouseDown(true);
			}
			else if (event.button.button == SDL_BUTTON_RIGHT)
			{
                Keymap_MouseDown(false);
//				Keyboard.bRButtonDown |= BUTTON_MOUSE;
			}
			else if (event.button.button == SDL_BUTTON_MIDDLE)
			{
				/* Start double-click sequence in emulation time */
//				Keyboard.LButtonDblClk = 1;
			}
			break;

		 case SDL_MOUSEBUTTONUP:
			if (event.button.button == SDL_BUTTON_LEFT)
			{
                Keymap_MouseUp(true);
//				Keyboard.bLButtonDown &= ~BUTTON_MOUSE;
			}
			else if (event.button.button == SDL_BUTTON_RIGHT)
			{
                Keymap_MouseUp(false);
//				Keyboard.bRButtonDown &= ~BUTTON_MOUSE;
			}
			break;

		 case SDL_KEYDOWN:
            if (ConfigureParams.Keyboard.bDisableKeyRepeat && event.key.repeat)
                break;

            Keymap_KeyDown(&event.key.keysym);
			break;

		 case SDL_KEYUP:
			Keymap_KeyUp(&event.key.keysym);
			break;
                

		default:
			/* don't let unknown events delay event processing */
			bContinueProcessing = true;
			break;
		}
	} while (bContinueProcessing || !(bEmulationActive || bQuitProgram));
}