Get touch area dimensions for indirect touches (like tvOS or PS4 controller)
Hi. I'm developing for Apple TV, but this question concerns all inputs that have indirect touches.
Specifically, I want to process a user's touch relative to the center of the touch area. To do that, I need the dimensions of the touch area. This is different from using the screen size, which works for direct touches like on iOS.
I know the area is 800x800 so that's hardcoded for now, but obviously that will break if they change their specs or if I try to port this to PS4 or something.
So does anyone know how to find the dimensions of an indirect touch area? Thanks.
Answer by hexagonius · Jan 24, 2016 at 11:04 AM
I think the full support is only available to the corresponding build platform. In this post for example they talk about the full support of the PS4 controller:
http://blogs.unity3d.com/2014/06/16/unity-for-playstation4-is-here/
What PS4 features are available?
Unity for PlayStation®4 brings support for powerful next-generation technologies such as Shader > Model 5 and compute shaders, allowing developers to create truly stunning visuals. What’s more, > we already have support for all the DUALSHOCK®4 features, including accessing each controller’s > individual speaker, touchpad, vibration, and light color.
From what I've found out about the Apple TV Remote is that it does not favour touch area to screen mapping. Whatever you're doing, I guess you'll have to deal with delta movement of the swipe gestures.
Yeah, I guess that might be it. $$anonymous$$inda dumb, since the user experience would be significantly better if I could make this work right. But it does look like Apple simply doesn't want you to do that. The positions being reported by my touches seem to be kind of variable (the same spot on the touch pad is not giving me a consistent position). Oh well...
Answer by Mantas-Puida · Jan 25, 2016 at 08:37 PM
Apple does not provide API to get absolute touch values from TV Remote touch area. Though there is work around for that: 1) put TV Remote analog input to absolute values: UnityEngine.Apple.TV.Remote.reportAbsoluteDpadValues = true;
2) scale analog input to resolution you want:
if (Input.touchCount > 0)
{
float x = Input.GetAxis("Horizontal") * 800.0f; // Replace 800.0f with any number you like
float y = Input.GetAxis("Vertical") * 800.0f;
// Do something with x and y
}
Your answer
Follow this Question
Related Questions
How can I have a uniform struct in a Shader? 0 Answers
Differentiate between types of key press 1 Answer
How do you detect if a touch is hitting an object? 0 Answers
HELLPPPPP!!!! 0 Answers
The equivalent way of Input.GetKeyDown() in new input system 1 Answer