How hammadzaigham/preysense works
1. Project shape
- PreySense is a single Windows desktop app built with .NET 10 / WinForms.
- The executable is the main user-facing control panel; there is no separate backend service in this repo.
2. Top-level orchestration
- Program.cs launches the WinForms app.
- MainForm is the central shell and is split by concern into Core, Startup, Refresh, Power, Battery, Rgb, Layout, and the designer file.
- This form coordinates all hardware actions, UI refreshes, mode switching, and device state polling.
3. Hardware control boundary
- The app’s core purpose is to bypass Acer Predator Sense and talk directly to hardware/vendor interfaces.
- The main integration points are:
- Acer WMI / AcerService for laptop-specific controls
- NVIDIA NVML / wrapper code for GPU metrics and control
- PawnIO / MSR access for CPU power-limit and low-level tuning
- Windows input hooks for hotkeys and physical key integration
4. Performance mode subsystem
- Mode/ contains the logic for user-selectable performance profiles.
- ProfileManager, PerformanceProfile, PowerLimitController, and FanCurveStorage manage per-mode settings such as power limits, fan curves, and GPU offsets.
- This subsystem is the main state model for the app and feeds both UI and hardware actions.
5. Fan and thermal control
- Fan/ implements custom fan-curve UI and logic.
- Fan settings are likely persisted per profile and applied through Acer-specific control paths.
- The fan subsystem is tightly coupled to performance modes and the on-screen overlay.
6. GPU control and mode switching
- Gpu/ handles NVIDIA-related operations, including clock offsets and GPU mode switching.
- NvidiaWrapper, NvmlHelper, and NvidiaGpuControl form a small abstraction over NVIDIA APIs.
- GPU mode choices map to laptop platform modes such as iGPU-only, hybrid, or dGPU-exclusive operation.
7. Battery, power, and display controls
- Battery/ manages charge limits.
- MainForm.Power and related helpers manage platform power settings and display behavior.
- Helpers/Display/ includes display management and RGB profile support, suggesting refresh-rate switching and color-profile coordination are first-class features.
8. RGB lighting subsystem
- Rgb/ and Color/ provide keyboard lighting controls and color configuration UI.
- Helpers/Hardware/AcerServiceClient and documentation under docs/acer_service_rgb.md indicate RGB control is done through Acer service protocol interactions, not generic Windows lighting APIs.
9. Input and automation
- Input/ handles global keyboard hooks and Predator-key-related shortcuts.
- KeyboardHook, WmiHotkeyWatcher, and QuickAccessModeWatcher allow the app to react to physical laptop controls and trigger mode changes without needing the main window focused.
10. Overlay / HUD subsystem
- Overlay/ implements a custom hardware telemetry HUD.
- It combines real-time metrics from ETW, process/memory helpers, and native drawing/windowing to show FPS, temperatures, power, fan RPM, and usage graphs.
- This is a separate presentation surface from the main control UI, but it shares hardware state with the core app.
11. UI architecture
- UI/Controls/ contains a large custom control library themed for the app.
- RForm, MetricsSettingsForm, and related controls suggest a strongly branded, custom-drawn WinForms UI rather than standard system widgets.
- The UI layer is primarily a presentation boundary over the hardware/mode subsystems.
12. Persistence and configuration
- User settings, profiles, fan curves, and app state are stored in the registry under HKCU\SOFTWARE\PreySense.
- The app also appears to maintain model-specific or feature-specific state in helper classes rather than a separate database or config service.
13. Platform assumptions and operational boundary
- The app is explicitly Windows-only and intended for Acer Predator hardware with compatible WMI/service interfaces.
- Some capabilities require extra system components: admin rights, the PawnIO driver, and Acer service components for RGB or low-level control.
14. Support files and release tooling
- docs/ contains reverse-engineering notes, BIOS/service scripts, and backup service packages used for compatibility work.
- .github/workflows/release.yml and publish.ps1 indicate automated packaging/release support, but they are not part of runtime architecture.
Main entry points: MainForm.cs Main Form · AcerServiceClient.cs Hardware APIs · ProfileManager.cs Profiles · MainForm.Core.cs Core
Components 19
App shell
WinForms entrypoint and main window orchestration
- Program · Starts the WinForms application
app/Program.cs - Main Form · Central app window coordinating startup, refresh, layout, power, battery, and RGB
app/MainForm/MainForm.cs - Core · MainForm core coordination logic
app/MainForm/MainForm.Core.cs - Startup · MainForm startup and initialization flow
app/MainForm/MainForm.Startup.cs - Refresh · MainForm UI and device refresh cycle
app/MainForm/MainForm.Refresh.cs - Power · MainForm power and display behavior controls
app/MainForm/MainForm.Power.cs - Battery · MainForm battery and charge-limit controls
app/MainForm/MainForm.Battery.cs - RGB · MainForm RGB integration and mode coordination
app/MainForm/MainForm.Rgb.cs
Hardware integration
Direct vendor and low-level system interfaces
- Hardware APIs · Acer WMI/service, NVIDIA NVML, and PawnIO/MSR adapters
app/Helpers/Hardware/AcerServiceClient.cs - Display Helpers · Display management and RGB profile support
app/Helpers/Display/DisplayManager.cs - PawnIO · Low-level MSR and PawnIO wrapper layer
app/Pawn/PawnIOWrapper.cs
Control planes
User-facing subsystems that manage modes, power, fans, GPU, battery, RGB, and input
- Profiles · Performance profile state and per-mode settings
app/Mode/ProfileManager.cs - Fans · Fan curve UI and fan tuning logic
app/Fan/Fans.cs - GPU · NVIDIA control and GPU mode switching
app/Gpu/NvidiaGpuControl.cs - Battery Control · Battery charge-limit feature boundary
app/Battery/BatteryControl.cs - RGB Form · Keyboard lighting control surface
app/Rgb/RgbForm.cs - Input · Global hooks and laptop key watchers
app/Input/KeyboardHook.cs
Connections 23
- Program → Main Form: launches · Application entry creates the main window
- Main Form → Startup: starts · Startup initializes hardware and UI state
- Main Form → Core: coordinates · Core shell owns feature wiring
- Main Form → Refresh: polls · Refresh loop updates UI and device state
- Main Form → Power: controls · Power-related actions flow through the main form
- Main Form → Battery: controls · Battery controls are surfaced from the main shell
- Main Form → RGB: controls · RGB actions are routed through the main shell
- Core → Profiles: uses · Main orchestration reads and applies performance profiles
- Core → Hardware APIs: invokes · Core actions call vendor and low-level hardware interfaces
- Profiles → Fans: feeds · Profiles include fan-curve settings
- Profiles → GPU: feeds · Profiles include GPU mode and offset settings
- Profiles → PawnIO: applies via · Power limits and tuning values are applied through MSR access
- Fans → Hardware APIs: writes · Fan settings are pushed through Acer-specific control paths
- GPU → Hardware APIs: uses · GPU operations rely on NVIDIA wrapper and NVML access
- Battery Control → Hardware APIs: uses · Charge-limit control uses vendor/system interfaces
- RGB Form → Hardware APIs: uses · Lighting control uses Acer service protocol
- Input → Core: triggers · Hotkeys and key watchers switch modes or update state
- Overlay → Profiles: reads · HUD reflects current performance profile state
- Overlay → Hardware APIs: monitors · Overlay displays real-time telemetry from hardware sources
- Overlay → Display Helpers: coordinates · Overlay presentation shares display and profile helpers
- UI Kit → Main Form: composes · Custom controls build the main WinForms shell
- Power → Display Helpers: uses · Power and refresh behavior coordinate with display management
- RGB → Display Helpers: uses · RGB workflow coordinates with display/profile helpers