Joystick button can be config'd to activate Fill tool

https://sourceforge.net/p/tuxpaint/feature-requests/199/
This commit is contained in:
Bill Kendrick 2023-02-18 14:17:55 -08:00
parent a4020ef8c5
commit 95cc093b80
5 changed files with 33 additions and 3 deletions

View file

@ -7,7 +7,7 @@ Various contributors (see below, and AUTHORS.txt)
https://tuxpaint.org/
2023.February.16 (0.9.29)
2023.February.18 (0.9.29)
* Improvements to "Stamp" tool:
-----------------------------
* Stamps may now be rotated.
@ -122,6 +122,10 @@ https://tuxpaint.org/
Note: Bumps `TP_MAGIC_API_VERSION` to 0x00000007.
Bill Kendrick <bill@newbreedsoftware.com>
* Joystick button to activate "Fill" tool added.
(Closes https://sourceforge.net/p/tuxpaint/feature-requests/199/)
Bill Kendrick <bill@newbreedsoftware.com>
* Bug Fixes:
----------
* Always creating 24-bit canvases, in an attempt to avoid blending

View file

@ -185,6 +185,7 @@ joystick-btn-lines, MULTI(joystick_button_selectlinestool)
joystick-btn-shapes, MULTI(joystick_button_selectshapestool)
joystick-btn-text, MULTI(joystick_button_selecttexttool)
joystick-btn-label, MULTI(joystick_button_selectlabeltool)
joystick-btn-fill, MULTI(joystick_button_selectfilltool)
joystick-btn-magic, MULTI(joystick_button_selectmagictool)
joystick-btn-undo, MULTI(joystick_button_undo)
joystick-btn-redo, MULTI(joystick_button_redo)

View file

@ -80,6 +80,7 @@ struct cfginfo
const char *joystick_button_selectshapestool;
const char *joystick_button_selecttexttool;
const char *joystick_button_selectlabeltool;
const char *joystick_button_selectfilltool;
const char *joystick_button_selectmagictool;
const char *joystick_button_undo;
const char *joystick_button_redo;

View file

@ -3,7 +3,7 @@
# Bill Kendrick <bill@newbreedsoftware.com>; https://tuxpaint.org/
# Based on inkscape's completion file, by allali@univ-mlv.fr
#
# Last modified 2022-12-11
# Last modified 2023-02-18
#
# $Id$
@ -94,6 +94,7 @@ _tuxpaint()
--joystick-btn-shapes\
--joystick-btn-text \
--joystick-btn-label \
--joystick-btn-fill \
--joystick-btn-magic \
--joystick-btn-undo \
--joystick-btn-redo \

View file

@ -1360,6 +1360,7 @@ static int joystick_button_selectlinestool = 255;
static int joystick_button_selectshapestool = 255;
static int joystick_button_selecttexttool = 255;
static int joystick_button_selectlabeltool = 255;
static int joystick_button_selectfilltool = 255;
static int joystick_button_selectmagictool = 255;
static int joystick_button_undo = 255;
static int joystick_button_redo = 255;
@ -8410,7 +8411,7 @@ void show_usage(int exitcode)
" [--joystick-buttons-ignore=BUTTON1,BUTTON2,...]\n"
" [--joystick-btn-COMMAND=BUTTON]\n"
/* Find these in "src/parse.gperf" & "src/tuxpaint-completion.bash" */
" (commands: escape, brush, stamp, lines, shapes, text, label, magic,\n"
" (commands: escape, brush, stamp, lines, shapes, text, label, fill, magic,\n"
" undo, redo, eraser, new, open, save, pgsetup, print)\n"
"\n",
progname);
@ -29241,6 +29242,20 @@ static void setup_config(char *argv[])
joystick_button_selectlabeltool =
strtof(tmpcfg.joystick_button_selectlabeltool, NULL);
}
if (tmpcfg.joystick_button_selectfilltool)
{
if (strtof(tmpcfg.joystick_button_selectfilltool, NULL) < 0
|| strtof(tmpcfg.joystick_button_selectfilltool, NULL) > 254)
{
/* FIXME: Find better exit code */
fprintf(stderr,
"Joystick button fill tool shortcurt (now %s) must be between 0 and 254",
tmpcfg.joystick_button_selectfilltool);
exit(1);
}
joystick_button_selectfilltool =
strtof(tmpcfg.joystick_button_selectfilltool, NULL);
}
if (tmpcfg.joystick_button_selectmagictool)
{
if (strtof(tmpcfg.joystick_button_selectmagictool, NULL) < 0
@ -31819,6 +31834,7 @@ static void handle_joybuttonupdownscl(SDL_Event event, int oldpos_x,
event.button.button == joystick_button_selectshapestool ||
event.button.button == joystick_button_selecttexttool ||
event.button.button == joystick_button_selectlabeltool ||
event.button.button == joystick_button_selectfilltool ||
event.button.button == joystick_button_selectmagictool ||
event.button.button == joystick_button_selecterasertool)
@ -31865,6 +31881,13 @@ static void handle_joybuttonupdownscl(SDL_Event event, int oldpos_x,
real_r_tools.y + TOOL_LABEL / 2 * button_h + button_h / 2;
}
else if (event.button.button == joystick_button_selectfilltool)
{
ev.button.x = (TOOL_FILL % 2) * button_w + button_w / 2;
ev.button.y =
real_r_tools.y + TOOL_FILL / 2 * button_h + button_h / 2;
}
else if (event.button.button == joystick_button_selectmagictool)
{
ev.button.x = (TOOL_MAGIC % 2) * button_w + button_w / 2;