Bugstick icon indicating copy to clipboard operation
Bugstick copied to clipboard

Add a joystick base shape as rect

Open iascchen opened this issue 9 years ago • 2 comments

if app:base_shape="rect", the angle and offset will be in range [ [-1,1], [-1, 1] ]

    <com.jmedeisis.bugstick.Joystick
    ...
          app:base_shape="rect" >
    ...
    </com.jmedeisis.bugstick.Joystick>

iascchen avatar Feb 14 '16 10:02 iascchen

Hey, thanks for your contribution. Rectangular pad support would be a great feature.

Couple comments:

  • I'm not a fan of having one more separate property, i.e. base_shape. It adds unnecessary complexity. We should be able to provide this feature as part of the motion_constraint property, which it logically belongs to. Renaming the default NONE to OVAL may be appropriate in this case.
  • Hijacking the onDrag(degrees, offset) callback to return two parameters that are not degrees and offset is not acceptable from a library point of view. The interface must not be misleading the library user. One solution may be to change our existing interface to return normalized offset values as in your solution, and then provide some static utility methods (or simply example code) to convert to degrees and offset for users who want the current output.

The situation is quite interesting in that the motion_constraint is closely related to the sort of information a user would want in the onDrag callback. For example, for the HORIZONTAL and VERTICAL constraints you typically really only want a single normalized value [-1, 1]. For your rectangular pad case you want two normalized values. For the oval case an angle value is likely more useful.

As I noted in the README, I'd like to see some way to easily create and plug in arbitrary motion constraints, be it an oval, rectangle, diamond, or squiggly path. Perhaps this is a good opportunity to explore some sort of API for accomplishing this?

What do you think?

justasm avatar Feb 14 '16 12:02 justasm

yes, customize motion_constraint is a better solution. 👍

iascchen avatar Feb 14 '16 13:02 iascchen