Skip to content

fix(capture): skip phones as the camera; hide Scanlight cards until polled - #1773

Open
kurtwindisch wants to merge 3 commits into
marcinz606:mainfrom
kurtwindisch:fix/camera-skips-phones
Open

kurtwindisch wants to merge 3 commits into
marcinz606:mainfrom
kurtwindisch:fix/camera-skips-phones

Conversation

@kurtwindisch

@kurtwindisch kurtwindisch commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Camera scanning opened a connected iPhone as the scanning camera (#1772). GphotoCamera.open() called Camera().init() without a port, so libgphoto2 opened the first device on the bus.

  • list_cameras() and open() skip a device whose libgphoto2 driver entry is typed as an audio player (MTP phones and players) or carries Apple's USB vendor 0x05ac (iPhone and iPad are typed as still cameras).
  • open() points the camera at the chosen device's port and lets libgphoto2 detect the model there. It picks the device again on each retry, so a body that comes back at a new USB address still opens.
  • A bus with only a phone fails the open with a translated message.
  • FakeGP and the simulated gphoto module now have port and abilities lists, so tests and make run-sim run the real path.

Scanlight cards at startup

The Camera panel started in RGB mode, so the Preset card, Keep Light On and the RGB gate showed for every user until the first connection poll answered. A Fujifilm open takes a few seconds, and the same reporter could click + on a Preset card with no Scanlight connected. The panel now starts in white-light mode, and the first poll decides. The "You can also connect the Scanlight" hint also waits for that poll.

Why not the capture flag

libgphoto2 sets GP_OPERATION_CAPTURE_IMAGE only on entries marked as capture-tested. 753 of 1,129 major-brand camera entries lack it, including the X-T30, X-S10, X-H2S, X100V and the A6000 from #621. Over the full 2.5.34 table, the device-type and vendor rule skips all 398 phone and tablet entries and keeps every camera entry except the Ricoh Theta V and Z1 in MTP mode. A model with no entry counts as a camera.

Known limit

An Android phone in PTP ("Transfer photos") mode with no table entry matches the generic "USB PTP Class Camera" entry, and still counts as a camera. Closing that needs an open of the device to read what it reports.

Test plan

  • make all
  • New tests: a phone ahead of the camera, a phone alone, a body that comes back at a new address during a retry, list filtering for an iPhone, an MTP phone, an entry without the capture flag and an unknown model
  • In the app: an iPhone is not recognized, and an X-T30 II connects
  • make run-sim driver: Scan > Camera connects the simulated camera ("● Camera (USB)")
  • make run-sim driver: the Preset card is hidden before the first poll and shows once the simulated Scanlight answers
  • New tests: a fresh panel hides the Scanlight cards and the hint; a first poll without a Scanlight shows the hint; one with a Scanlight shows the cards

Fixes #1772

🤖 Generated with Claude Code

GphotoCamera.open() called Camera().init() without a port, so
libgphoto2 opened the first device on the bus. With an iPhone
connected, NegPy opened the phone as the camera: the Camera dot
turned green and Scan was enabled. A user's log showed six such
sessions ('Apple iPhone 5 (PTP mode)', live view NO, settings NO).

list_cameras() and open() now skip a device whose driver entry is
typed as an audio player (MTP phones and players) or carries
Apple's USB vendor (iPhone and iPad are typed as still cameras).
The capture flag cannot decide: most camera entries lack it,
including the X-T30, X-S10 and the A6000 from marcinz606#621. Over the
libgphoto2 2.5.34 table, the rule skips all 398 phone entries and
keeps every camera entry except two Ricoh Theta 360 cameras in
MTP mode. A model with no entry counts as a camera.

open() points the camera at the chosen port and lets libgphoto2
detect the model there. It picks the device on each retry, so a
body that comes back at a new USB address still opens. A bus with
only a phone fails the open with a message that says so.

Verified in the app: an iPhone is not recognized, and an X-T30 II
connects. make run-sim still connects the simulated camera.

Fixes marcinz606#1772

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Camera panel started in RGB mode, so the Preset card, Keep
Light On and the RGB gate showed for every user until the first
connection poll answered. A Fujifilm open takes a few seconds, long
enough to click + on a Preset card for a light that is not there.

The panel now starts in white-light mode. The first poll decides:
a Scanlight shows its cards, and no Scanlight shows the "You can
also connect the Scanlight" hint, which stays hidden until then.

Verified with make run-sim: the Preset card is hidden before the
first poll and shows once the simulated Scanlight answers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kurtwindisch kurtwindisch changed the title fix(capture): skip phones when choosing the scanning camera fix(capture): skip phones as the camera; hide Scanlight cards until polled Dec 4, 2026
open() created a libgphoto2 Camera before _pick_device(), so a bus
with only a phone left one unused native handle per attempt for the
garbage collector. The camera is now created only once a device is
picked.

Verified with make run-sim: the simulated camera still connects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

Camera scanning opens a connected iPhone as the camera

1 participant