-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathkeyboard.h
83 lines (66 loc) · 2.51 KB
/
keyboard.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* keyboard.h
* Typing
*
* Created by Michael Dickens on 8/7/09.
*
* Includes the keyboard struct and the fitness function.
*/
#ifndef __KEYBOARD_H__
#define __KEYBOARD_H__
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include "tools.h"
/* Takes a Keyboard pointer k and an integer index.
*
* WARNING: Both k and index are evaluated multiple times.
*/
#define charAt(k, index) ((index) < ksize ? (k)->layout[index] : (k)->shiftedLayout[index - ksize])
#define setCharAt(k, index, c) ((index) < ksize ? ((k)->layout[index] = (c)) : ((k)->shiftedLayout[index - ksize] = (c)))
void buildShuffledIndices(int indices[], int length);
int initKeyboard(Keyboard *k);
int setLayout(Keyboard *k, char *layout);
int layoutFromFile(FILE *file, Keyboard *k);
void copyKeyboard(Keyboard *k, Keyboard *original);
int swap(Keyboard *k, int loc1, int loc2);
int swapPair(Keyboard *k, int loc1, int loc2);
int printLayoutOnly(Keyboard *k);
int printLayoutRaw(char layout[]);
int printPercentages(Keyboard *k);
int charToPrintable(char *buffer, char c, int changeSpace);
int qwertyPositions(Keyboard *k);
int readLayouts(Keyboard pool[], int length);
int isSwappable(char c);
int isLegalSwap(Keyboard *k, int i, int j);
void shuffleLayout(Keyboard *kbd);
/* Returns the index of c on either the shifted or unshifted layout. */
int locIgnoreShifted(Keyboard *k, char c);
/* Returns the index of c if c is on the unshifted layout, or index + ksize
* if c is on the shifted layout.
*/
int locWithShifted(Keyboard *k, char c);
/* To use, set USE_COST_ARRAY to TRUE. */
int allDigraphCosts[KSIZE_MAX][KSIZE_MAX];
int calcFitnessDirect(Keyboard *k);
int scoreDigraphDirect(Keyboard *k, char digraph[], int64_t multiplier);
int calcFitness(Keyboard *k);
int scoreDigraph(Keyboard *k, char digraph[], int64_t multiplier, int allLocs[]);
char shortcutKeys[4];
char seedLayout[KSIZE_MAX]; // Holds every letter and is randomly shuffled. Used to seed the keyboards.
unsigned int seedVal;
int64_t calcShortcuts(Keyboard *k);
int64_t calcQWERTY(Keyboard *k);
int64_t calcBrackets(Keyboard *k);
int64_t calcBracketsGeneric(Keyboard *k, char openChar, char closeChar);
int64_t calcNumbersShifted(Keyboard *k);
int calcFingerWork(Keyboard *k);
int calcInRoll(int loc0, int loc1);
int calcOutRoll(int loc0, int loc1);
int calcSameFinger(int loc0, int loc1);
int calcRowChange(int loc0, int loc1);
int calcHomeJump(int loc0, int loc1);
int calcRingJump(int loc0, int loc1);
int calcToCenter(int loc0, int loc1);
int calcToOutside(int loc0, int loc1);
#endif