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 | ||
|
|
4ee3f23df8 |
@@ -200,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);
|
||||
@@ -265,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)
|
||||
@@ -290,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
|
||||
@@ -328,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(){
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="@drawable/ic_trigger_button_left"
|
||||
android:text="LB"
|
||||
android:text="L"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:textColor="#25FFFFFF"/>
|
||||
@@ -154,7 +154,7 @@
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:background="@drawable/ic_trigger_button_right"
|
||||
android:text="RB"
|
||||
android:text="R"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:textColor="#25FFFFFF"/>
|
||||
|
||||
+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