Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ public interface OnMultipleLongPressListener {
*/
private int mButtonDirection = 0;

/*
* Detect if joystick has been pressed, even if strength and angle are 0
*/
private boolean isPressed = false;


/*
CONSTRUCTORS
Expand Down Expand Up @@ -438,7 +443,7 @@ public boolean onTouchEvent(MotionEvent event) {
mPosX = mButtonDirection > 0 ? mCenterX : (int) event.getX(); // direction positive is vertical axe

if (event.getAction() == MotionEvent.ACTION_UP) {

isPressed = false;
// stop listener because the finger left the touch screen
mThread.interrupt();

Expand All @@ -456,6 +461,7 @@ public boolean onTouchEvent(MotionEvent event) {
}

if (event.getAction() == MotionEvent.ACTION_DOWN) {
isPressed = true;
if (mThread != null && mThread.isAlive()) {
mThread.interrupt();
}
Expand Down Expand Up @@ -845,6 +851,13 @@ public void setButtonDirection(int direction) {
mButtonDirection = direction;
}

/*
* Returns whether or not joystick is pressed, independent of angle/strength
*/
public boolean isPressed(){
return isPressed;
}


/*
IMPLEMENTS
Expand All @@ -868,4 +881,4 @@ public void run() {
}
}
}
}
}