Same as original

Revision:
12:710078d50d9b
Parent:
10:5ca60e724a76
Child:
13:af578b53ff0e
--- a/button.cpp	Wed Feb 17 06:27:45 2016 +0000
+++ b/button.cpp	Thu Feb 18 10:04:20 2016 +0000
@@ -1,7 +1,7 @@
 //-----------------------------------------------------------
-//  Button class
+//  Button class coping with multi-touch
 //
-//  2015/12/31, Copyright (c) 2015 MIKAMI, Naoki
+//  2016/02/18, Copyright (c) 2016 MIKAMI, Naoki
 //-----------------------------------------------------------
 
 #include "button.hpp"
@@ -31,19 +31,20 @@
     // Check touch detected
     bool Button::Touched()
     {
+        bool rtn = false;
         TS_StateTypeDef state;
         ts_.GetState(&state);
 
-        if (state.touchDetected)
+        for (int n=0; n<state.touchDetected; n++)
         {
-            uint16_t x = state.touchX[0];
-            uint16_t y = state.touchY[0];
+            uint16_t x = state.touchX[n];
+            uint16_t y = state.touchY[n];
 
-            return ( (X_ <= x) && (x <= X_+W_) &&
-                     (Y_ <= y) && (y <= Y_+H_) ) ? true : false;
+            if ( (X_ <= x) && (x <= X_+W_) &&
+                 (Y_ <= y) && (y <= Y_+H_) ) rtn = true;
+            if (rtn) break;
         }
-        else
-            return false;
+        return rtn;
     }
         
     // Check touch detected and redraw button