#571 new kbd layout wip

This commit is contained in:
Vadim Grigoruk 2018-08-09 01:21:06 +03:00
parent 10bbae4822
commit 7dc0311298
6 changed files with 97 additions and 5 deletions

View File

@ -258,7 +258,7 @@ bin/menu.o: src/menu.c $(TIC80_H) $(TIC_H)
bin/surf.o: src/surf.c $(TIC80_H) $(TIC_H) bin/surf.o: src/surf.c $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@ $(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/system.o: src/system.c src/keycodes.inl src/kbdlayout.inl $(TIC80_H) $(TIC_H) bin/system.o: src/system.c src/keycodes.inl src/kbdlayout.inl src/kbdlabels.inl $(TIC80_H) $(TIC_H)
$(CC) $< $(OPT) $(INCLUDES) -c -o $@ $(CC) $< $(OPT) $(INCLUDES) -c -o $@
bin/chip.o: src/system/chip.c src/keycodes.c $(TIC80_H) $(TIC_H) bin/chip.o: src/system/chip.c src/keycodes.c $(TIC80_H) $(TIC_H)

File diff suppressed because one or more lines are too long

Binary file not shown.

72
src/kbdlabels.inl Normal file
View File

@ -0,0 +1,72 @@
{"ESC", 0*8+3, 0*8+3, true},
{"F1", 2*8+4, 0*8+3, true},
{"F2", 4*8+4, 0*8+3, true},
{"F3", 6*8+4, 0*8+3, true},
{"F4", 8*8+4, 0*8+3, true},
{"F5", 10*8+4, 0*8+3, true},
{"F6", 12*8+4, 0*8+3, true},
{"F7", 14*8+4, 0*8+3, true},
{"F8", 16*8+4, 0*8+3, true},
{"F9", 18*8+4, 0*8+3, true},
{"F10", 20*8+3, 0*8+3, true},
{"TAB", 0*8+3, 2*8+4, true},
{"`", 2*8+3, 2*8+3},
{"[", 4*8+3, 2*8+3},
{"]", 6*8+3, 2*8+3},
{";", 8*8+3, 2*8+3},
{"'", 10*8+3, 2*8+3},
{"-", 12*8+3, 2*8+3},
{"=", 14*8+3, 2*8+3},
{"/", 16*8+3, 2*8+3},
{"F11", 18*8+3, 2*8+3, true},
{"F12", 20*8+3, 2*8+3, true},
{"1", 0*8+3, 4*8+3},
{"2", 2*8+3, 4*8+3},
{"3", 4*8+3, 4*8+3},
{"4", 6*8+3, 4*8+3},
{"5", 8*8+3, 4*8+3},
{"6", 10*8+3, 4*8+3},
{"7", 12*8+3, 4*8+3},
{"8", 14*8+3, 4*8+3},
{"9", 16*8+3, 4*8+3},
{"0", 18*8+3, 4*8+3},
{"BAC", 20*8+3, 4*8+4, true},
{"Q", 0*8+3, 6*8+3},
{"W", 2*8+3, 6*8+3},
{"E", 4*8+3, 6*8+3},
{"R", 6*8+3, 6*8+3},
{"T", 8*8+3, 6*8+3},
{"Y", 10*8+3, 6*8+3},
{"U", 12*8+3, 6*8+3},
{"I", 14*8+3, 6*8+3},
{"O", 16*8+3, 6*8+3},
{"P", 18*8+3, 6*8+3},
{"\\", 20*8+3, 6*8+3},
{"A", 1*8+3, 8*8+3},
{"S", 3*8+3, 8*8+3},
{"D", 5*8+3, 8*8+3},
{"F", 7*8+3, 8*8+3},
{"G", 9*8+3, 8*8+3},
{"H", 11*8+3, 8*8+3},
{"J", 13*8+3, 8*8+3},
{"K", 15*8+3, 8*8+3},
{"L", 17*8+3, 8*8+3},
{"ENTER", 19*8+3, 8*8+4, true},
{"Z", 2*8+3, 10*8+3},
{"X", 4*8+3, 10*8+3},
{"C", 6*8+3, 10*8+3},
{"V", 8*8+3, 10*8+3},
{"B", 10*8+3, 10*8+3},
{"N", 12*8+3, 10*8+3},
{"M", 14*8+3, 10*8+3},
{",", 16*8+3, 10*8+3},
{".", 18*8+3, 10*8+3, true},
{"CTRL", 0*8+5, 12*8+4, true},
{"ALT", 3*8+6, 12*8+4, true},

View File

@ -168,6 +168,26 @@ static void updateGamepadParts()
platform.gamepad.part.y = (SDL_Point){rect.w - 2*tileSize, 0*tileSize + offset}; platform.gamepad.part.y = (SDL_Point){rect.w - 2*tileSize, 0*tileSize + offset};
} }
static void drawKeyboardLabels(s32 shift)
{
tic_mem* tic = platform.studio->tic;
enum{Color = tic_color_dark_gray};
typedef struct {const char* text; s32 x; s32 y; bool alt;} Label;
static const Label Labels[] =
{
#include "kbdlabels.inl"
};
for(s32 i = 0; i < COUNT_OF(Labels); i++)
{
const Label* label = Labels + i;
if(label->text)
tic->api.text(tic, label->text, label->x, label->y + shift, Color, label->alt);
}
}
static void initTouchKeyboard() static void initTouchKeyboard()
{ {
tic_mem* tic = platform.studio->tic; tic_mem* tic = platform.studio->tic;
@ -190,7 +210,7 @@ static void initTouchKeyboard()
tic->api.map(tic, &platform.studio->config()->cart->bank0.map, tic->api.map(tic, &platform.studio->config()->cart->bank0.map,
&platform.studio->config()->cart->bank0.tiles, 8, 0, Cols, Rows, 0, 0, -1, 1); &platform.studio->config()->cart->bank0.tiles, 8, 0, Cols, Rows, 0, 0, -1, 1);
// drawKeyboardLabels(0); drawKeyboardLabels(0);
tic->api.blit(tic, NULL, NULL, NULL); tic->api.blit(tic, NULL, NULL, NULL);
@ -210,7 +230,7 @@ static void initTouchKeyboard()
tic->api.map(tic, &platform.studio->config()->cart->bank0.map, tic->api.map(tic, &platform.studio->config()->cart->bank0.map,
&platform.studio->config()->cart->bank0.tiles, TIC_MAP_SCREEN_WIDTH+8, 0, Cols, Rows, 0, 0, -1, 1); &platform.studio->config()->cart->bank0.tiles, TIC_MAP_SCREEN_WIDTH+8, 0, Cols, Rows, 0, 0, -1, 1);
// drawKeyboardLabels(2); drawKeyboardLabels(2);
tic->api.blit(tic, NULL, NULL, NULL); tic->api.blit(tic, NULL, NULL, NULL);

View File

@ -662,7 +662,7 @@ static s32 api_fixed_text(tic_mem* memory, const char* text, s32 x, s32 y, u8 co
static s32 drawNonFixedChar(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width, s32 height, u8 color, s32 scale, bool alt) static s32 drawNonFixedChar(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width, s32 height, u8 color, s32 scale, bool alt)
{ {
const u8* ptr = memory->font.data + (symbol)*BITS_IN_BYTE + (alt ? TIC_FONT_CHARS / 2 : 0); const u8* ptr = memory->font.data + (symbol + (alt ? TIC_FONT_CHARS / 2 : 0))*BITS_IN_BYTE;
const s32 FontWidth = alt ? TIC_ALTFONT_WIDTH : TIC_FONT_WIDTH; const s32 FontWidth = alt ? TIC_ALTFONT_WIDTH : TIC_FONT_WIDTH;