mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-16 08:05:34 -04:00
Move click and touch listener to separate
This commit is contained in:
parent
abc40ff025
commit
0585f29567
@ -8,36 +8,19 @@ import net.kdt.pojavlaunch.customcontrols.*;
|
||||
import net.kdt.pojavlaunch.prefs.*;
|
||||
import org.lwjgl.glfw.*;
|
||||
|
||||
public class CustomCtrlMainActivity extends BaseMainActivity implements OnClickListener, OnTouchListener {
|
||||
public class CustomCtrlMainActivity extends BaseMainActivity {
|
||||
private CustomControls mControl;
|
||||
private ControlLayout mControlLayout;
|
||||
|
||||
private View.OnClickListener mClickListener;
|
||||
private View.OnTouchListener mTouchListener;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
initLayout(R.layout.main_with_customctrl);
|
||||
|
||||
ControlData[] specialButtons = ControlData.getSpecialButtons();
|
||||
specialButtons[0].specialButtonListener
|
||||
= specialButtons[1].specialButtonListener
|
||||
= specialButtons[4].specialButtonListener
|
||||
= ((View.OnClickListener) this);
|
||||
|
||||
specialButtons[2].specialButtonListener
|
||||
= specialButtons[3].specialButtonListener
|
||||
= specialButtons[5].specialButtonListener
|
||||
= ((View.OnTouchListener) this);
|
||||
|
||||
mControlLayout = findViewById(R.id.main_control_layout);
|
||||
mControl = new CustomControls();
|
||||
mControlLayout.setModifiable(false);
|
||||
loadControl(LauncherPreferences.PREF_DEFAULTCTRL_PATH);
|
||||
mControlLayout.loadLayout(mControl);
|
||||
|
||||
// toggleGui(null);
|
||||
mControlLayout.toggleControlVisible();
|
||||
}
|
||||
|
||||
mClickListener = new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (view instanceof ControlButton) {
|
||||
@ -57,7 +40,9 @@ public class CustomCtrlMainActivity extends BaseMainActivity implements OnClickL
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
mTouchListener = new View.OnTouchListener(){
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent e) {
|
||||
boolean isDown;
|
||||
@ -77,7 +62,6 @@ public class CustomCtrlMainActivity extends BaseMainActivity implements OnClickL
|
||||
|
||||
if (view instanceof ControlButton) {
|
||||
ControlButton button = (ControlButton) view;
|
||||
appendToLog("Debug: touch special btn " + button.getProperties().keycode);
|
||||
switch (button.getProperties().keycode) {
|
||||
case ControlData.SPECIALBTN_MOUSEPRI:
|
||||
sendMouseButton(LWJGLGLFWKeycode.GLFW_MOUSE_BUTTON_LEFT, isDown);
|
||||
@ -101,6 +85,28 @@ public class CustomCtrlMainActivity extends BaseMainActivity implements OnClickL
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
ControlData[] specialButtons = ControlData.getSpecialButtons();
|
||||
specialButtons[0].specialButtonListener
|
||||
= specialButtons[1].specialButtonListener
|
||||
= specialButtons[4].specialButtonListener
|
||||
= mClickListener;
|
||||
|
||||
specialButtons[2].specialButtonListener
|
||||
= specialButtons[3].specialButtonListener
|
||||
= specialButtons[5].specialButtonListener
|
||||
= mTouchListener;
|
||||
|
||||
mControlLayout = findViewById(R.id.main_control_layout);
|
||||
mControl = new CustomControls();
|
||||
mControlLayout.setModifiable(false);
|
||||
loadControl(LauncherPreferences.PREF_DEFAULTCTRL_PATH);
|
||||
mControlLayout.loadLayout(mControl);
|
||||
|
||||
// toggleGui(null);
|
||||
mControlLayout.toggleControlVisible();
|
||||
}
|
||||
|
||||
private void loadControl(String path) {
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user