Omnimaga

Calculator Community => TI Calculators => Calculator C => Topic started by: aeTIos on November 21, 2014, 08:56:25 am

Title: Getting touchpad coordinates
Post by: aeTIos 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
Title: Re: Getting touchpad coordinates
Post by: Vogtinator 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
Title: Re: Getting touchpad coordinates
Post by: Matrefeytontias 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.
Title: Re: Getting touchpad coordinates
Post by: Vogtinator 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)
Title: Re: Getting touchpad coordinates
Post by: aeTIos 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.
Title: Re: Getting touchpad coordinates
Post by: Vogtinator 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).