Reassign first param of click handler to hold SDL button index
authorparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Mon, 16 Feb 2009 13:32:46 +0000 (13:32 +0000)
committerparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Mon, 16 Feb 2009 13:32:46 +0000 (13:32 +0000)
git-svn-id: https://s.snth.net/svn/neverball/trunk@2760 78b8d119-cf0a-0410-b17c-f493084dd1d7

ball/main.c
ball/st_level.c
ball/st_over.c
ball/st_play.c
ball/st_shared.c
putt/main.c
putt/st_all.c
putt/st_conf.c
share/st_resol.c

index e9025b9..6fc958b 100644 (file)
@@ -97,11 +97,11 @@ static int loop(void)
             break;
 
         case SDL_MOUSEBUTTONDOWN:
-            d = st_click((e.button.button == SDL_BUTTON_LEFT) ? -1 : 1, 1);
+            d = st_click(e.button.button, 1);
             break;
 
         case SDL_MOUSEBUTTONUP:
-            d = st_click((e.button.button == SDL_BUTTON_LEFT) ? -1 : 1, 0);
+            d = st_click(e.button.button, 0);
             break;
 
         case SDL_KEYDOWN:
index 26bba56..d8bd6b3 100644 (file)
@@ -88,7 +88,7 @@ static void level_timer(int id, float dt)
 
 static int level_click(int b, int d)
 {
-    return (b < 0 && d == 1) ? goto_state(&st_play_ready) : 1;
+    return (b == SDL_BUTTON_LEFT && d == 1) ? goto_state(&st_play_ready) : 1;
 }
 
 static int level_keybd(int c, int d)
index 842b8af..45e48e3 100644 (file)
@@ -58,7 +58,7 @@ static void over_timer(int id, float dt)
 
 static int over_click(int b, int d)
 {
-    return (b < 0 && d == 1) ? goto_state(&st_start) : 1;
+    return (b == SDL_BUTTON_LEFT && d == 1) ? goto_state(&st_start) : 1;
 }
 
 static int over_buttn(int b, int d)
index f6d8079..d48a8f7 100644 (file)
@@ -86,7 +86,7 @@ static void play_ready_timer(int id, float dt)
 
 static int play_ready_click(int b, int d)
 {
-    return (b < 0 && d == 1) ? goto_state(&st_play_loop) : 1;
+    return (b == SDL_BUTTON_LEFT && d == 1) ? goto_state(&st_play_loop) : 1;
 }
 
 static int play_ready_keybd(int c, int d)
@@ -144,7 +144,7 @@ static void play_set_timer(int id, float dt)
 
 static int play_set_click(int b, int d)
 {
-    if (b < 0 && d == 1)
+    if (b == SDL_BUTTON_LEFT && d == 1)
     {
         game_set_fly(0.0f, NULL);
         game_client_step(NULL);
@@ -277,7 +277,7 @@ static void play_loop_stick(int id, int a, int k)
 
 static int play_loop_click(int b, int d)
 {
-    view_rotate = d ? b : 0;
+    view_rotate = d ? (b == SDL_BUTTON_LEFT ? -1 : +1) : 0;
     return 1;
 }
 
index 028c7ad..b27f343 100644 (file)
@@ -84,7 +84,7 @@ void shared_angle(int id, int x, int z)
 
 int shared_click(int b, int d)
 {
-    if (b < 0 && d == 1)
+    if (b == SDL_BUTTON_LEFT && d == 1)
         return st_buttn(config_get_d(CONFIG_JOYSTICK_BUTTON_A), 1);
     else
         return 1;
index 1666b0a..59698f1 100644 (file)
@@ -93,11 +93,11 @@ static int loop(void)
             break;
 
         case SDL_MOUSEBUTTONDOWN:
-            d = st_click((e.button.button == SDL_BUTTON_LEFT) ? -1 : 1, 1);
+            d = st_click(e.button.button, 1);
             break;
 
         case SDL_MOUSEBUTTONUP:
-            d = st_click((e.button.button == SDL_BUTTON_LEFT) ? -1 : 1, 0);
+            d = st_click(e.button.button, 0);
             break;
 
         case SDL_KEYDOWN:
index a4c366e..92f9ea9 100644 (file)
@@ -254,7 +254,7 @@ static void title_point(int id, int x, int y, int dx, int dy)
 
 static int title_click(int b, int d)
 {
-    return (d && b < 0) ? title_action(gui_token(gui_click())) : 1;
+    return d && b == SDL_BUTTON_LEFT ? title_action(gui_token(gui_click())) : 1;
 }
 
 static int title_buttn(int b, int d)
@@ -403,7 +403,7 @@ static void course_stick(int id, int a, int v)
 
 static int course_click(int b, int d)
 {
-    return (d && b < 0) ? course_action(gui_token(gui_click())) : 1;
+    return d && b == SDL_BUTTON_LEFT ? course_action(gui_token(gui_click())) : 1;
 }
 
 static int course_buttn(int b, int d)
@@ -520,7 +520,7 @@ static void party_point(int id, int x, int y, int dx, int dy)
 
 static int party_click(int b, int d)
 {
-    return (d && b < 0) ? party_action(gui_token(gui_click())) : 1;
+    return d && b == SDL_BUTTON_LEFT ? party_action(gui_token(gui_click())) : 1;
 }
 
 static int party_buttn(int b, int d)
@@ -626,7 +626,7 @@ static void pause_point(int id, int x, int y, int dx, int dy)
 
 static int pause_click(int b, int d)
 {
-    return (d && b < 0) ? pause_action(gui_token(gui_click())) : 1;
+    return d && b == SDL_BUTTON_LEFT ? pause_action(gui_token(gui_click())) : 1;
 }
 
 static int pause_keybd(int c, int d)
@@ -734,7 +734,7 @@ static void next_point(int id, int x, int y, int dx, int dy)
 
 static int next_click(int b, int d)
 {
-    return (d && b < 0) ? goto_state(&st_flyby) : 1;
+    return (d && b == SDL_BUTTON_LEFT) ? goto_state(&st_flyby) : 1;
 }
 
 static int next_keybd(int c, int d)
@@ -833,7 +833,7 @@ static void flyby_timer(int id, float dt)
 
 static int flyby_click(int b, int d)
 {
-    if (d && b < 0)
+    if (d && b == SDL_BUTTON_LEFT)
     {
         game_set_fly(0.f);
         return goto_state(&st_stroke);
@@ -926,7 +926,7 @@ static void stroke_stick(int id, int a, int v)
 
 static int stroke_click(int b, int d)
 {
-    return (d && b < 0) ? goto_state(&st_roll) : 1;
+    return (d && b == SDL_BUTTON_LEFT) ? goto_state(&st_roll) : 1;
 }
 
 static int stroke_buttn(int b, int d)
@@ -1033,7 +1033,7 @@ static void goal_timer(int id, float dt)
 
 static int goal_click(int b, int d)
 {
-    if (b < 0 && d == 1)
+    if (b == SDL_BUTTON_LEFT && d == 1)
     {
         if (hole_next())
             goto_state(&st_next);
@@ -1103,7 +1103,7 @@ static void stop_timer(int id, float dt)
 
 static int stop_click(int b, int d)
 {
-    if (b < 0 && d == 1)
+    if (b == SDL_BUTTON_LEFT && d == 1)
     {
         if (hole_next())
             goto_state(&st_next);
@@ -1178,7 +1178,7 @@ static void fall_timer(int id, float dt)
 
 static int fall_click(int b, int d)
 {
-    if (b < 0 && d == 1)
+    if (b == SDL_BUTTON_LEFT && d == 1)
     {
         if (hole_next())
             goto_state(&st_next);
@@ -1235,7 +1235,7 @@ static void score_timer(int id, float dt)
 
 static int score_click(int b, int d)
 {
-    if (b < 0 && d == 1)
+    if (b == SDL_BUTTON_LEFT && d == 1)
     {
         if (hole_move())
             return goto_state(&st_next);
@@ -1288,7 +1288,7 @@ static void over_timer(int id, float dt)
 
 static int over_click(int b, int d)
 {
-    return (d && b < 0) ? goto_state(&st_title) : 1;
+    return (d && b == SDL_BUTTON_LEFT) ? goto_state(&st_title) : 1;
 }
 
 static int over_buttn(int b, int d)
index fe8b6a0..5a36a98 100644 (file)
@@ -303,7 +303,7 @@ static void conf_stick(int id, int a, int v)
 
 static int conf_click(int b, int d)
 {
-    if (b < 0 && d == 1)
+    if (b == SDL_BUTTON_LEFT && d == 1)
         return conf_action(gui_token(gui_click()));
     return 1;
 }
index c3ebaa3..9faa29b 100644 (file)
@@ -143,7 +143,7 @@ static void resol_stick(int id, int a, int v)
 
 static int resol_click(int b, int d)
 {
-    if (b < 0 && d == 1)
+    if (b == SDL_BUTTON_LEFT && d == 1)
         return resol_action(gui_token(gui_click()));
     return 1;
 }