Skip to content

libretro: fix Boktai 1 solar bar mapping and add external analog solar input mode#320

Open
TideGear wants to merge 2 commits intolibretro:masterfrom
TideGear:solar-fixes
Open

libretro: fix Boktai 1 solar bar mapping and add external analog solar input mode#320
TideGear wants to merge 2 commits intolibretro:masterfrom
TideGear:solar-fixes

Conversation

@TideGear
Copy link

Summary

This PR intentionally contains two commits:

  • b78535f: fix a long-standing Boktai 1 solar meter bug in libretro (8 bars treated like 10)
  • e4d1e6c: add external analog solar input mode and update solar option labels

What changed

  • Fix Boktai 1 solar handling to use its real 8-bar meter behavior instead of 10-bar behavior.
  • Keep Boktai 2/3 behavior unchanged (10 bars).
  • Add a new Solar Sensor core option value: Use external sensor (Ojo del Sol).
  • In external mode:
    • poll all connected libretro input ports
    • require R3 hold as an unlock gate
    • read Right Stick X+ deflection and map it to bars with floor/clamp logic
    • apply per-game max bars (Boktai 1: 8, Boktai 2/3: 10)
  • Suppress default L3/R3 brighten/darken stepping while external mode is active.
  • Update option labels for clarity (Solar Sensor, Static: N bars, including intl tables).

Why

  • Boktai 1 only has 8 bars; treating it like 10 causes overshoot and incorrect stepping.
  • External analog input gives fast, predictable meter control.
  • This works both with external hardware and a normal gamepad:
    • hold R3
    • move right stick right for more sun
  • The interface is generic and open for other devices to target, not tied to one product.

How to test

  1. Load Boktai 1 and verify solar stepping no longer behaves like a 10-bar meter.
  2. Load Boktai 2 or 3 and verify 10-bar behavior is unchanged.
  3. In Core Options, set Solar Sensor to Use external sensor (Ojo del Sol).
  4. Without holding R3, move right stick: solar value should not update.
  5. Hold R3 and move right stick right: solar value should track stick deflection.
  6. Release R3 while maintaining deflection to lock in the solar value.
  7. Confirm L3/R3 brighten/darken binds do not interfere while external mode is active.
  8. Switch back to sensor and static values; verify normal behavior still works.

Notes

  • I am the creator of the Ojo del Sol, but this implementation is intentionally usable without it.
  • If naming the option with Ojo del Sol is considered too product-specific, I can rename it to a generic label.
  • Most line churn is from mirrored option-table updates in libretro_core_options_intl.h.

Boktai 1 only has 8 solar sensor bars, but the libretro core
exposed all 10 steps (matching Boktai 2/3) for every Boktai game.
This caused L3/R3 presses to overshoot — the player had to cycle
through 10 increments when only 8 are meaningful.

Detect Boktai 1 at ROM load time by checking the game code
(U3IJ, U3IE, U3IP) and store the result in a static bool.

Add two mapping functions that convert between the internal
10-step index and the 8-bar user-facing value. Steps 3/4 both
map to bar 3 and steps 8/9 both map to bar 7, matching the
game's native bar boundaries.

Apply the mapping in all input paths: L3/R3 stepping, static
core option values, and sensor-based input. The internal
luxLevelIndex and shared GBA_LUX_LEVELS array are unchanged,
so Boktai 2/3 and all other platforms are unaffected.
… option labels

Rename the mgba_solar_sensor_level option label from Solar Sensor Level to Solar Sensor.
Add a new option value: external (Use external sensor (Ojo del Sol)).
Relabel static levels to Static: N bars (0 through 10) in both default and intl core option tables.
Implement external sensor input handling in the libretro runtime:
Scan all connected input ports.
Require R3 held as the unlock gate.
Read Right Stick X+ deflection and map to bars with floor/clamp behavior.
Apply Boktai-specific bar ranges (0-8 for Boktai 1, 0-10 for Boktai 2/3).
Suppress default R3/L3 brighten/darken solar binds while external mode is active so they do not interfere.
@TideGear
Copy link
Author

Open to questions and suggestions!

@TideGear TideGear marked this pull request as ready for review February 26, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant