Project

General

Profile

Download (21.6 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / main / RubikSurfaceView.java @ a4472437

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.main;
21

    
22
import android.app.ActivityManager;
23
import android.content.Context;
24
import android.content.pm.ConfigurationInfo;
25
import android.opengl.GLSurfaceView;
26
import android.util.AttributeSet;
27
import android.util.DisplayMetrics;
28
import android.view.MotionEvent;
29

    
30
import org.distorted.library.type.Static2D;
31
import org.distorted.library.type.Static3D;
32
import org.distorted.library.type.Static4D;
33
import org.distorted.objects.RubikObject;
34
import org.distorted.objects.RubikObjectMovement;
35
import org.distorted.solvers.SolverMain;
36
import org.distorted.states.RubikState;
37
import org.distorted.states.RubikStateSolver;
38
import org.distorted.states.RubikStateSolving;
39

    
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41

    
42
public class RubikSurfaceView extends GLSurfaceView
43
{
44
    private static final int NUM_SPEED_PROBES = 10;
45
    private static final int INVALID_POINTER_ID = -1;
46

    
47
    public static final int MODE_ROTATE  = 0;
48
    public static final int MODE_DRAG    = 1;
49
    public static final int MODE_REPLACE = 2;
50

    
51
    // Moving the finger from the middle of the vertical screen to the right edge will rotate a
52
    // given face by SWIPING_SENSITIVITY/2 degrees.
53
    private final static int SWIPING_SENSITIVITY  = 240;
54
    // Moving the finger by 0.3 of an inch will start a Rotation.
55
    private final static float ROTATION_SENSITIVITY = 0.3f;
56

    
57
    // Where did we get this sqrt(3)/2 ? From the (default, i.e. 60 degrees - see InternalOutputSurface!)
58
    // FOV of the projection matrix of the Node onto the Screen.
59
    // Take a look how the CAMERA_POINT is used in onTouchEvent - (x,y) there are expressed in sort of
60
    // 'half-NDC' coordinates i.e. they range from +0.5 to -0.5; thus CAMERA_POINT also needs to be
61
    // in 'half-NDC'. Since in this coordinate system the height of the screen is equal to 1, then the
62
    // Z-distance from the center of the object to the camera is equal to (scrHeight/2)/tan(FOV/2) =
63
    // 0.5/tan(30) = sqrt(3)/2.
64
    // Why is the Z-distance between the camera and the object equal to (scrHeight/2)/tan(FOV/2)?
65
    // Because of the way the View part of the ModelView matrix is constructed in EffectQueueMatrix.send().
66
    private final Static4D CAMERA_POINT = new Static4D(0, 0, (float)Math.sqrt(3)*0.5f, 0);
67

    
68
    private RubikRenderer mRenderer;
69
    private RubikPreRender mPreRender;
70
    private RubikObjectMovement mMovement;
71
    private boolean mDragging, mBeginningRotation, mContinuingRotation;
72
    private int mScreenWidth, mScreenHeight, mScreenMin;
73

    
74
    private int mPtrID1, mPtrID2;
75
    private int mNumFingersDown;
76
    private float mX, mY;
77
    private float mStartRotX, mStartRotY;
78
    private float mAxisX, mAxisY;
79
    private float mRotationFactor;
80
    private int mLastCubitColor, mLastCubitFace, mLastCubit;
81
    private int mCurrentAxis, mCurrentRow;
82
    private float mCurrentAngle, mCurrRotSpeed;
83
    private float[] mLastX;
84
    private float[] mLastY;
85
    private long[] mLastT;
86
    private int mFirstIndex, mLastIndex;
87
    private int mDensity;
88

    
89
    private static Static4D mQuat= new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);
90
    private static Static4D mTemp= new Static4D(0,0,0,1);
91

    
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93

    
94
    void setScreenSize(int width, int height)
95
      {
96
      mScreenWidth = width;
97
      mScreenHeight= height;
98

    
99
      mScreenMin = Math.min(width, height);
100
      }
101

    
102
///////////////////////////////////////////////////////////////////////////////////////////////////
103

    
104
    boolean isVertical()
105
      {
106
      return mScreenHeight>mScreenWidth;
107
      }
108

    
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110

    
111
    RubikRenderer getRenderer()
112
      {
113
      return mRenderer;
114
      }
115

    
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117

    
118
    RubikPreRender getPreRender()
119
      {
120
      return mPreRender;
121
      }
122

    
123
///////////////////////////////////////////////////////////////////////////////////////////////////
124

    
125
    void setQuat()
126
      {
127
      mQuat.set(mTemp);
128
      }
129

    
130
///////////////////////////////////////////////////////////////////////////////////////////////////
131

    
132
    Static4D getQuat()
133
      {
134
      return mQuat;
135
      }
136

    
137
///////////////////////////////////////////////////////////////////////////////////////////////////
138

    
139
    void setMovement(RubikObjectMovement movement)
140
      {
141
      mMovement = movement;
142
      }
143

    
144
///////////////////////////////////////////////////////////////////////////////////////////////////
145

    
146
    private Static4D quatFromAngle(float angle)
147
      {
148
      float cosA = (float)Math.cos(angle);
149
      float sinA =-(float)Math.sin(angle);
150

    
151
      return new Static4D(0, 0, sinA, cosA);
152
      }
153

    
154
///////////////////////////////////////////////////////////////////////////////////////////////////
155

    
156
    private Static4D quatFromDrag(float dragX, float dragY)
157
      {
158
      float axisX = dragY;  // inverted X and Y - rotation axis is perpendicular to (dragX,dragY)
159
      float axisY = dragX;  // Why not (-dragY, dragX) ? because Y axis is also inverted!
160
      float axisZ = 0;
161
      float axisL = (float)Math.sqrt(axisX*axisX + axisY*axisY + axisZ*axisZ);
162

    
163
      if( axisL>0 )
164
        {
165
        axisX /= axisL;
166
        axisY /= axisL;
167
        axisZ /= axisL;
168

    
169
        float ratio = axisL;
170
        ratio = ratio - (int)ratio;     // the cos() is only valid in (0,Pi)
171

    
172
        float cosA = (float)Math.cos(Math.PI*ratio);
173
        float sinA = (float)Math.sqrt(1-cosA*cosA);
174

    
175
        return new Static4D(axisX*sinA, axisY*sinA, axisZ*sinA, cosA);
176
        }
177

    
178
      return new Static4D(0f, 0f, 0f, 1f);
179
      }
180

    
181
///////////////////////////////////////////////////////////////////////////////////////////////////
182
// cast the 3D axis we are currently rotating along to the 2D in-screen-surface axis
183

    
184
    private void computeCurrentAxis(Static3D axis)
185
      {
186
      Static4D axis4D = new Static4D(axis.get0(), axis.get1(), axis.get2(), 0);
187
      Static4D result = rotateVectorByQuat(axis4D, mQuat);
188

    
189
      mAxisX =result.get0();
190
      mAxisY =result.get1();
191

    
192
      float len = (float)Math.sqrt(mAxisX*mAxisX + mAxisY*mAxisY);
193
      mAxisX /= len;
194
      mAxisY /= len;
195
      }
196

    
197
///////////////////////////////////////////////////////////////////////////////////////////////////
198
// return quat1*quat2
199

    
200
    public static Static4D quatMultiply( Static4D quat1, Static4D quat2 )
201
      {
202
      float qx = quat1.get0();
203
      float qy = quat1.get1();
204
      float qz = quat1.get2();
205
      float qw = quat1.get3();
206

    
207
      float rx = quat2.get0();
208
      float ry = quat2.get1();
209
      float rz = quat2.get2();
210
      float rw = quat2.get3();
211

    
212
      float tx = rw*qx - rz*qy + ry*qz + rx*qw;
213
      float ty = rw*qy + rz*qx + ry*qw - rx*qz;
214
      float tz = rw*qz + rz*qw - ry*qx + rx*qy;
215
      float tw = rw*qw - rz*qz - ry*qy - rx*qx;
216

    
217
      return new Static4D(tx,ty,tz,tw);
218
      }
219

    
220
///////////////////////////////////////////////////////////////////////////////////////////////////
221
// rotate 'vector' by quat  ( i.e. return quat*vector*(quat^-1) )
222

    
223
    public static Static4D rotateVectorByQuat(Static4D vector, Static4D quat)
224
      {
225
      float qx = quat.get0();
226
      float qy = quat.get1();
227
      float qz = quat.get2();
228
      float qw = quat.get3();
229

    
230
      Static4D quatInverted= new Static4D(-qx,-qy,-qz,qw);
231
      Static4D tmp = quatMultiply(quat,vector);
232

    
233
      return quatMultiply(tmp,quatInverted);
234
      }
235

    
236
///////////////////////////////////////////////////////////////////////////////////////////////////
237
// rotate 'vector' by quat^(-1)  ( i.e. return (quat^-1)*vector*quat )
238

    
239
    public static Static4D rotateVectorByInvertedQuat(Static4D vector, Static4D quat)
240
      {
241
      float qx = quat.get0();
242
      float qy = quat.get1();
243
      float qz = quat.get2();
244
      float qw = quat.get3();
245

    
246
      Static4D quatInverted= new Static4D(-qx,-qy,-qz,qw);
247
      Static4D tmp = quatMultiply(quatInverted,vector);
248

    
249
      return quatMultiply(tmp,quat);
250
      }
251

    
252
///////////////////////////////////////////////////////////////////////////////////////////////////
253

    
254
    private void addSpeedProbe(float x, float y)
255
      {
256
      long currTime = System.currentTimeMillis();
257
      boolean theSame = mLastIndex==mFirstIndex;
258

    
259
      mLastIndex++;
260
      if( mLastIndex>=NUM_SPEED_PROBES ) mLastIndex=0;
261

    
262
      mLastT[mLastIndex] = currTime;
263
      mLastX[mLastIndex] = x;
264
      mLastY[mLastIndex] = y;
265

    
266
      if( mLastIndex==mFirstIndex)
267
        {
268
        mFirstIndex++;
269
        if( mFirstIndex>=NUM_SPEED_PROBES ) mFirstIndex=0;
270
        }
271

    
272
      if( theSame )
273
        {
274
        mLastT[mFirstIndex] = currTime;
275
        mLastX[mFirstIndex] = x;
276
        mLastY[mFirstIndex] = y;
277
        }
278
      }
279

    
280
///////////////////////////////////////////////////////////////////////////////////////////////////
281

    
282
    private void computeCurrentSpeedInInchesPerSecond()
283
      {
284
      long firstTime = mLastT[mFirstIndex];
285
      long lastTime  = mLastT[mLastIndex];
286
      float fX = mLastX[mFirstIndex];
287
      float fY = mLastY[mFirstIndex];
288
      float lX = mLastX[mLastIndex];
289
      float lY = mLastY[mLastIndex];
290

    
291
      long timeDiff = lastTime-firstTime;
292

    
293
      mLastIndex = 0;
294
      mFirstIndex= 0;
295

    
296
      mCurrRotSpeed = timeDiff>0 ? 1000*retFingerDragDistanceInInches(fX,fY,lX,lY)/timeDiff : 0;
297
      }
298

    
299
///////////////////////////////////////////////////////////////////////////////////////////////////
300

    
301
    private float retFingerDragDistanceInInches(float xFrom, float yFrom, float xTo, float yTo)
302
      {
303
      float xDist = mScreenWidth*(xFrom-xTo);
304
      float yDist = mScreenHeight*(yFrom-yTo);
305
      float distInPixels = (float)Math.sqrt(xDist*xDist + yDist*yDist);
306

    
307
      return distInPixels/mDensity;
308
      }
309

    
310
///////////////////////////////////////////////////////////////////////////////////////////////////
311

    
312
    private void setUpDragOrRotate(boolean down, float x, float y)
313
      {
314
      int mode = RubikState.getMode();
315

    
316
      if( mode==MODE_DRAG )
317
        {
318
        mDragging           = true;
319
        mBeginningRotation  = false;
320
        mContinuingRotation = false;
321
        }
322
      else
323
        {
324
        Static4D touchPoint1 = new Static4D(x, y, 0, 0);
325
        Static4D rotatedTouchPoint1= rotateVectorByInvertedQuat(touchPoint1, mQuat);
326
        Static4D rotatedCamera= rotateVectorByInvertedQuat(CAMERA_POINT, mQuat);
327

    
328
        if( mMovement!=null && mMovement.faceTouched(rotatedTouchPoint1,rotatedCamera) )
329
          {
330
          mDragging           = false;
331
          mContinuingRotation = false;
332

    
333
          if( mode==MODE_ROTATE )
334
            {
335
            mBeginningRotation= mPreRender.canRotate();
336
            }
337
          else if( mode==MODE_REPLACE )
338
            {
339
            mBeginningRotation= false;
340

    
341
            if( down )
342
              {
343
              RubikStateSolver solver = (RubikStateSolver) RubikState.SVER.getStateClass();
344
              mLastCubitFace = mMovement.getTouchedFace();
345
              float[] point = mMovement.getTouchedPoint3D();
346
              int color = solver.getCurrentColor();
347
              RubikObject object = mPreRender.getObject();
348
              mLastCubit = object.getCubit(point);
349
              mPreRender.setTextureMap( mLastCubit, mLastCubitFace, color );
350
              mLastCubitColor = SolverMain.cubitIsLocked(object.getObjectList(), object.getSize(), mLastCubit);
351
              }
352
            }
353
          }
354
        else
355
          {
356
          mDragging           = true;
357
          mBeginningRotation  = false;
358
          mContinuingRotation = false;
359
          }
360
        }
361
      }
362

    
363
///////////////////////////////////////////////////////////////////////////////////////////////////
364

    
365
    private void drag(float x, float y)
366
      {
367
      mTemp.set(quatMultiply(quatFromDrag(mX-x,y-mY), mQuat));
368
      mPreRender.setQuatOnNextRender();
369
      mX = x;
370
      mY = y;
371
      }
372

    
373
///////////////////////////////////////////////////////////////////////////////////////////////////
374

    
375
    private void finishRotation()
376
      {
377
      computeCurrentSpeedInInchesPerSecond();
378
      int angle = mPreRender.getObject().computeNearestAngle(mCurrentAngle, mCurrRotSpeed);
379
      mPreRender.finishRotation(angle);
380

    
381
      if( RubikState.getCurrentState()==RubikState.SOLV && angle!=0 )
382
        {
383
        RubikStateSolving solving = (RubikStateSolving)RubikState.SOLV.getStateClass();
384
        solving.addMove(mCurrentAxis, mCurrentRow, angle);
385
        }
386

    
387
      mContinuingRotation = false;
388
      mBeginningRotation  = false;
389
      mDragging           = true;
390
      }
391

    
392
///////////////////////////////////////////////////////////////////////////////////////////////////
393

    
394
    private void continueRotation(float x, float y)
395
      {
396
      float dx = x-mStartRotX;
397
      float dy = y-mStartRotY;
398
      float alpha = dx*mAxisX + dy*mAxisY;
399
      float x2 = dx - alpha*mAxisX;
400
      float y2 = dy - alpha*mAxisY;
401

    
402
      float len = (float)Math.sqrt(x2*x2 + y2*y2);
403

    
404
      // we have the length of 1D vector 'angle', now the direction:
405
      float tmp = mAxisY==0 ? -mAxisX*y2 : mAxisY*x2;
406

    
407
      float angle = (tmp>0 ? 1:-1)*len*mRotationFactor;
408
      mCurrentAngle = SWIPING_SENSITIVITY*angle;
409
      mPreRender.getObject().continueRotation(mCurrentAngle);
410

    
411
      addSpeedProbe(x2,y2);
412
      }
413

    
414
///////////////////////////////////////////////////////////////////////////////////////////////////
415

    
416
    private void beginRotation(float x, float y)
417
      {
418
      mStartRotX = x;
419
      mStartRotY = y;
420

    
421
      Static4D touchPoint2 = new Static4D(x, y, 0, 0);
422
      Static4D rotatedTouchPoint2= rotateVectorByInvertedQuat(touchPoint2, mQuat);
423

    
424
      Static2D res = mMovement.newRotation(rotatedTouchPoint2);
425
      RubikObject object = mPreRender.getObject();
426

    
427
      mCurrentAxis = (int)res.get0();
428
      float offset = res.get1();
429
      mCurrentRow = (int)(object.returnMultiplier()*offset);
430
      computeCurrentAxis( object.getRotationAxis()[mCurrentAxis] );
431
      mRotationFactor = object.returnRotationFactor(offset);
432

    
433
      object.beginNewRotation( mCurrentAxis, mCurrentRow );
434

    
435
      if( RubikState.getCurrentState()==RubikState.READ )
436
        {
437
        RubikStateSolving solving = (RubikStateSolving)RubikState.SOLV.getStateClass();
438
        solving.resetElapsed();
439

    
440
        final RubikActivity act = (RubikActivity)getContext();
441

    
442
        act.runOnUiThread(new Runnable()
443
          {
444
          @Override
445
          public void run()
446
            {
447
            RubikState.switchState( act, RubikState.SOLV);
448
            }
449
          });
450
        }
451

    
452
      addSpeedProbe(x,y);
453

    
454
      mBeginningRotation = false;
455
      mContinuingRotation= true;
456
      }
457

    
458
///////////////////////////////////////////////////////////////////////////////////////////////////
459

    
460
    private void actionMove(MotionEvent event)
461
      {
462
      int pointer = event.findPointerIndex(mPtrID1 != INVALID_POINTER_ID ? mPtrID1:mPtrID2);
463

    
464
      float pX = event.getX(pointer);
465
      float pY = event.getY(pointer);
466

    
467
      float x = (pX - mScreenWidth*0.5f)/mScreenMin;
468
      float y = (mScreenHeight*0.5f -pY)/mScreenMin;
469

    
470
      if( mBeginningRotation )
471
        {
472
        if( retFingerDragDistanceInInches(mX,mY,x,y) > ROTATION_SENSITIVITY )
473
          {
474
          beginRotation(x,y);
475
          }
476
        }
477
      else if( mContinuingRotation )
478
        {
479
        continueRotation(x,y);
480
        }
481
      else if( mDragging )
482
        {
483
        drag(x,y);
484
        }
485
      else
486
        {
487
        setUpDragOrRotate(false,x,y);
488
        }
489
      }
490

    
491
///////////////////////////////////////////////////////////////////////////////////////////////////
492

    
493
    private void actionDown(MotionEvent event)
494
      {
495
      mNumFingersDown++;
496
      mPtrID1 = event.getPointerId(0);
497

    
498
      float x = event.getX();
499
      float y = event.getY();
500

    
501
      mX = (x - mScreenWidth*0.5f)/mScreenMin;
502
      mY = (mScreenHeight*0.5f -y)/mScreenMin;
503

    
504
      setUpDragOrRotate(true,mX,mY);
505
      }
506

    
507
///////////////////////////////////////////////////////////////////////////////////////////////////
508

    
509
    private void actionUp(MotionEvent event)
510
      {
511
      mNumFingersDown--;
512

    
513
      mPtrID1 = INVALID_POINTER_ID;
514
      mPtrID2 = INVALID_POINTER_ID;
515

    
516
      if( mContinuingRotation )
517
        {
518
        finishRotation();
519
        }
520

    
521
      if( mLastCubitColor>=0 )
522
        {
523
        mPreRender.setTextureMap( mLastCubit, mLastCubitFace, mLastCubitColor );
524
        }
525
      }
526

    
527
///////////////////////////////////////////////////////////////////////////////////////////////////
528

    
529
    private void actionDown2(MotionEvent event)
530
      {
531
      mNumFingersDown++;
532

    
533
      int index = event.getActionIndex();
534

    
535
      if( mPtrID1==INVALID_POINTER_ID )
536
        {
537
        mPtrID1 = event.getPointerId(index);
538
        float x = event.getX(index);
539
        float y = event.getY(index);
540

    
541
        mX = (x - mScreenWidth*0.5f)/mScreenMin;
542
        mY = (mScreenHeight*0.5f -y)/mScreenMin;
543
        }
544
      else if( mPtrID2==INVALID_POINTER_ID )
545
        {
546
        mPtrID2 = event.getPointerId(index);
547

    
548
        if( mBeginningRotation || mContinuingRotation )
549
          {
550
          float x = event.getX();
551
          float y = event.getY();
552

    
553
          mX = (x - mScreenWidth*0.5f)/mScreenMin;
554
          mY = (mScreenHeight*0.5f -y)/mScreenMin;
555
          }
556
        }
557

    
558
      if( mBeginningRotation )
559
        {
560
        mContinuingRotation = false;
561
        mBeginningRotation  = false;
562
        mDragging           = true;
563
        }
564
      else if( mContinuingRotation )
565
        {
566
        finishRotation();
567
        }
568
      }
569

    
570
///////////////////////////////////////////////////////////////////////////////////////////////////
571

    
572
    private void actionUp2(MotionEvent event)
573
      {
574
      mNumFingersDown--;
575

    
576
      int index = event.getActionIndex();
577

    
578
      if( index==0 )
579
        {
580
        mPtrID1 = INVALID_POINTER_ID;
581
        int pointer = event.findPointerIndex(mPtrID2);
582
        float x1 = event.getX(pointer);
583
        float y1 = event.getY(pointer);
584

    
585
        mX = (x1 - mScreenWidth*0.5f)/mScreenMin;
586
        mY = (mScreenHeight*0.5f -y1)/mScreenMin;
587
        }
588
      else
589
        {
590
        mPtrID2 = INVALID_POINTER_ID;
591
        }
592
      }
593

    
594
///////////////////////////////////////////////////////////////////////////////////////////////////
595
// PUBLIC API
596
///////////////////////////////////////////////////////////////////////////////////////////////////
597

    
598
    public RubikSurfaceView(Context context, AttributeSet attrs)
599
      {
600
      super(context,attrs);
601

    
602
      if(!isInEditMode())
603
        {
604
        mLastCubitColor = -1;
605
        mCurrRotSpeed   = 0.0f;
606

    
607
        mLastX = new float[NUM_SPEED_PROBES];
608
        mLastY = new float[NUM_SPEED_PROBES];
609
        mLastT = new long[NUM_SPEED_PROBES];
610
        mFirstIndex =0;
611
        mLastIndex  =0;
612

    
613
        mPtrID1 = INVALID_POINTER_ID;
614
        mPtrID2 = INVALID_POINTER_ID;
615

    
616
        mNumFingersDown = 0;
617

    
618
        mRenderer  = new RubikRenderer(this);
619
        mPreRender = new RubikPreRender(this);
620

    
621
        RubikActivity act = (RubikActivity)context;
622
        DisplayMetrics dm = new DisplayMetrics();
623
        act.getWindowManager().getDefaultDisplay().getMetrics(dm);
624

    
625
        mDensity = dm.densityDpi;
626

    
627
        final ActivityManager activityManager= (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
628

    
629
        if( activityManager!=null )
630
          {
631
          final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
632
          setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
633
          setRenderer(mRenderer);
634
          }
635
        }
636
      }
637

    
638
///////////////////////////////////////////////////////////////////////////////////////////////////
639

    
640
    @Override
641
    public boolean onTouchEvent(MotionEvent event)
642
      {
643
      int action = event.getActionMasked();
644

    
645
      switch(action)
646
         {
647
         case MotionEvent.ACTION_DOWN        : actionDown(event) ; break;
648
         case MotionEvent.ACTION_MOVE        : actionMove(event) ; break;
649
         case MotionEvent.ACTION_UP          : actionUp(event)   ; break;
650
         case MotionEvent.ACTION_POINTER_DOWN: actionDown2(event); break;
651
         case MotionEvent.ACTION_POINTER_UP  : actionUp2(event)  ; break;
652
         }
653

    
654
      return true;
655
      }
656
}
657

    
(4-4/4)