diff --git a/Makefile b/Makefile
index 77c5f13c1..e15bb691c 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@
# bill@newbreedsoftware.com
# http://www.tuxpaint.org/
-# June 14, 2002 - January 4, 2014
+# June 14, 2002 - March 30, 2014
# The version number, for release:
diff --git a/docs/OPTIONS.txt b/docs/OPTIONS.txt
index 6e2999658..a73ae1645 100644
--- a/docs/OPTIONS.txt
+++ b/docs/OPTIONS.txt
@@ -386,11 +386,15 @@ Windows Users
onscreen-keyboard-disable-change=yes
Disables the possibility for changing the layout of the
- on-screen keyboard when using the Text and Label tools,
- usefull for simplifying things for the small children.
+ on-screen keyboard when using the Text and Label tools, useful
+ for simplifying things for the small children.
Note: Using this option implies automatically
onscreen-keyboard=yes, so setting both is redundant.
+ joystick-dev=N
+ Specify which joystick device should be used by Tux Paint.
+ Default value is 0 (the first joystick).
+
joystick-slowness=SPEED
Sets a delay at each axis motion, allowing to slow the
joystick. Allowed values are from 0 to 500. Default value is
@@ -417,7 +421,7 @@ Windows Users
joystick-btn-escape=BUTTON NUMBER
Selects the joystick button number, as seen by SDL, that will
- be used to generate a escape event. Usefull to dismiss dialogs
+ be used to generate a escape event. Useful to dismiss dialogs
and quit.
joystick-btn-brush=BUTTON NUMBER
@@ -1028,6 +1032,9 @@ Command-Line Informational Options
--lang help
Display a list of available languages in Tux Paint.
+ --joystick-dev list
+ Display list of attached joysticks available to Tux Paint.
+
----------------------------------------------------------------------
Choosing a Different Language
diff --git a/docs/html/OPTIONS.html b/docs/html/OPTIONS.html
index b27c573a2..002ad69f7 100644
--- a/docs/html/OPTIONS.html
+++ b/docs/html/OPTIONS.html
@@ -482,11 +482,17 @@ New Breed Software
onscreen-keyboard-disable-change=yes
Disables the possibility for changing the layout of the on-screen keyboard when using the Text and
- Label tools, usefull for simplifying things for the small children.
+ Label tools, useful for simplifying things for the small children.
Note: Using this option implies automatically onscreen-keyboard=yes, so setting both is redundant.
+ joystick-dev=N
+
+ Specify which joystick device should be used by Tux Paint.
+ Default value is 0 (the first joystick).
+
+
joystick-slowness=SPEED
Sets a delay at each axis motion, allowing to slow the joystick.
@@ -520,7 +526,7 @@ New Breed Software
joystick-btn-escape=BUTTON NUMBER
Selects the joystick button number, as seen by SDL, that will be used to generate a escape event.
- Usefull to dismiss dialogs and quit.
+ Useful to dismiss dialogs and quit.
joystick-btn-brush=BUTTON NUMBER
@@ -1527,6 +1533,11 @@ New Breed Software
Display a list of available languages in Tux Paint.
+
+ --joystick-dev list
+
+ Display list of attached joysticks available to Tux Paint.
+
diff --git a/src/dirwalk.c b/src/dirwalk.c
index 9964efd56..8aabf02c1 100644
--- a/src/dirwalk.c
+++ b/src/dirwalk.c
@@ -1,7 +1,7 @@
/*
dirwalk.c
- Copyright (c) 2009
+ Copyright (c) 2009-2014
http://www.tuxpaint.org/
This program is free software; you can redistribute it and/or modify
@@ -107,13 +107,17 @@ void loadfont_callback(SDL_Surface * screen, const char *restrict const dir,
char fname[512];
TuxPaint_Font *font;
snprintf(fname, sizeof fname, "%s/%s", dir, files[i].str);
-/* */printf("Loading font: %s (locale is: %s)\n", fname, (locale ? locale : "NULL")); /**/ //EP
+#ifdef DEBUG
+ printf("Loading font: %s (locale is: %s)\n", fname, (locale ? locale : "NULL")); //EP
+#endif
if (locale && strstr(fname, "locale") && !all_locale_fonts)
{
char fname_check[512];
/* We're (probably) loading from our locale fonts folder; ONLY load our locale's font */
snprintf(fname_check, sizeof fname_check, "%s/%s.ttf", dir, locale);
-/* */printf("checking vs \"%s\" vs \"%s\"\n", fname_check, fname); /**/ //EP
+#ifdef DEBUG
+ printf("checking \"%s\" vs \"%s\"\n", fname_check, fname); //EP
+#endif
if (strcmp(fname, fname_check) == 0)
font = TuxPaint_Font_OpenFont("", fname, text_sizes[text_size]);
else
diff --git a/src/fonts.c b/src/fonts.c
index 75b9ad709..688452852 100644
--- a/src/fonts.c
+++ b/src/fonts.c
@@ -1,7 +1,7 @@
/*
fonts.c
- Copyright (c) 2009
+ Copyright (c) 2009-2014
http://www.tuxpaint.org/
This program is free software; you can redistribute it and/or modify
@@ -259,11 +259,15 @@ TuxPaint_Font *load_locale_font(TuxPaint_Font * fallback, int size)
void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf)
{
+#ifdef DEBUG
printf("TuxPaint_Font_CloseFont step 1 (%p)\n", tpf); //EP
+#endif
if (!tpf) return; //EP
#ifndef NO_SDLPANGO
+#ifdef DEBUG
printf("TuxPaint_Font_CloseFont step 2 (%p, %d)\n", tpf->pango_context, tpf->typ); //EP
+#endif
if (tpf->typ == FONT_TYPE_PANGO)
if (tpf->pango_context) //EP
{
@@ -274,7 +278,9 @@ void TuxPaint_Font_CloseFont(TuxPaint_Font * tpf)
}
#endif
+#ifdef DEBUG
printf("TuxPaint_Font_CloseFont step 3 (%p, %d)\n", tpf->ttf_font, tpf->typ); //EP
+#endif
if (tpf->typ == FONT_TYPE_TTF)
if (tpf->ttf_font) //EP
{
diff --git a/src/i18n.c b/src/i18n.c
index e71e0f313..6d0d0cc8b 100644
--- a/src/i18n.c
+++ b/src/i18n.c
@@ -4,7 +4,7 @@
For Tux Paint
Language-related functions
- Copyright (c) 2002-2012 by Bill Kendrick and others
+ Copyright (c) 2002-2014 by Bill Kendrick and others
bill@newbreedsoftware.com
http://www.tuxpaint.org/
@@ -25,7 +25,7 @@
$Id$
- June 14, 2002 - March 28, 2013
+ June 14, 2002 - March 29, 2014
*/
#include
@@ -697,8 +697,6 @@ static void set_langint_from_locale_string(const char *restrict loc)
}
}
-#define DEBUG
-
#define HAVE_SETENV
#ifdef WIN32
#undef HAVE_SETENV
@@ -729,12 +727,15 @@ static int set_current_language(const char *restrict loc)
/* First set the locale according to the environment, then try to overwrite with loc,
after that, ctype_utf8() call will test the compatibility with utf8 and try to load
a different locale if the resulting one is not compatible. */
+#ifdef DEBUG
printf ("Locale BEFORE is: %s\n", setlocale(LC_ALL,NULL));//EP
+#endif
setlocale(LC_ALL, "");
setlocale(LC_ALL, loc);
ctype_utf8();
+#ifdef DEBUG
printf ("Locale AFTER is: %s\n", setlocale(LC_ALL,NULL));//EP
-
+#endif
bindtextdomain("tuxpaint", LOCALEDIR);
/* Old version of glibc does not have bind_textdomain_codeset() */
@@ -821,14 +822,19 @@ printf ("Locale AFTER is: %s\n", setlocale(LC_ALL,NULL));//EP
free(oldloc);
+#ifdef DEBUG
printf("lang_prefixes[%d] is \"%s\"\n", get_current_language(), lang_prefixes[get_current_language()]);
+#endif
+
return y_nudge;
}
int setup_i18n(const char *restrict lang, const char *restrict locale)
{
+#ifdef DEBUG
printf("lang %p, locale %p\n", lang, locale);
printf("lang \"%s\", locale \"%s\"\n", lang, locale);
+#endif
if(locale)
{
diff --git a/src/manpage/tuxpaint.1 b/src/manpage/tuxpaint.1
index 811664e34..8a18a1416 100644
--- a/src/manpage/tuxpaint.1
+++ b/src/manpage/tuxpaint.1
@@ -1,5 +1,5 @@
-.\" tuxpaint.1 - 2011.06.30
-.TH TUXPAINT 1 "30 June 2011" "0.9.22" "Tux Paint"
+.\" tuxpaint.1 - 2014.03.30
+.TH TUXPAINT 1 "30 March 2014" "0.9.22" "Tux Paint"
.SH NAME
tuxpaint -- "Tux Paint", a drawing program for young children.
@@ -67,6 +67,10 @@ tuxpaint -- "Tux Paint", a drawing program for young children.
.br
[\-\-onscreen-keyboard]
.br
+[\-\-joystick-dev=\fIDEVICE\fP]
+.br
+[\-\-joystick-dev=list]
+.br
[\-\-joystick-slowness=\fISPEED\fP]
.br
[\-\-joystick-threshold=\fITHRESHOLD\fP]
diff --git a/src/parse.gperf b/src/parse.gperf
index a0f453a1e..f8bc26e37 100644
--- a/src/parse.gperf
+++ b/src/parse.gperf
@@ -158,6 +158,7 @@ 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-dev, MULTI(joystick_dev)
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 2aec36908..6ff400746 100644
--- a/src/parse.h
+++ b/src/parse.h
@@ -58,6 +58,7 @@ struct cfginfo
const char *onscreen_keyboard;
const char *onscreen_keyboard_layout;
const char *onscreen_keyboard_disable_change;
+ const char *joystick_dev;
const char *joystick_slowness;
const char *joystick_lowthreshold;
const char *joystick_maxsteps;
diff --git a/src/tuxpaint-completion.bash b/src/tuxpaint-completion.bash
index 97b228a54..9a96ae549 100644
--- a/src/tuxpaint-completion.bash
+++ b/src/tuxpaint-completion.bash
@@ -64,6 +64,7 @@ _tuxpaint()
--onscreen-keyboard \
--onscreen-keyboard-layout \
--onscreen-keyboard-disable-change \
+ --joystick-dev \
--joystick-slowness \
--joystick-threshold \
--joystick-maxsteps \
diff --git a/src/tuxpaint.c b/src/tuxpaint.c
index d129e8929..c287197e4 100644
--- a/src/tuxpaint.c
+++ b/src/tuxpaint.c
@@ -3,7 +3,7 @@
Tux Paint - A simple drawing program for children.
- Copyright (c) 2002-2012 by Bill Kendrick and others; see AUTHORS.txt
+ Copyright (c) 2002-2014 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com
http://www.tuxpaint.org/
@@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
- June 14, 2002 - March 2, 2012
+ June 14, 2002 - March 30, 2014
*/
@@ -1092,6 +1092,7 @@ static int fullscreen;
static int native_screensize;
static int grab_input;
static int rotate_orientation;
+static int joystick_dev = 0;
static int disable_print;
static int print_delay;
@@ -6381,16 +6382,17 @@ void show_usage(int exitcode)
" %s [--colorfile FILE]\n"
" %s [--mouse-accessibility]\n"
" %s [--onscreen-keyboard]\n"
- " %s [--joystick-slowness] (0-500). Default value is 15\n"
- " %s [--joystick-threshold] (0-32766). Default value is 3200\n"
- " %s [--joystick-maxsteps] (1-7). Default value is 7\n"
+ " %s [--joystick-dev N] (default=0)\n"
+ " %s [--joystick-slowness N] (0-500; default value is 15)\n"
+ " %s [--joystick-threshold N] (0-32766; default value is 3200)\n"
+ " %s [--joystick-maxsteps N] (1-7; default value is 7)\n"
"\n",
progname, progname,
blank, blank, blank, blank,
blank, blank, blank, blank,
blank, blank, blank, blank,
blank, blank, blank, blank,
- blank, blank, blank,
+ blank, blank, blank, blank,
blank, blank, blank, blank, blank, blank, blank, blank, blank,
#ifdef WIN32
blank,
@@ -7531,28 +7533,40 @@ static int generate_fontconfig_cache_real(void)
SDL_Surface * tmp_surf;
SDL_Color black = { 0, 0, 0, 0 };
+#ifdef DEBUG
printf("-- Hello from generate_fontconfig_cache() (thread # %d)\n", SDL_ThreadID()); fflush(stdout);
+#endif
tmp_font = TuxPaint_Font_OpenFont(PANGO_DEFAULT_FONT, NULL, 12);
if (tmp_font != NULL)
{
+#ifdef DEBUG
printf("-- Generated a font.\n"); fflush(stdout);
+#endif
tmp_surf = render_text(tmp_font, "Test", black);
if (tmp_surf != NULL) {
+#ifdef DEBUG
printf("-- Generated a surface\n"); fflush(stdout);
+#endif
SDL_FreeSurface(tmp_surf);
} else {
+#ifdef DEBUG
printf("-- Failed to make a surface!\n"); fflush(stdout);
+#endif
}
TuxPaint_Font_CloseFont(tmp_font);
} else {
+#ifdef DEBUG
printf("-- Failed to generate a font!\n"); fflush(stdout);
+#endif
}
fontconfig_thread_done = 1;
+#ifdef DEBUG
printf("-- generate_fontconfig_cache() is done\n"); fflush(stdout);
+#endif
return(0);
}
@@ -12197,21 +12211,27 @@ static void cleanup(void)
if (medium_font != NULL)
{
- printf("cleanup: medium font\n"); //EP
+#ifdef DEBUG
+ printf("cleanup: medium font\n"); //EP
+#endif
TuxPaint_Font_CloseFont(medium_font);
medium_font = NULL;
}
if (small_font != NULL)
{
- printf("cleanup: small font\n"); //EP
+#ifdef DEBUG
+ printf("cleanup: small font\n"); //EP
+#endif
TuxPaint_Font_CloseFont(small_font);
small_font = NULL;
}
if (large_font != NULL)
{
- printf("cleanup: large font\n"); //EP
+#ifdef DEBUG
+ printf("cleanup: large font\n"); //EP
+#endif
TuxPaint_Font_CloseFont(large_font);
large_font = NULL;
}
@@ -21841,6 +21861,19 @@ static void setup_config(char *argv[])
if(tmpcfg.papersize)
papersize = tmpcfg.papersize;
#endif
+ if(tmpcfg.joystick_dev)
+ {
+ if(strcmp(tmpcfg.joystick_dev, "list") == 0) {
+ joystick_dev = -1;
+ } else {
+ if(strtof(tmpcfg.joystick_dev, NULL) < 0 || strtof(tmpcfg.joystick_dev, NULL) > 100)
+ {
+ printf("Joystick dev (now %s) must be between 0 and 100.\n", tmpcfg.joystick_dev);
+ exit(1);
+ }
+ joystick_dev = strtof(tmpcfg.joystick_dev, NULL);
+ }
+ }
if(tmpcfg.joystick_slowness)
{
if(strtof(tmpcfg.joystick_slowness, NULL) < 0 || strtof(tmpcfg.joystick_slowness, NULL) > 500)
@@ -22063,7 +22096,9 @@ static void setup_config(char *argv[])
onscreen_keyboard = TRUE;
}
+#ifdef DEBUG
printf("\n\nPromptless save:\nask: %d\nnew: %d\nover: %d\n\n", _promptless_save_over_ask, _promptless_save_over_new, _promptless_save_over);
+#endif
if (_promptless_save_over_ask) {
promptless_save = SAVE_OVER_PROMPT;
@@ -22081,7 +22116,9 @@ static void chdir_to_binary(char *argv0)
{
char curdir[256]; //EP added this block to print out of current directory
getcwd(curdir, sizeof(curdir));
+#ifdef DEBUG
printf("Binary Path: %s\nCurrent directory at launchtime: %s\n", argv0, curdir);
+#endif
#if defined(__BEOS__) || defined(WIN32) || defined(__APPLE__) //EP added __APPLE__
/* if run from gui, like OpenTracker in BeOS or Explorer in Windows,
@@ -22445,9 +22482,8 @@ static void setup(void)
}
}
-
-
- do_lock_file();
+ if (joystick_dev != -1)
+ do_lock_file();
init_flags = SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK;
if (use_sound)
@@ -22487,6 +22523,34 @@ static void setup(void)
SDL_SetEventFilter(TP_EventFilter);
+ /* Set up joystick */
+
+ if (joystick_dev == -1) {
+ printf("%i joystick(s) were found:\n", SDL_NumJoysticks() );
+
+ for( i=0; i < SDL_NumJoysticks(); i++ )
+ {
+ printf(" %d: %s\n", i, SDL_JoystickName(i));
+ }
+
+ SDL_Quit();
+ exit(0);
+ }
+
+ joystick = SDL_JoystickOpen(joystick_dev);
+ if (joystick == NULL) {
+ fprintf(stderr, "Could not open joystick device %d: %s\n", joystick_dev, SDL_GetError());
+ } else {
+ SDL_JoystickEventState(SDL_ENABLE);
+#ifdef DEBUG
+ printf("Number of Axes: %d\n", SDL_JoystickNumAxes(joystick));
+ printf("Number of Buttons: %d\n", SDL_JoystickNumButtons(joystick));
+ printf("Number of Balls: %d\n", SDL_JoystickNumBalls(joystick));
+ printf("Number of Hats: %d\n", SDL_JoystickNumHats(joystick));
+#endif
+ }
+
+
#ifndef NOSOUND
#ifndef WIN32
if (use_sound && Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 1024) < 0)
@@ -22738,28 +22802,36 @@ static void setup(void)
fontconfig_thread_done = 0;
+#ifdef DEBUG
printf("Spawning Pango thread\n"); fflush(stdout);
+#endif
fontconfig_thread = SDL_CreateThread(generate_fontconfig_cache, NULL);
if (fontconfig_thread == NULL) {
fprintf(stderr, "Failed to create Pango setup thread: %s\n", SDL_GetError());
} else {
+#ifdef DEBUG
printf("Thread spawned\n"); fflush(stdout);
+#endif
if (generate_fontconfig_cache_spinner(screen)) /* returns 1 if aborted */
{
- printf("Aborted!\n"); fflush(stdout);
+ printf("Pango thread aborted!\n"); fflush(stdout);
SDL_KillThread(fontconfig_thread);
SDL_Quit();
exit(0);
/* FIXME: Let's be more graceful about exiting (e.g., clean up lockfile!) -bjk 2010.04.27 */
}
+#ifdef DEBUG
printf("Done generating cache\n"); fflush(stdout);
+#endif
}
#ifdef FORKED_FONTS
/* NOW we can fork our own font scanner stuff, and let it run in the bgkd -bjk 2010.04.27 */
+#ifdef DEBUG
printf("Now running font scanner\n"); fflush(stdout);
+#endif
run_font_scanner(screen, lang_prefixes[get_current_language()]);
#endif
@@ -23473,7 +23545,6 @@ int main(int argc, char *argv[])
time_t t = time(NULL);
strftime(logTime, sizeof(logTime), "%A %d/%m/%Y %H:%M:%S", localtime(&t));
printf("Tux Paint log - %s\n", logTime);
-
#endif
chdir_to_binary(argv[0]);
@@ -23484,11 +23555,15 @@ int main(int argc, char *argv[])
// must start ASAP, but depends on locale which in turn needs the config
#ifdef NO_SDLPANGO
/* Only fork it now if we're not planning on creating a thread to handle fontconfig stuff -bjk 2010.04.27 */
+#ifdef DEBUG
printf("Running font scanner\n"); fflush(stdout);
+#endif
run_font_scanner(screen, lang_prefixes[get_current_language()]);
#else
+#ifdef DEBUG
printf("NOT running font scanner\n"); fflush(stdout);
#endif
+#endif
#endif
/* Warnings to satisfy SF.net Bug #3327493 -bjk 2011.06.24 */
@@ -23516,21 +23591,6 @@ int main(int argc, char *argv[])
claim_to_be_ready();
- printf("%i joysticks were found.\n\n", SDL_NumJoysticks() );
- printf("The names of the joysticks are:\n");
-
- for( i=0; i < SDL_NumJoysticks(); i++ )
- {
- printf(" %s\n", SDL_JoystickName(i));
- }
-
- joystick = SDL_JoystickOpen(0);
- SDL_JoystickEventState(SDL_ENABLE);
-
- printf("Number of Axes: %d\n", SDL_JoystickNumAxes(joystick));
- printf("Number of Buttons: %d\n", SDL_JoystickNumButtons(joystick));
- printf("Number of Balls: %d\n", SDL_JoystickNumBalls(joystick));
- printf("Number of Hats: %d\n", SDL_JoystickNumHats(joystick));
mainloop();
@@ -23979,7 +24039,7 @@ static void handle_joybuttonupdownscl(SDL_Event event, int oldpos_x, int oldpos_
ts -= 2;
}
- /* We don't need this ATM, but better left it ready in case the number of tools grows enouth */
+ /* We don't need this ATM, but better left it ready in case the number of tools grows enough */
while (eby > real_r_tools.y + real_r_tools.h + ts / 2 * button_h)
{
ev.button.y = real_r_tools.y + real_r_tools.h + 1;
@@ -23995,7 +24055,11 @@ static void handle_joybuttonupdownscl(SDL_Event event, int oldpos_x, int oldpos_
ev.button.type = SDL_MOUSEBUTTONUP;
ev.button.state = SDL_RELEASED;
}
-printf("result %d %d\n", ev.button.x, ev.button.y);
+
+#ifdef DEBUG
+ printf("result %d %d\n", ev.button.x, ev.button.y);
+#endif
+
SDL_PushEvent(&ev);
}