[Tux4kids-commits] r1709 - tuxmath/trunk/src
David Bruce
dbruce-guest at alioth.debian.org
Tue Dec 29 21:08:40 UTC 2009
Author: dbruce-guest
Date: 2009-12-29 21:08:40 +0000 (Tue, 29 Dec 2009)
New Revision: 1709
Modified:
tuxmath/trunk/src/factoroids.c
tuxmath/trunk/src/game.c
Log:
Hackish fix to allow use of main keyboard '+' sign in tuxmath.
It depends on the US qwerty layout, and probably isn't optimal.
Modified: tuxmath/trunk/src/factoroids.c
===================================================================
--- tuxmath/trunk/src/factoroids.c 2009-12-29 21:08:26 UTC (rev 1708)
+++ tuxmath/trunk/src/factoroids.c 2009-12-29 21:08:40 UTC (rev 1709)
@@ -187,7 +187,7 @@
static int xdead, ydead, isdead, countdead;
static int roto_speed;
-/*************** The Factor and Faraction Activiy game Functions ***************/
+/*************** The Factor and Fraction Activity Game Functions ***************/
/* Local function prototypes: */
Modified: tuxmath/trunk/src/game.c
===================================================================
--- tuxmath/trunk/src/game.c 2009-12-29 21:08:26 UTC (rev 1708)
+++ tuxmath/trunk/src/game.c 2009-12-29 21:08:40 UTC (rev 1709)
@@ -199,7 +199,7 @@
static int num_comets_alive(void);
static void game_mouse_event(SDL_Event event);
-static void game_key_event(SDLKey key);
+static void game_key_event(SDLKey key, SDLMod mod);
static void free_on_exit(void);
static void help_add_comet(const char* formula_str, const char* ans_str);
@@ -1363,6 +1363,7 @@
{
SDL_Event event;
SDLKey key;
+ SDLMod mod;
while (SDL_PollEvent(&event) > 0)
{
@@ -1373,7 +1374,8 @@
else if (event.type == SDL_KEYDOWN)
{
key = event.key.keysym.sym;
- game_key_event(key);
+ mod = event.key.keysym.mod;
+ game_key_event(key, mod);
}
else if (event.type == SDL_MOUSEBUTTONDOWN)
{
@@ -3507,7 +3509,7 @@
{
int keypad_w, keypad_h, x, y, row, column;
SDLKey key = SDLK_UNKNOWN;
-
+ SDLMod mod = event.key.keysym.mod;
keypad_w = 0;
keypad_h = 0;
@@ -3517,7 +3519,7 @@
&&(event.button.y <= images[IMG_STOP]->h))
{
key = SDLK_ESCAPE;
- game_key_event(key);
+ game_key_event(key, mod);
return;
}
@@ -3671,13 +3673,13 @@
}
/* now can proceed as if keyboard was used */
- game_key_event(key);
+ game_key_event(key, mod);
}
}
/* called by either key presses or mouse clicks on */
/* on-screen keypad */
-void game_key_event(SDLKey key)
+void game_key_event(SDLKey key, SDLMod mod)
{
int i;
key_pressed = 1; // Signal back in cases where waiting on any key
@@ -3791,10 +3793,22 @@
neg_answer_picked = 1;
tux_pressing = 1;
}
- else if ((key == SDLK_PLUS || key == SDLK_KP_PLUS)
- && MC_GetOpt(ALLOW_NEGATIVES) ) /* do nothing unless neg answers allowed */
+ else if ( /* Effort to make logical operators clear: */
+ (
+ ( /* HACK this hard-codes the plus sign to the US layout: */
+ (key == SDLK_EQUALS) && (mod & KMOD_SHIFT)
+ )
+ ||
+ (
+ key == SDLK_KP_PLUS
+ )
+ )
+ &&
+ MC_GetOpt(ALLOW_NEGATIVES)
+ ) /* do nothing unless neg answers allowed */
{
/* allow player to make answer positive: */
+ printf("SDKL_PLUS received\n");
neg_answer_picked = 0;
tux_pressing = 1;
}
More information about the Tux4kids-commits
mailing list