# Flat Android controls and HUD editor (Test31c / v1.0.13 code41)

Applies to the flat Android package `com.halo.decomp` (Android 9+ / ARM64). Quest
uses tracked controllers and has no flat touch overlay.

## Play with the defaults

| Control | Default action |
| --- | --- |
| MOVE | Walk, strafe and reverse; radial analog dead zone |
| LOOK | Swipe to turn; lift to stop; dragging FIRE also aims |
| FIRE | Shoot while held |
| A / Jump | Jump / menu confirm |
| B / Melee | Melee / menu cancel |
| X / Use | Reload; hold to interact / pick up |
| Y / Swap | Change weapon |
| Crouch / Zoom | Left / right stick clicks |
| Grenade | Throw selected grenade |
| Sprint | Shown only while SPRINT (Player profile > MOVEMENT) is HOLD or TOGGLE, and not over the menus: held, it sprints as the keyboard's key does (HOLD); a tap starts or stops it (TOGGLE). Test73b |
| Type / Light | Xbox black / white: grenade type / flashlight in default profile |
| Menu / Back | Start / Back |
| Arrows | D-pad and menu navigation |
| Touch | Auto / Always show / Always hide visibility policy |
| HUD | Open layout editing while the overlay is visible |

The game's selected controller profile still determines button actions. MOVE + FIRE/drag permits movement, aim and fire with two fingers. More fingers can operate other controls. Physical gamepads remain player one; stronger analog input wins and buttons merge. External mouse events pass through to SDL.

## Menus and fallback navigation

The original circular controls keep their saved positions in menus and gameplay;
there is no separate rectangular menu strip. MOVE or the arrows navigate,
**A / Jump** confirms, **B / Melee** or **Back** cancels, **X / Use** and
**Y / Swap** perform the game's displayed X/Y actions, and **Menu** sends Start.
These controls also work with the original stock menus if OpenCE loading fails.

Tap native menu rows or keyboard keys directly in uncovered space. A contact
belongs to either its circular control or the direct pointer, never both.
The existing **Touch** button changes visibility; **HUD** opens the editor.
Those recovery buttons remain reachable in menus when controls are hidden.
Returning to gameplay follows the saved visibility/controller policy. A finger
held through Resume must lift before it can operate a gameplay control.

## Customize during play

Tap **HUD** in the upper-left safe area. Held inputs are released. Drag any of the 20 controls (SPRINT among them while SPRINT is HOLD or TOGGLE). Selected controls turn amber. **Options** adjusts the selected control's horizontal/vertical position, size (65-160%) and opacity (15-100%). Its **Select a control** list can recover a control hidden under another control or the toolbar. Select a control in that list and turn off **Show and enable this touch control** to remove it from gameplay drawing and touch handling. Hidden controls remain faintly visible and selectable in the editor, and can be restored there. Existing installs default every control to visible.

Global options include scale (65-150%), opacity, independent horizontal/vertical sensitivity (0.25-3), radial dead zone (0-30%), floating movement origin, invert vertical aim, swipe versus held-stick aiming, optional drag-anywhere camera look, and blue/cyan/white/amber/green colors. Individual and global opacity multiply. Labels retain a minimum readability level.

**Save** commits the layout and all options to private app preferences. **Cancel** restores the last saved settings. **Reset** restores defaults in the working editor; Save commits that reset, Cancel undoes it. Editing and options suppress gameplay input, but an online match continues; find somewhere safe first. Editing does not pause the server.

### Export and import a touch layout

From **HUD > OPTIONS**, use **Export touch layout preset** or **Import touch layout preset**. Android's document picker lets you save or choose a `.hcecontrols` file; no broad file-storage permission is needed. A preset contains the touch positions, sizes, visibility, appearance, touch/gyro sensitivity and touch behavior. It does not contain gamepad mappings, saves, game files or account data. Import previews into the unsaved editor: tap **SAVE** to apply it or **CANCEL** to discard it. A canceled picker leaves the layout alone. Imports are versioned and validated, limited to 64 KiB, and reject unknown or out-of-range fields. Keep a copy of presets you want to reuse or share.

One full safe-area screen-width swipe turns 180 degrees at sensitivity 1. Start inside LOOK or FIRE, then drag beyond its circle if needed. Floating movement starts within MOVE and places the stick origin under that initial touch. Dead zone affects MOVE and held-stick look, not swipe look. Positions are normalized to the usable display and clamped to keep circles clear of edges and display cutouts. Resizing does not permanently rewrite saved positions.

## Optional drag-anywhere camera look

In gameplay, tap **HUD > OPTIONS**, enable **Drag anywhere to look (hide LOOK
pad)**, choose **Back to editor**, then **SAVE**. It is off by default.
The option appears in the existing Touch options dialog; it does not require a
new menu or launcher screen.

When enabled, only the **LOOK** joystick is hidden. Its former area joins the
free-look space; MOVE, FIRE and the other controls retain their positions.
LOOK stays visible in the editor and returns to its saved position when the
option is disabled. In menus its uncovered area accepts direct menu taps.

A finger that starts outside all controls can drag to turn the view. Its camera
control lasts until it lifts, even when crossing over a button. MOVE and all
buttons have priority when a touch starts inside them, including a button held
by another finger. One free-space finger can aim alongside movement and other
buttons. It uses the existing horizontal/vertical sensitivity and invert
settings, always as a relative swipe even when the dedicated LOOK control uses
held-stick mode. It does not operate in menus or the HUD editor, does not change
physical gamepad mappings, and is absent from Quest VR. **Cancel** restores the
saved choice; **Reset + Save** disables it again.

## Gyro aim (1.0.10, an option)

Turn the phone to aim. It is **off by default**. Turn it on in the game (tap **HUD**, then **Options**, then **Gyro aim**, then **Save**) or in the launcher (**Controller & touch settings**). Both places change the same setting.

- **Always on:** the phone's turn always aims.
- **Only while a finger is on LOOK or FIRE:** the phone aims only while you touch LOOK or hold FIRE. Lift your thumb to turn the phone back without moving the view, like lifting a mouse off the desk.
- **Gyro horizontal / vertical sensitivity** (0.25-4 in the game, 25-400% in the launcher): at 1 (100%) the view turns as far as the phone does.
- **Invert gyro vertical aim.**

Gyro aim works together with swipes, sticks and a controller. It uses the gravity sensor where the phone has one, so turning your body turns the view whether you hold the phone upright or tilted back. A phone held still does not drift. Like swipe aim, it turns off the controller's aim magnetism while you use it, unless `input.mouse_aim_assist` is on. It pauses while you edit the HUD, in menus, and when the game is in the background. Phones without a gyroscope show "no gyroscope on this device".

## Input safeguards

Contacts own their initial control by pointer ID until release; sliding across another control does not press it. Quick button taps survive between native polls. Cancel, pause, focus loss, hide, resize, editor entry and detachment clear held input and pending edges. Relative aim is accumulated in radians and consumed once, independent of the game's stick turn rate; motion older than 250 ms is discarded. Cancellation generations clear already-polled motion. The host/guest record is 32 bytes, with four axes, a button mask, relative yaw/pitch and generation. VR compiles out the writer/merge.

## Validation and references

`tools/test_test31_touch_lifecycle.py` compiles the complete production
`TouchControls` view with deterministic Android framework doubles. It executes
real touch streams, menu/fallback navigation, menu-to-game transitions,
controller hide/disconnect, editing dialogs, Save/Cancel/Reset, free-space look
and multi-touch ownership. It does not prove Android rendering or device
acceptance. `tools/test_test31_flat_pointer.py` additionally checks the actual
JNI snapshot and native pointer bridge.

`tools/test_test15_io.py` executes the production JNI snapshot functions with mocked time, and checks pure touch layout math over 16:9, 20:9, 4:3 and portrait dimensions. Tests cover taps, cancellation, stale motion, NaN, clamps and diagonal analog movement. Android Java and both native flavors must compile. These checks do not constitute phone gameplay acceptance.

Usability references: Activision's [Warzone Mobile control customization guide](https://www.callofduty.com/uk/en/blog/2024/03/call-of-duty-warzone-mobile-complete-control-plus-customization-controller-options) (position, scale, transparency and sensitivity), and Android's [multi-touch guidance](https://developer.android.com/develop/ui/views/touch-and-input/gestures/multi). No game control code or artwork from those references was copied.

Gyro aim math and wiring: `tools/test_test28.py` (display rotations, tilt, sensitivity, invert, still phone, bad samples).

Device checks to collect: simultaneous move/fire/aim/jump, menus and controller profiles, cancel/focus/rotation, save/reopen/cancel/reset, controls under toolbar and notches, gamepad coexistence, and confirmation that Quest has no touch overlay. Automated checks do not establish physical-device acceptance.

Additional native-port reference: id Software's public [DOOM iOS HUD editor](https://github.com/id-Software/DOOM-iOS/blob/master/code/iphone/hud.c), reviewed for drag ownership, screen-edge clamping and saved-control lifecycle. This was design comparison only; none of its GPL code/art was copied into this implementation.

Controller & touch settings in the launcher controls automatic hiding and recovery. Auto is the default; only a fully mapped SDL gamepad hides the HUD. Always hide is an explicit override; restore visibility in the launcher. See [controller support](ANDROID-GAMEPAD.md).


# Android controller guide (v1.0.10)

For the flat ARM64 Android APK in v1.0.10, Android's input system and bundled
SDL3 translate common USB/Bluetooth gamepads into Halo's Xbox controller state.
Xbox-style controllers are the primary target. There is no Windows XInput DLL
to install. Pair in Android settings or connect USB, then launch the game.
The launcher has **Controller & touch settings** and **Controller input check**.
The latter displays Android buttons and both common right-stick/trigger axis
conventions; the launch log records SDL recognition and ready-controller count.
No device identifiers, input telemetry or settings are uploaded.

## Default controls

| Xbox position | Halo default |
| --- | --- |
| Left stick | Move / strafe; menu selection |
| Right stick | Aim; vehicle camera/steering follows Halo's controls |
| RT | Fire, analog trigger |
| LT | Throw selected grenade, analog trigger |
| A (south) | Jump / confirm |
| B (east) | Melee / cancel |
| X (west) | Reload; hold to use / pick up / enter or exit vehicles |
| Y (north) | Switch weapons |
| LB | Flashlight (original Xbox white button) |
| RB | Switch grenade type (original Xbox black button) |
| Left stick click | Crouch |
| Right stick click | Zoom |
| Start / Menu | Pause; launcher confirm |
| Back / View | Halo Back input / multiplayer score display |
| D-pad | Menu navigation and game-specific navigation |

These are the native default profile. Halo's Options retains controller layouts,
look sensitivity and inverted aim. PlayStation Cross/Circle/Square/Triangle map
by south/east/west/north position. Nintendo pads default to the same positions;
the optional A/B + X/Y swap follows the printed face labels in gameplay and
uses the same confirm/cancel swap in launcher dialogs. Guide/Home remains an
Android system function. Rear paddles depend on the controller's own mapping.

## Touch and reconnect behavior

- **Auto (default):** hide the complete touch HUD only after SDL has a mapped,
  opened gamepad with both sticks and triggers. A keyboard, TV remote or partial
  joystick cannot hide it. Show it again when the last ready pad disconnects.
- **Always show:** touch and the first gamepad merge into player one; releasing
  a touch cannot cancel a held controller button. Stronger stick input wins.
- **Always hide:** deliberate override, including after disconnect. Restore
  Auto/Show in the launcher. The in-game Touch button also opens this policy.

Detection refreshes every half second while the activity is resumed and on
Android device-change notifications. All touch contacts clear on visibility
changes. Active HUD editing stays visible until saved/cancelled. Unplugged SDL
handles are closed/recycled; reconnecting does not exhaust the handle table.
The first recognized pad shares player one. Additional native ports retain
existing behavior; this is not a new Android split-screen feature.

## Response and vibration

Launcher settings offer independent movement/aim dead zones (0-45%), horizontal
and vertical stick response (25-200%), trigger dead zone (0-40%), face-button
swap and vibration on/off. They apply on the next game launch. Defaults keep
the original Halo stick dead zone (~27.5%) and 100% response; trigger default
is 5%. The host compensates for the guest's existing 9000-unit dead zone so
two dead zones are not stacked. This does not change touch or VR input.

SDL handles Android trigger-axis aliases. A reviewed patch to pinned SDL 3.4.16
adds missing generic Android mappings for button-only L2/R2: Java carries their
capability bits and C maps them to independent trigger axes. Existing analog
mappings take priority; no duplicate button injection is used. Both
trigger values remain independently bounded. Halo motor values reach SDL rumble
when enabled; capability depends on Android version, controller driver and USB
versus Bluetooth. Unsupported vibration never blocks input. On focus loss the
flat physical pad returns neutral; rumble is stopped by the next feedback call
or expires within 100 ms. Gameplay is not paused by disconnecting during an
online match. Automatic touch recovery avoids leaving the player stranded.

## Menus and checking a controller

The native game menus receive the same Xbox state as gameplay. Launcher and
project dialogs use Android focus controls: D-pad/left stick navigates with
repeat, A confirms, B returns. Stick repeats stop on neutral, focus loss,
window closure or device removal. Text entry/file selection may use Android's
system keyboard/picker; their controller support is provided by Android.

1. Connect an Xbox-style pad by USB, then repeat using Bluetooth if supported.
2. Open input check; verify every button, both stick axes and independent triggers.
3. Navigate launcher/browser/options using only the pad; launch a campaign.
4. Check each action above, hold/release triggers, diagonal movement, menus,
   invert/sensitivity and supported vibration.
5. Unplug while moving/firing: no held input, touch returns in Auto. Reconnect.
6. Background/resume, switch gamepad models, and test touch plus pad in Always show.
7. Recheck Quest controllers, touch gameplay and paired co-op with both candidate APKs.

Automated checks execute the production host adapter with mock SDL devices,
all 65,536 raw stick values, 600 disconnect/reconnect cycles, focus/rumble gates,
trigger bounds, the production SDL analog/digital trigger mapper and
visibility/navigation policies. These do not certify a
physical controller/driver, Bluetooth transport, Android focus behavior or
headset regression. Device acceptance remains pending.

## Primary references

- [Android controller overview](https://developer.android.com/games/sdk/game-controller/overview)
- [Android controller actions and trigger aliases](https://developer.android.com/games/sdk/game-controller/controller-input)
- [SDL3 gamepad API](https://wiki.libsdl.org/SDL3/CategoryGamepad)
- Bundled SDL Android joystick/controller implementation, `host_sdl.c`,
  `xinput_sdl.c`, and `source/input/input_abstraction.c` are the implementation
  evidence for these mappings. SDL's mapping database remains bundled and does
  not download unreviewed runtime input code.
