fixed menu keyboard
This commit is contained in:
parent
1110fa7991
commit
665a5640a5
106
src/menu.c
106
src/menu.c
|
@ -179,47 +179,47 @@ static void drawTab(Menu* menu, s32 x, s32 y, s32 id)
|
||||||
|
|
||||||
static void drawPlayerButtons(Menu* menu, s32 x, s32 y)
|
static void drawPlayerButtons(Menu* menu, s32 x, s32 y)
|
||||||
{
|
{
|
||||||
// tic_mem* tic = menu->tic;
|
tic_mem* tic = menu->tic;
|
||||||
|
|
||||||
// u8 chromakey = 0;
|
u8 chromakey = 0;
|
||||||
|
|
||||||
// SDL_Scancode* codes = getKeymap();
|
tic_key* codes = getKeymap();
|
||||||
|
|
||||||
// enum {Width = 41, Height = TIC_SPRITESIZE, Rows = 4, Cols = 2, MaxChars = 5, Buttons = 8};
|
enum {Width = 41, Height = TIC_SPRITESIZE, Rows = 4, Cols = 2, MaxChars = 5, Buttons = 8};
|
||||||
|
|
||||||
// for(s32 i = 0; i < Buttons; i++)
|
for(s32 i = 0; i < Buttons; i++)
|
||||||
// {
|
{
|
||||||
// tic_rect rect = {x + i / Rows * (Width+2), y + (i%Rows)*(Height+1), Width, TIC_SPRITESIZE};
|
tic_rect rect = {x + i / Rows * (Width+2), y + (i%Rows)*(Height+1), Width, TIC_SPRITESIZE};
|
||||||
// bool over = false;
|
bool over = false;
|
||||||
|
|
||||||
// s32 index = i+menu->gamepad.tab * Buttons;
|
s32 index = i+menu->gamepad.tab * Buttons;
|
||||||
|
|
||||||
// if(checkMousePos(&rect))
|
if(checkMousePos(&rect))
|
||||||
// {
|
{
|
||||||
// setCursor(tic_cursor_hand);
|
setCursor(tic_cursor_hand);
|
||||||
|
|
||||||
// over = true;
|
over = true;
|
||||||
|
|
||||||
// if(checkMouseClick(&rect, tic_mouse_left))
|
if(checkMouseClick(&rect, tic_mouse_left))
|
||||||
// {
|
{
|
||||||
// menu->gamepad.selected = menu->gamepad.selected != index ? index : -1;
|
menu->gamepad.selected = menu->gamepad.selected != index ? index : -1;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if(menu->gamepad.selected == index && menu->ticks % TIC_FRAMERATE < TIC_FRAMERATE / 2)
|
if(menu->gamepad.selected == index && menu->ticks % TIC_FRAMERATE < TIC_FRAMERATE / 2)
|
||||||
// continue;
|
continue;
|
||||||
|
|
||||||
// tic->api.sprite_ex(tic, &tic->config.bank0.tiles, 8+i, rect.x, rect.y, 1, 1, &chromakey, 1, 1, tic_no_flip, tic_no_rotate);
|
tic->api.sprite_ex(tic, &tic->config.bank0.tiles, 8+i, rect.x, rect.y, 1, 1, &chromakey, 1, 1, tic_no_flip, tic_no_rotate);
|
||||||
|
|
||||||
// s32 code = codes[index];
|
s32 code = codes[index];
|
||||||
// char label[32];
|
char label[32] = "fix names...";
|
||||||
// strcpy(label, code ? SDL_GetKeyName(SDL_GetKeyFromScancode(code)) : "...");
|
// strcpy(label, code ? SDL_GetKeyName(SDL_GetKeyFromScancode(code)) : "...");
|
||||||
|
|
||||||
// if(strlen(label) > MaxChars)
|
if(strlen(label) > MaxChars)
|
||||||
// label[MaxChars] = '\0';
|
label[MaxChars] = '\0';
|
||||||
|
|
||||||
// tic->api.text(tic, label, rect.x+10, rect.y+2, (over ? tic_color_gray : tic_color_black));
|
tic->api.text(tic, label, rect.x+10, rect.y+2, (over ? tic_color_gray : tic_color_black));
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawGamepadSetupTabs(Menu* menu, s32 x, s32 y)
|
static void drawGamepadSetupTabs(Menu* menu, s32 x, s32 y)
|
||||||
|
@ -432,42 +432,38 @@ static void saveMapping(Menu* menu)
|
||||||
fsSaveRootFile(menu->fs, KEYMAP_DAT_PATH, getKeymap(), KEYMAP_SIZE, true);
|
fsSaveRootFile(menu->fs, KEYMAP_DAT_PATH, getKeymap(), KEYMAP_SIZE, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static void processKeydown(Menu* menu, SDL_Keysym* keysum)
|
static void processKeyboard(Menu* menu)
|
||||||
// {
|
{
|
||||||
// if(menu->gamepad.selected < 0)
|
tic_mem* tic = menu->tic;
|
||||||
// return;
|
|
||||||
|
|
||||||
// SDL_Scancode scancode = keysum->scancode;
|
if(menu->gamepad.selected < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
// switch(scancode)
|
if(isKeyBeenPressed(tic_key_escape));
|
||||||
// {
|
else if(isAnyKeyBeenPressed())
|
||||||
// case SDL_SCANCODE_ESCAPE: break;
|
{
|
||||||
// default:
|
for(s32 i = 0; i < TIC80_KEY_BUFFER; i++)
|
||||||
// {
|
{
|
||||||
// SDL_Scancode* codes = getKeymap();
|
tic_key key = tic->ram.input.keyboard.keys[i];
|
||||||
// codes[menu->gamepad.selected] = scancode;
|
|
||||||
|
|
||||||
// saveMapping(menu);
|
if(tic->api.keyp(tic, key, -1, -1))
|
||||||
// }
|
{
|
||||||
// }
|
tic_key* codes = getKeymap();
|
||||||
|
codes[menu->gamepad.selected] = key;
|
||||||
|
saveMapping(menu);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// menu->gamepad.selected = -1;
|
menu->gamepad.selected = -1;
|
||||||
// }
|
}
|
||||||
|
|
||||||
static void tick(Menu* menu)
|
static void tick(Menu* menu)
|
||||||
{
|
{
|
||||||
menu->ticks++;
|
menu->ticks++;
|
||||||
|
|
||||||
// SDL_Event* event = NULL;
|
processKeyboard(menu);
|
||||||
// while ((event = pollEvent()))
|
|
||||||
// {
|
|
||||||
// switch(event->type)
|
|
||||||
// {
|
|
||||||
// case SDL_KEYUP:
|
|
||||||
// processKeydown(menu, &event->key.keysym);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
if(getStudioMode() != TIC_MENU_MODE)
|
if(getStudioMode() != TIC_MENU_MODE)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue