ShizuStore

RedTrigger

zampierilucas

3.0.15 · GitHub

Download APK
Vendor-specific Android 10+ 3 months ago MIT
6 ShizuStore
431 GitHub
14 Stars
18 MB Size

More about this app

System-wide shoulder triggers for Nubia Red Magic phones

RedTrigger

How It Works • Requirements • Setup • Building • Architecture

Android Min SDK 29 MIT License Shizuku

Get it on F-Droid


Android app that enables shoulder triggers (SAR capacitive sensors) on Nubia Red Magic phones system-wide, without needing Game Space.

Screenshots

Main screen    Debug log    About

The Problem

Nubia's game framework controls the shoulder trigger hardware. Triggers only work inside Game Space, and the system resets trigger settings every time you switch apps. RedTrigger fixes both issues.

How It Works

  1. Sets nubia_game_scene=1 to activate SAR sensors without launching full Game Space
  2. Runs a foreground service with a ContentObserver watchdog that detects when Nubia's SystemMgr resets the setting (on every notifyActivityResumed)
  3. Re-applies trigger settings instantly, keeping triggers active across all apps

Key Remapping (via Shizuku)

The Nubia game service intercepts the raw trigger keys (F7/F8) and converts them to screen taps. RedTrigger works around this by:

  • Reading raw input events from /dev/input/eventX using a Shizuku UserService (getevent)
  • Optionally injecting remapped key events (L1/R1) so apps like KeyMapper can capture them
  • Using a virtual uinput device for injection so events appear as real hardware input

Requirements

  • Nubia Red Magic phone (tested on Red Magic 11 Pro)
  • Shizuku installed and running

Setup

  1. Install RedTrigger from F-Droid (or build the APK yourself)
  2. Install and start Shizuku (wireless ADB or root)
  3. Open RedTrigger and grant Shizuku permission when prompted
  4. Tap "Enable Triggers"

RedTrigger automatically grants itself the required WRITE_SECURE_SETTINGS permission via Shizuku, so no manual ADB commands are needed.

The watchdog service starts automatically and persists across app switches. Enable "Auto-enable on boot" in the app to survive reboots.

Building

Requires Android SDK and JDK 17.

# Using justfile (recommended)
just build        # Build debug APK
just ship         # Build + copy to shared storage
just version      # Show current version
just bump-patch   # 3.0.0 → 3.0.1
just bump-minor   # 3.0.0 → 3.1.0
just clean        # Clean build artifacts

# Or directly with Gradle
ANDROID_HOME=/path/to/android-sdk \
JAVA_HOME=/path/to/jdk-17 \
./gradlew assembleDebug --no-daemon --no-configuration-cache

APK output: app/build/outputs/apk/debug/RedTrigger-v{version}.apk

Architecture

Component Description
TriggerManager Reads/writes Android Global Settings to enable/disable triggers
TriggerService Foreground service with ContentObserver watchdog
InputReader Manages Shizuku UserService lifecycle (app process)
InputService Shizuku UserService that reads /dev/input/eventX (Shizuku process)
uinput_injector Native C binary that creates a virtual gamepad via /dev/uinput
BootReceiver Re-enables triggers on device boot
DebugLog In-app log buffer with color-coded UI display

Communication between the app process and Shizuku process uses AIDL:

  • IInputService.aidl — app → Shizuku (start/stop, config)
  • ITriggerCallback.aidl — Shizuku → app (trigger events, debug)

SAR Input Devices

The shoulder triggers appear as capacitive touch sensors:

  • Left trigger (SAR0) → KEY_F7
  • Right trigger (SAR1) → KEY_F8
  • Device names contain nubia_tgk_aw_sar

Tech Stack

  • Kotlin + Jetpack Compose
  • Material 3
  • Shizuku API
  • Native C (uinput virtual gamepad)
  • Android SDK 35 (min SDK 29)

License

MIT © Lucas Zampieri

Close

How Shizuku is used

Can read Nubia shoulder triggers and remap them to gamepad buttons via Shizuku with `getevent` and `pm grant`.

This is an AI-assisted analysis of Shizuku-related usages in the app's public source code. It is best effort, so it may not catch every single usage.

How this app uses Shizuku

RedTrigger uses Shizuku to run a privileged input service that unlocks system-wide shoulder triggers on Nubia Red Magic phones.

  • Detect trigger hardware: finds the capacitive shoulder sensors by listing input devices with the getevent -pl shell command through Shizuku and filtering for Nubia SAR devices.
  • Read trigger presses: streams press and release events for the left and right triggers with the getevent -ql shell command through Shizuku, mapping them from KEY_F7 and KEY_F8.
  • Self grant settings permission: grants itself WRITE_SECURE_SETTINGS with the pm grant shell command through Shizuku, then turns on the Nubia trigger settings for game scene, game mode and gesture blocking.
  • Keep triggers enabled: watches those system settings and rewrites them if the system resets them, so triggers stay active system-wide.
  • Remap to gamepad buttons: when injection is on, forwards trigger presses to a virtual gamepad device created by its bundled helper, so games see them as standard L1 and R1 buttons.

Android APIs or commands used

  • getevent -pl
  • getevent -ql
  • pm grant
  • pm path
  • Settings.Global.putInt

Notable details

Trigger activation targets Nubia specific settings (nubia_game_scene, nubia_game_mode, cc_game_mis_operate). If no SAR trigger device is found, the service listens on all input devices instead. Key injection to L1 and R1 can be toggled in settings.

Close

Changelog

What's new for version 3.0.15

Close

Permissions

7 permissions requested

  • android.permission.WRITE_SECURE_SETTINGS
  • android.permission.RECEIVE_BOOT_COMPLETED
  • android.permission.FOREGROUND_SERVICE
  • android.permission.FOREGROUND_SERVICE_SPECIAL_USE
  • android.permission.POST_NOTIFICATIONS
  • com.redtrigger.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION
  • moe.shizuku.manager.permission.API_V23
Close

Sources

2 sources

3.0.15 GitHub · com.redtrigger
Selected Download
3.0.15 F-Droid · com.redtrigger · com.redtrigger
Download