OSDN Git Service

fixed Nate's fuck up, cause he's just a minion
[mikumikustudio/libgdx-mikumikustudio.git] / backends / gdx-backend-android / src / com / badlogic / gdx / backends / android / AndroidInputThreePlus.java
1 package com.badlogic.gdx.backends.android;\r
2 \r
3 import java.util.ArrayList;\r
4 \r
5 import android.content.Context;\r
6 import android.view.MotionEvent;\r
7 import android.view.View;\r
8 import android.view.View.OnGenericMotionListener;\r
9 \r
10 import com.badlogic.gdx.Application;\r
11 \r
12 /**\r
13  * Subclass of AndroidInput, used on Androd +3.x to get generic motion events for \r
14  * things like gampads/joysticks and so on.\r
15  * @author mzechner\r
16  *\r
17  */\r
18 public class AndroidInputThreePlus extends AndroidInput implements OnGenericMotionListener {\r
19         ArrayList<OnGenericMotionListener> genericMotionListeners = new ArrayList();\r
20         \r
21         public AndroidInputThreePlus (Application activity, Context context, Object view, AndroidApplicationConfiguration config) {\r
22                 super(activity, context, view, config);\r
23                 // we hook into View, for LWPs we call onTouch below directly from\r
24                 // within the AndroidLivewallpaperEngine#onTouchEvent() method.\r
25                 if (view instanceof View) {\r
26                         View v = (View)view;\r
27                         v.setOnGenericMotionListener(this);\r
28                 }\r
29         }\r
30         \r
31         @Override\r
32         public boolean onGenericMotion (View view, MotionEvent event) {\r
33                 for (int i = 0, n = genericMotionListeners.size(); i < n; i++)\r
34                         if (genericMotionListeners.get(i).onGenericMotion(view, event)) return true;\r
35                 return false;\r
36         }\r
37         \r
38         public void addGenericMotionListener (OnGenericMotionListener listener) {\r
39                 genericMotionListeners.add(listener);\r
40         }\r
41 }\r