dcsimg
Results 1 to 5 of 5

Thread: Programming Anomaly

  1. #1

    Thread Starter
    Android OpenGL ES Guru Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,224

    Programming Anomaly

    Well I got one thats gonna make your brains explode as much as mine. Lets see if you can solve this. Im not gonna post this in any particular forum language, mostly because it will not get any views much less solved. So Im gonna make this universal with only pseudo code. It does involve mobile apps though because it uses multitouch. Lets see how smart yall are.

    So here is the problem. Im making a dual analog controller much like the ps4 or xbox controller using a smaller circle inside a large circle. The small circle never leaves the boundary of the large circle. Actually its already made, and works, but its not multitouch. The analog controller is wrapped in a class. To make 2, obviosly I am using two analog controller objects.

    The multitouch gesture event is being read from the MainActivity, much like in VB.Net, getting the mouse event from the Form. The more fingers touching the screen, the higher the pointer counter goes up. For example, if 3 fingers touch the screen, the pointer counter will be 3. If its 2 fingers, the pointer counter will be 2, etc etc. Easy right? The touch[ ] array is declared as a Vertex2D which only has x and y. So it gets the x and y coords per finger WITHOUT a for loop with the use of its events.

    Now comes the anamoly. With my analog controller objects, if you touch over the object, touched, a boolean variable in the class, will be true, else itll be false if outside the boundary. The pointer counter is fed into the method that controls the inner circle as an arguement. However, this becomes a problem. What if you touch the right analog controller first and then the left? What if two fingers are touching one controller? Right now at the moment. Multitouch is not working. I can move one analog stick but not the other because it locks in place when multitouch takes place. But when i try to handle the special cases as I mentioned above, Im unable to code it! Its an anamoly that becomes uncodable. What do you think?

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    32,504

    Re: Programming Anomaly

    I think it's worthy of being moved to General Developer.

    Frankly, it sounds like it was designed in such a way that this problem is inevitable. How much control do you have over this? Did you do all the coding, part of it, or none of it? If you have full control, it sounds like you have inadequate information being passed in, as if the design limits the function.
    My usual boring signature: Nothing

  3. #3
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    4,620

    Re: Programming Anomaly

    How do you process the touch to determine which instance is touched, i.e. set the touched variable?
    It seems like you could have a static list as part of the class that holds the various instances, so if you have multiple touch inputs, you can process each to determine if they fall in the bounds of one of the instances and process it in that instance.
    If you have two touches in the same instance, and you don't plan on a gesture processing, then I assume you would ignore the second touch in that case, or average the two, or use the one further from the center, or something else...

  4. #4

    Thread Starter
    Android OpenGL ES Guru Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,224

    Re: Programming Anomaly

    Quote Originally Posted by Shaggy Hiker View Post
    I think it's worthy of being moved to General Developer.

    Frankly, it sounds like it was designed in such a way that this problem is inevitable. How much control do you have over this? Did you do all the coding, part of it, or none of it? If you have full control, it sounds like you have inadequate information being passed in, as if the design limits the function.
    All of the code is my code. I designed it myself. But I think you are right. I designed it in such a way that I ran into a dead end brick wall and made Multitouch impossible. And possibly will need to redesign it. The analog controller works great like I said, but I would like both controllers to function at the same time as opposed to one at a time.

    Quote Originally Posted by passel View Post
    How do you process the touch to determine which instance is touched, i.e. set the touched variable?
    The analog controller class has the boolean variable to be set when it is true. But this becomes a problem. Lets say you run it through the main game loop to check for touch:

    Code:
                    for (int i = 0; i < Constants.MAX_FINGERS; i++){
                        controller[0].checkForTouch(i);
                        controller[1].checkForTouch(i);
                    }
    For simplicity, lets test the first controller; controller 0. If the first touch actually is touching the controller, it sets it to true. But the second touch is not touching it, so it is set back to false. Ouch! Looks like it'll need redesigned there.

    Quote Originally Posted by passel View Post
    If you have two touches in the same instance, and you don't plan on a gesture processing, then I assume you would ignore the second touch in that case, or average the two, or use the one further from the center, or something else...
    I guess I could test if the touch is false before calculating, otherwise skip it.

  5. #5
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    4,620

    Re: Programming Anomaly

    Quote Originally Posted by Jacob Roman View Post
    ...
    The analog controller class has the boolean variable to be set when it is true. But this becomes a problem. Lets say you run it through the main game loop to check for touch:


    For simplicity, lets test the first controller; controller 0. If the first touch actually is touching the controller, it sets it to true. But the second touch is not touching it, so it is set back to false. Ouch! Looks like it'll need redesigned there.

    I guess I could test if the touch is false before calculating, otherwise skip it.
    Hopefully the touch order has some consistency once engaged, i.e. the first touch will remain the first touch as long as the finger is not lifted, and the second is the second. That way when the values change you know that index 0 is moving from the previous index 0 position, and index 1's value is associated with the previous index 1.
    If the count drops, then (I assume) a finger has been lifted and maybe you have to do a proximity check again to see which finger was lifted in case it was the 0 index one, and I assume the previous index 1 finger is now reported in index 0.

    I think you would have to maintain that type of correlation between touch index and the object instance associated with that touch so you don't process a given touch by more than one instance of the class.
    But, I haven't had to deal with it, so I'm making this all up.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width