Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Touchpad drag function #27

Open
NMartin354 opened this issue Apr 18, 2020 · 1 comment
Open

Touchpad drag function #27

NMartin354 opened this issue Apr 18, 2020 · 1 comment

Comments

@NMartin354
Copy link

Is there any support for relative controls? Like take the value of trackpadGetLastXY() on first touch = trackpadFirstXY, then replace the output to the result of percentage of [Square Root of {trackpadFirstXY - trackpadGetLastXY() } ]until the finger is released?
So that the output = the distance dragged.

If this isn't in the code already, what current fields output the XY coordinates? Can I make them a function like the one I referenced?

@2bndy5
Copy link

2bndy5 commented Apr 30, 2020

I'm curious why you want this specific functionality. Are you trying to emulate a trackball mouse?
So the trackpads' firmware (not the OpenSteamController firmware) support 3 data output modes: Relative, Absolute, & AnyMeas. TL;DR -> skip to bottom.

Relative mode (not exactly what you're trying to describe)

In this mode, the trackpad outputs the difference in position data between 2 samples (sample rate defaults to 10 milliseconds which is the fastest possible for finger stimulus; sample rate could be reduced to as slow as 100 milliseconds). This mode doesn't seem to be implemented in the OpenSteamController firmware. If it were, position data would be output as a signed byte (-128 to 127) for each axis (X and Y only). This is designed for (and often referred to in the datasheet as) "mouse mode" because the expected mouse HID reports follow the data output of a single trackpad in Relative mode. Conventionally, this mode is used to continuously read any steady stream of samples, and there is no way to differentiate between samples that are touch-start events or touch-end events.

Absolute mode

In this mode, the trackpad outputs the exact position (in positive numbers) of the touch event in relation to the an "anchor" corner. Valve has their trackpads custom tailored by Cirque (maybe hard-wired 180 rotation), so the "anchor" corner could be bottom-right as opposed to the default top-left. The data output ranges 0-2047 for X-axis and 0-1535 for Y-axis. The Z-axis can also be read in this mode to determine if finger is hovering (> 0) or in direct contact (~ 0). Please remember that the steam controller uses a curved overlay in which the Z-axis output will be a non-zero value for direct contact with trackpad's circular edge. The sample rate of Relative mode also applies to Absolute mode, but this will be less of a problem in Absolute mode for your "dragging" distance goal.

AnyMeas mode

This is the mode that the OpenSteamController firmware is currently using. It provides a way of reading the raw ADC values from the trackpads' matrix of electrodes (12 for Y-axis and 16 for X-axis). It is very nuanced and not documented at all. For some reason, the OpenSteamController firmware uses 600 for X-axis center (where X-axis ranges 0-1200) and 350 for Y-axis center (where Y-axis ranges 0-700). The sample rate of Absolute & Relative modes does not apply to AnyMeas mode as measurements are triggered manually.

How to modify the OpenSteamController firmware

You will have to add variables to keep track of beginning and ending locations for a touch event (using x_loc & y_loc after calling trackpadGetLastXY()) in the tpadMonitor() function, then calculate the "dragged" distance with something like sqrt(<delta Y-axis data>^2 + <delta X-axis data>^2)). To use Absolute data mode from the trackpad will take some doing as the derelict code in the OpenSteamController firmware pertaining to Absolute mode seems incomplete or maybe artifacts from testing during development. Again, Relative mode will take even more doing since there's no implementation in the OpenSteamController firmware for it and what I said about the sample rate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants