View Javadoc

1   /*
2    * Copyright 2007-2008 motej
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License. 
15   */
16  package motejx.adapters;
17  
18  import motejx.extensions.classic.ClassicControllerAnalogListener;
19  import motejx.extensions.classic.LeftAnalogStickEvent;
20  import motejx.extensions.classic.LeftAnalogTriggerEvent;
21  import motejx.extensions.classic.RightAnalogStickEvent;
22  import motejx.extensions.classic.RightAnalogTriggerEvent;
23  
24  /**
25   * 
26   * <p>
27   * @author <a href="mailto:vfritzsch@users.sourceforge.net">Volker Fritzsch</a>
28   */
29  public abstract class StatefulClassicControllerAnalogAdapter implements
30  		ClassicControllerAnalogListener {
31  
32  	protected LeftAnalogStickEvent latestLeftAnalogStickEvent;
33  	protected RightAnalogStickEvent latestRightAnalogStickEvent;
34  	protected LeftAnalogTriggerEvent latestLeftAnalogTriggerEvent;
35  	protected RightAnalogTriggerEvent latestRightAnalogTriggerEvent;
36  	
37  	/* (non-Javadoc)
38  	 * @see motejx.extensions.classic.ClassicControllerAnalogListener#leftAnalogStickChanged(motejx.extensions.classic.LeftAnalogStickEvent)
39  	 */
40  	public void leftAnalogStickChanged(LeftAnalogStickEvent evt) {
41  		if (!evt.equals(latestLeftAnalogStickEvent)) {
42  			latestLeftAnalogStickEvent = evt;
43  			leftAnalogStickStateChanged(evt);
44  		}
45  	}
46  
47  	public abstract void leftAnalogStickStateChanged(LeftAnalogStickEvent evt);
48  
49  	/* (non-Javadoc)
50  	 * @see motejx.extensions.classic.ClassicControllerAnalogListener#leftAnalogTriggerChanged(motejx.extensions.classic.LeftAnalogTriggerEvent)
51  	 */
52  	public void leftAnalogTriggerChanged(LeftAnalogTriggerEvent evt) {
53  		if (!evt.equals(latestLeftAnalogTriggerEvent)) {
54  			latestLeftAnalogTriggerEvent = evt;
55  			leftAnalogTriggerStateChanged(evt);
56  		}
57  	}
58  
59  	public abstract void leftAnalogTriggerStateChanged(LeftAnalogTriggerEvent evt);
60  
61  	/* (non-Javadoc)
62  	 * @see motejx.extensions.classic.ClassicControllerAnalogListener#rightAnalogStickChanged(motejx.extensions.classic.RightAnalogStickEvent)
63  	 */
64  	public void rightAnalogStickChanged(RightAnalogStickEvent evt) {
65  		if (!evt.equals(latestRightAnalogStickEvent)) {
66  			latestRightAnalogStickEvent = evt;
67  			rightAnalogStickStateChanged(evt);
68  		}
69  	}
70  
71  	public abstract void rightAnalogStickStateChanged(RightAnalogStickEvent evt);
72  
73  	/* (non-Javadoc)
74  	 * @see motejx.extensions.classic.ClassicControllerAnalogListener#rightAnalogTriggerChanged(motejx.extensions.classic.RightAnalogTriggerEvent)
75  	 */
76  	public void rightAnalogTriggerChanged(RightAnalogTriggerEvent evt) {
77  		if (!evt.equals(latestRightAnalogTriggerEvent)) {
78  			latestRightAnalogTriggerEvent = evt;
79  			rightAnalogTriggerStateChanged(evt);
80  		}
81  	}
82  
83  	public abstract void rightAnalogTriggerStateChanged(RightAnalogTriggerEvent evt);
84  
85  }