Skip to content

Commit

Permalink
More SDL fixes:
Browse files Browse the repository at this point in the history
- Console key works as it should, at least on QWERTY keyboards. Someone
  will have to check AZERTY keyboards for me.
- Backspace key now works in text entry.
- Mouse input is scaled 2x, like the X11 driver does.
- Some basic logging so I know I'm using the SDL code and not the X11 code.
  • Loading branch information
icculus committed Aug 31, 2005
1 parent 3ca916a commit 5bc2c49
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions code/unix/linux_glimp_sdl.c
Expand Up @@ -165,12 +165,6 @@ static const char *XLateKey(SDL_keysym *keysym, int *key)
return buf;
}

if (keysym->unicode == '~') // the console.
{
buf[0] = *key = '~';
return buf;
}

buf[0] = '\0';

switch (keysym->sym)
Expand Down Expand Up @@ -210,7 +204,7 @@ static const char *XLateKey(SDL_keysym *keysym, int *key)

// bk001206 - from Ryan's Fakk2
//case SDLK_BackSpace: *key = 8; break; // ctrl-h
case SDLK_BACKSPACE: *key = K_BACKSPACE; break; // ctrl-h
case SDLK_BACKSPACE: *key = K_BACKSPACE; buf[0] = 8; break; // ctrl-h
case SDLK_KP_PERIOD: *key = K_KP_DEL; break;
case SDLK_DELETE: *key = K_DEL; break;
case SDLK_PAUSE: *key = K_PAUSE; break;
Expand All @@ -235,6 +229,9 @@ static const char *XLateKey(SDL_keysym *keysym, int *key)
case SDLK_KP_DIVIDE: *key = K_KP_SLASH; break;
case SDLK_SPACE: *key = K_SPACE; break;

// !!! FIXME: Console key...may not be accurate on all keyboards!
case SDLK_BACKQUOTE: *key = '~'; break;

default:
if (keysym->unicode <= 255) // maps to ASCII?
{
Expand All @@ -252,7 +249,7 @@ static const char *XLateKey(SDL_keysym *keysym, int *key)
break;
}

return NULL;
return buf;
}

static void install_grabs(void)
Expand Down Expand Up @@ -319,7 +316,13 @@ static void HandleEvents(void)

case SDL_MOUSEMOTION:
if (mouse_active)
{
if (abs(e.motion.xrel) > 1)
e.motion.xrel *= 2;
if (abs(e.motion.yrel) > 1)
e.motion.yrel *= 2;
Sys_QueEvent( t, SE_MOUSE, e.motion.xrel, e.motion.yrel, 0, NULL );
}
break;

case SDL_MOUSEBUTTONDOWN:
Expand Down Expand Up @@ -489,11 +492,13 @@ static qboolean GLW_StartDriverAndSetMode( const char *drivername,

if (!SDL_WasInit(SDL_INIT_VIDEO))
{
ri.Printf( PRINT_ALL, "Calling SDL_Init(SDL_INIT_VIDEO)...\n");
if (SDL_Init(SDL_INIT_VIDEO) == -1)
{
ri.Printf( PRINT_ALL, "SDL_Init(SDL_INIT_VIDEO) failed: %s\n", SDL_GetError());
return qfalse;
}
ri.Printf( PRINT_ALL, "SDL_Init(SDL_INIT_VIDEO) passed.\n");
}

// don't ever bother going into fullscreen with a voodoo card
Expand Down Expand Up @@ -1286,11 +1291,13 @@ void IN_StartupJoystick( void )

if (!SDL_WasInit(SDL_INIT_JOYSTICK))
{
Com_Printf( PRINT_ALL, "Calling SDL_Init(SDL_INIT_JOYSTICK)...\n");
if (SDL_Init(SDL_INIT_JOYSTICK) == -1)
{
Com_Printf("SDL_Init(SDL_INIT_JOYSTICK) failed: %s\n", SDL_GetError());
return;
}
Com_Printf( PRINT_ALL, "SDL_Init(SDL_INIT_JOYSTICK) passed.\n");
}

total = SDL_NumJoysticks();
Expand Down

0 comments on commit 5bc2c49

Please sign in to comment.