コード例 #1
0
ファイル: keymap.c プロジェクト: pcercuei/glfrontier
/*
  User press key down
*/
void Keymap_KeyDown(SDL_keysym *sdlkey)
{
  BOOL bPreviousKeyState;
  char STScanCode;
  int symkey = sdlkey->sym;
  //int scankey = sdlkey->scancode;
  int modkey = sdlkey->mod;

  /*fprintf(stderr, "keydown: sym=%i scan=%i mod=$%x\n",symkey, scankey, modkey);*/

  /* Handle special keys */
  if(symkey == SDLK_MODE || symkey == SDLK_LMETA || symkey == SDLK_NUMLOCK)
  {
    /* Ignore modifier keys that aren't passed to the ST */
    return;
  }
  else if(symkey == SDLK_F11 || symkey == SDLK_F12)
  {
    ShortCutKey.Key = symkey;
    return;
  }

  /* Set down */
  bPreviousKeyState = input.key_states[symkey];
  input.key_states[symkey] = TRUE;

  /* If pressed short-cut key, retain keypress until safe to execute (start of VBL) */
  if((modkey&KMOD_MODE) || (modkey&KMOD_RMETA) || (modkey&KMOD_CTRL))
  {
    ShortCutKey.Key = symkey;
    if( modkey&(KMOD_LCTRL|KMOD_RCTRL) )  ShortCutKey.bCtrlPressed = TRUE;
    if( modkey&(KMOD_LSHIFT|KMOD_RSHIFT) )  ShortCutKey.bShiftPressed = TRUE;
  }
  else
  {
    STScanCode = Keymap_RemapKeyToSTScanCode(sdlkey);
    if(STScanCode != (char)-1)
    {
      if(!bPreviousKeyState)
        Input_PressSTKey(STScanCode, TRUE);
    }
  }
}
コード例 #2
0
ファイル: keymap.c プロジェクト: lordashram/hatari-libretro
/**
 * User released key
 */
void Keymap_KeyUp(SDL_keysym *sdlkey)
{
	char STScanCode;
	int symkey = sdlkey->sym;
	int modkey = sdlkey->mod;

	/*fprintf(stderr, "keyup: sym=%i scan=%i mod=$%x\n",symkey, sdlkey->scancode, modkey);*/

	/* Ignore short-cut keys here */

	if (ShortCut_CheckKeys(modkey, symkey, 0))
		return;

	/* If using keyboard emulation, DON'T send keys to keyboard processor!!!
	 * Some games use keyboard as pause! */
	if (Joy_KeyUp(symkey, modkey))
		return;

	/* Handle special keys */
	if (symkey == SDLK_RALT || symkey == SDLK_LMETA || symkey == SDLK_RMETA
	        || symkey == SDLK_MODE || symkey == SDLK_NUMLOCK)
	{
		/* Ignore modifier keys that aren't passed to the ST */
		return;
	}

	/* Release key (only if was pressed) */
	if (Keyboard.KeyStates[symkey])
	{
		STScanCode = Keymap_RemapKeyToSTScanCode(sdlkey);
		if (STScanCode != (char)-1)
		{
			IKBD_PressSTKey(STScanCode, false);
		}
	}

	Keyboard.KeyStates[symkey] = false;
}
コード例 #3
0
/**
 * User press key down
 */
void Keymap_KeyDown(SDL_keysym *sdlkey)
{
	uint8_t STScanCode;
	int symkey = sdlkey->sym;
	int modkey = sdlkey->mod;

	LOG_TRACE(TRACE_KEYMAP, "key down: sym=%i scan=%i mod=0x%x\n", symkey,
	          sdlkey->scancode, modkey);

	if (ShortCut_CheckKeys(modkey, symkey, 1))
		return;

	/* If using joystick emulation via keyboard, DON'T send keys to keyboard processor!!!
	 * Some games use keyboard as pause! */
	if (Joy_KeyDown(symkey, modkey))
		return;

	/* Handle special keys */
	if (symkey == SDLK_RALT || symkey == SDLK_LMETA || symkey == SDLK_RMETA
	        || symkey == SDLK_MODE || symkey == SDLK_NUMLOCK)
	{
		/* Ignore modifier keys that aren't passed to the ST */
		return;
	}

	STScanCode = Keymap_RemapKeyToSTScanCode(sdlkey);
	LOG_TRACE(TRACE_KEYMAP, "key map: sym=0x%x to ST-scan=0x%02x\n", symkey, STScanCode);
	if (STScanCode != (uint8_t)-1)
	{
		if (!Keyboard.KeyStates[STScanCode])
		{
			/* Set down */
			Keyboard.KeyStates[STScanCode] = true;
			IKBD_PressSTKey(STScanCode, true);
		}
	}
}
コード例 #4
0
ファイル: keymap.c プロジェクト: lordashram/hatari-libretro
/**
 * User press key down
 */
void Keymap_KeyDown(SDL_keysym *sdlkey)
{
	bool bPreviousKeyState;
	char STScanCode;
	int symkey = sdlkey->sym;
	int modkey = sdlkey->mod;

	/*fprintf(stderr, "keydown: sym=%i scan=%i mod=$%x\n",symkey, sdlkey->scancode, modkey);*/

	if (ShortCut_CheckKeys(modkey, symkey, 1))
		return;

	/* If using joystick emulation via keyboard, DON'T send keys to keyboard processor!!!
	 * Some games use keyboard as pause! */
	if (Joy_KeyDown(symkey, modkey))
		return;

	/* Handle special keys */
	if (symkey == SDLK_RALT || symkey == SDLK_LMETA || symkey == SDLK_RMETA
	        || symkey == SDLK_MODE || symkey == SDLK_NUMLOCK)
	{
		/* Ignore modifier keys that aren't passed to the ST */
		return;
	}

	/* Set down */
	bPreviousKeyState = Keyboard.KeyStates[symkey];
	Keyboard.KeyStates[symkey] = true;

	STScanCode = Keymap_RemapKeyToSTScanCode(sdlkey);
	if (STScanCode != (char)-1)
	{
		if (!bPreviousKeyState)
			IKBD_PressSTKey(STScanCode, true);
	}
}
コード例 #5
0
ファイル: keymap.c プロジェクト: lordashram/hatari-libretro
/**
 * 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);
			}
		}
	}

}
コード例 #6
0
ファイル: keymap.c プロジェクト: pcercuei/glfrontier
/*
  User released key
*/
void Keymap_KeyUp(SDL_keysym *sdlkey)
{
  char STScanCode;
  int symkey = sdlkey->sym;
  //int scankey = sdlkey->scancode;

  /*fprintf(stderr, "keyup: sym=%i scan=%i mod=$%x\n",symkey, scankey, modkey);*/

  /* Handle special keys */
  if(symkey == SDLK_MODE || symkey == SDLK_LMETA || symkey == SDLK_NUMLOCK)
  {
    /* Ignore modifier keys that aren't passed to the ST */
    return;
  }
  else if(symkey == SDLK_CAPSLOCK)
  {
    /* Simulate another capslock key press */
    Input_PressSTKey(0x3A, TRUE);
  }
  else if(symkey == SDLK_F11 || symkey == SDLK_F12)
  {
    return;
  }

  /* Release key (only if was pressed) */
  if(input.key_states[symkey])
  {
    STScanCode = Keymap_RemapKeyToSTScanCode(sdlkey);
    if(STScanCode != (char)-1)
    {
      Input_PressSTKey(STScanCode,FALSE);
    }
  }

  input.key_states[symkey] = FALSE;
}