Пример #1
0
/**
 * Invoke shortcut identified by name. This supports only keys for
 * functionality that cannot be invoked with command line options
 * or otherwise for remote GUIs etc.
 */
bool Shortcut_Invoke(const char *shortcut)
{
	struct {
		SHORTCUTKEYIDX id;
		const char *name;
	} shortcuts[] = {
		{ SHORTCUT_MOUSEGRAB, "mousegrab" },
		{ SHORTCUT_COLDRESET, "coldreset" },
		{ SHORTCUT_WARMRESET, "warmreset" },
		{ SHORTCUT_SCREENSHOT, "screenshot" },
		{ SHORTCUT_BOSSKEY, "bosskey" },
		{ SHORTCUT_RECANIM, "recanim" },
		{ SHORTCUT_RECSOUND, "recsound" },
		{ SHORTCUT_SAVEMEM, "savemem" },
		{ SHORTCUT_QUIT, "quit" },
		{ SHORTCUT_NONE, NULL }
	};
	int i;

	if (ShortCutKey != SHORTCUT_NONE)
	{
		fprintf(stderr, "Shortcut invocation failed, shortcut already active\n");
		return false;
	}
	for (i = 0; shortcuts[i].name; i++)
	{
		if (strcmp(shortcut, shortcuts[i].name) == 0)
		{
			ShortCutKey = shortcuts[i].id;
			ShortCut_ActKey();
			ShortCutKey = SHORTCUT_NONE;
			return true;
		}
	}
	fprintf(stderr, "WARNING: unknown shortcut '%s'\n\n", shortcut);
	fprintf(stderr, "Hatari shortcuts are:\n");
	for (i = 0; shortcuts[i].name; i++)
	{
		fprintf(stderr, "- %s\n", shortcuts[i].name);
	}
	return false;
}
Пример #2
0
/**
 * User pressed key down
 */
void Keymap_KeyDown(SDL_Keysym *sdlkey)
{
    Uint8 next_mod, next_key;

    if (ShortCut_CheckKeys(sdlkey->mod, sdlkey->sym, 1)) { // Check if we pressed a shortcut
        ShortCut_ActKey();
        return;
    }
    
    if (ConfigureParams.Keyboard.nKeymapType==KEYMAP_SYMBOLIC) {
        next_key = Keymap_GetKeyFromSymbol(sdlkey->sym);
        next_mod = Keymap_Keydown_GetModFromSymbol(sdlkey->sym);
    } else {
        next_key = Keymap_GetKeyFromScancode(sdlkey->scancode);
        next_mod = Keymap_Keydown_GetModFromScancode(sdlkey->scancode);
    }
    
    Log_Printf(LOG_KEYMAP_LEVEL, "[Keymap] NeXT Keycode: $%02x, Modifiers: $%02x\n", next_key, next_mod);
    
    kms_keydown(next_mod, next_key);
}
Пример #3
0
/**
 * User pressed key down
 */
void Keymap_KeyDown(SDL_Keysym *sdlkey)
{
    Log_Printf(LOG_WARN, "Key pressed: %s\n", SDL_GetKeyName(sdlkey->sym));
    
    int symkey = sdlkey->sym;
	int modkey = sdlkey->mod;
    if (ShortCut_CheckKeys(modkey, symkey, 1)) {// Check if we pressed a shortcut
        ShortCut_ActKey();
        return;
    }
    Uint8 keycode = translate_key(symkey);
#if NEW_MOD_HANDLING
    Uint8 modifiers = translate_modifiers(modkey);
#else
    Uint8 modifiers = modifier_keydown(symkey);
#endif
    
    Log_Printf(LOG_WARN, "Keycode: $%02x, Modifiers: $%02x\n", keycode, modifiers);
    
    kms_keydown(modifiers, keycode);
}
Пример #4
0
/**
 * 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));
}