Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorperepujal <perepujal>2011-09-04 22:35:24 (GMT)
committer perepujal <perepujal>2011-09-04 22:35:24 (GMT)
commite476a6db89dfb5640d462d00410f03d3d7d20ce2 (patch)
treee59ed0f36e3d9b30ecfefadec93587d609f2c757
parent7e6d3d65fc653ad73cf86b76a84bc4d9e5923859 (diff)
Adding an option to select the initial onscreen keyboard layout, adding an option to disable changes between layouts
-rw-r--r--src/onscreen_keyboard.c15
-rw-r--r--src/onscreen_keyboard.h3
-rw-r--r--src/parse.gperf2
-rw-r--r--src/parse.h2
-rw-r--r--src/tuxpaint.c30
5 files changed, 43 insertions, 9 deletions
diff --git a/src/onscreen_keyboard.c b/src/onscreen_keyboard.c
index 8f23d24..224217b 100644
--- a/src/onscreen_keyboard.c
+++ b/src/onscreen_keyboard.c
@@ -31,7 +31,7 @@ static struct osk_layout *load_layout(on_screen_keyboard *keyboard, char *layout
static void print_composemap(osk_composenode *composemap, char * sp);
#endif
-struct osk_keyboard *osk_create(char *layout_name, SDL_Surface *canvas, SDL_Surface *button_up, SDL_Surface *button_down, SDL_Surface *button_off)
+struct osk_keyboard *osk_create(char *layout_name, SDL_Surface *canvas, SDL_Surface *button_up, SDL_Surface *button_down, SDL_Surface *button_off, int disable_change)
{
SDL_Surface *surface;
osk_layout *layout;
@@ -39,7 +39,7 @@ struct osk_keyboard *osk_create(char *layout_name, SDL_Surface *canvas, SDL_Surf
keyboard = malloc(sizeof(on_screen_keyboard));
-
+ keyboard->disable_change = disable_change;
layout = load_layout(keyboard, layout_name);
if (!layout)
{
@@ -67,7 +67,7 @@ struct osk_keyboard *osk_create(char *layout_name, SDL_Surface *canvas, SDL_Surf
printf("Error creating the onscreen keyboard surface\n");
return NULL;
}
- keyboard->name = layout_name;
+ // keyboard->name = layout_name;
keyboard->layout = layout;
keyboard->surface = surface;
keyboard->rect.x = 0;
@@ -110,6 +110,8 @@ static struct osk_layout *load_layout(on_screen_keyboard *keyboard, char *layout
filename = malloc(255);
if (layout_name != NULL)
{
+ keyboard->name = layout_name;
+
/* Try full path */
fi = fopen(layout_name, "r");
if (fi == NULL)
@@ -124,6 +126,7 @@ static struct osk_layout *load_layout(on_screen_keyboard *keyboard, char *layout
/* Fallback to default */
snprintf(filename, 255, "%sosk/default.layout", DATA_PREFIX);
fi = fopen(filename, "r");
+ keyboard->name = "default.layout";
}
}
}
@@ -131,6 +134,7 @@ static struct osk_layout *load_layout(on_screen_keyboard *keyboard, char *layout
{
snprintf(filename, 255, "%sosk/default.layout", DATA_PREFIX);
fi = fopen(filename, "r");
+ keyboard->name = "default.layout";
}
free(filename);
@@ -1325,6 +1329,9 @@ struct osk_keyboard * osk_clicked(on_screen_keyboard *keyboard, int x, int y)
/* Select next or previous keyboard */
if (key->keycode == 1 || key->keycode == 2)
{
+ if (keyboard->disable_change)
+ return(keyboard);
+
aux_list = strdup(keyboard->keyboard_list);
printf("auxlist: %s\n", aux_list);
printf("kn %s\n", keyboard->name);
@@ -1371,7 +1378,7 @@ struct osk_keyboard * osk_clicked(on_screen_keyboard *keyboard, int x, int y)
}
- new_keyboard = osk_create(strdup(name), keyboard->surface, keyboard->button_up, keyboard->button_down, keyboard->button_off);
+ new_keyboard = osk_create(strdup(name), keyboard->surface, keyboard->button_up, keyboard->button_down, keyboard->button_off, keyboard->disable_change);
printf("freeeeeeeeeeeeeeeeeeeeeee\n");
free(aux_list);
diff --git a/src/onscreen_keyboard.h b/src/onscreen_keyboard.h
index 94b58af..53c467c 100644
--- a/src/onscreen_keyboard.h
+++ b/src/onscreen_keyboard.h
@@ -102,6 +102,7 @@ typedef struct osk_keyboard
osk_keymodifiers keymodifiers; /* A shortcurt to find the place of the pressed modifiers */
osk_layout *layout; /* The layout struct */
char *layout_name[256]; /* The layout name */
+ int disable_change; /* If true, stay with the first layout found */
wchar_t * key[256]; /* The text of the key */
int keycode; /* The unicode code corresponding to the key */
wchar_t * composed; /* The unicode char found after a sequence of key presses */
@@ -110,7 +111,7 @@ typedef struct osk_keyboard
osk_key * last_key_pressed; /* The last key pressed */
} 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);
+struct osk_keyboard *osk_create(char *layout_name, SDL_Surface *canvas, SDL_Surface *button_up, SDL_Surface *button_down, SDL_Surface * button_off, int disable_change);
struct osk_layout *osk_load_layout(char *layout_name);
diff --git a/src/parse.gperf b/src/parse.gperf
index 61ba6c5..29a051d 100644
--- a/src/parse.gperf
+++ b/src/parse.gperf
@@ -155,6 +155,8 @@ windowed, NEGBOOL(fullscreen)
windowsize, MULTI(parsertmp_windowsize)
mouse-accessibility, POSBOOL(mouseaccessibility)
onscreen-keyboard, POSBOOL(onscreen_keyboard)
+onscreen-keyboard-layout, MULTI(onscreen_keyboard_layout)
+onscreen-keyboard-disable-change, POSBOOL(onscreen_keyboard_disable_change)
joystick-slowness, MULTI(joystick_slowness)
joystick-threshold, MULTI(joystick_lowthreshold)
joystick-maxsteps, MULTI(joystick_maxsteps)
diff --git a/src/parse.h b/src/parse.h
index 209acb8..2aec369 100644
--- a/src/parse.h
+++ b/src/parse.h
@@ -56,6 +56,8 @@ struct cfginfo
const char *wheely;
const char *mouseaccessibility;
const char *onscreen_keyboard;
+ const char *onscreen_keyboard_layout;
+ const char *onscreen_keyboard_disable_change;
const char *joystick_slowness;
const char *joystick_lowthreshold;
const char *joystick_maxsteps;
diff --git a/src/tuxpaint.c b/src/tuxpaint.c
index 3feb92d..f671071 100644
--- a/src/tuxpaint.c
+++ b/src/tuxpaint.c
@@ -1022,6 +1022,8 @@ static void update_canvas(int x1, int y1, int x2, int y2)
static int emulate_button_pressed = 0;
static int mouseaccessibility = 0;
static int onscreen_keyboard = 0;
+static char * onscreen_keyboard_layout = NULL;
+static int onscreen_keyboard_disable_change = 0;
static int joystick_low_threshold = 3200;
static int joystick_slowness = 15;
static int joystick_maxsteps = 7;
@@ -1412,7 +1414,7 @@ static Uint16 *wcstou16(const wchar_t * str)
}
-SDL_Surface *render_text_w(TuxPaint_Font * restrict font,
+static SDL_Surface *render_text_w(TuxPaint_Font * restrict font,
const wchar_t * restrict str,
SDL_Color color)
{
@@ -1983,7 +1985,7 @@ static void eat_sdl_events(void)
else if (event.type == SDL_ACTIVEEVENT)
handle_active(&event);
else if (event.type == SDL_KEYDOWN)
- {//AAAAAAAAAAAAAAQQQQQQQQQQQQQQQQQQUUUUUUUUUUUUUUUUUUIIIIIIIIIII
+ {
SDLKey key = event.key.keysym.sym;
SDLMod ctrl = event.key.keysym.mod & KMOD_CTRL;
SDLMod alt = event.key.keysym.mod & KMOD_ALT;
@@ -3391,7 +3393,12 @@ static void mainloop(void)
if (onscreen_keyboard)
{
if (kbd == NULL)
- kbd = osk_create("test.layout", screen, img_btnsm_up, img_btnsm_down, img_btnsm_off);
+ {
+ if (onscreen_keyboard_layout)
+ kbd = osk_create(onscreen_keyboard_layout, screen, img_btnsm_up, img_btnsm_down, img_btnsm_off, onscreen_keyboard_disable_change);
+ else
+ kbd = osk_create("default", screen, img_btnsm_up, img_btnsm_down, img_btnsm_off, onscreen_keyboard_disable_change);
+ }
if (kbd == NULL)
printf("kbd = NULL\n");
else
@@ -21570,6 +21577,7 @@ static void setup_config(char *argv[])
SETBOOL(wheely);
SETBOOL(mouseaccessibility);
SETBOOL(onscreen_keyboard);
+ SETBOOL(onscreen_keyboard_disable_change);
SETBOOL(_promptless_save_over);
SETBOOL(_promptless_save_over_new);
SETBOOL(_promptless_save_over_ask);
@@ -21838,7 +21846,7 @@ static void setup_config(char *argv[])
}
joystick_button_pagesetup = strtof(tmpcfg.joystick_button_pagesetup, NULL);
}
- if(tmpcfg.joystick_button_print)
+ if(tmpcfg.joystick_button_print)
{
if (strtof(tmpcfg.joystick_button_print, NULL) < 0 || strtof(tmpcfg.joystick_button_print, NULL) > 254)
{
@@ -21849,6 +21857,20 @@ static void setup_config(char *argv[])
joystick_button_print = strtof(tmpcfg.joystick_button_print, NULL);
}
+
+ /* having any of theese implies having onscreen keyboard setted */
+ if(tmpcfg.onscreen_keyboard_layout)
+ {
+ onscreen_keyboard_layout = strdup(tmpcfg.onscreen_keyboard_layout);
+ onscreen_keyboard = TRUE;
+ }
+
+ if(tmpcfg.onscreen_keyboard_disable_change)
+ {
+ onscreen_keyboard_disable_change = strdup(tmpcfg.onscreen_keyboard_disable_change);
+ onscreen_keyboard = TRUE;
+ }
+
printf("\n\nPromptless save:\nask: %d\nnew: %d\nover: %d\n\n", _promptless_save_over_ask, _promptless_save_over_new, _promptless_save_over);
if (_promptless_save_over_ask) {