Skip to content

feat(ios): restore MIDI music, native haptics, and enhanced mobile controls - #1

Open
Yukaii wants to merge 9 commits into
anilseyrek:masterfrom
Yukaii:feat/midi-and-haptics
Open

Yukaii wants to merge 9 commits into
anilseyrek:masterfrom
Yukaii:feat/midi-and-haptics

Conversation

@Yukaii

@Yukaii Yukaii commented Aug 24, 2026

Copy link
Copy Markdown

Summary

This PR resolves key mobile gaps and enhances the iOS port with:

  1. Original MIDI background music playback via bundled FreePats General MIDI sound set.
  2. Authentic native tactile haptic feedback (flippers, plunger, tilt nudge, and ball bounces).
  3. Enhanced mobile menu with high scores viewer, demo mode, player count selection (1–4), volume sliders, and game exit.
  4. Fallback touch nudge zones and demo mode ball launch fixes.

Changes

1. MIDI Background Music

  • Bundled FreePats General MIDI GUS sound set in game_resources/timidity/ and configured timidity.cfg.
  • Wired Mix_SetTimidityCfg in midi.cpp on game launch before tracks load.
  • Updated extract_assets.py to download the FreePats sound set alongside Microsoft game data.
  • Handled iOS backgrounding and foregrounding lifecycle events to properly pause/resume audio playback without state desync.

2. Native iOS Haptic Feedback

  • Added Platform/iOS/Haptics.{h,mm} utilizing UIImpactFeedbackGenerator with pre-warming (prepare()).
  • Flippers: Crisp light transient on tap (UIImpactFeedbackStyleLight).
  • Plunger: Medium transient on release (UIImpactFeedbackStyleMedium).
  • Nudge: Medium transient on valid motion/touch nudge (UIImpactFeedbackStyleMedium).
  • Ball Bounces: Subtle soft micro-feedback (UIImpactFeedbackStyleSoft) dynamically scaled to collision impact velocity with a 45ms throttle against rail buzzing.

3. Mobile Menu & Controls Enhancements

  • Added High Scores viewer modal trigger.
  • Added Demo Mode toggle with reliable autonomous ball feeding and launching.
  • Added Player Selection (1–4 players) cycling.
  • Added interactive Sound Volume and Music Volume sliders.
  • Added Exit Game option.
  • Added optional Touch Nudge zones as fallback for simulators and devices without accelerometers.

4. Build & Resource Fixes

  • Fixed asset extraction destination path in extract_assets.py.
  • Updated CMakeModules/iOS.cmake to use CMAKE_SOURCE_DIR for bundle resources.
  • Updated documentation (README.md and Platform/iOS/README-iOS.md).

Testing

  • Verified on physical iPhone and iOS Simulator.
  • Verified simultaneous sound effects + MIDI playback.
  • Verified backgrounding/locking and returning restores audio cleanly.
  • Verified haptic sensations on flipper taps, plunger release, tilt nudges, and ball bounces.
  • Verified demo mode autonomously launches and plays.

Yukaii added 9 commits August 24, 2026 14:52
- P0: Restore MIDI background music on iOS by bundling FreePats GM instrument set and configuring SDL2_mixer Timidity backend via Mix_SetTimidityCfg(). Handle lifecycle background/foreground audio pause and resume.
- P1: Add native iOS haptic feedback (UIImpactFeedbackGenerator) for flipper press, plunger release, and accelerometer tilt nudge.
- P2: Add Haptics option toggle and enable Music by default in settings and mobile popup menu.
- Update asset extraction script to fetch FreePats sound set.
…and mobile menu controls

- Add touch nudge zones on upper-left and upper-right table areas as fallback for devices without accelerometer / simulator.
- Add High Scores viewer button to mobile popup menu.
- Add player count selection (1-4 players) to mobile menu.
- Add Demo Mode toggle to mobile menu.
- Add Sound and Music volume sliders to mobile menu.
- Add Language selection cycling to mobile menu.
- Update README and iOS documentation.
…emo mode

- Clean up orphaned plunger timer in TDemo::Message(Reset).
- Increase TPlunger PullbackDelay from 25ms to 150ms to ensure collision impulse transfers reliably across modern frame rates.
- Trigger demo plunger launch sequence when ball is fed or idle in plunger chute during demo mode.
… full width by default

- Restore PullbackDelay = 0.025f for smooth and responsive manual hold pullback.
- Separate ReleasedTimer duration (0.08s) from PullbackDelay.
- Default Touch Nudge to off so upper 28% remains full-width plunger by default.
…ollisions

- Add UIImpactFeedbackStyleSoft feedback generator for ball bounces.
- Trigger BallBounce in maths::basic_collision with intensity scaled by collision speed (threshold >= 0.3).
- Include 45ms rate limiter to prevent buzzing when rolling against rails.
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