Exemplo n.º 1
0
/**
 * @brief Check call to SDL_GetKeyFromScancode
 * 
 * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyFromScancode
 */
int
keyboard_getKeyFromScancode(void *arg)
{
   SDL_Keycode result;

   /* Case where input is valid */
   result = SDL_GetKeyFromScancode(SDL_SCANCODE_A);
   SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(valid)");
   SDLTest_AssertCheck(result == SDLK_a, "Verify result from call, expected: %i, got: %i", SDLK_a, result);

   /* Case where input is zero */
   result = SDL_GetKeyFromScancode(0);
   SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(0)");
   SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);

   /* Clear error message */
   SDL_ClearError();
   SDLTest_AssertPass("Call to SDL_ClearError()");

   /* Case where input is invalid (too small) */
   result = SDL_GetKeyFromScancode(-999);
   SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(-999)");
   SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
   _checkInvalidScancodeError();

   /* Case where input is invalid (too big) */
   result = SDL_GetKeyFromScancode(999);
   SDLTest_AssertPass("Call to SDL_GetKeyFromScancode(999)");
   SDLTest_AssertCheck(result == SDLK_UNKNOWN, "Verify result from call is UNKNOWN, expected: %i, got: %i", SDLK_UNKNOWN, result);
   _checkInvalidScancodeError();

   return TEST_COMPLETED;
}
Exemplo n.º 2
0
void SetDefaultKeyMap(DefaultMaps dmap, bool replace) {
	switch (dmap) {
	case DEFAULT_MAPPING_KEYBOARD:
		{
			bool azerty = false;
			bool qwertz = false;
#if defined(SDL)
			char q, w, y;
			q = SDL_GetKeyFromScancode(SDL_SCANCODE_Q);
			w = SDL_GetKeyFromScancode(SDL_SCANCODE_W);
			y = SDL_GetKeyFromScancode(SDL_SCANCODE_Y);
			if (q == 'a' && w == 'z' && y == 'y')
				azerty = true;
			else if (q == 'q' && w == 'w' && y == 'z')
				qwertz = true;
#elif defined(USING_WIN_UI)
			HKL localeId = GetKeyboardLayout(0);
			// TODO: Is this list complete enough?
			switch ((int)(intptr_t)localeId & 0xFFFF) {
			case 0x407:
				qwertz = true;
				break;
			case 0x040c:
			case 0x080c:
			case 0x1009:
				azerty = true;
				break;
			default:
				break;
			}
#endif
			if (azerty) {
				SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultAzertyKeyboardKeyMap, ARRAY_SIZE(defaultAzertyKeyboardKeyMap), replace);
			} else if (qwertz) {
				SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultQwertzKeyboardKeyMap, ARRAY_SIZE(defaultQwertzKeyboardKeyMap), replace);
			} else {
				SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultQwertyKeyboardKeyMap, ARRAY_SIZE(defaultQwertyKeyboardKeyMap), replace);
			}
		}
		break;
	case DEFAULT_MAPPING_X360:
		SetDefaultKeyMap(DEVICE_ID_X360_0, default360KeyMap, ARRAY_SIZE(default360KeyMap), replace);
		break;
	case DEFAULT_MAPPING_SHIELD:
		SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultShieldKeyMap, ARRAY_SIZE(defaultShieldKeyMap), replace);
		break;
	case DEFAULT_MAPPING_PAD:
		SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultPadMap, ARRAY_SIZE(defaultPadMap), replace);
		break;
	case DEFAULT_MAPPING_OUYA:
		SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultOuyaMap, ARRAY_SIZE(defaultOuyaMap), replace);
		break;
	case DEFAULT_MAPPING_XPERIA_PLAY:
		SetDefaultKeyMap(DEVICE_ID_DEFAULT, defaultXperiaPlay, ARRAY_SIZE(defaultXperiaPlay), replace);
		break;
	}

	UpdateNativeMenuKeys();
}
void mw2_Input::CheckDevices() 
{
	SDL_Event ev;
	
	while (SDL_PollEvent(&ev) == 1)
	{
		switch (ev.type)
		{
			case SDL_QUIT:
				mw2_Application::Exit();
				break;
			case SDL_KEYDOWN:
				mKeysValue[ SDL_GetKeyFromScancode(ev.key.keysym.scancode) ] = 3;
				break;
			case SDL_KEYUP:
				mKeysValue[ SDL_GetKeyFromScancode(ev.key.keysym.scancode) ] = 0;
				break;
			case SDL_MOUSEBUTTONDOWN:
				mButtonsValue[ ev.button.button ] = 3;
				break;
			case SDL_MOUSEBUTTONUP:
				mButtonsValue[ ev.button.button ] = 0;
				break;
			case SDL_MOUSEMOTION:
				mMousePosition->x = ev.motion.x;
				mMousePosition->y = ev.motion.y;
				break;
		}
	}
	
	// update keys
	for (int i = 0; i < sizeof(KEYS) / sizeof(*KEYS); i++) 
	{
		if (mKeysValue[KEYS[i]] == 3) 
		{
			mKeysValue[KEYS[i]] = 2;
		} 
		else if (mKeysValue[KEYS[i]] == 2) 
		{
			mKeysValue[KEYS[i]] = 1;
		}
	}

	// update buttons
	for (int i = 0; i < sizeof(BUTTONS) / sizeof(*BUTTONS); i++)  
	{
		if (mButtonsValue[BUTTONS[i]] == 3) 
		{
			mButtonsValue[BUTTONS[i]] = 2;
		} 
		else if (mButtonsValue[BUTTONS[i]] == 2)
		{
			mButtonsValue[BUTTONS[i]] = 1;
		}
	}
}
Exemplo n.º 4
0
static mrb_value
mrb_sdl2_keyboard_key_from_scancode(mrb_state *mrb, mrb_value mod)
{
  mrb_int code;
  mrb_get_args(mrb, "i", &code);
  return mrb_fixnum_value(SDL_GetKeyFromScancode((SDL_Scancode)code));
}
Exemplo n.º 5
0
Arquivo: Input.cpp Projeto: 456z/gosu
wchar_t Gosu::Input::idToChar(Button btn)
{
    if (btn.id() > kbRangeEnd)
        return 0;
    
    // SDL_GetKeyName would return "Space" for this value.
    if (btn.id() == kbSpace)
        return L' ';
    
    SDL_Keycode keycode = SDL_GetKeyFromScancode(static_cast<SDL_Scancode>(btn.id()));
    if (keycode == SDLK_UNKNOWN)
        return 0;
    
    const char* name = SDL_GetKeyName(keycode);
    if (name == NULL)
        return 0;
    
    std::wstring wname = utf8ToWstring(name);
    if (wname.length() != 1)
        return 0;
    
    // Convert to lower case to be consistent with previous versions of Gosu.
    // Also, German umlauts are already reported in lower-case by the SDL, so
    // this makes everything a little more consistent.
    //
    // This should handle Turkish i/I just fine because it uses the current
    // locale, but if we ever receive bug reports from Turkish users, they are
    // likely caused by a combination of this line and an invalid locale :)
    return std::towlower(wname[0]);
}
Exemplo n.º 6
0
static void shortcutInput(int& shortcut)
{
	Lumix::StaticString<50> popup_name("");
	popup_name << (Lumix::i64)&shortcut;

	Lumix::StaticString<50> button_label(SDL_GetKeyName(SDL_GetKeyFromScancode((SDL_Scancode)shortcut)));
	button_label << "###" << (Lumix::i64)&shortcut;

	if (ImGui::Button(button_label, ImVec2(65, 0))) shortcut = -1;

	auto& io = ImGui::GetIO();
	int key_count;
	auto* state = SDL_GetKeyboardState(&key_count);
	if (ImGui::IsItemHovered())
	{
		for (int i = 0; i < key_count; ++i)
		{
			if (state[i])
			{
				shortcut = i;
				break;
			}
		}
	}
}
Exemplo n.º 7
0
const std::string hotkey_keyboard::get_name_helper() const
{
	std::string ret = std::string(SDL_GetKeyName(SDL_GetKeyFromScancode(scancode_)));

	if (ret.size() == 1) {
		boost::algorithm::to_lower(ret);
	}

	return ret;
}
Exemplo n.º 8
0
int osinterface_scancode_to_rct_keycode(int sdl_key){
	char keycode = (char)SDL_GetKeyFromScancode((SDL_Scancode)sdl_key);

	// Until we reshufle the text files to use the new positions 
	// this will suffice to move the majority to the correct positions.
	// Note any special buttons PgUp PgDwn are mapped wrong.
	if (keycode >= 'a' && keycode <= 'z')keycode = toupper(keycode);

	return keycode;
}
Exemplo n.º 9
0
bool ConfirmScreen(const char *info, const char *msg)
{
	int w = gGraphicsDevice.cachedConfig.Res.x;
	int h = gGraphicsDevice.cachedConfig.Res.y;
	ClearScreen(&gGraphicsDevice);
	FontStr(info, Vec2iNew((w - FontStrW(info)) / 2, (h - FontH()) / 2));
	FontStr(msg, Vec2iNew((w - FontStrW(msg)) / 2, (h + FontH()) / 2));
	BlitFlip(&gGraphicsDevice);

	SDL_Keycode k = SDL_GetKeyFromScancode(GetKey(&gEventHandlers));
	return k == SDLK_y;
}
Exemplo n.º 10
0
bool ConfirmScreen(const char *info, const char *msg)
{
	int w = gGraphicsDevice.cachedConfig.Res.x;
	int h = gGraphicsDevice.cachedConfig.Res.y;
	ClearScreen(&gGraphicsDevice);
	FontStr(info, svec2i((w - FontStrW(info)) / 2, (h - FontH()) / 2));
	FontStr(msg, svec2i((w - FontStrW(msg)) / 2, (h + FontH()) / 2));
	WindowContextPreRender(&gGraphicsDevice.gameWindow);
	BlitUpdateFromBuf(&gGraphicsDevice, gGraphicsDevice.screen);
	WindowContextPostRender(&gGraphicsDevice.gameWindow);

	SDL_Keycode k = SDL_GetKeyFromScancode(GetKey(&gEventHandlers));
	return k == SDLK_y;
}
Exemplo n.º 11
0
Keyboard::Key Keyboard::getKeyFromScancode(Scancode scancode) const
{
	SDL_Scancode sdlscancode = SDL_SCANCODE_UNKNOWN;
	scancodes.find(scancode, sdlscancode);

	SDL_Keycode sdlkey = SDL_GetKeyFromScancode(sdlscancode);

	for (int i = 0; i < KEY_MAX_ENUM; i++)
	{
		if (keymap[i] == sdlkey)
			return (Key) i;
	}

	return KEY_UNKNOWN;
}
Exemplo n.º 12
0
std::string KeyboardConfig::getKeyName(const int key)
{
    if (key == -1)
        return "";
    if (key > -1)
    {
#ifdef USE_SDL2
        return SDL_GetKeyName(SDL_GetKeyFromScancode(
            static_cast<SDL_Scancode>(key)));
#else
        return SDL_GetKeyName(static_cast<SDLKey>(key));
#endif
    }

    // TRANSLATORS: long key name, should be short
    return strprintf(_("key_%d"), static_cast<int>(key));
}
Exemplo n.º 13
0
/**
 * \brief Refresh the state of the keys.
 */
void bear::input::keyboard::refresh_keys()
{
  int num_codes;
  const Uint8* scan_codes( SDL_GetKeyboardState( &num_codes ) );

  m_pressed_keys.clear();

  for (unsigned int i=0; i!=(unsigned int)num_codes; ++i)
    if ( scan_codes[i] == 1 )
      {
        const SDL_Keymod mod( SDL_GetModState() );
        const key_code k
          ( sdl_key_to_local
            ( SDL_GetKeyFromScancode( static_cast<SDL_Scancode>(i) ),
              mod & KMOD_SHIFT, mod & KMOD_ALT) );

        if ( (k != kc_not_a_key) &&
             (k != kc_num_lock) &&
             (k != kc_caps_lock) &&
             (k != kc_scroll_lock) )
          m_pressed_keys.push_back( k );
      }
} // keyboard::refresh_keys()
void FHTML5InputInterface::Tick(float DeltaTime, const SDL_Event& Event,TSharedRef < FGenericWindow>& ApplicationWindow )
{

	switch (Event.type)
	{
		case SDL_KEYDOWN:
			{
				SDL_KeyboardEvent KeyEvent = Event.key;
				const SDL_Keycode KeyCode = KeyEvent.keysym.scancode;
				const bool bIsRepeated = KeyEvent.repeat != 0;

				// First KeyDown, then KeyChar. This is important, as in-game console ignores first character otherwise
				MessageHandler->OnKeyDown(KeyCode, KeyEvent.keysym.sym, bIsRepeated);

				// Backspace/Return input caught here. 
				// Note that TextInput still seems to get characters messages too but slate seems to not process them.
				if (KeyCode == SDL_SCANCODE_BACKSPACE || KeyCode == SDL_SCANCODE_RETURN)
				{
					const TCHAR Character = SDL_GetKeyFromScancode(Event.key.keysym.scancode);
					UE_LOG(LogHTML5Input, Verbose, TEXT("TextInput: Text:%c bIsRepeated:%s"), Character, bIsRepeated ? TEXT("TRUE") : TEXT("FALSE"));
					MessageHandler->OnKeyChar(Character, bIsRepeated);
				}
				UE_LOG(LogHTML5Input, Verbose, TEXT("KeyDown: Code:%d bIsRepeated:%s"), KeyCode, bIsRepeated ? TEXT("TRUE") : TEXT("FALSE"));
			}
			break;
		case SDL_KEYUP:
			{
				SDL_KeyboardEvent keyEvent = Event.key;
				const SDL_Keycode KeyCode = keyEvent.keysym.scancode;
				const bool IsRepeat = keyEvent.repeat != 0;

				MessageHandler->OnKeyUp( KeyCode, keyEvent.keysym.sym, IsRepeat );
				UE_LOG(LogHTML5Input, Verbose, TEXT("KeyUp Code:%d"), KeyCode);
			}
			break;
		case SDL_TEXTINPUT:
			{
				const bool bIsRepeated = Event.key.repeat != 0;
				const TCHAR Character = *ANSI_TO_TCHAR(Event.text.text);

				MessageHandler->OnKeyChar(Character, bIsRepeated);
				UE_LOG(LogHTML5Input, Verbose, TEXT("TextInput: Text:%c bIsRepeated:%s"), Character, bIsRepeated ? TEXT("TRUE") : TEXT("FALSE"));
			}
			break;
		case SDL_MOUSEBUTTONDOWN:
			{
				EMouseButtons::Type MouseButton = Event.button.button == 1 ? EMouseButtons::Left : Event.button.button == 2 ? EMouseButtons::Middle : EMouseButtons::Right;
				MessageHandler->OnMouseDown(ApplicationWindow, MouseButton );
				UE_LOG(LogHTML5Input, Verbose, TEXT("MouseButtonDown ID:%d"), Event.button.button);
			}
			break;
		case SDL_MOUSEBUTTONUP:
			{
				EMouseButtons::Type MouseButton = Event.button.button == 1 ? EMouseButtons::Left : Event.button.button == 2 ? EMouseButtons::Middle : EMouseButtons::Right;
				MessageHandler->OnMouseUp(MouseButton );
				UE_LOG(LogHTML5Input, Verbose, TEXT("MouseButtonUp ID:%d"), Event.button.button);
			}
			break; 
		case SDL_MOUSEMOTION:
			{
				//Cursor->SetPosition(Event.motion.x, Event.motion.y);
				MessageHandler->OnRawMouseMove(Event.motion.xrel, Event.motion.yrel);
				MessageHandler->OnMouseMove(); 
				UE_LOG(LogHTML5Input, Verbose, TEXT("MouseMotion Pos(%d, %d) XRel:%d YRel:%d"), Event.motion.x, Event.motion.y, Event.motion.xrel, Event.motion.yrel);
			} 
			break;
		case SDL_MOUSEWHEEL:
			{
				SDL_MouseWheelEvent* w = (SDL_MouseWheelEvent*)&Event;
				const float SpinFactor = 1 / 120.0f;
				MessageHandler->OnMouseWheel(w->y * SpinFactor);
				UE_LOG(LogHTML5Input, Verbose, TEXT("MouseWheel %f"), SpinFactor);
			}
			break;
		default:
			// unhandled. 
			break; 
	}
}
Exemplo n.º 15
0
variant playable_custom_object::get_player_value_by_slot(int slot) const
{
	switch(slot) {
	case CUSTOM_OBJECT_PLAYER_DIFFICULTY: {
		if(preferences::force_difficulty() != INT_MIN) {
			return variant(preferences::force_difficulty());
		}

		return variant(difficulty_);
	}
	case CUSTOM_OBJECT_PLAYER_CAN_INTERACT: {
		return variant(can_interact_);
	}
	case CUSTOM_OBJECT_PLAYER_UNDERWATER_CONTROLS: {
		return variant(underwater_controls_);
	}
	case CUSTOM_OBJECT_PLAYER_CTRL_MOD_KEY: {
		return variant(SDL_GetModState());
	}
	case CUSTOM_OBJECT_PLAYER_CTRL_KEYS: {
		std::vector<variant> result;
		if(level_runner::get_current() && level_runner::get_current()->get_debug_console() && level_runner::get_current()->get_debug_console()->has_keyboard_focus()) {
			//the debug console is stealing all keystrokes.
			return variant(&result);
		}

#if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
		int ary_length;
		const Uint8* key_state = SDL_GetKeyboardState(&ary_length);

#ifndef NO_EDITOR
		if(level_runner::get_current()) {
			const editor* e = level_runner::get_current()->get_editor();
			if(e && e->has_keyboard_focus()) {
				//the editor has the focus, so we tell the game there
				//are no keys pressed.
				ary_length = 0;
			}
		}
#endif

		for(int count = 0; count < ary_length; ++count) {
			if(key_state[count]) {				//Returns only keys that are down so the list that ffl has to deal with is small.
				SDL_Keycode k = SDL_GetKeyFromScancode(SDL_Scancode(count));
				if(k < 128 && util::c_isprint(k)) {
					std::string str(1,k);
					result.push_back(variant(str));
				} else {
					result.push_back(variant(k));
				}
			}
		}
#endif
		return variant(&result);
	}
	case CUSTOM_OBJECT_PLAYER_CTRL_MICE: {
		std::vector<variant> result;
		

#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
		const int nmice = SDL_GetNumMice();
#else
		const int nmice = 1;
#endif
		for(int n = 0; n != nmice; ++n) {
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
			SDL_SelectMouse(n);
#endif
			std::vector<variant> info;
			int x, y;
			Uint8 button_state = input::sdl_get_mouse_state(&x, &y);
			translate_mouse_coords(&x, &y);

			info.push_back(variant(x));
			info.push_back(variant(y));

			if(button_state & SDL_BUTTON(SDL_BUTTON_LEFT)) {
				info.push_back(variant("left"));
			}

			if(button_state & SDL_BUTTON(SDL_BUTTON_RIGHT)) {
				info.push_back(variant("right"));
			}

			if(button_state & SDL_BUTTON(SDL_BUTTON_MIDDLE)) {
				info.push_back(variant("middle"));
			}

			if(button_state & SDL_BUTTON(SDL_BUTTON_X1)) { //these aren't tested
				info.push_back(variant("x1"));
			}

			if(button_state & SDL_BUTTON(SDL_BUTTON_X2)) {
				info.push_back(variant("x2"));
			}

			result.push_back(variant(&info));
		}

		return variant(&result);
	}
	case CUSTOM_OBJECT_PLAYER_CTRL_TILT: {
		return variant(-joystick::iphone_tilt());
	}
	case CUSTOM_OBJECT_PLAYER_CTRL_X: {
		return variant(underwater_ctrl_x_);
	}
	case CUSTOM_OBJECT_PLAYER_CTRL_Y: {
		return variant(underwater_ctrl_y_);
	}
	case CUSTOM_OBJECT_PLAYER_CTRL_REVERSE_AB: {
		return variant::from_bool(reverse_ab_);
	}
	case CUSTOM_OBJECT_PLAYER_CONTROL_SCHEME: {
		return variant(preferences::control_scheme());
	}
	case CUSTOM_OBJECT_PLAYER_VERTICAL_LOOK: {
		return variant(vertical_look_);
	}
	case CUSTOM_OBJECT_PLAYER_CONTROL_LOCK: {
        std::vector<variant> result;
        
        const unsigned char* locked_control_frame = controls::get_local_control_lock();
        
        if (locked_control_frame == nullptr) {
            return variant();
        }
        
        for(int i = 0; i < 8; ++i){
            if((*locked_control_frame & (0x01 << i)) ){
                
                result.push_back( variant(ctrl[i]) );
            } else {
                //this key isn't pressed
            }            
        }
       
        return variant(&result);
       
    }
        
	}

	ASSERT_LOG(false, "unknown slot in get_player_value_by_slot: " << slot);
}
Exemplo n.º 16
0
/* Human readable string representation */
std::string sourceDescString(const SourceDesc &src)
{
	char buf[128];
	char pos;

	switch (src.type)
	{
	case Invalid:
		return std::string();

	case Key:
	{
		if (src.d.scan == SDL_SCANCODE_LSHIFT)
			return "Shift";

		SDL_Keycode key = SDL_GetKeyFromScancode(src.d.scan);
		const char *str = SDL_GetKeyName(key);

		if (*str == '\0')
			return "Unknown key";
		else
			return str;
	}
	case JButton:
		snprintf(buf, sizeof(buf), "JS %d", src.d.jb);
		return buf;

	case JHat:
		switch(src.d.jh.pos)
		{
		case SDL_HAT_UP:
			pos = 'U';
			break;

		case SDL_HAT_DOWN:
			pos = 'D';
			break;

		case SDL_HAT_LEFT:
			pos = 'L';
			break;

		case SDL_HAT_RIGHT:
			pos = 'R';
			break;

		default:
			pos = '-';
		}
		snprintf(buf, sizeof(buf), "Hat %d:%c",
		         src.d.jh.hat, pos);
		return buf;

	case JAxis:
		snprintf(buf, sizeof(buf), "Axis %d%c",
		         src.d.ja.axis, src.d.ja.dir == Negative ? '-' : '+');
		return buf;
	}

	assert(!"unreachable");
	return "";
}
Exemplo n.º 17
0
/*
===============
IN_TranslateSDLToJKKey
===============
*/
static fakeAscii_t IN_TranslateSDLToJKKey( SDL_Keysym *keysym, qboolean down ) {
	fakeAscii_t key = A_NULL;

	if ( keysym->sym >= A_LOW_A && keysym->sym <= A_LOW_Z )
		key = (fakeAscii_t)(A_CAP_A + (keysym->sym - A_LOW_A));
	else if ( keysym->sym >= A_LOW_AGRAVE && keysym->sym <= A_LOW_THORN && keysym->sym != A_DIVIDE )
		key = (fakeAscii_t)(A_CAP_AGRAVE + (keysym->sym - A_LOW_AGRAVE));
	else if ( keysym->sym >= SDLK_SPACE && keysym->sym < SDLK_DELETE )
		key = (fakeAscii_t)keysym->sym;
	else
	{
		IN_TranslateNumpad( keysym, &key );

		switch( keysym->sym )
		{
			case SDLK_PAGEUP:       key = A_PAGE_UP;       break;
			case SDLK_KP_9:         key = A_KP_9;          break;
			case SDLK_PAGEDOWN:     key = A_PAGE_DOWN;     break;
			case SDLK_KP_3:         key = A_KP_3;          break;
			case SDLK_KP_7:         key = A_KP_7;          break;
			case SDLK_HOME:         key = A_HOME;          break;
			case SDLK_KP_1:         key = A_KP_1;          break;
			case SDLK_END:          key = A_END;           break;
			case SDLK_KP_4:         key = A_KP_4;          break;
			case SDLK_LEFT:         key = A_CURSOR_LEFT;   break;
			case SDLK_KP_6:         key = A_KP_6;          break;
			case SDLK_RIGHT:        key = A_CURSOR_RIGHT;  break;
			case SDLK_KP_2:         key = A_KP_2;          break;
			case SDLK_DOWN:         key = A_CURSOR_DOWN;   break;
			case SDLK_KP_8:         key = A_KP_8;          break;
			case SDLK_UP:           key = A_CURSOR_UP;     break;
			case SDLK_ESCAPE:       key = A_ESCAPE;        break;
			case SDLK_KP_ENTER:     key = A_KP_ENTER;      break;
			case SDLK_RETURN:       key = A_ENTER;         break;
			case SDLK_TAB:          key = A_TAB;           break;
			case SDLK_F1:           key = A_F1;            break;
			case SDLK_F2:           key = A_F2;            break;
			case SDLK_F3:           key = A_F3;            break;
			case SDLK_F4:           key = A_F4;            break;
			case SDLK_F5:           key = A_F5;            break;
			case SDLK_F6:           key = A_F6;            break;
			case SDLK_F7:           key = A_F7;            break;
			case SDLK_F8:           key = A_F8;            break;
			case SDLK_F9:           key = A_F9;            break;
			case SDLK_F10:          key = A_F10;           break;
			case SDLK_F11:          key = A_F11;           break;
			case SDLK_F12:          key = A_F12;           break;

			case SDLK_BACKSPACE:    key = A_BACKSPACE;     break;
			case SDLK_KP_PERIOD:    key = A_KP_PERIOD;     break;
			case SDLK_DELETE:       key = A_DELETE;        break;
			case SDLK_PAUSE:        key = A_PAUSE;         break;

			case SDLK_LSHIFT:
			case SDLK_RSHIFT:       key = A_SHIFT;         break;

			case SDLK_LCTRL:
			case SDLK_RCTRL:        key = A_CTRL;          break;

			case SDLK_RALT:
			case SDLK_LALT:         key = A_ALT;           break;

			case SDLK_KP_5:         key = A_KP_5;          break;
			case SDLK_INSERT:       key = A_INSERT;        break;
			case SDLK_KP_0:         key = A_KP_0;          break;
			case SDLK_KP_MULTIPLY:  key = A_STAR;          break;
			case SDLK_KP_PLUS:      key = A_KP_PLUS;       break;
			case SDLK_KP_MINUS:     key = A_KP_MINUS;      break;
			case SDLK_KP_DIVIDE:    key = A_FORWARD_SLASH; break;

			case SDLK_SCROLLLOCK:   key = A_SCROLLLOCK;    break;
			case SDLK_NUMLOCKCLEAR: key = A_NUMLOCK;       break;
			case SDLK_CAPSLOCK:     key = A_CAPSLOCK;      break;

			case L'\u00D7':			key = A_MULTIPLY;		break;
			case L'\u00E0':			key = A_LOW_AGRAVE;		break;
			case L'\u00E1':			key = A_LOW_AACUTE;		break;
			case L'\u00E2':			key = A_LOW_ACIRCUMFLEX; break;
			case L'\u00E3':			key = A_LOW_ATILDE;		break;
			case L'\u00E4':			key = A_LOW_ADIERESIS;	break;
			case L'\u00E5':			key = A_LOW_ARING;		break;
			case L'\u00E6':			key = A_LOW_AE;			break;
			case L'\u00E7':			key = A_LOW_CCEDILLA;	break;
			case L'\u00E8':			key = A_LOW_EGRAVE;		break;
			case L'\u00E9':			key = A_LOW_EACUTE;		break;
			case L'\u00EA':			key = A_LOW_ECIRCUMFLEX; break;
			case L'\u00EB':			key = A_LOW_EDIERESIS;	break;
			case L'\u00EC':			key = A_LOW_IGRAVE;		break;
			case L'\u00ED':			key = A_LOW_IACUTE;		break;
			case L'\u00EE':			key = A_LOW_ICIRCUMFLEX; break;
			case L'\u00EF':			key = A_LOW_IDIERESIS;	break;
			case L'\u00F0':			key = A_LOW_ETH;		break;
			case L'\u00F1':			key = A_LOW_NTILDE;		break;
			case L'\u00F2':			key = A_LOW_OGRAVE;		break;
			case L'\u00F3':			key = A_LOW_OACUTE;		break;
			case L'\u00F4':			key = A_LOW_OCIRCUMFLEX; break;
			case L'\u00F5':			key = A_LOW_OTILDE;		break;
			case L'\u00F6':			key = A_LOW_ODIERESIS;	break;
			case L'\u00F7':			key = A_DIVIDE;			break;
			case L'\u00F8':			key = A_LOW_OSLASH;		break;
			case L'\u00F9':			key = A_LOW_UGRAVE;		break;
			case L'\u00FA':			key = A_LOW_UACUTE;		break;
			case L'\u00FB':			key = A_LOW_UCIRCUMFLEX; break;
			case L'\u00FC':			key = A_LOW_UDIERESIS;	break;
			case L'\u00FD':			key = A_LOW_YACUTE;		break;
			case L'\u00FE':			key = A_LOW_THORN;		break;
			case L'\u00FF':			key = A_LOW_YDIERESIS;	break;

			default:
				break;
		}
	}

	if( in_keyboardDebug->integer )
		IN_PrintKey( keysym, key, down );

	if ( cl_consoleUseScanCode->integer )
	{
		if ( keysym->scancode == SDL_SCANCODE_GRAVE )
		{
			SDL_Keycode translated = SDL_GetKeyFromScancode( SDL_SCANCODE_GRAVE );

			if ( (translated != SDLK_CARET) || (translated == SDLK_CARET && (keysym->mod & KMOD_SHIFT)) )
			{
				// Console keys can't be bound or generate characters
				key = A_CONSOLE;
			}
		}
	}
	else
	{
		if ( IN_IsConsoleKey( key, 0 ) )
		{
			// Console keys can't be bound or generate characters
			key = A_CONSOLE;
		}
	}

	return key;
}
        }
    }
    /*
    if (scancode == SDL_SCANCODE_UNKNOWN) {
        SDL_Log("WinRT TranslateKeycode, unknown keycode=%d\n", (int)keycode);
    }
    */
    return scancode;
}

void
WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^args)
{
    SDL_Scancode sdlScancode = WINRT_TranslateKeycode((int)args->VirtualKey, args->KeyStatus.ScanCode);
#if 0
    SDL_Keycode keycode = SDL_GetKeyFromScancode(sdlScancode);
    SDL_Log("key down, handled=%s, ext?=%s, released?=%s, menu key down?=%s, "
            "repeat count=%d, native scan code=0x%x, was down?=%s, vkey=%d, "
            "sdl scan code=%d (%s), sdl key code=%d (%s)\n",
        (args->Handled ? "1" : "0"),
        (args->KeyStatus.IsExtendedKey ? "1" : "0"),
        (args->KeyStatus.IsKeyReleased ? "1" : "0"),
        (args->KeyStatus.IsMenuKeyDown ? "1" : "0"),
        args->KeyStatus.RepeatCount,
        args->KeyStatus.ScanCode,
        (args->KeyStatus.WasKeyDown ? "1" : "0"),
        args->VirtualKey,
        sdlScancode,
        SDL_GetScancodeName(sdlScancode),
        keycode,
        SDL_GetKeyName(keycode));
Exemplo n.º 19
0
const char *getInputName(Uint32 scancode) {
	if( scancode>=0 && scancode<283 ) {
		return SDL_GetKeyName(SDL_GetKeyFromScancode(static_cast<SDL_Scancode>(scancode)));
	} else if( scancode<299 ) {
		switch( scancode ) {
			case 283:
				return "Mouse 0";
			case 284:
				return "Mouse 1";
			case 285:
				return "Mouse 2";
			case 286:
				return "Mouse 3";
			case 287:
				return "Wheel up";
			case 288:
				return "Wheel down";
			case 289:
				return "Mouse 6";
			case 290:
				return "Mouse 7";
			case 291:
				return "Mouse 8";
			case 292:
				return "Mouse 9";
			case 293:
				return "Mouse 10";
			case 294:
				return "Mouse 11";
			case 295:
				return "Mouse 12";
			case 296:
				return "Mouse 13";
			case 297:
				return "Mouse 14";
			case 298:
				return "Mouse 15";
			default:
				return "Unknown key";
		}
	} else if( scancode<315 ) {
		switch( scancode ) {
			case 299:
				return "Button 0";
			case 300:
				return "Button 1";
			case 301:
				return "Button 2";
			case 302:
				return "Button 3";
			case 303:
				return "Button 4";
			case 304:
				return "Button 5";
			case 305:
				return "Button 6";
			case 306:
				return "Button 7";
			case 307:
				return "Button 8";
			case 308:
				return "Button 9";
			case 309:
				return "Button 10";
			case 310:
				return "Button 11";
			case 311:
				return "Button 12";
			case 312:
				return "Button 13";
			case 313:
				return "Button 14";
			case 314:
				return "Button 15";
			default:
				return "Unknown key";
		}
	} else {
		return "Unknown key";
	}
}
Exemplo n.º 20
0
 int to_keycode(VirtualKey vkey)
 {
     return SDL_GetKeyFromScancode(
         static_cast<SDL_Scancode>(to_scancode(vkey)));
 }
Exemplo n.º 21
0
inline int32_t from_scan(int32_t scan_code) noexcept {
    return SDL_GetKeyFromScancode(static_cast<SDL_Scancode>(scan_code));
}