d0k3 / GodMode9

GodMode9 Explorer - A full access file browser for the Nintendo 3DS console :godmode:
GNU General Public License v3.0
2.09k stars 190 forks source link

Need some help with my own project #777

Closed Ghost-Bit closed 2 years ago

Ghost-Bit commented 2 years ago

I cannot, for the life of me, figure out how to implement the touchscreen in baremetal arm9 3ds c code, can you please tell me how i can do this without copying over fifty different header files that don't even work at all or without telling me to search harder? i've been searching for a week now, and everything's just been a maze trying to figure out where and how to get these mysterious, mythical coordinates.

Wolfvak commented 2 years ago

The touchscreen is part of the TSC ("Touch & Sound Controller" as far as we know, aka "CODEC"), a separate chip that's connected via SPI. In order to get data off it, it needs to be in a valid state (either because you already know it is in one, or because you reinitialized it yourself).

Once the chip is in this "known good state" you can retrieve the touchscreen (and circle pad) status by reading 0x34 bytes from register 0xFB:0x01 and processing them a bit to get a number between 0 and 4095 for both X and Y coordinates. There are a few more corrections done in the GM9 side itself to account for inaccuracies (the calibration tests done in software are really needed) and can then be used.

This is not the place to ask these questions so I'll close the issue, but you can join our IRC channel or discord server if you want to ask more follow up Qs.