src/events/SDL_keyboard.c
changeset 7191 75360622e65f
parent 6983 b72f56ab9867
child 7258 89d47188c9a4
     1.1 --- a/src/events/SDL_keyboard.c	Sat May 18 12:48:50 2013 -0700
     1.2 +++ b/src/events/SDL_keyboard.c	Sat May 18 14:17:52 2013 -0700
     1.3 @@ -860,7 +860,7 @@
     1.4  SDL_GetKeyFromScancode(SDL_Scancode scancode)
     1.5  {
     1.6      SDL_Keyboard *keyboard = &SDL_keyboard;
     1.7 -    
     1.8 +
     1.9      if (scancode < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) {
    1.10            SDL_InvalidParamError("scancode");
    1.11            return 0;
    1.12 @@ -890,7 +890,7 @@
    1.13      const char *name;
    1.14      if (scancode < SDL_SCANCODE_UNKNOWN || scancode >= SDL_NUM_SCANCODES) {
    1.15            SDL_InvalidParamError("scancode");
    1.16 -          return "";    
    1.17 +          return "";
    1.18      }
    1.19  
    1.20      name = SDL_scancode_names[scancode];
    1.21 @@ -902,24 +902,24 @@
    1.22  
    1.23  SDL_Scancode SDL_GetScancodeFromName(const char *name)
    1.24  {
    1.25 -	int i;
    1.26 +    int i;
    1.27  
    1.28 -	if (!name || !*name) {
    1.29 -	        SDL_InvalidParamError("name");
    1.30 -		return SDL_SCANCODE_UNKNOWN;
    1.31 -	}
    1.32 +    if (!name || !*name) {
    1.33 +            SDL_InvalidParamError("name");
    1.34 +        return SDL_SCANCODE_UNKNOWN;
    1.35 +    }
    1.36  
    1.37 -	for (i = 0; i < SDL_arraysize(SDL_scancode_names); ++i) {
    1.38 -		if (!SDL_scancode_names[i]) {
    1.39 -			continue;
    1.40 -		}		
    1.41 -		if (SDL_strcasecmp(name, SDL_scancode_names[i]) == 0) {
    1.42 -			return (SDL_Scancode)i;
    1.43 -		}
    1.44 -	}
    1.45 +    for (i = 0; i < SDL_arraysize(SDL_scancode_names); ++i) {
    1.46 +        if (!SDL_scancode_names[i]) {
    1.47 +            continue;
    1.48 +        }
    1.49 +        if (SDL_strcasecmp(name, SDL_scancode_names[i]) == 0) {
    1.50 +            return (SDL_Scancode)i;
    1.51 +        }
    1.52 +    }
    1.53  
    1.54 -	SDL_InvalidParamError("name");
    1.55 -	return SDL_SCANCODE_UNKNOWN;
    1.56 +    SDL_InvalidParamError("name");
    1.57 +    return SDL_SCANCODE_UNKNOWN;
    1.58  }
    1.59  
    1.60  const char *
    1.61 @@ -964,51 +964,51 @@
    1.62  SDL_Keycode
    1.63  SDL_GetKeyFromName(const char *name)
    1.64  {
    1.65 -	SDL_Keycode key;
    1.66 +    SDL_Keycode key;
    1.67  
    1.68          /* Check input */
    1.69          if (name == NULL) return SDLK_UNKNOWN;
    1.70 -        
    1.71 -	/* If it's a single UTF-8 character, then that's the keycode itself */
    1.72 -	key = *(const unsigned char *)name;
    1.73 -	if (key >= 0xF0) {
    1.74 -		if (SDL_strlen(name) == 4) {
    1.75 -			int i = 0;
    1.76 -			key  = (Uint16)(name[i]&0x07) << 18;
    1.77 -			key |= (Uint16)(name[++i]&0x3F) << 12;
    1.78 -			key |= (Uint16)(name[++i]&0x3F) << 6;
    1.79 -			key |= (Uint16)(name[++i]&0x3F);
    1.80 -			return key;
    1.81 -		}
    1.82 -		return SDLK_UNKNOWN;
    1.83 -	} else if (key >= 0xE0) {
    1.84 -		if (SDL_strlen(name) == 3) {
    1.85 -			int i = 0;
    1.86 -			key  = (Uint16)(name[i]&0x0F) << 12;
    1.87 -			key |= (Uint16)(name[++i]&0x3F) << 6;
    1.88 -			key |= (Uint16)(name[++i]&0x3F);
    1.89 -			return key;
    1.90 -		}
    1.91 -		return SDLK_UNKNOWN;
    1.92 -	} else if (key >= 0xC0) {
    1.93 -		if (SDL_strlen(name) == 2) {
    1.94 -			int i = 0;
    1.95 -			key  = (Uint16)(name[i]&0x1F) << 6;
    1.96 -			key |= (Uint16)(name[++i]&0x3F);
    1.97 -			return key;
    1.98 -		}
    1.99 -		return SDLK_UNKNOWN;
   1.100 -	} else {
   1.101 -		if (SDL_strlen(name) == 1) {
   1.102 -			if (key >= 'A' && key <= 'Z') {
   1.103 -				key += 32;
   1.104 -			}
   1.105 -			return key;
   1.106 -		}
   1.107  
   1.108 -		/* Get the scancode for this name, and the associated keycode */
   1.109 -		return SDL_default_keymap[SDL_GetScancodeFromName(name)];
   1.110 -	}
   1.111 +    /* If it's a single UTF-8 character, then that's the keycode itself */
   1.112 +    key = *(const unsigned char *)name;
   1.113 +    if (key >= 0xF0) {
   1.114 +        if (SDL_strlen(name) == 4) {
   1.115 +            int i = 0;
   1.116 +            key  = (Uint16)(name[i]&0x07) << 18;
   1.117 +            key |= (Uint16)(name[++i]&0x3F) << 12;
   1.118 +            key |= (Uint16)(name[++i]&0x3F) << 6;
   1.119 +            key |= (Uint16)(name[++i]&0x3F);
   1.120 +            return key;
   1.121 +        }
   1.122 +        return SDLK_UNKNOWN;
   1.123 +    } else if (key >= 0xE0) {
   1.124 +        if (SDL_strlen(name) == 3) {
   1.125 +            int i = 0;
   1.126 +            key  = (Uint16)(name[i]&0x0F) << 12;
   1.127 +            key |= (Uint16)(name[++i]&0x3F) << 6;
   1.128 +            key |= (Uint16)(name[++i]&0x3F);
   1.129 +            return key;
   1.130 +        }
   1.131 +        return SDLK_UNKNOWN;
   1.132 +    } else if (key >= 0xC0) {
   1.133 +        if (SDL_strlen(name) == 2) {
   1.134 +            int i = 0;
   1.135 +            key  = (Uint16)(name[i]&0x1F) << 6;
   1.136 +            key |= (Uint16)(name[++i]&0x3F);
   1.137 +            return key;
   1.138 +        }
   1.139 +        return SDLK_UNKNOWN;
   1.140 +    } else {
   1.141 +        if (SDL_strlen(name) == 1) {
   1.142 +            if (key >= 'A' && key <= 'Z') {
   1.143 +                key += 32;
   1.144 +            }
   1.145 +            return key;
   1.146 +        }
   1.147 +
   1.148 +        /* Get the scancode for this name, and the associated keycode */
   1.149 +        return SDL_default_keymap[SDL_GetScancodeFromName(name)];
   1.150 +    }
   1.151  }
   1.152  
   1.153  /* vi: set ts=4 sw=4 expandtab: */