Author Topic: Touch in kernel plugins  (Read 145 times)

Offline Rufis_

  • End User
  • *
  • Posts: 5
  • You'll never see it coming
    • View Profile
Touch in kernel plugins
« on: February 21, 2021, 05:58:42 PM »
I've been struggling for months to get touch working in kernel plugins and finally I figured out how to do it.

Functions like ksceTouchPeek or ksceTouchRead simply refuse to work after Shell spawns; they won't return any error NOR they will write data to the output buffer(s).
So, to get touch information you have to hook either function, and manually copy the data. But not every app uses touch, which means that you can get information out of the touch panel only if the currently running application needs it too.

After a bit of digging I found out that function SceTouchForDriver_3F3FBF69 sets a value in memory, DAT_810075c4, to 1 every time it gets called. This same value is used by ksceTouchPeek*/ksceTouchRead* functions to calculate the last parameter for FUN_81003b84, which should be the function that actually gets the data from the touch panel.
It is currently unknown what SceTouchForDriver_3F3FBF69 does (looks like it just copies some data around, perhaps information about the currently active process) or what DAT_810075c4 represents and why it affects said functions.
But with this knowledge we can get touch to work; all we have to do is set DAT_810075c4 to 0 before calling peek or read. I would recommend to set it back to its previous value after getting the buffer data, but leaving it to 0 doesn't seem to have any side effects.
It is also possible to hook SceTouchForDriver_3F3FBF69 and disable it, but this might cause some issues.

WARNING: since it is still unclear what SceTouchForDriver_3F3FBF69 does, modifying DAT_810075c4 MIGHT CAUSE SOME TROUBLES (e.g. user application might stop responding to touch input). That said, I did some tests and everything seems to be working just fine.

Offline Rufis_

  • End User
  • *
  • Posts: 5
  • You'll never see it coming
    • View Profile
Re: Touch in kernel plugins
« Reply #1 on: February 21, 2021, 06:02:28 PM »
DAT_810075c4 is in segment1 + 0x05C4 in SceTouch for FW 3.60