[SOLVED] Two finger drag

Hi there!

Is there anything implemented already to support two finger dragging in jme? I’ve been looking at the code (TouchEvent, AndroidGestureProcessor, AndroidInputHandler, AndroidTouchInput and so on…) and I think there isn’t anything as such


Afaik Lemur input system has multitouch support (search forum for lemur + multitouch). Maybe you can take use of it.

On Android devices (and other touch supporting platforms), Lemur supports multi-finger drag. (You can drag multiple sliders at the same time with different fingers, for example.)

It’s just using the regular JME events and keeping track of the touch ID, though.

Thanks for the answers but I’m not sure if lemur itself fits my use-case although I’ll have a look at the code just in case it gives me some ideas. Is this GitHub - jMonkeyEngine-Contributions/Lemur: Lemur is a jMonkeyEngine-based UI toolkit. current lemur repo?

What I’m trying to achieve is to fully move the camera using touch input as follows:

  • Single finger drag → rotate camera (currently supported by default by mouse emulation)
  • Dual finger drag → move the camera up/down/left/forward (I’m trying to implement this)
  • Scale/Zoom gesture → move the camera forward/backwards (easy using TouchEvent.Type.SCALE_MOVE)

I tried checking the MOVE event of PointerId==1 but it’s mixing scale and move because both are run at the same time when scaling. Obviously when you scale you’re moving both your fingers…

Any idea is welcome :wink:

I think it’s a similar problem to detecting a key combination like ctrl+T… there is no built in way to do that. If you want to know when ctrl is pressed and T is pressed then you track control and T and know they are both pressed.

While I have no direct experience with the touch stuff, I imagine it’s a similar thing. If you want to know if finger one is dragging this way and finger two is dragging that way then you need to keep track of the fingers and know what’s happening to both of them.

And yes, that’s the only Lemur repo I know of (and I’m the author).

1 Like

After my last post I started working on this and I did something similar to your suggestion. I’m keeping track of events to properly decide if scaling or dragging and it’s working fine :+1: