mirror of
https://github.com/jamessanford/kegs.git
synced 2025-02-08 18:30:46 +00:00
Add special touch zone to Joystick driver.
This commit is contained in:
parent
54108c346f
commit
f5f5a3b70b
@ -392,13 +392,17 @@ public class KegsMain extends SherlockFragmentActivity implements KegsKeyboard.S
|
||||
updateActionBar(bitmapSize.showActionBar());
|
||||
|
||||
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() {
|
||||
mOverrideActionBar = !mOverrideActionBar;
|
||||
updateActionBar(mOverrideActionBar);
|
||||
}
|
||||
});
|
||||
};
|
||||
mKegsTouch.setSpecialZone(zone);
|
||||
mJoystick.setSpecialZone(zone);
|
||||
|
||||
// Force another redraw of the bitmap into the canvas. Bug workaround.
|
||||
getThread().updateScreen();
|
||||
|
@ -13,6 +13,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
class TouchJoystick {
|
||||
private ConcurrentLinkedQueue mEventQueue;
|
||||
private TouchSpecialZone mSpecialZone = null;
|
||||
private int mTouchSlop;
|
||||
|
||||
private int mMotionPointer = -1; // active pointer Id
|
||||
@ -33,6 +34,10 @@ class TouchJoystick {
|
||||
// mTouchSlop = configuration.getScaledTouchSlop();
|
||||
}
|
||||
|
||||
public void setSpecialZone(TouchSpecialZone zone) {
|
||||
mSpecialZone = zone;
|
||||
}
|
||||
|
||||
private void reset_tracks(boolean resetA, boolean resetB) {
|
||||
if (resetA && trackA != null) {
|
||||
trackA.recycle();
|
||||
@ -134,8 +139,10 @@ class TouchJoystick {
|
||||
if (mMotionPointer == -1) {
|
||||
// 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.
|
||||
mButton1 = 1;
|
||||
mEventQueue.add(new Event.JoystickKegsEvent(0xFFFF, 0xFFFF, mButton1));
|
||||
if (mSpecialZone != null && !mSpecialZone.click(e, pointerId)) {
|
||||
mButton1 = 1;
|
||||
mEventQueue.add(new Event.JoystickKegsEvent(0xFFFF, 0xFFFF, mButton1));
|
||||
}
|
||||
}
|
||||
// SEND JOYSTICK BUTTON UP
|
||||
mButton1 = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user