this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

detect default mapping for non US keyboard #1748 #1339

nesbox b8f585c1 a9de2951

+351 -296
+2 -12
src/studio/config.c
··· 237 237 .volume = MAX_VOLUME, 238 238 .vsync = true, 239 239 .fullscreen = false, 240 - .mapping = (tic_mapping) 241 - { 242 - tic_key_up, 243 - tic_key_down, 244 - tic_key_left, 245 - tic_key_right, 246 - 247 - tic_key_z, // a 248 - tic_key_x, // b 249 - tic_key_a, // x 250 - tic_key_s, // y 251 - }, 252 240 }, 253 241 }; 242 + 243 + tic_sys_default_mapping(&config->data.options.mapping); 254 244 255 245 { 256 246 static const u8 ConfigZip[] =
+50 -62
src/studio/studio.c
··· 1137 1137 tic_sys_fullscreen_set(impl.config->data.options.fullscreen = (pos == 1)); 1138 1138 } 1139 1139 1140 - static const char OffValue[] = "<OFF> "; 1141 - static const char OnValue[] = "<ON> "; 1140 + static const char OffValue[] = "<OFF>"; 1141 + static const char OnValue[] = "<ON> "; 1142 1142 1143 1143 static MenuOption FullscreenOption = 1144 1144 { ··· 1198 1198 { 1199 1199 OPTION_VALUES( 1200 1200 { 1201 - "<00> ", "<01> ", "<02> ", "<03> ", 1202 - "<04> ", "<05> ", "<06> ", "<07> ", 1203 - "<08> ", "<09> ", "<10> ", "<11> ", 1204 - "<12> ", "<13> ", "<14> ", "<15> ", 1201 + "<00> ", "<01> ", "<02> ", "<03> ", 1202 + "<04> ", "<05> ", "<06> ", "<07> ", 1203 + "<08> ", "<09> ", "<10> ", "<11> ", 1204 + "<12> ", "<13> ", "<14> ", "<15> ", 1205 1205 }), 1206 1206 optionVolumeGet, 1207 1207 optionVolumeSet, 1208 1208 }; 1209 1209 1210 - // !TODO: temp var 1211 - static s32 KeyboardPos = 0; 1212 - 1213 - static s32 optionKeyboardGet() 1214 - { 1215 - // !TODO: not impelemnted 1216 - return KeyboardPos; 1217 - } 1218 - 1219 - static void optionKeyboardSet(s32 pos) 1220 - { 1221 - // !TODO: not impelemnted 1222 - KeyboardPos = pos; 1223 - } 1224 - 1225 - static MenuOption KeyboardOption = 1226 - { 1227 - OPTION_VALUES( 1228 - { 1229 - "<QWERTY>", 1230 - "<AZERTY>", 1231 - "<QWERTZ>", 1232 - "<QZERTY>", 1233 - }), 1234 - optionKeyboardGet, 1235 - optionKeyboardSet, 1236 - }; 1237 - 1238 1210 static void showGamepadMenu(); 1239 1211 1240 1212 static const MenuItem OptionMenu[] = ··· 1245 1217 {"VSYNC ", NULL, &VSyncOption, "VSYNC needs restart!"}, 1246 1218 {"FULLSCREEN ", NULL, &FullscreenOption}, 1247 1219 {"VOLUME ", NULL, &VolumeOption}, 1248 - {"KEYBOARD ", NULL, &KeyboardOption}, 1249 1220 {"SETUP GAMEPAD", showGamepadMenu}, 1250 1221 {"", NULL}, 1251 1222 {"BACK", showGameMenu}, ··· 1287 1258 1288 1259 static const char* KeysList[] = 1289 1260 { 1261 + "<...> ", 1290 1262 "<A> ", "<B> ", "<C> ", "<D> ", "<E> ", "<F> ", "<G> ", "<H> ", 1291 1263 "<I> ", "<J> ", "<K> ", "<L> ", "<M> ", "<N> ", "<O> ", "<P> ", 1292 1264 "<Q> ", "<R> ", "<S> ", "<T> ", "<U> ", "<V> ", "<W> ", "<X> ", 1293 1265 "<Y> ", "<Z> ", "<0> ", "<1> ", "<2> ", "<3> ", "<4> ", "<5> ", 1294 1266 "<6> ", "<7> ", "<8> ", "<9> ", "<-> ", "<=> ", "<[> ", "<]> ", 1295 - "<\\> ","<;> ", "<'> ", "<`> ", "<,> ", "<.> ", "</> ", "< > ", 1267 + "<\\> ","<;> ", "<'> ", "<`> ", "<,> ", "<.> ", "</> ", "<SPACE>", 1296 1268 "<TAB> ", "<RET> ", "<BACKS>", "<DEL> ", "<INS> ", "<PGUP> ", "<PGDN> ", "<HOME> ", 1297 1269 "<END> ", "<UP> ", "<DOWN> ", "<LEFT> ", "<RIGHT>", "<CAPS> ", "<CTRL> ", "<SHIFT>", 1298 1270 "<ALT> ", "<ESC> ", "<F1> ", "<F2> ", "<F3> ", "<F4> ", "<F5> ", "<F6> ", ··· 1301 1273 1302 1274 static tic_mapping GamepadMapping; 1303 1275 1304 - #define OPTION_KEY(KEY) \ 1305 - \ 1306 - enum{KEY ## KeyIndex = __COUNTER__}; \ 1307 - \ 1308 - static s32 option ## KEY ## KeyGet() \ 1309 - { \ 1310 - return GamepadMapping.data[KEY ## KeyIndex] - 1; \ 1311 - } \ 1312 - \ 1313 - static void option ## KEY ## KeySet(s32 pos) \ 1314 - { \ 1315 - GamepadMapping.data[KEY ## KeyIndex] = pos + 1; \ 1316 - } \ 1317 - \ 1318 - static MenuOption KEY ## KeyOption = \ 1319 - { \ 1320 - .values = KeysList, \ 1321 - .count = COUNT_OF(KeysList), \ 1322 - option ## KEY ## KeyGet, \ 1323 - option ## KEY ## KeySet, \ 1276 + #define OPTION_KEY(KEY) \ 1277 + \ 1278 + enum{KEY ## KeyIndex = __COUNTER__}; \ 1279 + \ 1280 + static s32 option ## KEY ## KeyGet() \ 1281 + { \ 1282 + return GamepadMapping.data[KEY ## KeyIndex]; \ 1283 + } \ 1284 + \ 1285 + static void option ## KEY ## KeySet(s32 pos) \ 1286 + { \ 1287 + GamepadMapping.data[KEY ## KeyIndex] = pos; \ 1288 + } \ 1289 + \ 1290 + static MenuOption KEY ## KeyOption = \ 1291 + { \ 1292 + .values = KeysList, \ 1293 + .count = COUNT_OF(KeysList), \ 1294 + option ## KEY ## KeyGet, \ 1295 + option ## KEY ## KeySet, \ 1324 1296 }; 1325 1297 1326 1298 OPTION_KEY(Up) ··· 1332 1304 OPTION_KEY(X) 1333 1305 OPTION_KEY(Y) 1334 1306 1335 - static void backGamepadMenu() 1307 + static void saveGamepadMenu() 1336 1308 { 1337 1309 impl.config->data.options.mapping = GamepadMapping; 1338 1310 showOptionsMenu(); 1339 1311 } 1340 1312 1341 - static void showGamepadMenu() 1313 + static void resetGamepadMenu(); 1314 + 1315 + static void initGamepadMenu() 1342 1316 { 1343 1317 static const MenuItem GamepadMenu[] = 1344 1318 { ··· 1351 1325 {"X ", NULL, &XKeyOption}, 1352 1326 {"Y ", NULL, &YKeyOption}, 1353 1327 1354 - {"", NULL}, 1355 - {"BACK", backGamepadMenu}, 1328 + {"", NULL}, 1329 + {"SAVE MAPPING", saveGamepadMenu}, 1330 + {"RESET TO DEFAULTS", resetGamepadMenu}, 1331 + {"BACK", showOptionsMenu}, 1356 1332 }; 1357 1333 1358 - GamepadMapping = impl.studio.tic->ram.mapping; 1334 + GamepadMapping = getConfig()->options.mapping; 1359 1335 1360 1336 studio_menu_init(impl.menu, GamepadMenu, COUNT_OF(GamepadMenu), 1361 - 0, COUNT_OF(OptionMenu) - 3, backGamepadMenu, NULL); 1337 + 0, COUNT_OF(OptionMenu) - 3, showOptionsMenu, NULL); 1338 + } 1339 + 1340 + static void resetGamepadMenu() 1341 + { 1342 + tic_sys_default_mapping(&GamepadMapping); 1343 + initGamepadMenu(); 1344 + } 1345 + 1346 + static void showGamepadMenu() 1347 + { 1348 + GamepadMapping = getConfig()->options.mapping; 1349 + initGamepadMenu(); 1362 1350 } 1363 1351 1364 1352 static inline bool pointInRect(const tic_point* pt, const tic_rect* rect)
+1
src/studio/system.h
··· 60 60 void tic_sys_preseed(); 61 61 bool tic_sys_keyboard_text(char* text); 62 62 void tic_sys_update_config(); 63 + void tic_sys_default_mapping(tic_mapping* mapping); 63 64 64 65 #define CODE_COLORS_LIST(macro) \ 65 66 macro(BG) \
+231 -215
src/system/baremetalpi/kernel.cpp
··· 60 60 /* 61 61 unsigned int sleep(unsigned int seconds) 62 62 { 63 - mTimer.SimpleMsDelay (seconds*1000); 63 + mTimer.SimpleMsDelay (seconds*1000); 64 64 } 65 65 */ 66 66 67 67 static struct 68 68 { 69 69 70 - Studio* studio; 70 + Studio* studio; 71 71 72 - struct 73 - { 74 - bool state[tic_keys_count]; 75 - } keyboard; 72 + struct 73 + { 74 + bool state[tic_keys_count]; 75 + } keyboard; 76 76 77 - char* clipboard; 77 + char* clipboard; 78 78 79 79 } platform; 80 80 81 81 void tic_sys_clipboard_set(const char* text) 82 82 { 83 - if(platform.clipboard) 84 - { 85 - free(platform.clipboard); 86 - platform.clipboard = NULL; 87 - } 83 + if(platform.clipboard) 84 + { 85 + free(platform.clipboard); 86 + platform.clipboard = NULL; 87 + } 88 88 89 - platform.clipboard = strdup(text); 89 + platform.clipboard = strdup(text); 90 90 } 91 91 92 92 bool tic_sys_clipboard_has() 93 93 { 94 - return platform.clipboard != NULL; 94 + return platform.clipboard != NULL; 95 95 } 96 96 97 97 char* tic_sys_clipboard_get() 98 98 { 99 - return platform.clipboard ? strdup(platform.clipboard) : NULL; 99 + return platform.clipboard ? strdup(platform.clipboard) : NULL; 100 100 } 101 101 102 102 void tic_sys_clipboard_free(const char* text) 103 103 { 104 - free((void*)text); 104 + free((void*)text); 105 105 } 106 106 107 107 u64 tic_sys_counter_get() 108 108 { 109 - return CTimer::Get()->GetTicks(); 109 + return CTimer::Get()->GetTicks(); 110 110 } 111 111 112 112 u64 tic_sys_freq_get() 113 113 { 114 - return HZ; 114 + return HZ; 115 115 } 116 116 117 117 void tic_sys_fullscreen_set(bool value) ··· 138 138 void tic_sys_preseed() 139 139 { 140 140 #if defined(__TIC_MACOSX__) 141 - srandom(time(NULL)); 142 - random(); 141 + srandom(time(NULL)); 142 + random(); 143 143 #else 144 - srand(time(NULL)); 145 - rand(); 144 + srand(time(NULL)); 145 + rand(); 146 146 #endif 147 147 } 148 148 ··· 151 151 152 152 } 153 153 154 + void tic_sys_default_mapping(tic_mapping* mapping) 155 + { 156 + *mapping = (tic_mapping) 157 + { 158 + tic_key_up, 159 + tic_key_down, 160 + tic_key_left, 161 + tic_key_right, 162 + 163 + tic_key_z, // a 164 + tic_key_x, // b 165 + tic_key_a, // x 166 + tic_key_s, // y 167 + }; 168 + } 169 + 154 170 bool tic_sys_keyboard_text(char* text) 155 171 { 156 - return false; 172 + return false; 157 173 } 158 174 159 175 void screenCopy(CScreenDevice* screen, u32* ts) 160 176 { 161 - u32 pitch = screen->GetPitch(); 162 - u32* buf = screen->GetBuffer(); 163 - for (int y = 0; y < TIC80_HEIGHT; y++) 164 - { 165 - u32 *line = ts + ((y+TIC80_OFFSET_TOP)*(TIC80_FULLWIDTH) + TIC80_OFFSET_LEFT); 166 - memcpy(buf + (pitch * y), line, TIC80_WIDTH * 4); 167 - } 177 + u32 pitch = screen->GetPitch(); 178 + u32* buf = screen->GetBuffer(); 179 + for (int y = 0; y < TIC80_HEIGHT; y++) 180 + { 181 + u32 *line = ts + ((y+TIC80_OFFSET_TOP)*(TIC80_FULLWIDTH) + TIC80_OFFSET_LEFT); 182 + memcpy(buf + (pitch * y), line, TIC80_WIDTH * 4); 183 + } 168 184 169 - // single pixel mouse pointer, disappear after 10 seconds unmoved 170 - if (mouseTime<600) 171 - { 172 - u32 midx = pitch*(mousey)+mousex; 173 - buf[midx]= 0xffffff; 174 - } 185 + // single pixel mouse pointer, disappear after 10 seconds unmoved 186 + if (mouseTime<600) 187 + { 188 + u32 midx = pitch*(mousey)+mousex; 189 + buf[midx]= 0xffffff; 190 + } 175 191 176 - // memcpy(screen->GetBuffer(), tic->screen, TIC80_WIDTH*TIC80_HEIGHT*4); would have been too good 192 + // memcpy(screen->GetBuffer(), tic->screen, TIC80_WIDTH*TIC80_HEIGHT*4); would have been too good 177 193 } 178 194 179 195 ··· 182 198 183 199 void mouseEventHandler (TMouseEvent Event, unsigned nButtons, unsigned nPosX, unsigned nPosY, int nWheelMove) 184 200 { 185 - keyspinlock.Acquire(); 186 - mousex = nPosX/MOUSE_SENS; 187 - mousey = nPosY/MOUSE_SENS; 188 - mousebuttons = nButtons; 189 - keyspinlock.Release(); 201 + keyspinlock.Acquire(); 202 + mousex = nPosX/MOUSE_SENS; 203 + mousey = nPosY/MOUSE_SENS; 204 + mousebuttons = nButtons; 205 + keyspinlock.Release(); 190 206 } 191 207 192 208 void gamePadStatusHandler (unsigned nDeviceIndex, const TGamePadState *pState) 193 209 { 194 210 195 - keyspinlock.Acquire(); 196 - // Just copy buttons and axes. 197 - gamepad.buttons = pState -> buttons; 198 - gamepad.naxes = pState -> naxes; 199 - for (int i = 0; i< pState->naxes; i++) 200 - { 201 - gamepad.axes[i].value = pState -> axes[i].value; 202 - } 203 - keyspinlock.Release(); 211 + keyspinlock.Acquire(); 212 + // Just copy buttons and axes. 213 + gamepad.buttons = pState -> buttons; 214 + gamepad.naxes = pState -> naxes; 215 + for (int i = 0; i< pState->naxes; i++) 216 + { 217 + gamepad.axes[i].value = pState -> axes[i].value; 218 + } 219 + keyspinlock.Release(); 204 220 } 205 221 206 222 207 223 void inputToTic() 208 224 { 209 - tic_mem* tic = platform.studio->tic; 225 + tic_mem* tic = platform.studio->tic; 210 226 211 - tic80_input* tic_input = &tic->ram.input; 227 + tic80_input* tic_input = &tic->ram.input; 212 228 213 - // mouse 214 - if (mousebuttons & 0x01) tic_input->mouse.left = true; else tic_input->mouse.left = false; 215 - if (mousebuttons & 0x02) tic_input->mouse.right = true; else tic_input->mouse.right = false; 216 - if (mousebuttons & 0x04) tic_input->mouse.middle = true; else tic_input->mouse.middle = false; 217 - tic_input->mouse.x = mousex + TIC80_OFFSET_LEFT; 218 - tic_input->mouse.y = mousey + TIC80_OFFSET_TOP; 229 + // mouse 230 + if (mousebuttons & 0x01) tic_input->mouse.left = true; else tic_input->mouse.left = false; 231 + if (mousebuttons & 0x02) tic_input->mouse.right = true; else tic_input->mouse.right = false; 232 + if (mousebuttons & 0x04) tic_input->mouse.middle = true; else tic_input->mouse.middle = false; 233 + tic_input->mouse.x = mousex + TIC80_OFFSET_LEFT; 234 + tic_input->mouse.y = mousey + TIC80_OFFSET_TOP; 219 235 220 - if( (mousex == mousexOld) && (mousey == mouseyOld) && (mousebuttons == mousebuttonsOld)) 221 - { 222 - mouseTime++; 223 - } 224 - else 225 - { 226 - mouseTime = 0; 227 - } 236 + if( (mousex == mousexOld) && (mousey == mouseyOld) && (mousebuttons == mousebuttonsOld)) 237 + { 238 + mouseTime++; 239 + } 240 + else 241 + { 242 + mouseTime = 0; 243 + } 228 244 229 - mousexOld = mousex; 230 - mouseyOld = mousey; 231 - mousebuttonsOld = mousebuttons; 245 + mousexOld = mousex; 246 + mouseyOld = mousey; 247 + mousebuttonsOld = mousebuttons; 232 248 233 - // keyboard 234 - tic_input->gamepads.first.data = 0; 235 - tic_input->keyboard.data = 0; 249 + // keyboard 250 + tic_input->gamepads.first.data = 0; 251 + tic_input->keyboard.data = 0; 236 252 237 - u32 keynum = 0; 253 + u32 keynum = 0; 238 254 239 - //dbg("MODIF %02x ", keyboardModifiers); 255 + //dbg("MODIF %02x ", keyboardModifiers); 240 256 241 - if(keyboardModifiers & 0x11) tic_input->keyboard.keys[keynum++]= tic_key_ctrl; 242 - if(keyboardModifiers & 0x22) tic_input->keyboard.keys[keynum++]= tic_key_shift; 243 - if(keyboardModifiers & 0x44) tic_input->keyboard.keys[keynum++]= tic_key_alt; 257 + if(keyboardModifiers & 0x11) tic_input->keyboard.keys[keynum++]= tic_key_ctrl; 258 + if(keyboardModifiers & 0x22) tic_input->keyboard.keys[keynum++]= tic_key_shift; 259 + if(keyboardModifiers & 0x44) tic_input->keyboard.keys[keynum++]= tic_key_alt; 244 260 245 - for (unsigned i = 0; i < 6; i++) 246 - { 247 - if (keyboardRawKeys[i] != 0) 248 - { 249 - // keyboard 250 - if(keynum<TIC80_KEY_BUFFER){ 251 - tic_keycode tkc = TicKeyboardCodes[keyboardRawKeys[i]]; 252 - if(tkc != tic_key_unknown) tic_input->keyboard.keys[keynum++]= tkc; 253 - } 254 - // key to gamepad 255 - switch(keyboardRawKeys[i]) 256 - { 257 - case 0x1d: tic_input->gamepads.first.a = true; break; 258 - case 0x1b: tic_input->gamepads.first.b = true; break; 259 - case 0x52: tic_input->gamepads.first.up = true; break; 260 - case 0x51: tic_input->gamepads.first.down = true; break; 261 - case 0x50: tic_input->gamepads.first.left = true; break; 262 - case 0x4F: tic_input->gamepads.first.right = true; break; 263 - } 264 - //dbg(" %02x ", keyboardRawKeys[i]); 261 + for (unsigned i = 0; i < 6; i++) 262 + { 263 + if (keyboardRawKeys[i] != 0) 264 + { 265 + // keyboard 266 + if(keynum<TIC80_KEY_BUFFER){ 267 + tic_keycode tkc = TicKeyboardCodes[keyboardRawKeys[i]]; 268 + if(tkc != tic_key_unknown) tic_input->keyboard.keys[keynum++]= tkc; 269 + } 270 + // key to gamepad 271 + switch(keyboardRawKeys[i]) 272 + { 273 + case 0x1d: tic_input->gamepads.first.a = true; break; 274 + case 0x1b: tic_input->gamepads.first.b = true; break; 275 + case 0x52: tic_input->gamepads.first.up = true; break; 276 + case 0x51: tic_input->gamepads.first.down = true; break; 277 + case 0x50: tic_input->gamepads.first.left = true; break; 278 + case 0x4F: tic_input->gamepads.first.right = true; break; 279 + } 280 + //dbg(" %02x ", keyboardRawKeys[i]); 265 281 266 - } 267 - } 268 - //dbg("\n"); 282 + } 283 + } 284 + //dbg("\n"); 269 285 270 286 271 - // gamepads 287 + // gamepads 272 288 273 - if (gamepad.buttons & 0x100) tic_input->gamepads.first.a = true; 274 - if (gamepad.buttons & 0x200) tic_input->gamepads.first.b = true; 275 - if (gamepad.buttons & 0x400) tic_input->gamepads.first.x = true; 276 - if (gamepad.buttons & 0x800) tic_input->gamepads.first.y = true; 277 - // map ESC to a gamepad button to exit the game 278 - if (gamepad.buttons & 0x10) tic_input->keyboard.keys[keynum++]= tic_key_escape; 289 + if (gamepad.buttons & 0x100) tic_input->gamepads.first.a = true; 290 + if (gamepad.buttons & 0x200) tic_input->gamepads.first.b = true; 291 + if (gamepad.buttons & 0x400) tic_input->gamepads.first.x = true; 292 + if (gamepad.buttons & 0x800) tic_input->gamepads.first.y = true; 293 + // map ESC to a gamepad button to exit the game 294 + if (gamepad.buttons & 0x10) tic_input->keyboard.keys[keynum++]= tic_key_escape; 279 295 280 - // TODO use min and max instead of hardcoded range 281 - if (gamepad.naxes > 0) 282 - { 283 - if (gamepad.axes[0].value < 50) tic_input->gamepads.first.left = true; 284 - if (gamepad.axes[0].value > 200) tic_input->gamepads.first.right = true; 296 + // TODO use min and max instead of hardcoded range 297 + if (gamepad.naxes > 0) 298 + { 299 + if (gamepad.axes[0].value < 50) tic_input->gamepads.first.left = true; 300 + if (gamepad.axes[0].value > 200) tic_input->gamepads.first.right = true; 285 301 286 - } 287 - if (gamepad.naxes > 1) 288 - { 289 - if (gamepad.axes[1].value < 50) tic_input->gamepads.first.up = true; 290 - if (gamepad.axes[1].value > 200) tic_input->gamepads.first.down = true; 291 - } 302 + } 303 + if (gamepad.naxes > 1) 304 + { 305 + if (gamepad.axes[1].value < 50) tic_input->gamepads.first.up = true; 306 + if (gamepad.axes[1].value > 200) tic_input->gamepads.first.down = true; 307 + } 292 308 /* 293 309 dbg("G:BTN 0x%X", gamepad.buttons); 294 310 ··· 318 334 } 319 335 void KeyStatusHandlerRaw (unsigned char ucModifiers, const unsigned char RawKeys[6]) 320 336 { 321 - // this gets called with whatever key is currently pressed in RawKeys 322 - // (plus modifiers). 323 - keyspinlock.Acquire(); 324 - keyboardModifiers = ucModifiers; 325 - memcpy(keyboardRawKeys, RawKeys, sizeof(unsigned char)*6); 326 - keyspinlock.Release(); 337 + // this gets called with whatever key is currently pressed in RawKeys 338 + // (plus modifiers). 339 + keyspinlock.Acquire(); 340 + keyboardModifiers = ucModifiers; 341 + memcpy(keyboardRawKeys, RawKeys, sizeof(unsigned char)*6); 342 + keyspinlock.Release(); 327 343 } 328 344 329 345 void testmkdir(const char* name) 330 346 { 331 - dbg("creating %s : ", name); 332 - FRESULT res = f_mkdir(name); 333 - if(res == FR_OK) 334 - { 335 - dbg("ok\n"); 336 - } 337 - else 338 - { 339 - dbg("KO %d\n", res); 340 - } 347 + dbg("creating %s : ", name); 348 + FRESULT res = f_mkdir(name); 349 + if(res == FR_OK) 350 + { 351 + dbg("ok\n"); 352 + } 353 + else 354 + { 355 + dbg("KO %d\n", res); 356 + } 341 357 } 342 358 343 359 void teststat(const char* name) 344 360 { 345 - dbg("K:%s", name); 346 - FILINFO filinfo; 347 - FRESULT res = f_stat (name, &filinfo); 348 - dbg("stat: %d ", res); 349 - dbg("size: %ld ", filinfo.fsize); 350 - dbg("attr: %02x\n", filinfo.fattrib); 361 + dbg("K:%s", name); 362 + FILINFO filinfo; 363 + FRESULT res = f_stat (name, &filinfo); 364 + dbg("stat: %d ", res); 365 + dbg("size: %ld ", filinfo.fsize); 366 + dbg("attr: %02x\n", filinfo.fattrib); 351 367 } 352 368 353 369 TShutdownMode Run(void) 354 370 { 355 - initializeCore(); 356 - mLogger.Write (KN, LogNotice, "TIC80 Port"); 371 + initializeCore(); 372 + mLogger.Write (KN, LogNotice, "TIC80 Port"); 357 373 358 - //teststat("circle.txt"); 359 - //teststat("no.txt"); 360 - //teststat("carts"); 374 + //teststat("circle.txt"); 375 + //teststat("no.txt"); 376 + //teststat("carts"); 361 377 362 - testmkdir("tic80"); 363 - //CTimer::SimpleMsDelay(5000); 378 + testmkdir("tic80"); 379 + //CTimer::SimpleMsDelay(5000); 364 380 365 - // ok testmkdir("primo"); 366 - // ko testmkdir("secondo/bis"); 367 - // ok testmkdir(".terzo"); 368 - // ko testmkdir(".quarto/"); 369 - // ko testmkdir("quinto/"); 370 - // ok testmkdir("sesto bis"); 381 + // ok testmkdir("primo"); 382 + // ko testmkdir("secondo/bis"); 383 + // ok testmkdir(".terzo"); 384 + // ko testmkdir(".quarto/"); 385 + // ko testmkdir("quinto/"); 386 + // ok testmkdir("sesto bis"); 371 387 372 - dbg("Calling studio init instance..\n"); 388 + dbg("Calling studio init instance..\n"); 373 389 374 - if (pKeyboard) 375 - { 376 - dbg("With keyboard\n"); 377 - malloc(77); 378 - char arg0[] = "xxkernel"; 379 - char* argv[] = { &arg0[0], NULL }; 380 - int argc = 1; 381 - malloc(88); 382 - platform.studio = studioInit(argc, argv, 44100, "tic80"); 383 - malloc(99); 390 + if (pKeyboard) 391 + { 392 + dbg("With keyboard\n"); 393 + malloc(77); 394 + char arg0[] = "xxkernel"; 395 + char* argv[] = { &arg0[0], NULL }; 396 + int argc = 1; 397 + malloc(88); 398 + platform.studio = studioInit(argc, argv, 44100, "tic80"); 399 + malloc(99); 384 400 385 - } 386 - else 387 - { 388 - // if no keyboard, start in surf mode! 389 - char arg0[] = "xxkernel"; 390 - char arg1[] = "--cmd=surf"; 391 - char* argv[] = { &arg0[0], &arg1[0], NULL }; 392 - int argc = 2; 393 - dbg("Without keyboard\n"); 394 - platform.studio = studioInit(argc, argv, 44100, "tic80"); 395 - } 396 - dbg("studioInit OK\n"); 401 + } 402 + else 403 + { 404 + // if no keyboard, start in surf mode! 405 + char arg0[] = "xxkernel"; 406 + char arg1[] = "--cmd=surf"; 407 + char* argv[] = { &arg0[0], &arg1[0], NULL }; 408 + int argc = 2; 409 + dbg("Without keyboard\n"); 410 + platform.studio = studioInit(argc, argv, 44100, "tic80"); 411 + } 412 + dbg("studioInit OK\n"); 397 413 398 - if( !platform.studio) 399 - { 400 - Die("Could not init studio"); 401 - } 414 + if( !platform.studio) 415 + { 416 + Die("Could not init studio"); 417 + } 402 418 403 - // gotoSurf(); 404 - platform.studio->tic->screen_format = TIC80_PIXEL_COLOR_BGRA8888; 405 - dbg("Studio init ok..\n"); 419 + // gotoSurf(); 420 + platform.studio->tic->screen_format = TIC80_PIXEL_COLOR_BGRA8888; 421 + dbg("Studio init ok..\n"); 406 422 407 - if (pKeyboard){ 408 - pKeyboard->RegisterKeyStatusHandlerRaw (KeyStatusHandlerRaw); 409 - } 423 + if (pKeyboard){ 424 + pKeyboard->RegisterKeyStatusHandlerRaw (KeyStatusHandlerRaw); 425 + } 410 426 411 - initGamepads(mDeviceNameService, gamePadStatusHandler); 427 + initGamepads(mDeviceNameService, gamePadStatusHandler); 412 428 413 - if (pMouse) { 414 - pMouse->RegisterEventHandler (mouseEventHandler); 415 - } 429 + if (pMouse) { 430 + pMouse->RegisterEventHandler (mouseEventHandler); 431 + } 416 432 417 - tic_mem* tic = platform.studio->tic; 418 - tic80_input* tic_input = &tic->ram.input; 419 - tic_input->keyboard.data = 0; 433 + tic_mem* tic = platform.studio->tic; 434 + tic80_input* tic_input = &tic->ram.input; 435 + tic_input->keyboard.data = 0; 420 436 421 437 422 - // sound system 423 - mSound->AllocateQueue(1000); 424 - mSound->SetWriteFormat(SoundFormatSigned16); 438 + // sound system 439 + mSound->AllocateQueue(1000); 440 + mSound->SetWriteFormat(SoundFormatSigned16); 425 441 426 - if (!mSound->Start()) 427 - { 428 - Die("Could not start sound."); 429 - } 442 + if (!mSound->Start()) 443 + { 444 + Die("Could not start sound."); 445 + } 430 446 431 - // MAIN LOOP 432 - while(true) 433 - { 434 - keyspinlock.Acquire(); 435 - inputToTic(); 436 - keyspinlock.Release(); 447 + // MAIN LOOP 448 + while(true) 449 + { 450 + keyspinlock.Acquire(); 451 + inputToTic(); 452 + keyspinlock.Release(); 437 453 438 - platform.studio->tick(); 439 - platform.studio->sound(); 454 + platform.studio->tick(); 455 + platform.studio->sound(); 440 456 441 - mSound->Write(tic->samples.buffer, tic->samples.size); 457 + mSound->Write(tic->samples.buffer, tic->samples.size); 442 458 443 - mScreen.vsync(); 459 + mScreen.vsync(); 444 460 445 - screenCopy(&mScreen, platform.studio->tic->screen); 461 + screenCopy(&mScreen, platform.studio->tic->screen); 446 462 447 - mScheduler.Yield(); // for sound 448 - } 463 + mScheduler.Yield(); // for sound 464 + } 449 465 450 - return ShutdownHalt; 466 + return ShutdownHalt; 451 467 }
+16
src/system/n3ds/main.c
··· 221 221 222 222 } 223 223 224 + void tic_sys_default_mapping(tic_mapping* mapping) 225 + { 226 + *mapping = (tic_mapping) 227 + { 228 + tic_key_up, 229 + tic_key_down, 230 + tic_key_left, 231 + tic_key_right, 232 + 233 + tic_key_z, // a 234 + tic_key_x, // b 235 + tic_key_a, // x 236 + tic_key_s, // y 237 + }; 238 + } 239 + 224 240 bool tic_sys_keyboard_text(char* text) 225 241 { 226 242 return false;
+35 -7
src/system/sdl/main.c
··· 995 995 } 996 996 #endif 997 997 998 - static void handleKeydown(SDL_Keycode keycode, bool down, bool* state) 998 + static const u32 KeyboardCodes[tic_keys_count] = 999 999 { 1000 - static const u32 KeyboardCodes[tic_keys_count] = 1001 - { 1002 - #include "keycodes.inl" 1003 - }; 1000 + #include "keycodes.inl" 1001 + }; 1004 1002 1003 + static void handleKeydown(SDL_Keycode keycode, bool down, bool* state) 1004 + { 1005 1005 for(tic_key i = 0; i < COUNT_OF(KeyboardCodes); i++) 1006 1006 { 1007 1007 if(KeyboardCodes[i] == keycode) ··· 1478 1478 #endif 1479 1479 } 1480 1480 1481 + void tic_sys_default_mapping(tic_mapping* mapping) 1482 + { 1483 + static const SDL_Scancode Scancodes[] = 1484 + { 1485 + SDL_SCANCODE_UP, 1486 + SDL_SCANCODE_DOWN, 1487 + SDL_SCANCODE_LEFT, 1488 + SDL_SCANCODE_RIGHT, 1489 + SDL_SCANCODE_Z, 1490 + SDL_SCANCODE_X, 1491 + SDL_SCANCODE_A, 1492 + SDL_SCANCODE_S, 1493 + }; 1494 + 1495 + for(s32 s = 0; s < COUNT_OF(Scancodes); ++s) 1496 + { 1497 + SDL_Keycode keycode = SDL_GetKeyFromScancode(Scancodes[s]); 1498 + 1499 + for(tic_key i = 0; i < COUNT_OF(KeyboardCodes); i++) 1500 + { 1501 + if(KeyboardCodes[i] == keycode) 1502 + { 1503 + mapping->data[s] = i; 1504 + break; 1505 + } 1506 + } 1507 + } 1508 + } 1509 + 1481 1510 static void gpuTick() 1482 1511 { 1483 1512 tic_mem* tic = platform.studio->tic; ··· 1576 1605 1577 1606 static s32 start(s32 argc, char **argv, const char* folder) 1578 1607 { 1608 + SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK); 1579 1609 platform.studio = studioInit(argc, argv, TIC80_SAMPLERATE, folder); 1580 1610 1581 1611 SCOPE(platform.studio->close()) ··· 1587 1617 } 1588 1618 else 1589 1619 { 1590 - SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK); 1591 - 1592 1620 initSound(); 1593 1621 1594 1622 {
+16
src/system/sokol/sokol.c
··· 126 126 127 127 } 128 128 129 + void tic_sys_default_mapping(tic_mapping* mapping) 130 + { 131 + *mapping = (tic_mapping) 132 + { 133 + tic_key_up, 134 + tic_key_down, 135 + tic_key_left, 136 + tic_key_right, 137 + 138 + tic_key_z, // a 139 + tic_key_x, // b 140 + tic_key_a, // x 141 + tic_key_s, // y 142 + }; 143 + } 144 + 129 145 bool tic_sys_keyboard_text(char* text) 130 146 { 131 147 *text = platform.keyboard.text;