Previously the socket funtions did not write the sockaddr_in struct fully and instead always returned
the "internal" length, which did not account for the zeroed padding.
This commit adds support for all service commands of all 4 QTM services
(`qtm:u`, `qtm:s`, `qtm:sp` (which are built on top of one another) and
`qtm:c` ("hardware check")), with precise documentation about each command's
behaviour and about I/O internals.
The existing `qtm:c` code in libctru had a lot of misconceptions; this commit is
a full rewrite with breaking changes.
In particular: QTM does *not* track the position of 4 points on the user's face.
Instead, it tracks the position of the user's eyes (but not the direction they are
looking at) and reports their coordinates in camera space and in world space.
The data is presented in a console/hardware-agnostic way to the user.
QTM is a service process responsible for:
- eye tracking (see above). Head tracking data is available even when "super-stable 3D"
is disabled
- parallax barrier management through the TI TCA6416A I2C->Parallel expander.
The parallax barrier hardware on N3DS requires that software (in this case, QTM process)
alternates between writing the barrier's mask pattern & polarity followed by the bit-negation
of that pattern on polarity continuously, at all times
- automatic barrier management by adjusting it with the results of eye-tracking ("super-stable 3D")
- automatic (and manual) IR LED emitter management so that eye-tracking can work even in the dark
- fowarding camera brightness information from cam:q. GSP uses this for auto-brightness
Fixes issue where fopen("test.txt","r") opens 3dstest.txt instead of test.txt.
Also correct misuse of strncat() as count applies to src not dest.
See:
8136d94657806a4d34c5
Since kernel doesn't directly access the LMA, but just does memory
management on them instead, they should be passed as u32 (uptr) instead
of void *.
Also change CodeSetInfo to CodeSetHeader to avoid confusion with
ExHeader types.
Fix chainload method used when HM is not launched.
We now wait for custom PM to change our launch flag and ask us to
terminate. We previously had a few issues:
- a potential race condition where we exit before PM changes our
runflags (not observed)
- a kernel deadlock between ExitProcess and TerminateProcess (observed,
this is due to Nintendo's lack of barrier in many of their atomics
code)
- debuggers reporting that we were terminated, instead of exiting
gracefully (not desirable)
This implements the syscalls for `clock_gettime` and `clock_getres`. We
support two clocks: CLOCK_REALTIME and CLOCK_MONOTONIC. I've opted to
use the existing `osGetTime()` code for the realtime clock, because it's
known to work.
For CLOCK_MONOTONIC I've used `svcGetSystemTick()` directly, as it has a
higher resolution. We can ignore the drift and so on, because it's
supposed to be just the number of ticks since last boot.