comparison Xcode-iPhoneOS/Demos/src/keyboard.c @ 5083:25d4feb7c127

Renamed SDL_keysym to SDL_KeySym Renamed SDL_scancode to SDL_ScanCode Added #defines to SDL_compat.h
author krogoway
date Mon, 24 Jan 2011 13:47:35 -0600
parents 64ce267332c6
children
comparison
equal deleted inserted replaced
5082:de59e0218aa2 5083:25d4feb7c127
32 (for example, we don't want shift + 1 to produce the character '1', 32 (for example, we don't want shift + 1 to produce the character '1',
33 but rather the character '!') 33 but rather the character '!')
34 */ 34 */
35 typedef struct 35 typedef struct
36 { 36 {
37 SDL_scancode scancode; /* scancode of the key we want to map */ 37 SDL_ScanCode scancode; /* scancode of the key we want to map */
38 int allow_no_mod; /* is the map valid if the key has no modifiers? */ 38 int allow_no_mod; /* is the map valid if the key has no modifiers? */
39 SDLMod mod; /* what modifiers are allowed for the mapping */ 39 SDLMod mod; /* what modifiers are allowed for the mapping */
40 int index; /* what index in the font does the scancode map to */ 40 int index; /* what index in the font does the scancode map to */
41 } fontMapping; 41 } fontMapping;
42 42
101 {SDL_SCANCODE_5, 0, KMOD_SHIFT, 5}, /* % */ 101 {SDL_SCANCODE_5, 0, KMOD_SHIFT, 5}, /* % */
102 102
103 }; 103 };
104 104
105 /* 105 /*
106 This function maps an SDL_keysym to an index in the bitmap font. 106 This function maps an SDL_KeySym to an index in the bitmap font.
107 It does so by scanning through the font mapping table one entry 107 It does so by scanning through the font mapping table one entry
108 at a time. 108 at a time.
109 109
110 If a match is found (scancode and allowed modifiers), the proper 110 If a match is found (scancode and allowed modifiers), the proper
111 index is returned. 111 index is returned.
112 112
113 If there is no entry for the key, -1 is returned 113 If there is no entry for the key, -1 is returned
114 */ 114 */
115 int 115 int
116 keyToIndex(SDL_keysym key) 116 keyToIndex(SDL_KeySym key)
117 { 117 {
118 int i, index = -1; 118 int i, index = -1;
119 for (i = 0; i < TABLE_SIZE; i++) { 119 for (i = 0; i < TABLE_SIZE; i++) {
120 fontMapping compare = map[i]; 120 fontMapping compare = map[i];
121 if (key.scancode == compare.scancode) { 121 if (key.scancode == compare.scancode) {
238 238
239 int index; /* index of last key we pushed in the bitmap font */ 239 int index; /* index of last key we pushed in the bitmap font */
240 SDL_Window *window; 240 SDL_Window *window;
241 SDL_Event event; /* last event received */ 241 SDL_Event event; /* last event received */
242 SDLMod mod; /* key modifiers of last key we pushed */ 242 SDLMod mod; /* key modifiers of last key we pushed */
243 SDL_scancode scancode; /* scancode of last key we pushed */ 243 SDL_ScanCode scancode; /* scancode of last key we pushed */
244 244
245 if (SDL_Init(SDL_INIT_VIDEO) < 0) { 245 if (SDL_Init(SDL_INIT_VIDEO) < 0) {
246 printf("Error initializing SDL: %s", SDL_GetError()); 246 printf("Error initializing SDL: %s", SDL_GetError());
247 } 247 }
248 /* create window */ 248 /* create window */