diff --git a/README.md b/README.md index 8f01cec..8df50c5 100644 --- a/README.md +++ b/README.md @@ -48,4 +48,3 @@ From the main game list, open the side menu (toolbar "menu" icon) and look under ## License This project is licensed under the [GNU GPL v3.0](LICENSE). -If you distribute builds (including on Google Play), GPL requires providing the corresponding source code to recipients (see [Source & Third-Party](#source--third-party)). diff --git a/android/app/src/main/cpp/android_input_system.cpp b/android/app/src/main/cpp/android_input_system.cpp index 7e8c53b..7a4cb84 100644 --- a/android/app/src/main/cpp/android_input_system.cpp +++ b/android/app/src/main/cpp/android_input_system.cpp @@ -175,6 +175,19 @@ void AndroidInputSystem::ApplyConfig(const Util::Config::Node& config) m_touchSpikeBeat.a = keySc(get("InputBeat", "KEY_S"), SDL_SCANCODE_S); m_touchSpikeCharge.a = keySc(get("InputCharge", "KEY_D"), SDL_SCANCODE_D); m_touchSpikeJump.a = keySc(get("InputJump", "KEY_F"), SDL_SCANCODE_F); + + m_touchFishingCast.a = keySc(get("InputFishingCast", "KEY_Z"), SDL_SCANCODE_Z); + m_touchFishingSelect.a = keySc(get("InputFishingSelect", "KEY_X"), SDL_SCANCODE_X); + m_touchFishingReel.a = keySc(get("InputFishingReel", "KEY_SPACE"), SDL_SCANCODE_SPACE); + m_touchFishingTension.a = keySc(get("InputFishingTension", "KEY_T"), SDL_SCANCODE_T); + + m_touchMagPedal1.a = keySc(get("InputMagicalPedal1", "KEY_A"), SDL_SCANCODE_A); + m_touchMagPedal2.a = keySc(get("InputMagicalPedal2", "KEY_S"), SDL_SCANCODE_S); + + m_touchSkiPollLeft.a = keySc(get("InputSkiPollLeft", "KEY_A"), SDL_SCANCODE_A); + m_touchSkiPollRight.a = keySc(get("InputSkiPollRight", "KEY_S"), SDL_SCANCODE_S); + m_touchSkiSelect1.a = keySc(get("InputSkiSelect1", "KEY_Q"), SDL_SCANCODE_Q); + m_touchSkiSelect2.a = keySc(get("InputSkiSelect2", "KEY_W"), SDL_SCANCODE_W); } bool AndroidInputSystem::InitializeSystem() @@ -340,6 +353,16 @@ void AndroidInputSystem::HandleTouch(const SDL_TouchFingerEvent& tf, bool down) case 1116: SetKeys(m_touchSpikeBeat, down); return; case 1117: SetKeys(m_touchSpikeCharge, down); return; case 1118: SetKeys(m_touchSpikeJump, down); return; + case 1120: SetKeys(m_touchFishingCast, down); return; + case 1121: SetKeys(m_touchFishingSelect, down); return; + case 1122: SetKeys(m_touchFishingReel, down); return; + case 1123: SetKeys(m_touchFishingTension, down); return; + case 1130: SetKeys(m_touchMagPedal1, down); return; + case 1131: SetKeys(m_touchMagPedal2, down); return; + case 1140: SetKeys(m_touchSkiPollLeft, down); return; + case 1141: SetKeys(m_touchSkiPollRight, down); return; + case 1142: SetKeys(m_touchSkiSelect1, down); return; + case 1143: SetKeys(m_touchSkiSelect2, down); return; default: break; } diff --git a/android/app/src/main/cpp/android_input_system.h b/android/app/src/main/cpp/android_input_system.h index a39010f..8b28bd0 100644 --- a/android/app/src/main/cpp/android_input_system.h +++ b/android/app/src/main/cpp/android_input_system.h @@ -141,6 +141,19 @@ private: DualScancode m_touchSpikeCharge{SDL_SCANCODE_D, SDL_SCANCODE_UNKNOWN}; DualScancode m_touchSpikeJump{SDL_SCANCODE_F, SDL_SCANCODE_UNKNOWN}; + DualScancode m_touchFishingCast{SDL_SCANCODE_Z, SDL_SCANCODE_UNKNOWN}; + DualScancode m_touchFishingSelect{SDL_SCANCODE_X, SDL_SCANCODE_UNKNOWN}; + DualScancode m_touchFishingReel{SDL_SCANCODE_SPACE, SDL_SCANCODE_UNKNOWN}; + DualScancode m_touchFishingTension{SDL_SCANCODE_T, SDL_SCANCODE_UNKNOWN}; + + DualScancode m_touchMagPedal1{SDL_SCANCODE_A, SDL_SCANCODE_UNKNOWN}; + DualScancode m_touchMagPedal2{SDL_SCANCODE_S, SDL_SCANCODE_UNKNOWN}; + + DualScancode m_touchSkiPollLeft{SDL_SCANCODE_A, SDL_SCANCODE_UNKNOWN}; + DualScancode m_touchSkiPollRight{SDL_SCANCODE_S, SDL_SCANCODE_UNKNOWN}; + DualScancode m_touchSkiSelect1{SDL_SCANCODE_Q, SDL_SCANCODE_UNKNOWN}; + DualScancode m_touchSkiSelect2{SDL_SCANCODE_W, SDL_SCANCODE_UNKNOWN}; + bool m_gunTouchEnabled = false; SDL_FingerID m_gunFinger = 0; bool m_gunFingerActive = false; diff --git a/android/app/src/main/java/com/izzy2lost/super3/Super3Activity.kt b/android/app/src/main/java/com/izzy2lost/super3/Super3Activity.kt index 1c718ea..0a21856 100644 --- a/android/app/src/main/java/com/izzy2lost/super3/Super3Activity.kt +++ b/android/app/src/main/java/com/izzy2lost/super3/Super3Activity.kt @@ -140,6 +140,26 @@ class Super3Activity : SDLActivity() { gamesXml.isNotBlank() && GameInputsIndex.hasAnyInputType(gamesXml, game, setOf("gun1", "gun2", "analog_gun1", "analog_gun2")) + val isSoccer = + game.isNotBlank() && + gamesXml.isNotBlank() && + GameInputsIndex.hasAnyInputType(gamesXml, game, setOf("soccer", "twin_joysticks")) + + val isFishing = + game.isNotBlank() && + gamesXml.isNotBlank() && + GameInputsIndex.hasAnyInputType(gamesXml, game, setOf("fishing")) + + val isSki = + game.isNotBlank() && + gamesXml.isNotBlank() && + GameInputsIndex.hasAnyInputType(gamesXml, game, setOf("ski")) + + val isMagTruck = + game.isNotBlank() && + gamesXml.isNotBlank() && + GameInputsIndex.hasAnyInputType(gamesXml, game, setOf("magtruck")) + val isFighting = game.isNotBlank() && gamesXml.isNotBlank() && @@ -150,12 +170,15 @@ class Super3Activity : SDLActivity() { gamesXml.isNotBlank() && GameInputsIndex.hasAnyInputType(gamesXml, game, setOf("spikeout")) + val showFightButtons = isFighting || isSpikeout || isSoccer || isFishing || isSki + val showFightStick = showFightButtons || isMagTruck + val shifterEnabled = getSharedPreferences("super3_prefs", MODE_PRIVATE) .getBoolean("overlay_shifter_enabled", false) val showShifter = shifterEnabled && (hasShift4 || hasShiftUpDown) overlay.findViewById(R.id.overlay_pedals)?.visibility = - if (isRacing) View.VISIBLE else View.GONE + if (isRacing || isMagTruck) View.VISIBLE else View.GONE overlay.findViewById(R.id.overlay_wheel)?.visibility = if (isRacing) View.VISIBLE else View.GONE @@ -167,10 +190,10 @@ class Super3Activity : SDLActivity() { if (isGunGame) View.VISIBLE else View.GONE overlay.findViewById(R.id.overlay_fight_stick)?.visibility = - if (isFighting || isSpikeout) View.VISIBLE else View.GONE + if (showFightStick) View.VISIBLE else View.GONE overlay.findViewById(R.id.overlay_fight_buttons)?.visibility = - if (isFighting || isSpikeout) View.VISIBLE else View.GONE + if (showFightButtons) View.VISIBLE else View.GONE fun nativeTouch(action: Int, fingerId: Int, x: Float, y: Float, p: Float = 1.0f) { SDLActivity.onNativeTouch(0, fingerId, action, x, y, p) @@ -233,10 +256,14 @@ class Super3Activity : SDLActivity() { bindMomentary(R.id.overlay_reload, fingerId = 1109, x = 0.90f, y = 0.90f) } - if (isFighting || isSpikeout) { + if (showFightButtons) { val baseId = if (isSpikeout) { 1115 + } else if (isFishing) { + 1120 + } else if (isSki) { + 1140 } else { 1110 } @@ -245,7 +272,9 @@ class Super3Activity : SDLActivity() { bindHeld(R.id.overlay_fight_kick, fingerId = baseId + 1, x = 0.82f, y = 0.65f) bindHeld(R.id.overlay_fight_guard, fingerId = baseId + 2, x = 0.90f, y = 0.45f) bindHeld(R.id.overlay_fight_escape, fingerId = baseId + 3, x = 0.82f, y = 0.35f) + } + if (showFightStick) { val stick = overlay.findViewById(R.id.overlay_fight_stick) val knob = overlay.findViewById(R.id.overlay_fight_stick_knob) stick?.setOnTouchListener { v, ev -> @@ -294,47 +323,54 @@ class Super3Activity : SDLActivity() { overlay.findViewById(R.id.overlay_fight_stick)?.setOnTouchListener(null) } - if (isRacing) { + if (isRacing || isMagTruck) { + val gasId = if (isMagTruck) 1130 else 1103 + val brakeId = if (isMagTruck) 1131 else 1104 + // Match the native pedal zone (right-middle), independent of UI placement. - bindHeld(R.id.overlay_gas, fingerId = 1103, x = 0.85f, y = 0.35f) - bindHeld(R.id.overlay_brake, fingerId = 1104, x = 0.85f, y = 0.80f) + bindHeld(R.id.overlay_gas, fingerId = gasId, x = 0.85f, y = 0.35f) + bindHeld(R.id.overlay_brake, fingerId = brakeId, x = 0.85f, y = 0.80f) val wheel = overlay.findViewById(R.id.overlay_wheel) - wheel?.setOnTouchListener { v, ev -> - val w = v.width.toFloat().coerceAtLeast(1f) - val cx = w / 2f - val dx = (ev.x - cx) / cx - val steer = dx.coerceIn(-1f, 1f) + if (isRacing) { + wheel?.setOnTouchListener { v, ev -> + val w = v.width.toFloat().coerceAtLeast(1f) + val cx = w / 2f + val dx = (ev.x - cx) / cx + val steer = dx.coerceIn(-1f, 1f) - v.rotation = steer * 75f + v.rotation = steer * 75f - val encodedX = ((steer + 1f) / 2f).coerceIn(0f, 1f) - val encodedY = 0.5f + val encodedX = ((steer + 1f) / 2f).coerceIn(0f, 1f) + val encodedY = 0.5f - when (ev.actionMasked) { - MotionEvent.ACTION_DOWN -> { - v.alpha = 0.75f - nativeTouch(MotionEvent.ACTION_DOWN, 1107, encodedX, encodedY) - true + when (ev.actionMasked) { + MotionEvent.ACTION_DOWN -> { + v.alpha = 0.75f + nativeTouch(MotionEvent.ACTION_DOWN, 1107, encodedX, encodedY) + true + } + MotionEvent.ACTION_MOVE -> { + nativeTouch(MotionEvent.ACTION_MOVE, 1107, encodedX, encodedY) + true + } + MotionEvent.ACTION_UP -> { + v.alpha = 1.0f + v.rotation = 0f + nativeTouch(MotionEvent.ACTION_UP, 1107, 0.5f, encodedY) + true + } + MotionEvent.ACTION_CANCEL -> { + v.alpha = 1.0f + v.rotation = 0f + nativeTouch(MotionEvent.ACTION_UP, 1107, 0.5f, encodedY) + true + } + else -> true } - MotionEvent.ACTION_MOVE -> { - nativeTouch(MotionEvent.ACTION_MOVE, 1107, encodedX, encodedY) - true - } - MotionEvent.ACTION_UP -> { - v.alpha = 1.0f - v.rotation = 0f - nativeTouch(MotionEvent.ACTION_UP, 1107, 0.5f, encodedY) - true - } - MotionEvent.ACTION_CANCEL -> { - v.alpha = 1.0f - v.rotation = 0f - nativeTouch(MotionEvent.ACTION_UP, 1107, 0.5f, encodedY) - true - } - else -> true } + } else { + wheel?.setOnTouchListener(null) } val shifter = overlay.findViewById(R.id.overlay_shifter)