Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added possibility to center one of the axis only #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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 @@ -212,6 +212,16 @@ public interface OnMultipleLongPressListener {
private int mButtonDirection = 0;


public enum AxisToCenter {
BOTH, X, Y
}

/**
* axis to be centered
*/
private AxisToCenter axisToCenter = AxisToCenter.BOTH;


/*
CONSTRUCTORS
*/
Expand Down Expand Up @@ -540,8 +550,18 @@ private int getStrength() {
* Reset the button position to the center.
*/
public void resetButtonPosition() {
mPosX = mCenterX;
mPosY = mCenterY;
switch (axisToCenter) {
case BOTH:
mPosX = mCenterX;
mPosY = mCenterY;
break;
case X:
mPosX = mCenterX;
break;
case Y:
mPosY = mCenterY;
break;
}
}


Expand Down Expand Up @@ -800,6 +820,21 @@ public void setButtonDirection(int direction) {
mButtonDirection = direction;
}

/**
* get axis to be centered
* @return
*/
public AxisToCenter getAxisToCenter() {
return axisToCenter;
}

/**
* set axis to be centered
* @param axisToCenter
*/
public void setAxisToCenter(AxisToCenter axisToCenter) {
this.axisToCenter = axisToCenter;
}

/*
IMPLEMENTS
Expand Down