mirror of
https://github.com/jamessanford/kegs.git
synced 2024-06-07 00:29:27 +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());
|
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();
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user