Changeset - r5099:1031de4e6e2f
[Not reviewed]
master
0 1 0
Darkvater - 18 years ago 2006-11-16 16:50:54
darkvater@openttd.org
(svn r7170) -Fix: [sdl] Non-working console toggle for some keyboard layouts. Do not OR the backquote
character but set it. Happened on Linux with Hungarian keyboard for example.
1 file changed with 11 insertions and 11 deletions:
0 comments (0 inline, 0 general)
video/sdl_v.c
Show inline comments
 
@@ -251,74 +251,74 @@ static const VkMapping _vk_mapping[] = {
 
	// What is the virtual keycode for numeric enter??
 
	AM(SDLK_KP0, SDLK_KP9, WKC_NUM_0, WKC_NUM_9),
 
	AS(SDLK_KP_DIVIDE,   WKC_NUM_DIV),
 
	AS(SDLK_KP_MULTIPLY, WKC_NUM_MUL),
 
	AS(SDLK_KP_MINUS,    WKC_NUM_MINUS),
 
	AS(SDLK_KP_PLUS,     WKC_NUM_PLUS),
 
	AS(SDLK_KP_ENTER,    WKC_NUM_ENTER),
 
	AS(SDLK_KP_PERIOD,   WKC_NUM_DECIMAL)
 
};
 

	
 
static uint32 ConvertSdlKeyIntoMy(SDL_keysym *sym)
 
{
 
	const VkMapping *map;
 
	uint key = 0;
 

	
 
	for (map = _vk_mapping; map != endof(_vk_mapping); ++map) {
 
		if ((uint)(sym->sym - map->vk_from) <= map->vk_count) {
 
			key = sym->sym - map->vk_from + map->map_to;
 
			break;
 
		}
 
	}
 

	
 
	// check scancode for BACKQUOTE key, because we want the key left of "1", not anything else (on non-US keyboards)
 
#if defined(WIN32) || defined(__OS2__)
 
	if (sym->scancode == 41) key |= WKC_BACKQUOTE;
 
	if (sym->scancode == 41) key = WKC_BACKQUOTE;
 
#elif defined(__APPLE__)
 
	if (sym->scancode == 10) key |= WKC_BACKQUOTE;
 
	if (sym->scancode == 10) key = WKC_BACKQUOTE;
 
#elif defined(__MORPHOS__)
 
	if (sym->scancode == 0)  key |= WKC_BACKQUOTE;  // yes, that key is code '0' under MorphOS :)
 
	if (sym->scancode == 0)  key = WKC_BACKQUOTE;  // yes, that key is code '0' under MorphOS :)
 
#elif defined(__BEOS__)
 
	if (sym->scancode == 17)  key |= WKC_BACKQUOTE;
 
	if (sym->scancode == 17) key = WKC_BACKQUOTE;
 
#elif defined(__SVR4) && defined(__sun)
 
	if (sym->scancode == 60) key |= WKC_BACKQUOTE;
 
	if (sym->scancode == 49) key |= WKC_BACKSPACE;
 
	if (sym->scancode == 60) key = WKC_BACKQUOTE;
 
	if (sym->scancode == 49) key = WKC_BACKSPACE;
 
#elif defined(__sgi__)
 
	if (sym->scancode == 22) key |= WKC_BACKQUOTE;
 
	if (sym->scancode == 22) key = WKC_BACKQUOTE;
 
#else
 
	if (sym->scancode == 41) key |= WKC_BACKQUOTE; // Linux console
 
	if (sym->scancode == 49) key |= WKC_BACKQUOTE;
 
	if (sym->scancode == 41) key = WKC_BACKQUOTE; // Linux console
 
	if (sym->scancode == 49) key = WKC_BACKQUOTE;
 
#endif
 

	
 
	// META are the command keys on mac
 
	if (sym->mod & KMOD_META)  key |= WKC_META;
 
	if (sym->mod & KMOD_SHIFT) key |= WKC_SHIFT;
 
	if (sym->mod & KMOD_CTRL)  key |= WKC_CTRL;
 
	if (sym->mod & KMOD_ALT)   key |= WKC_ALT;
 
	// these two lines really help porting hotkey combos. Uncomment to use -- Bjarni
 
#if 0
 
	DEBUG(driver, 0) ("scancode character pressed %d", sym->scancode);
 
	DEBUG(driver, 0) ("unicode character pressed %d", sym->unicode);
 
	DEBUG(driver, 0) ("scancode character pressed %u", sym->scancode);
 
	DEBUG(driver, 0) ("unicode character pressed %u", sym->unicode);
 
#endif
 
	return (key << 16) + sym->unicode;
 
}
 

	
 
static int PollEvent(void)
 
{
 
	SDL_Event ev;
 

	
 
	if (!SDL_CALL SDL_PollEvent(&ev)) return -2;
 

	
 
	switch (ev.type) {
 
		case SDL_MOUSEMOTION:
 
			if (_cursor.fix_at) {
 
				int dx = ev.motion.x - _cursor.pos.x;
 
				int dy = ev.motion.y - _cursor.pos.y;
 
				if (dx != 0 || dy != 0) {
 
					_cursor.delta.x += dx;
 
					_cursor.delta.y += dy;
 
					SDL_CALL SDL_WarpMouse(_cursor.pos.x, _cursor.pos.y);
 
				}
 
			} else {
 
				_cursor.delta.x = ev.motion.x - _cursor.pos.x;
 
				_cursor.delta.y = ev.motion.y - _cursor.pos.y;
 
				_cursor.pos.x = ev.motion.x;
0 comments (0 inline, 0 general)