#707 one more attempt
This commit is contained in:
		@@ -110,10 +110,17 @@ typedef struct
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
typedef u8 tic_key;
 | 
					typedef u8 tic_key;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef union
 | 
					typedef struct
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	tic_key keys[TIC80_KEY_BUFFER];
 | 
						union
 | 
				
			||||||
	u32 data;
 | 
						{
 | 
				
			||||||
 | 
							tic_key keys[TIC80_KEY_BUFFER];
 | 
				
			||||||
 | 
							u32 data;		
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						s8 text;
 | 
				
			||||||
 | 
						u8 temp[3];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} tic80_keyboard;
 | 
					} tic80_keyboard;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct
 | 
					typedef struct
 | 
				
			||||||
@@ -121,7 +128,6 @@ typedef struct
 | 
				
			|||||||
	tic80_gamepads gamepads;
 | 
						tic80_gamepads gamepads;
 | 
				
			||||||
	tic80_mouse mouse;
 | 
						tic80_mouse mouse;
 | 
				
			||||||
	tic80_keyboard keyboard;
 | 
						tic80_keyboard keyboard;
 | 
				
			||||||
 | 
					 | 
				
			||||||
} tic80_input;
 | 
					} tic80_input;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TIC80_API tic80* tic80_create(s32 samplerate);
 | 
					TIC80_API tic80* tic80_create(s32 samplerate);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										12
									
								
								src/code.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/code.c
									
									
									
									
									
								
							@@ -1046,7 +1046,7 @@ static void textEditTick(Code* code)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if(!tic->api.key(tic, tic_key_ctrl) && !tic->api.key(tic, tic_key_alt))
 | 
						if(!tic->api.key(tic, tic_key_ctrl) && !tic->api.key(tic, tic_key_alt))
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		char sym = getKeyboardText();
 | 
							char sym = tic->ram.input.keyboard.text;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(sym)
 | 
							if(sym)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -1113,6 +1113,8 @@ static char* downStrStr(const char* start, const char* from, const char* substr)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static void textFindTick(Code* code)
 | 
					static void textFindTick(Code* code)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						tic_mem* tic = code->tic;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(keyWasPressed(tic_key_return)) setCodeMode(code, TEXT_EDIT_MODE);
 | 
						if(keyWasPressed(tic_key_return)) setCodeMode(code, TEXT_EDIT_MODE);
 | 
				
			||||||
	else if(keyWasPressed(tic_key_up)
 | 
						else if(keyWasPressed(tic_key_up)
 | 
				
			||||||
		|| keyWasPressed(tic_key_down)
 | 
							|| keyWasPressed(tic_key_down)
 | 
				
			||||||
@@ -1137,7 +1139,7 @@ static void textFindTick(Code* code)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	char sym = getKeyboardText();
 | 
						char sym = tic->ram.input.keyboard.text;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(sym)
 | 
						if(sym)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@@ -1195,7 +1197,7 @@ static void textGoToTick(Code* code)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	char sym = getKeyboardText();
 | 
						char sym = tic->ram.input.keyboard.text;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(sym)
 | 
						if(sym)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
@@ -1265,6 +1267,8 @@ static void drawOutlineBar(Code* code, s32 x, s32 y)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static void textOutlineTick(Code* code)
 | 
					static void textOutlineTick(Code* code)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						tic_mem* tic = code->tic;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	if(keyWasPressed(tic_key_up))
 | 
						if(keyWasPressed(tic_key_up))
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		if(code->outline.index > 0)
 | 
							if(code->outline.index > 0)
 | 
				
			||||||
@@ -1295,7 +1299,7 @@ static void textOutlineTick(Code* code)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	char sym = getKeyboardText();
 | 
						char sym = tic->ram.input.keyboard.text;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(sym)
 | 
						if(sym)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2850,7 +2850,7 @@ static void tick(Console* console)
 | 
				
			|||||||
			console->cursor.delay = CONSOLE_CURSOR_DELAY;
 | 
								console->cursor.delay = CONSOLE_CURSOR_DELAY;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		char sym = getKeyboardText();
 | 
							char sym = tic->ram.input.keyboard.text;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(sym)
 | 
							if(sym)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -887,7 +887,7 @@ static void processTrackerKeyboard(Music* music)
 | 
				
			|||||||
			{
 | 
								{
 | 
				
			||||||
				s32 octave = -1;
 | 
									s32 octave = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				char sym = getKeyboardText();
 | 
									char sym = tic->ram.input.keyboard.text;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if(sym >= '1' && sym <= '8') octave = sym - '1';
 | 
									if(sym >= '1' && sym <= '8') octave = sym - '1';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -904,7 +904,7 @@ static void processTrackerKeyboard(Music* music)
 | 
				
			|||||||
			{
 | 
								{
 | 
				
			||||||
				s32 val = -1;
 | 
									s32 val = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				char sym = getKeyboardText();
 | 
									char sym = tic->ram.input.keyboard.text;
 | 
				
			||||||
							
 | 
												
 | 
				
			||||||
				if (sym >= '0' && sym <= '9') val = sym - '0';
 | 
									if (sym >= '0' && sym <= '9') val = sym - '0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -929,7 +929,7 @@ static void processTrackerKeyboard(Music* music)
 | 
				
			|||||||
			{
 | 
								{
 | 
				
			||||||
				s32 val = -1;
 | 
									s32 val = -1;
 | 
				
			||||||
							
 | 
												
 | 
				
			||||||
				char sym = getKeyboardText();
 | 
									char sym = tic->ram.input.keyboard.text;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if(sym >= '0' && sym <= '9') val = sym - '0';
 | 
									if(sym >= '0' && sym <= '9') val = sym - '0';
 | 
				
			||||||
				if(sym >= 'a' && sym <= 'f') val = sym - 'a' + 10;
 | 
									if(sym >= 'a' && sym <= 'f') val = sym - 'a' + 10;
 | 
				
			||||||
@@ -949,6 +949,7 @@ static void processTrackerKeyboard(Music* music)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static void processPatternKeyboard(Music* music)
 | 
					static void processPatternKeyboard(Music* music)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						tic_mem* tic = music->tic;
 | 
				
			||||||
	s32 channel = music->tracker.col / CHANNEL_COLS;
 | 
						s32 channel = music->tracker.col / CHANNEL_COLS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if(keyWasPressed(tic_key_delete)) 		setChannelPatternValue(music, 0, channel);
 | 
						if(keyWasPressed(tic_key_delete)) 		setChannelPatternValue(music, 0, channel);
 | 
				
			||||||
@@ -962,7 +963,7 @@ static void processPatternKeyboard(Music* music)
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		s32 val = -1;
 | 
							s32 val = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		char sym = getKeyboardText();
 | 
							char sym = tic->ram.input.keyboard.text;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(sym >= '0' && sym <= '9') val = sym - '0';
 | 
							if(sym >= '0' && sym <= '9') val = sym - '0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										30
									
								
								src/studio.c
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								src/studio.c
									
									
									
									
									
								
							@@ -234,36 +234,6 @@ static struct
 | 
				
			|||||||
	.argv = NULL,
 | 
						.argv = NULL,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
char getKeyboardText()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    tic_mem* tic = impl.studio.tic;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    static const char Symbols[] = 	" abcdefghijklmnopqrstuvwxyz0123456789-=[]\\;'`,./ ";
 | 
					 | 
				
			||||||
    static const char Shift[] =		" ABCDEFGHIJKLMNOPQRSTUVWXYZ)!@#$%^&*(_+{}|:\"~<>? ";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    enum{Count = sizeof Symbols};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    for(s32 i = 0; i < TIC80_KEY_BUFFER; i++)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        tic_key key = tic->ram.input.keyboard.keys[i];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if(key > 0 && key < Count && tic->api.keyp(tic, key, KEYBOARD_HOLD, KEYBOARD_PERIOD))
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            bool caps = tic->api.key(tic, tic_key_capslock);
 | 
					 | 
				
			||||||
            bool shift = tic->api.key(tic, tic_key_shift);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            return caps
 | 
					 | 
				
			||||||
                ? key >= tic_key_a && key <= tic_key_z 
 | 
					 | 
				
			||||||
                    ? shift ? Symbols[key] : Shift[key]
 | 
					 | 
				
			||||||
                    : shift ? Shift[key] : Symbols[key]
 | 
					 | 
				
			||||||
                : shift ? Shift[key] : Symbols[key];
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
bool keyWasPressed(tic_key key)
 | 
					bool keyWasPressed(tic_key key)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	tic_mem* tic = impl.studio.tic;
 | 
						tic_mem* tic = impl.studio.tic;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -157,7 +157,6 @@ tic_tiles* getBankTiles();
 | 
				
			|||||||
tic_palette* getBankPalette();
 | 
					tic_palette* getBankPalette();
 | 
				
			||||||
tic_map* getBankMap();
 | 
					tic_map* getBankMap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
char getKeyboardText();
 | 
					 | 
				
			||||||
bool keyWasPressed(tic_key key);
 | 
					bool keyWasPressed(tic_key key);
 | 
				
			||||||
bool anyKeyWasPressed();
 | 
					bool anyKeyWasPressed();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										130
									
								
								src/system.c
									
									
									
									
									
								
							
							
						
						
									
										130
									
								
								src/system.c
									
									
									
									
									
								
							@@ -65,7 +65,7 @@ static struct
 | 
				
			|||||||
			GPU_Image* down;
 | 
								GPU_Image* down;
 | 
				
			||||||
		} texture;
 | 
							} texture;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		char text;
 | 
							bool state[tic_keys_count];
 | 
				
			||||||
	} keyboard;
 | 
						} keyboard;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	u32 touchCounter;
 | 
						u32 touchCounter;
 | 
				
			||||||
@@ -397,96 +397,23 @@ static void processMouse()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static void processKeyboard()
 | 
					static void processKeyboard()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							SDL_Keymod mod = SDL_GetModState();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							platform.keyboard.state[tic_key_shift] = mod & KMOD_SHIFT;
 | 
				
			||||||
 | 
							platform.keyboard.state[tic_key_ctrl] = mod & KMOD_CTRL;
 | 
				
			||||||
 | 
							platform.keyboard.state[tic_key_alt] = mod & KMOD_ALT;
 | 
				
			||||||
 | 
							platform.keyboard.state[tic_key_capslock] = mod & KMOD_CAPS;
 | 
				
			||||||
 | 
						}	
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tic80_input* input = &platform.studio->tic->ram.input;
 | 
						tic80_input* input = &platform.studio->tic->ram.input;
 | 
				
			||||||
	input->keyboard.data = 0;
 | 
						input->keyboard.data = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	enum{BufSize = COUNT_OF(input->keyboard.keys)};
 | 
						enum{BufSize = COUNT_OF(input->keyboard.keys)};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SDL_Keymod mod = SDL_GetModState();
 | 
						for(s32 i = 0, c = 0; i < COUNT_OF(platform.keyboard.state) && c < BufSize; i++)
 | 
				
			||||||
 | 
							if(platform.keyboard.state[i])
 | 
				
			||||||
	// TODO: the ugliest hack ever
 | 
								input->keyboard.keys[c++] = i;
 | 
				
			||||||
	// will try to remove it
 | 
					 | 
				
			||||||
	if(mod & KMOD_RALT)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		static const struct {tic_keycode code; tic_keycode shift;} TextCodes[] =	
 | 
					 | 
				
			||||||
		{	
 | 
					 | 
				
			||||||
			['-'] = {tic_key_minus, tic_key_unknown},	
 | 
					 | 
				
			||||||
			['='] = {tic_key_equals, tic_key_unknown},	
 | 
					 | 
				
			||||||
			['['] = {tic_key_leftbracket, tic_key_unknown},	
 | 
					 | 
				
			||||||
			[']'] = {tic_key_rightbracket, tic_key_unknown},	
 | 
					 | 
				
			||||||
			['\\'] = {tic_key_backslash, tic_key_unknown},	
 | 
					 | 
				
			||||||
			[';'] = {tic_key_semicolon, tic_key_unknown},	
 | 
					 | 
				
			||||||
			['\''] = {tic_key_apostrophe, tic_key_unknown},	
 | 
					 | 
				
			||||||
			['`'] = {tic_key_grave, tic_key_unknown},	
 | 
					 | 
				
			||||||
			[','] = {tic_key_comma, tic_key_unknown},	
 | 
					 | 
				
			||||||
			['.'] = {tic_key_period, tic_key_unknown},	
 | 
					 | 
				
			||||||
			['/'] = {tic_key_slash, tic_key_unknown},	
 | 
					 | 
				
			||||||
			[')'] = {tic_key_0, tic_key_shift},	
 | 
					 | 
				
			||||||
			['!'] = {tic_key_1, tic_key_shift},	
 | 
					 | 
				
			||||||
			['@'] = {tic_key_2, tic_key_shift},	
 | 
					 | 
				
			||||||
			['#'] = {tic_key_3, tic_key_shift},	
 | 
					 | 
				
			||||||
			['$'] = {tic_key_4, tic_key_shift},	
 | 
					 | 
				
			||||||
			['%'] = {tic_key_5, tic_key_shift},	
 | 
					 | 
				
			||||||
			['^'] = {tic_key_6, tic_key_shift},	
 | 
					 | 
				
			||||||
			['&'] = {tic_key_7, tic_key_shift},	
 | 
					 | 
				
			||||||
			['*'] = {tic_key_8, tic_key_shift},	
 | 
					 | 
				
			||||||
			['('] = {tic_key_9, tic_key_shift},	
 | 
					 | 
				
			||||||
			['_'] = {tic_key_minus, tic_key_shift},	
 | 
					 | 
				
			||||||
			['+'] = {tic_key_equals, tic_key_shift},	
 | 
					 | 
				
			||||||
			['{'] = {tic_key_leftbracket, tic_key_shift},	
 | 
					 | 
				
			||||||
			['}'] = {tic_key_rightbracket, tic_key_shift},	
 | 
					 | 
				
			||||||
			['|'] = {tic_key_backslash, tic_key_shift},	
 | 
					 | 
				
			||||||
			[':'] = {tic_key_semicolon, tic_key_shift},	
 | 
					 | 
				
			||||||
			['"'] = {tic_key_apostrophe, tic_key_shift},	
 | 
					 | 
				
			||||||
			['~'] = {tic_key_grave, tic_key_shift},	
 | 
					 | 
				
			||||||
			['<'] = {tic_key_comma, tic_key_shift},	
 | 
					 | 
				
			||||||
			['>'] = {tic_key_period, tic_key_shift},	
 | 
					 | 
				
			||||||
			['?'] = {tic_key_slash, tic_key_shift},	
 | 
					 | 
				
			||||||
		};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		u8 text = platform.keyboard.text;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if(text && text < COUNT_OF(TextCodes))
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			input->keyboard.keys[0] = TextCodes[text].code;
 | 
					 | 
				
			||||||
			input->keyboard.keys[1] = TextCodes[text].shift;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		static const u32 KeyboardCodes[tic_keys_count] = 
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			#include "keycodes.inl"
 | 
					 | 
				
			||||||
		};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		s32 c = 0;
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			if(mod & KMOD_SHIFT) input->keyboard.keys[c++] = tic_key_shift;
 | 
					 | 
				
			||||||
			if(mod & KMOD_CTRL) input->keyboard.keys[c++] = tic_key_ctrl;
 | 
					 | 
				
			||||||
			if(mod & KMOD_CAPS) input->keyboard.keys[c++] = tic_key_capslock;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		const u8* keyboard = SDL_GetKeyboardState(NULL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		for(s32 i = 0; i < SDL_NUM_SCANCODES && c < BufSize; i++)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			if(keyboard[i])
 | 
					 | 
				
			||||||
			{			
 | 
					 | 
				
			||||||
				SDL_Keycode keycode = i == SDL_SCANCODE_AC_BACK 
 | 
					 | 
				
			||||||
					? SDLK_ESCAPE
 | 
					 | 
				
			||||||
					: SDL_GetKeyFromScancode(i);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				for(s32 k = 0; k < COUNT_OF(KeyboardCodes); k++)
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
					if(KeyboardCodes[k] == keycode)
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
						input->keyboard.keys[c++] = k;
 | 
					 | 
				
			||||||
						break;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}		
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if !defined(__EMSCRIPTEN__) && !defined(__MACOSX__)
 | 
					#if !defined(__EMSCRIPTEN__) && !defined(__MACOSX__)
 | 
				
			||||||
@@ -791,15 +718,30 @@ static void processTouchInput()
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void handleKeydown(SDL_Keycode keycode, bool down)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						static const u32 KeyboardCodes[tic_keys_count] = 
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							#include "keycodes.inl"
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for(tic_key i = 0; i < COUNT_OF(KeyboardCodes); i++)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if(KeyboardCodes[i] == keycode)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								platform.keyboard.state[i] = down;
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void pollEvent()
 | 
					static void pollEvent()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	tic_mem* tic = platform.studio->tic;
 | 
						tic_mem* tic = platform.studio->tic;
 | 
				
			||||||
	tic80_input* input = &tic->ram.input;
 | 
						tic80_input* input = &tic->ram.input;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{
 | 
						input->mouse.btns = 0;
 | 
				
			||||||
		input->mouse.btns = 0;
 | 
						tic->ram.input.keyboard.text = 0;
 | 
				
			||||||
		platform.keyboard.text = 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SDL_Event event;
 | 
						SDL_Event event;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -853,12 +795,18 @@ static void pollEvent()
 | 
				
			|||||||
			case SDL_WINDOWEVENT_FOCUS_GAINED: platform.studio->updateProject(); break;
 | 
								case SDL_WINDOWEVENT_FOCUS_GAINED: platform.studio->updateProject(); break;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
 | 
							case SDL_KEYDOWN:
 | 
				
			||||||
 | 
								handleKeydown(event.key.keysym.sym, true);
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
							case SDL_KEYUP:
 | 
				
			||||||
 | 
								handleKeydown(event.key.keysym.sym, false);
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
		case SDL_TEXTINPUT:
 | 
							case SDL_TEXTINPUT:
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				const char* text = event.text.text;
 | 
									const char* text = event.text.text;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if(strlen(text) == 1)
 | 
									if(strlen(text) == 1)
 | 
				
			||||||
					platform.keyboard.text = *text;
 | 
										tic->ram.input.keyboard.text = *text;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		case SDL_QUIT:
 | 
							case SDL_QUIT:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -81,7 +81,7 @@ STATIC_ASSERT(tic_track, sizeof(tic_track) == 3*MUSIC_FRAMES+3);
 | 
				
			|||||||
STATIC_ASSERT(tic_vram, sizeof(tic_vram) == TIC_VRAM_SIZE);
 | 
					STATIC_ASSERT(tic_vram, sizeof(tic_vram) == TIC_VRAM_SIZE);
 | 
				
			||||||
STATIC_ASSERT(tic_ram, sizeof(tic_ram) == TIC_RAM_SIZE);
 | 
					STATIC_ASSERT(tic_ram, sizeof(tic_ram) == TIC_RAM_SIZE);
 | 
				
			||||||
STATIC_ASSERT(tic_sound_register, sizeof(tic_sound_register) == 16+2);
 | 
					STATIC_ASSERT(tic_sound_register, sizeof(tic_sound_register) == 16+2);
 | 
				
			||||||
STATIC_ASSERT(tic80_input, sizeof(tic80_input) == 12);
 | 
					STATIC_ASSERT(tic80_input, sizeof(tic80_input) == 16);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void update_amp(blip_buffer_t* blip, tic_sound_register_data* data, s32 new_amp )
 | 
					static void update_amp(blip_buffer_t* blip, tic_sound_register_data* data, s32 new_amp )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -419,7 +419,7 @@ typedef union
 | 
				
			|||||||
		tic_tiles sprites;
 | 
							tic_tiles sprites;
 | 
				
			||||||
		tic_map map;
 | 
							tic_map map;
 | 
				
			||||||
		tic80_input input;
 | 
							tic80_input input;
 | 
				
			||||||
		u8 unknown[16];
 | 
							u8 unknown[12];
 | 
				
			||||||
		tic_sound_register registers[TIC_SOUND_CHANNELS];
 | 
							tic_sound_register registers[TIC_SOUND_CHANNELS];
 | 
				
			||||||
		tic_sfx sfx;
 | 
							tic_sfx sfx;
 | 
				
			||||||
		tic_music music;
 | 
							tic_music music;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user