Author Topic: Getting touchpad coordinates  (Read 7174 times)

0 Members and 1 Guest are viewing this topic.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Getting touchpad coordinates
« on: November 21, 2014, 08:56:25 am »
As per topic title. I would like to get the coordinates off the touchpad. I looked at matrefeytontias' code for nKaruga but I couldn't make much of it. What I'd like to know is 1) how to access the touchpad and 2) how to get the coordinates off it. TIA :D
I'm not a nerd but I pretend:

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: Getting touchpad coordinates
« Reply #1 on: November 21, 2014, 09:07:05 am »
It's fairly simple using the touchpad_scan function:
https://github.com/Vogtinator/pyWrite/blob/master/cursortask.cpp#L17

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Re: Getting touchpad coordinates
« Reply #2 on: November 21, 2014, 12:56:28 pm »
The touchpad code for nKaruga is in Player.cpp IIRC. Also, the touchpad needs "initialization", which is done at the start of main.
Basically, you "initialize" the touchpad by reading HW constants from it (you'll need them). You only do that once, since they are constants. When that's done, read the touchpad at any time with touchpad_scan.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: Getting touchpad coordinates
« Reply #3 on: November 21, 2014, 01:09:26 pm »
Quote
The touchpad code for nKaruga is in Player.cpp IIRC. Also, the touchpad needs "initialization", which is done at the start of main.
Basically, you "initialize" the touchpad by reading HW constants from it (you'll need them). You only do that once, since they are constants. When that's done, read the touchpad at any time with touchpad_scan.
The touchpad doesn't need initialization and the constants are actually fixed and the same everywhere, so you can completely skip that. (Anyway, only the relative coordinates are interesting, as touchpads are generally not used to get absolute coordinates, the way TI uses the touchpad to replace arrow keys is really annoying)

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Getting touchpad coordinates
« Reply #4 on: November 21, 2014, 01:12:30 pm »
Quote
The touchpad code for nKaruga is in Player.cpp IIRC. Also, the touchpad needs "initialization", which is done at the start of main.
Basically, you "initialize" the touchpad by reading HW constants from it (you'll need them). You only do that once, since they are constants. When that's done, read the touchpad at any time with touchpad_scan.
The touchpad doesn't need initialization and the constants are actually fixed and the same everywhere, so you can completely skip that. (Anyway, only the relative coordinates are interesting, as touchpads are generally not used to get absolute coordinates, the way TI uses the touchpad to replace arrow keys is really annoying)
Er, I actually do want the absolute coordinates, as I'm not planning to use it as a mouse movement device.
I'm not a nerd but I pretend:

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: Getting touchpad coordinates
« Reply #5 on: November 21, 2014, 01:50:48 pm »
May I ask what for, exactly? If you need to touch a certain place for instance, you'll never get it right first try.
The only application for absolute values I can imagine for now is a direct mapping of the touched position to a position on another plane, such as the screen
and for those a touchpad is just the wrong kind of input device. Especially the lower bits in the X and Y registers are noisy as the OS switches filtering off (via I²C when booting).