mirror of
https://github.com/izzy2lost/2ship2harkinian-Android.git
synced 2026-06-19 01:20:08 -07:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
821dd700ff | ||
|
|
ef7780ffaa |
@@ -149,25 +149,6 @@ public class MainActivity extends SDLActivity{
|
||||
}
|
||||
}
|
||||
|
||||
File configFile = new File(getExternalFilesDir(null), "2ship2harkinian.json");
|
||||
if (!configFile.exists()) {
|
||||
try {
|
||||
InputStream in = getAssets().open("2ship2harkinian.json");
|
||||
OutputStream out = new FileOutputStream(configFile);
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int read;
|
||||
while ((read = in.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, read);
|
||||
}
|
||||
|
||||
in.close();
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private native void nativeHandleSelectedFile(String filePath);
|
||||
@@ -219,6 +200,7 @@ public class MainActivity extends SDLActivity{
|
||||
|
||||
|
||||
public native void attachController();
|
||||
public native void detachController();
|
||||
// Native method for setting button state
|
||||
public native void setButton(int button, boolean value);
|
||||
public native void setCameraState(int axis, float value);
|
||||
@@ -284,10 +266,10 @@ public class MainActivity extends SDLActivity{
|
||||
addTouchListener(buttonX, ControllerButtons.BUTTON_X); // SDL Button 2 (X)
|
||||
addTouchListener(buttonY, ControllerButtons.BUTTON_Y); // SDL Button 3 (Y)
|
||||
|
||||
addTouchListener(buttonDpadUp, ControllerButtons.BUTTON_DPAD_UP); // SDL Button 10 (D-Pad Up)
|
||||
addTouchListener(buttonDpadDown, ControllerButtons.BUTTON_DPAD_DOWN); // SDL Button 11 (D-Pad Down)
|
||||
addTouchListener(buttonDpadLeft, ControllerButtons.BUTTON_DPAD_LEFT); // SDL Button 12 (D-Pad Left)
|
||||
addTouchListener(buttonDpadRight, ControllerButtons.BUTTON_DPAD_RIGHT); // SDL Button 13 (D-Pad Right)
|
||||
setupCButtons(buttonDpadUp, ControllerButtons.AXIS_RY, 1); // SDL Button 10 (D-Pad Up)
|
||||
setupCButtons(buttonDpadDown, ControllerButtons.AXIS_RY , -1); // SDL Button 11 (D-Pad Down)
|
||||
setupCButtons(buttonDpadLeft, ControllerButtons.AXIS_RX, 1); // SDL Button 12 (D-Pad Left)
|
||||
setupCButtons(buttonDpadRight, ControllerButtons.AXIS_RX, -1); // SDL Button 13 (D-Pad Right)
|
||||
|
||||
addTouchListener(buttonLB, ControllerButtons.BUTTON_LB); // SDL Button 4 (LB)
|
||||
addTouchListener(buttonRB, ControllerButtons.BUTTON_RB); // SDL Button 5 (RB)
|
||||
@@ -309,14 +291,19 @@ public class MainActivity extends SDLActivity{
|
||||
private void setupToggleButton(Button button, ViewGroup uiGroup){
|
||||
boolean isHidden = preferences.getBoolean("controlsVisible", false); // Default to 'false' (visible)
|
||||
uiGroup.setVisibility(isHidden ? View.INVISIBLE : View.VISIBLE); // Set the initial visibility based on the saved state
|
||||
/*if(isHidden){
|
||||
detachController();
|
||||
}*/
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
boolean isHidden = false;
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (isHidden) {
|
||||
uiGroup.setVisibility(View.VISIBLE); // Show UI elements
|
||||
//attachController();
|
||||
} else {
|
||||
uiGroup.setVisibility(View.INVISIBLE); // Hide UI elements
|
||||
//detachController();
|
||||
}
|
||||
preferences.edit().putBoolean("controlsVisible", !isHidden).apply();
|
||||
isHidden = !isHidden; // Toggle state
|
||||
@@ -347,6 +334,28 @@ public class MainActivity extends SDLActivity{
|
||||
});
|
||||
}
|
||||
|
||||
private void setupCButtons(Button button, int buttonNum, int direction) {
|
||||
button.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
setAxis(buttonNum, direction<0 ? Short.MAX_VALUE : Short.MIN_VALUE);
|
||||
button.setPressed(true);
|
||||
return true;
|
||||
case MotionEvent.ACTION_UP:
|
||||
setAxis(buttonNum, (short) 0);
|
||||
button.setPressed(false);
|
||||
return true;
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
setAxis(buttonNum, (short) 0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
boolean TouchAreaEnabled = true;
|
||||
|
||||
void DisableTouchArea(){
|
||||
|
||||
+1
-1
Submodule libultraship updated: 2860d3df9c...e823c0fa72
@@ -101,8 +101,8 @@ bool Camera_FreeLook(Camera* camera) {
|
||||
|
||||
#ifdef __ANDROID__
|
||||
if(Ship::Mobile::IsUsingTouchscreenControls()) {
|
||||
yawDiff = -Ship::Mobile::GetCameraYaw()*10.0f;
|
||||
pitchDiff = Ship::Mobile::GetCameraPitch()*10.0f;
|
||||
yawDiff += -Ship::Mobile::GetCameraYaw()*10.0f;
|
||||
pitchDiff += Ship::Mobile::GetCameraPitch()*10.0f;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user