* --joystick-buttons-ignore option can be used to ignore joystick buttons

(rather than all non-command-assigned buttons being used asi
  left-mouse-click)
 * Updated docs re: joysticks a bit.
This commit is contained in:
William Kendrick 2014-03-31 05:54:32 +00:00
parent 2146904cb0
commit e6365974f6
8 changed files with 62 additions and 10 deletions

View file

@ -113,6 +113,8 @@ tuxpaint -- "Tux Paint", a drawing program for young children.
.br
[\-\-joystick-btn-print=\fIBUTTON\fP]
.br
[\-\-joystick-buttons-ignore=\fIBUTTON1,BUTTON2,...\fP]
.br
[\-\-stampsize=\fISIZE\fP]
.br
[\-\-keyboard]

View file

@ -180,6 +180,7 @@ joystick-btn-open, MULTI(joystick_button_open)
joystick-btn-save, MULTI(joystick_button_save)
joystick-btn-pgsetup, MULTI(joystick_button_pagesetup)
joystick-btn-print, MULTI(joystick_button_print)
joystick-buttons-ignore, MULTI(joystick_buttons_ignore)
%%
void parse_one_option(struct cfginfo *restrict tmpcfg, const char *str, const char *opt, const char *restrict src)

View file

@ -80,6 +80,7 @@ struct cfginfo
const char *joystick_button_save;
const char *joystick_button_pagesetup;
const char *joystick_button_print;
const char *joystick_buttons_ignore;
};

View file

@ -86,6 +86,7 @@ _tuxpaint()
--joystick-btn-save \
--joystick-btn-pgsetup \
--joystick-btn-print \
--joystick-buttons-ignore \
--colorfile' -- $cur ) )
# We don't accept filenames on the command-line yet -bjk 2009.09.09
# else

View file

@ -1080,6 +1080,8 @@ static int joystick_button_open = 255;
static int joystick_button_save = 255;
static int joystick_button_pagesetup = 255;
static int joystick_button_print = 255;
static int joystick_buttons_ignore_len = 0;
static int joystick_buttons_ignore[256];
static Uint32 old_hat_ticks = 0;
static int oldpos_x;
static int oldpos_y;
@ -22082,6 +22084,22 @@ static void setup_config(char *argv[])
}
joystick_button_print = strtof(tmpcfg.joystick_button_print, NULL);
}
if(tmpcfg.joystick_buttons_ignore)
{
int i;
char * token;
token = strtok(tmpcfg.joystick_buttons_ignore, ",");
while (token != NULL) {
if (strtof(token, NULL) < 0 || strtof(token, NULL) > 254) {
/* FIXME: Find better exit code */
printf("Joystick buttons must be between 0 and 254", tmpcfg.joystick_button_print);
exit(1);
}
joystick_buttons_ignore[joystick_buttons_ignore_len++] = strtof(token, NULL);
token = strtok(NULL, ",");
}
}
/* having any of theese implies having onscreen keyboard setted */
@ -23899,6 +23917,7 @@ static void handle_joybuttonupdown(SDL_Event event, int oldpos_x, int oldpos_y)
}
static void handle_joybuttonupdownscl(SDL_Event event, int oldpos_x, int oldpos_y, SDL_Rect real_r_tools) {
int i, ignore = 0;
int eby, ts;
SDL_Event ev;
@ -24060,6 +24079,14 @@ static void handle_joybuttonupdownscl(SDL_Event event, int oldpos_x, int oldpos_
printf("result %d %d\n", ev.button.x, ev.button.y);
#endif
SDL_PushEvent(&ev);
}
/* See if it's a button we ignore */
for (i = 0; i < joystick_buttons_ignore_len && !ignore; i++) {
if (event.button.button == joystick_buttons_ignore[i]) {
ignore = 1;
}
}
if (!ignore)
SDL_PushEvent(&ev);
}