Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
Fixed a bug that caused toggling CAPS to lock the keyboard
Updated terminal type to match `xterm` so that more programs can run
Swapped B button to A, just for ergonomic's sake
  • Loading branch information
SantX27 committed Aug 7, 2019
1 parent fab365e commit e97cc04
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# st - simple terminal
# See LICENSE file for copyright and license details.

include config_rs97.mk
include config_miyoo.mk

SRC = st.c keyboard.c font.c msg_queue.c
OBJ = ${SRC:.c=.o}

all: options st libst-preload.so sdl_test
all: options st

libst-preload.so: st-preload.o msg_queue.o
${CC} -shared -o $@ $^
Expand Down
2 changes: 1 addition & 1 deletion config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static unsigned int doubleclicktimeout = 300;
static unsigned int tripleclicktimeout = 600;

/* TERM value */
static char termname[] = "st-256color";
static char termname[] = "xterm";

static unsigned int tabspaces = 4;
#define WORD_BREAK " "
Expand Down
4 changes: 2 additions & 2 deletions config_miyoo.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ LIBS = -lc -lutil

# flags
CPPFLAGS = -DVERSION=\"${VERSION}\"
CFLAGS += -g -Wall ${INCS} ${CPPFLAGS} -DRS97 -fPIC
CFLAGS += -g -Wall ${INCS} ${CPPFLAGS} -DMIYOO -fPIC
INCLUDES = -Iinclude $(SDL_CFLAGS)
LDFLAGS = -Wl,--start-group -lSDL -lSDL_image -lpng -ljpeg -lasound -lSDL_mixer -lfreetype -lSDL_ttf -logg -lvorbisidec -lmikmod -lmodplug -lm -pthread -lz -lstdc++ $(EXTRA_LDFLAGS) -Wl,--end-group
LDFLAGS = -g -lSDL -lasound

# compiler and linker
CC = $(CROSS_COMPILE)gcc
Expand Down
30 changes: 23 additions & 7 deletions keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@
#define NUM_ROWS 6
#define NUM_KEYS 18

#ifdef MIYOO

#define KEY_UP SDLK_UP
#define KEY_DOWN SDLK_DOWN
#define KEY_LEFT SDLK_LEFT
#define KEY_RIGHT SDLK_RIGHT
#define KEY_ENTER SDLK_LALT // A
#define KEY_TOGGLE SDLK_LCTRL // B
#define KEY_BACKSPACE SDLK_BACKSPACE // R
#define KEY_SHIFT SDLK_TAB // L
#define KEY_LOCATION SDLK_LSHIFT // Y
#define KEY_ACTIVATE SDLK_SPACE // X
#define KEY_QUIT SDLK_ESCAPE // SELECT
#define KEY_HELP SDLK_RETURN // START

#else

//#ifdef RS97

#define KEY_UP SDLK_UP
Expand All @@ -20,7 +37,6 @@
#define KEY_HELP SDLK_RETURN // START

/*#else
#define KEY_UP SDLK_UP
#define KEY_DOWN SDLK_DOWN
#define KEY_LEFT SDLK_LEFT
Expand All @@ -31,8 +47,8 @@
#define KEY_SHIFT SDLK_s
#define KEY_LOCATION SDLK_l
#define KEY_ACTIVATE SDLK_BACKQUOTE
#endif*/
*/
#endif

#define KMOD_SYNTHETIC (1 << 13)

Expand Down Expand Up @@ -96,8 +112,8 @@ void init_keyboard() {
char* help =
"How to use:\n"
" ARROWS: select key from keyboard\n"
" B: press key\n"
" A: toggle key (useful for shift/ctrl...)\n"
" A: press key\n"
" B: toggle key (useful for shift/ctrl...)\n"
" L: shift\n"
" R: backspace\n"
" X: change keyboard location (top/bottom)\n"
Expand Down Expand Up @@ -181,7 +197,7 @@ void update_modstate(int key, int state) {
else if(key == SDLK_LMETA) mod_state |= KMOD_LMETA;
else if(key == SDLK_RMETA) mod_state |= KMOD_RMETA;
//else if(key == SDLK_NUM) mod_state |= KMOD_NUM;
else if(key == SDLK_CAPSLOCK) mod_state |= KMOD_CAPS;
//else if(key == SDLK_CAPSLOCK) mod_state |= KMOD_CAPS;
else if(key == SDLK_MODE) mod_state |= KMOD_MODE;
} else if(state == STATE_UP) {
if(key == SDLK_LSHIFT) mod_state &= ~KMOD_LSHIFT;
Expand All @@ -193,7 +209,7 @@ void update_modstate(int key, int state) {
else if(key == SDLK_LMETA) mod_state &= ~KMOD_LMETA;
else if(key == SDLK_RMETA) mod_state &= ~KMOD_RMETA;
//else if(key == SDLK_NUM) mod_state &= ~KMOD_NUM;
else if(key == SDLK_CAPSLOCK) mod_state &= ~KMOD_CAPS;
//else if(key == SDLK_CAPSLOCK) mod_state &= ~KMOD_CAPS;
else if(key == SDLK_MODE) mod_state &= ~KMOD_MODE;
}
SDL_SetModState(mod_state);
Expand Down

0 comments on commit e97cc04

Please sign in to comment.