Simple utility to turn swipes into words -- "plugin" for wvkbd to enable swipe-typing under wayland SXMO.
Diffstat (limited to 'mapScore.c')
| -rw-r--r-- | mapScore.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -4,7 +4,7 @@ #define BUFSIZE 1024 char buffer[BUFSIZE]; // TODO: Support UTF-8. -int map[256][2]; +int map[256][3]; void makeMap(FILE *f) { int x = 0; int y = 0; @@ -16,6 +16,7 @@ void makeMap(FILE *f) { default: map[c][0] = x; map[c][1] = y; + map[c][2] = 1; break; } } @@ -24,9 +25,13 @@ void makeMap(FILE *f) { int scoreWord(char *word, int (*fun)(int*,int*)) { char *c = word; int score = 0; + char *p = c; for (c++;*c;c++) { if (*c == '\n') break; - score += (*fun)(map[c[-1]],map[c[0]]); + // pass over ignore unset chars. + if(map[(unsigned)*c][3] == 0) continue; + score += (*fun)(map[(unsigned)*p],map[(unsigned)*c]); + p=c; } return score; } |