1 package com.badlogic.gdx.backends.android;
\r
3 import java.util.ArrayList;
\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
10 import com.badlogic.gdx.Application;
\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
18 public class AndroidInputThreePlus extends AndroidInput implements OnGenericMotionListener {
\r
19 ArrayList<OnGenericMotionListener> genericMotionListeners = new ArrayList();
\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
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
38 public void addGenericMotionListener (OnGenericMotionListener listener) {
\r
39 genericMotionListeners.add(listener);
\r