indent onscreen_keyboard.c onscreen_keyboard.h

This commit is contained in:
Bill Kendrick 2017-10-15 10:59:50 -07:00
parent e283cdb473
commit e9447f8c3b
2 changed files with 1095 additions and 1094 deletions

File diff suppressed because it is too large Load diff

View file

@ -27,40 +27,40 @@ KMOD_ALT An Alt key is down
typedef struct osk_keymap typedef struct osk_keymap
{ {
int keycode; int keycode;
int disable_caps; /* If caps lock should affect this key */ int disable_caps; /* If caps lock should affect this key */
char * plain; /* The default Xkeysym for the keycode */ char *plain; /* The default Xkeysym for the keycode */
char * caps; /* If CapsLock or Shift + key */ char *caps; /* If CapsLock or Shift + key */
char * altgr; /* If AltGr + key */ char *altgr; /* If AltGr + key */
char * shiftaltgr; /* If AltGr + Shift + key */ char *shiftaltgr; /* If AltGr + Shift + key */
} osk_keymap; } osk_keymap;
typedef struct osk_key typedef struct osk_key
{ {
int keycode; /* The code associated to this key. If 0, then it is an empty key. */ int keycode; /* The code associated to this key. If 0, then it is an empty key. */
int row; int row;
int x; int x;
int y; int y;
float width; /* The width in buttons */ float width; /* The width in buttons */
char *plain_label; /* The text that will show the key */ char *plain_label; /* The text that will show the key */
char *top_label; /* The text that will show the key above the plain label. */ char *top_label; /* The text that will show the key above the plain label. */
char *altgr_label; /* The text that will show the key at the right of the plain label */ char *altgr_label; /* The text that will show the key at the right of the plain label */
char *shift_altgr_label; /* The text that will show the key when shift and altgr are activated */ char *shift_altgr_label; /* The text that will show the key when shift and altgr are activated */
int shiftcaps; /* If the value of the key should be shifted when capslock is active */ int shiftcaps; /* If the value of the key should be shifted when capslock is active */
int stick; /* If the key currently affects the others */ int stick; /* If the key currently affects the others */
} osk_key; } osk_key;
typedef struct osk_composenode typedef struct osk_composenode
{ {
wchar_t * keysym; wchar_t *keysym;
wchar_t * result; wchar_t *result;
int size; /* How many childs are there. */ int size; /* How many childs are there. */
struct osk_composenode ** childs; struct osk_composenode **childs;
// struct osk_composenode **parent; // struct osk_composenode **parent;
} osk_composenode; } osk_composenode;
typedef struct keysymdefs typedef struct keysymdefs
{ {
char * mnemo; char *mnemo;
int keysym; int keysym;
int unicode; int unicode;
} keysymdefs; } keysymdefs;
@ -71,11 +71,11 @@ typedef struct osk_layout
int *rows; int *rows;
int width; int width;
int height; int height;
char * fontpath; char *fontpath;
osk_key **keys; osk_key **keys;
osk_keymap *keymap; osk_keymap *keymap;
osk_composenode * composemap; osk_composenode *composemap;
keysymdefs * keysymdefs; keysymdefs *keysymdefs;
unsigned int sizeofkeysymdefs; unsigned int sizeofkeysymdefs;
SDL_Color bgcolor; SDL_Color bgcolor;
SDL_Color fgcolor; SDL_Color fgcolor;
@ -91,56 +91,61 @@ typedef struct osk_keymodifiers
typedef struct osk_kmdf typedef struct osk_kmdf
{ {
osk_key * shift; osk_key *shift;
osk_key * altgr; osk_key *altgr;
osk_key * compose; osk_key *compose;
osk_key * dead; osk_key *dead;
osk_key * dead2; osk_key *dead2;
osk_key * dead3; osk_key *dead3;
osk_key * dead4; osk_key *dead4;
} osk_kmdf; } osk_kmdf;
typedef struct osk_keyboard typedef struct osk_keyboard
{ {
char * name; /* The name of the keyboard */ char *name; /* The name of the keyboard */
char * keyboard_list; /* The names of the keyboards allowed from this one */ char *keyboard_list; /* The names of the keyboards allowed from this one */
SDL_Surface *surface; /* The surface containing the keyboard */ SDL_Surface *surface; /* The surface containing the keyboard */
SDL_Surface *button_up; /* The surfaces containing the buttons */ SDL_Surface *button_up; /* The surfaces containing the buttons */
SDL_Surface *button_down; SDL_Surface *button_down;
SDL_Surface *button_off; SDL_Surface *button_off;
SDL_Surface *button_nav; SDL_Surface *button_nav;
SDL_Surface *button_hold; SDL_Surface *button_hold;
SDL_Surface *oskdel; /* The surfaces containing some symbols for the buttons, delete arrow */ SDL_Surface *oskdel; /* The surfaces containing some symbols for the buttons, delete arrow */
SDL_Surface *osktab; /* Tab arrows */ SDL_Surface *osktab; /* Tab arrows */
SDL_Surface *oskenter; /* Return hook/arrow */ SDL_Surface *oskenter; /* Return hook/arrow */
SDL_Surface *oskcapslock; /* CapsLock */ SDL_Surface *oskcapslock; /* CapsLock */
SDL_Surface *oskshift; /* Shift */ SDL_Surface *oskshift; /* Shift */
int changed; /* If the surface has been modified (painted) */ int changed; /* If the surface has been modified (painted) */
SDL_Rect rect; /* The rectangle that has changed */ SDL_Rect rect; /* The rectangle that has changed */
int recreated; /* If the surface has been deleted and newly created */ int recreated; /* If the surface has been deleted and newly created */
int modifiers; /* The state of Alt, CTRL, Shift, CapsLock, AltGr keys */ int modifiers; /* The state of Alt, CTRL, Shift, CapsLock, AltGr keys */
osk_keymodifiers keymodifiers; /* A shortcurt to find the place of the pressed modifiers */ osk_keymodifiers keymodifiers; /* A shortcurt to find the place of the pressed modifiers */
osk_kmdf kmdf; osk_kmdf kmdf;
osk_layout *layout; /* The layout struct */ osk_layout *layout; /* The layout struct */
char *layout_name[256]; /* The layout name */ char *layout_name[256]; /* The layout name */
TTF_Font * osk_fonty; /* Font */ TTF_Font *osk_fonty; /* Font */
int disable_change; /* If true, stay with the first layout found */ int disable_change; /* If true, stay with the first layout found */
wchar_t * key[256]; /* The text of the key */ wchar_t *key[256]; /* The text of the key */
int keycode; /* The unicode code corresponding to the key */ int keycode; /* The unicode code corresponding to the key */
wchar_t * composed; /* The unicode char found after a sequence of key presses */ wchar_t *composed; /* The unicode char found after a sequence of key presses */
int composed_type; /* 1 if the value stored in composed is yet the unicode value */ int composed_type; /* 1 if the value stored in composed is yet the unicode value */
osk_composenode * composing; /* The node in the middle of a compose sequence */ osk_composenode *composing; /* The node in the middle of a compose sequence */
osk_key * last_key_pressed; /* The last key pressed */ osk_key *last_key_pressed; /* The last key pressed */
} on_screen_keyboard; } on_screen_keyboard;
struct osk_keyboard *osk_create(char *layout_name, SDL_Surface *canvas, SDL_Surface *button_up, SDL_Surface *button_down, SDL_Surface *button_off, SDL_Surface *button_nav, SDL_Surface *button_hold, SDL_Surface *oskdel, SDL_Surface *osktab, SDL_Surface *oskenter, SDL_Surface *oskcapslock, SDL_Surface *oskshift, int disable_change); struct osk_keyboard *osk_create(char *layout_name, SDL_Surface * canvas, SDL_Surface * button_up,
SDL_Surface * button_down, SDL_Surface * button_off, SDL_Surface * button_nav,
SDL_Surface * button_hold, SDL_Surface * oskdel, SDL_Surface * osktab,
SDL_Surface * oskenter, SDL_Surface * oskcapslock, SDL_Surface * oskshift,
int disable_change);
struct osk_layout *osk_load_layout(char *layout_name); struct osk_layout *osk_load_layout(char *layout_name);
void osk_get_layout_data(char *layout_name, int *layout_w, int *layout_h, char * layout_buttons, char *layout_labels, char *layout_keycodes); void osk_get_layout_data(char *layout_name, int *layout_w, int *layout_h, char *layout_buttons, char *layout_labels,
void osk_reset(on_screen_keyboard *osk); char *layout_keycodes);
struct osk_keyboard * osk_clicked(on_screen_keyboard *keyboard, int x, int y); void osk_reset(on_screen_keyboard * osk);
void osk_released(on_screen_keyboard *osk); struct osk_keyboard *osk_clicked(on_screen_keyboard * keyboard, int x, int y);
void osk_hover(on_screen_keyboard *keyboard, int x, int y); void osk_released(on_screen_keyboard * osk);
void osk_free(on_screen_keyboard *osk); void osk_hover(on_screen_keyboard * keyboard, int x, int y);
void osk_change_layout(on_screen_keyboard *osk); void osk_free(on_screen_keyboard * osk);
void osk_change_layout(on_screen_keyboard * osk);