Add special touch zone to Joystick driver.

This commit is contained in:
James Sanford 2012-12-21 19:57:07 -08:00
parent 54108c346f
commit f5f5a3b70b
2 changed files with 16 additions and 5 deletions

View File

@ -392,13 +392,17 @@ public class KegsMain extends SherlockFragmentActivity implements KegsKeyboard.S
updateActionBar(bitmapSize.showActionBar()); updateActionBar(bitmapSize.showActionBar());
mKegsView.updateScreenSize(bitmapSize); mKegsView.updateScreenSize(bitmapSize);
mKegsTouch.setSpecialZone(
new TouchSpecialZone(getSpecialActionBarRect(bitmapSize)) {
// Update special click zone that toggles the ActionBar.
final TouchSpecialZone zone = new TouchSpecialZone(getSpecialActionBarRect(bitmapSize)) {
public void activate() { public void activate() {
mOverrideActionBar = !mOverrideActionBar; mOverrideActionBar = !mOverrideActionBar;
updateActionBar(mOverrideActionBar); updateActionBar(mOverrideActionBar);
} }
}); };
mKegsTouch.setSpecialZone(zone);
mJoystick.setSpecialZone(zone);
// Force another redraw of the bitmap into the canvas. Bug workaround. // Force another redraw of the bitmap into the canvas. Bug workaround.
getThread().updateScreen(); getThread().updateScreen();

View File

@ -13,6 +13,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
class TouchJoystick { class TouchJoystick {
private ConcurrentLinkedQueue mEventQueue; private ConcurrentLinkedQueue mEventQueue;
private TouchSpecialZone mSpecialZone = null;
private int mTouchSlop; private int mTouchSlop;
private int mMotionPointer = -1; // active pointer Id private int mMotionPointer = -1; // active pointer Id
@ -33,6 +34,10 @@ class TouchJoystick {
// mTouchSlop = configuration.getScaledTouchSlop(); // mTouchSlop = configuration.getScaledTouchSlop();
} }
public void setSpecialZone(TouchSpecialZone zone) {
mSpecialZone = zone;
}
private void reset_tracks(boolean resetA, boolean resetB) { private void reset_tracks(boolean resetA, boolean resetB) {
if (resetA && trackA != null) { if (resetA && trackA != null) {
trackA.recycle(); trackA.recycle();
@ -134,8 +139,10 @@ class TouchJoystick {
if (mMotionPointer == -1) { if (mMotionPointer == -1) {
// No active movement, assume this click/release should be a button press/release. // No active movement, assume this click/release should be a button press/release.
// TODO it probably shouldn't be sent if they had their finger down for more than 500ms or so. // TODO it probably shouldn't be sent if they had their finger down for more than 500ms or so.
mButton1 = 1; if (mSpecialZone != null && !mSpecialZone.click(e, pointerId)) {
mEventQueue.add(new Event.JoystickKegsEvent(0xFFFF, 0xFFFF, mButton1)); mButton1 = 1;
mEventQueue.add(new Event.JoystickKegsEvent(0xFFFF, 0xFFFF, mButton1));
}
} }
// SEND JOYSTICK BUTTON UP // SEND JOYSTICK BUTTON UP
mButton1 = 0; mButton1 = 0;