- Timestamp:
- 09/04/2017 05:55:08 PM (7 years ago)
- Branches:
- master
- Children:
- e26a632, f51359c
- Parents:
- fffab34
- Location:
- emu
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
emu/all.h
rfffab34 rca77925 162 162 extern void kbd_write(uint32_t off, int32_t sz, uint32_t val); 163 163 164 extern void kbd_text(SDL_TextInputEvent *ev); 165 extern void kbd_key(SDL_KeyboardEvent *ev); 164 extern void kbd_key(SDL_KeyboardEvent *ev, bool dn); -
emu/kbd.c
rfffab34 rca77925 119 119 #endif 120 120 121 void kbd_key(SDL_KeyboardEvent *ev) 122 { 123 static bool on[24]; 124 121 void kbd_key(SDL_KeyboardEvent *ev, bool dn) 122 { 125 123 if ((ev->keysym.mod & KMOD_SHIFT) != 0 && 126 124 ev->keysym.sym >= SDLK_a && ev->keysym.sym <= SDLK_x) { 127 125 int32_t i = ev->keysym.sym - SDLK_a; 128 on[i] = !on[i];129 130 if ( on[i]) {126 ver2("kbd key %d %s", i, dn ? "dn" : "up"); 127 128 if (dn) { 131 129 key_touch(1 + i, 0x7f); 132 130 } … … 135 133 } 136 134 137 ver2("kbd key %d %s", i, on[i] ? "on" : "off"); 138 } 139 } 140 141 void kbd_text(SDL_TextInputEvent *ev) 142 { 143 for (int32_t i = 0; ev->text[i] != 0; ++i) { 144 if (ev->text[i] >= '0' && ev->text[i] <= '9') { 145 ver2("kbd dat %c", ev->text[i]); 146 int32_t sig = 60 + ev->text[i] - '0'; 147 but_on(sig); 148 but_off(sig); 149 continue; 150 } 151 152 switch (ev->text[i]) { 153 case 'x': 154 ver2("kbd x"); 155 but_on(70); 156 but_off(70); 135 return; 136 } 137 138 int32_t sig; 139 140 if (ev->keysym.sym >= SDLK_0 && ev->keysym.sym <= '9') { 141 int32_t i = ev->keysym.sym - SDLK_0; 142 ver2("kbd dat %d %s", i, dn ? "dn" : "up"); 143 sig = 60 + i; 144 } 145 else { 146 switch (ev->keysym.sym) { 147 case SDLK_x: 148 ver2("kbd x %s", dn ? "dn" : "up"); 149 sig = 70; 157 150 break; 158 151 159 case 'e': 160 ver2("kbd e"); 161 but_on(71); 162 but_off(71); 152 case SDLK_e: 153 ver2("kbd e %s", dn ? "dn" : "up"); 154 sig = 71; 163 155 break; 164 156 165 case 'm': 166 ver2("kbd m"); 167 but_on(72); 168 but_off(72); 157 case SDLK_m: 158 ver2("kbd m %s", dn ? "dn" : "up"); 159 sig = 72; 169 160 break; 170 } 161 162 default: 163 return; 164 } 165 } 166 167 if (dn) { 168 but_on(sig); 169 } 170 else { 171 but_off(sig); 171 172 } 172 173 } -
emu/sdl.c
rfffab34 rca77925 150 150 ser_text(&ev.text); 151 151 } 152 else if (win == vid_win) {153 kbd_text(&ev.text);154 }155 152 156 153 continue; … … 164 161 } 165 162 else if (win == vid_win) { 166 kbd_key(&ev.key); 163 kbd_key(&ev.key, true); 164 } 165 166 continue; 167 } 168 169 if (ev.type == SDL_KEYUP) { 170 ver("sdl ev key up %d", (int32_t)ev.key.keysym.sym); 171 172 if (win == vid_win) { 173 kbd_key(&ev.key, false); 167 174 } 168 175
Note:
See TracChangeset
for help on using the changeset viewer.