rust3ds / ctru-rs

Rust wrapper for libctru
https://rust3ds.github.io/ctru-rs/
Other
116 stars 17 forks source link

Camera rework and small fixes #137

Closed Meziu closed 8 months ago

Meziu commented 9 months ago

Big (and messy) PR incoming!

Changes related to the cam service:

Some other minor changes that were made in the mean time:

P.S. I'm sorry for mixing up the changes to the cam service and those related to TODO or other small fixes. I had initially envisioned this PR as a "todo fix" PR but as I worked on it I noticed that cam was going to need a lot of work.

Meziu commented 9 months ago

It seems like nobody on github ever used stereo calibration before (not even devkitPro's own examples include it) nor image quality calibration. In my tests it seems like CAMU_SetStereoCameraCalibrationData has no effect, so I'm wondering how these functions are supposed to work. The same goes for trimming, of which I have understood only that it accepts images of the "standard" supported resolutions (like VGA and TOP_LCD) but that I still can't grasp in its entirety (does it accept all resolutions with an area multiple of 256?).

@steveice10 Sorry for the tag, but since you've written the cam:u implementation for libctru, and have a lot of experience with FBI and cameras in general, would you mind sharing some of your knowledge with us? I've spent a couple of weeks reverse-engineering the cam service, but your insight would be greatly appreciated.

Meziu commented 9 months ago

Thank you so much for the information! I didn't expect your quick response 😄.

* You need to use `cam:s` (I think `cam:c` also works?) for privileged access. All 3 cam services share the same handler but have state checks on what service needs to be used to access certain commands.

Interesting. This effectively means I'd need to re-implement all IPC calls to use my own cam:s handle, correct? In libctru everything uses cam:u, so that probably won't work. Also, would that change bring any trade-offs that you know of, or is the handle to use only up to the specific needs?

2. For trimming I don't think I ever played with it thoroughly enough beyond standard dimensions to know what exactly it will and won't accept.

No problem, I've already been experimenting with it enough. I should be able to find some conclusive evidence in no time, i hope...

I guess I should try to merge this PR more or less as-is and work on re-implementing everything over cam:s if possible later, since it would be way too disruptive right now.

Meziu commented 8 months ago

This PR is finally ready to merge.