Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Edits propagate **in real time** to both the Controls Table and the Device View

**DirectInput product-GUID matching (`src/utils/directinput_guid.py`)** — SC profile XML stores joysticks with a `Product` attribute like `{PIDVID-0000-0000-0000-504944564944}` (the trailing constant is "PIDVID" in ASCII; the first 8 hex chars encode `(PID << 16) | VID`). This module parses VID/PID out of that GUID so connected pygame joysticks (whose `get_guid()` returns SDL's joystick-GUID format) can be matched to profile entries without ever calling DirectInput. Pure parsing, zero runtime deps. This powers the Config tab's device-to-joystick mapping.

**Check Profile (`src/utils/profile_checker.py`, `src/utils/system_devices.py`, `src/gui/profile_check_dialog.py`)** — Reads the raw profile XML (exported layout or live `actionmaps.xml`, which wraps everything in `<ActionProfiles>`) and reports problems as findings with severities. The device-numbering check compares each `<options type="joystick" instance="N" Product="…">` VID/PID with the Nth connected stick; `system_devices.py` gets that order from DirectInput on Windows (what SC uses), pygame elsewhere (approximate), or the mock backend. Unsaved edits are checked via a temp XML export.

**Theme system (`src/gui/theme.py`)** — Ported from sibling project `smart-citizen` for visual cohesion. Themes are applied by swapping the `QPalette` on the `QApplication`; widgets relying on `WindowText`/`Text` palette roles re-color automatically. Secondary/dim labels opt in via `setProperty("role", "secondary")` and an app-level QSS rule installed by `apply_theme`. The branded `Hyperspace Race Expanded` font (`assets/fonts/HyperspaceRace-ExpandedBold.otf`) is registered at startup via `load_application_fonts()` — the family name Qt reports is the prefixed `"FONTSPRING DEMO - …"` string, which is what the title bar matches.

**Input detection (`src/utils/input_detector.py`)** — Joystick (pygame), keyboard with modifier support (pynput), mouse (pynput). Runs in a thread with a 10-second timeout; communicates with the UI via Qt signals. Used by the Remap Dialog. Joysticks are read through `src/utils/joystick_backend.py` (pygame by default); `--mock-joysticks [file.json]` / `SCPE_MOCK_JOYSTICKS` swaps in virtual sticks plus a Virtual Joysticks panel, so device and Remap work can be tested with no hardware (see `docs/DEVELOPMENT.md`).
Expand Down Expand Up @@ -90,7 +92,7 @@ docs/ CHANGELOG, DEVELOPMENT, RELEASE_PROCESS, CREATING_PDF_TEMP
scripts/ ad-hoc utility scripts (NOT build scripts — see Build below)
includes generate_pdf_template.py used by the Add-Device-from-Template flow
deprecated/ old SVG/PNG/OCR system removed in v0.4.0; ignore unless excavating history
tests/ pytest unit tests: test_parser.py, test_directinput_guid.py, test_parse_joy_label.py
tests/ pytest unit tests (parser, DI GUIDs, joy labels, joystick backend, profile checker)
ABOUT.md rendered in the About tab at runtime (bundled into the exe)
README.md end-user guide (also rendered in-app)
VERSION.TXT single source of truth for version (read by src/utils/version.py)
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,19 @@ All export buttons are in the top header. Exports respect your current view (def

All exports use the **"Show Detailed"** setting - uncheck it for simplified exports, check it for complete details.

### Checking a Profile for Problems

Click **"Check Profile"** in the top header (enabled once a profile is loaded). SCPE looks for problems the game won't warn you about:

- **Device numbering** — compares the profile's js1, js2, … with the order this PC numbers your sticks right now. If they differ, bindings meant for one stick land on another in game. The dialog shows both side by side; re-plug the sticks and press **Check again** until every slot matches.
- **Sticks missing or added** — a profile stick that isn't connected, or a connected stick the profile doesn't know (which can push the others to higher numbers).
- **View actions forced to "press"** — look behind, view yaw and similar are hold actions; a forced "press" can leave the camera stuck.
- **One button switching several modes** — e.g. set salvage mode and toggle mining mode on the same button.
- **Tuning saved under an old device ID** — deadzone/saturation stored for an ID no stick in the profile has, so the game ignores it.
- **Partly bound hats**, **bindings on buttons a stick doesn't have**, and **js1 never cleared** (so the game's default joystick bindings still apply on it).

Unsaved edits are included in the check. On Windows, SCPE reads the stick order from DirectInput, the same source Star Citizen uses.

### Filtering and Searching Bindings

The **Controls Table** has multiple ways to find and organize what you're looking for:
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **Mislabeled Virpil templates** (issue #31) — `VPC MT-50CM3 (Left/Right)` are actually Alpha Prime grip diagrams on a MongoosT-50CM3 base and are now named that way. A dedicated MT-50CM3 **throttle** template still needs to be authored.

### Added
- **Check Profile** — A new header button checks the loaded profile (including unsaved edits) for problems Star Citizen doesn't report: the profile's js1/js2/… devices numbered differently from how this PC currently lists the sticks (so bindings would land on the wrong stick), profile sticks not connected or connected sticks missing from the profile, view/look actions forced to `activationMode="press"` (stuck camera), one input bound to several mode switches, deadzone/saturation tuning stored under a device ID no profile stick has, partly bound hats, bindings on buttons/hats a stick doesn't have, and js1 never cleared so game-default joystick bindings still apply. On Windows the stick order comes from DirectInput (the order the game uses, via `ctypes`, no new dependency); elsewhere from pygame, and in `--mock-joysticks` mode from the virtual sticks, so it is testable without hardware. **Check again** re-reads the sticks after re-plugging.
- **Develop and test without joysticks attached** — Joystick access now goes through a swappable backend (`src/utils/joystick_backend.py`). Run `python src/main.py --mock-joysticks [devices.json]` (or set `SCPE_MOCK_JOYSTICKS`) to replace real sticks with virtual ones described in a JSON file; a **Virtual Joysticks** panel opens beside the main window, and clicking its buttons, hats and axis sliders feeds the Remap dialog's *Detect Input* exactly as a real stick would. Presets in `tests/fixtures/mock_devices/` carry the VID/PID of the sticks in `example-profiles/`, so Config-tab mapping and Device View behave as on the joystick machine. The virtual setup can mirror any SC profile: by default it rebuilds from each profile you open (names, VID/PID, and enough buttons/hats for every binding), **Load setup…** picks any profile or devices file, and `--mock-joysticks` also accepts a profile `.xml`. Input-code translation is now a pure function with unit tests, and scripted fixtures replay recorded event sequences through the real detector loop in pytest. Normal launches are unchanged.
- **Release process ported from smart-citizen** — Long-lived `release/X.Y.Z` integration branches; PRs target the release branch and merging it to `main` is the release trigger. New workflows: `ci.yml` (tests + PyInstaller build verification on every PR to `main`/`release/**`), `release.yml` (on merge to `main`: auto-tags `v{VERSION}` from `VERSION.TXT`, builds the installer, publishes the GitHub Release with the CHANGELOG section as its body, posts to Discord), `installer-preview.yml` (add the `build-installer` label to a PR for a tester installer artifact), `installer-preview-cleanup.yml`, and `release-notify.yml` (manual Discord re-post). `.github/CODEOWNERS` requests review from the maintainer on every PR. `/start_release`, `/pre_release` and `/ship_release` commands walk the cycle with checkpoints; `docs/RELEASE_PROCESS.md` documents it.
- **Scripted build** — `scripts/build/build_exe.py` (PyInstaller `--onedir`, stable `SCProfileEditor.exe` name so shortcuts survive upgrades) and `scripts/build/build_all.bat`. `installer.iss` now reads the version from `VERSION.TXT` at compile time, so `VERSION.TXT` is the single place to bump. `scripts/release_notes.py` extracts a version's CHANGELOG section for the release body. `requirements-dev.txt` holds the test/build deps.
Expand Down
10 changes: 9 additions & 1 deletion docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Logging level is set in `src/main.py` — flip `logging.INFO` → `logging.DEBUG

## Testing

There is no UI test harness. Unit tests cover the parser, DirectInput GUID parsing, label parsing, and joystick input translation / the mock backend; all run without hardware.
There is no UI test harness. Unit tests cover the parser, DirectInput GUID parsing, label parsing, joystick input translation / the mock backend, and the Check Profile logic; all run without hardware.

```bash
pytest tests/
Expand Down Expand Up @@ -88,6 +88,14 @@ A **Virtual Joysticks** window opens next to the main window. Open a binding, pr

Copy `product` straight from an `<options type="joystick" Product="…">` line in an SC profile (or give `"vid"`/`"pid"` as hex strings) to mimic your own sticks. The optional `script` replays events each time detection starts; tests use it to run the real detection loop against recorded sequences (`tests/test_joystick_backend.py`, `recorded_session.json`).

**Check Profile without hardware.** In mock mode the virtual sticks are "this PC" for the Check Profile dialog, in panel order. To see a device-numbering mismatch, start with a devices file that lists the sticks in a different order from the profile:

```bash
python src/main.py --mock-joysticks tests/fixtures/mock_devices/check_profile_swapped.json
```

then open `tests/fixtures/profiles/check_profile_problems.xml` and click **Check Profile**: FSM.GA and T-Rudder show as swapped, along with one example of every other check. The logic lives in `src/utils/profile_checker.py` (pure, no Qt) and `src/utils/system_devices.py` (DirectInput order on Windows, pygame elsewhere, mock sticks in mock mode); `tests/test_profile_checker.py` covers it.

The devices file's order is the js order: the first device is `js1`. Mock mode is a developer flag only; release builds behave exactly as before unless it is passed.

**Other routes** if you need Star Citizen itself to see a fake stick (not just SCPE): install vJoy on Windows and drive it from a feeder app or `pyvjoy`. SCPE's pygame backend picks vJoy devices up like any other stick, no mock mode needed. `test_plan.md` and `TEST_PLAN_v0.8.2.md` at the repo root are historical references for what coverage typically looks like.
Expand Down
39 changes: 39 additions & 0 deletions src/gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@ def setup_ui(self):
self.save_profile_btn.setEnabled(False) # Disabled until profile is modified
action_row.addWidget(self.save_profile_btn)

self.check_profile_btn = QPushButton("Check Profile")
self.check_profile_btn.setStyleSheet("QPushButton { padding: 10px 20px; font-size: 14px; }")
self.check_profile_btn.setToolTip(
"Look for problems the game won't tell you about: sticks numbered differently on this PC, "
"view actions stuck on \"press\", one button switching several modes, tuning saved under "
"an old device ID, and more")
self.check_profile_btn.clicked.connect(self.check_profile)
self.check_profile_btn.setEnabled(False)
action_row.addWidget(self.check_profile_btn)

# Neutral-chrome buttons (export + help) inherit the theme's default
# Button palette role.
_neutral_btn_qss = "QPushButton { padding: 10px 20px; font-size: 14px; }"
Expand Down Expand Up @@ -934,6 +944,7 @@ def display_profile(self):
self.profile_name_input.setText(profile.profile_name)
self.profile_name_input.setEnabled(True)
self.update_profile_name_btn.setEnabled(True)
self.check_profile_btn.setEnabled(True)

# Update profile info label
self.profile_info_label.setText(f"Profile: {profile.profile_name}")
Expand Down Expand Up @@ -2417,6 +2428,34 @@ def on_update_profile_name(self):

logger.info(f"Profile name updated to: {new_name}")

def _profile_xml_for_check(self, temp_dir: str):
"""The XML to check: the file on disk, or a temp export when the
profile has unsaved edits (or was never saved)."""
profile = self.current_profile
if not profile:
return None
source = profile.source_xml_path or self.current_profile_path
if source and os.path.exists(source) and not profile.is_modified:
return source
from exporters.xml_exporter import export_profile, XMLExporter
out = os.path.join(temp_dir, "profile_to_check.xml")
if source and os.path.exists(source):
ok = export_profile(profile, source, out)
else:
ok = XMLExporter.create_new_profile(profile, out)
return out if ok else None

def check_profile(self):
"""Open the Check Profile dialog for the current profile."""
if not self.current_profile:
return
import tempfile
from gui.profile_check_dialog import ProfileCheckDialog
with tempfile.TemporaryDirectory(prefix="scpe-check-") as temp_dir:
dialog = ProfileCheckDialog(lambda: self._profile_xml_for_check(temp_dir),
self.current_profile.profile_name, self)
dialog.exec()

def save_profile(self):
"""Save the modified profile to XML"""
if not self.current_profile or not self.current_profile.is_modified:
Expand Down
Loading
Loading