Detect double click detection with Lemur

Before I reinvent the wheel… I wonder if there is a good and simple way to detect a double tab with Lemur. I use WASD to jump, dive, left and right and I would like to detect double tab on left and right. I feel like I’m probably not the first one for dashing :slight_smile: and hopefully there is already something laying around and I just don’t know or couldn’t find.

If not, I’ll try to implement it my self.

What constitutes a double click is going to vary from implementation to implementation so there is nothing built in.

thanks for the quick reply.

Are I am late? I did it by setting one or 2 variables in the click event and checked in update loop. If the conditions are meet I started an action. It might be in the filebrowser I made. Check my posts I think I had it linked somewhere. If not and if you are to lazy to do it by yourself you need to write me and I try to find the code snippet.

It’s fine I wrote a simple one not too difficult. I just wondered if there is something in Lemur handling double click as I didn’t see a benefit to reinvent the wheel, but there isn’t, so I did it my self. But thanks a lot for your offering I appreciate that.

Cant we use the “key combination” stuff in Lemur?
Like if I had a combo of “down, down, up” it’s much the same, “down down” would be “double click”, actually even seeing that he doesn’t talk about mouse clicks.

Because

collides with the elegant “functions” approach of lemur and especially leads to spaghetti code the more combinations you have.

That’s exactly what I’m looking for :sweat_smile: any examples I could look at?!

There are “key combos” like Lemur handles which is “pressing more than one key at the SAME TIME”. And there are “key combos” like fighting games have where pressing A A B A Down Up in sequence does a special move.

Lemur doesn’t handle those kinds of combos and handling them in a general way is fraught with peril.

When you think of something simple like a mouse click, even that is not so simple. Is it time between the presses? Time between the releases? Is there a period of time for the first pressed where the release doesn’t count anymore?

With things like “push forward twice to run” it’s even trickier. How far forward? How far back again? Do you time the peaks? The valleys? Both?

So to me it’s better for user code to handle this. It can still be done functionally… just not necessarily with “function IDs”.

For example, register an AnalogFunctionListener with the forward axis. Have that delegate to a StateFunctionListener that means “run” whenever the run conditions are met.

Granted, it’s not exactly as nice as just registering StateFunctionListener to F_RUN… but it’s not that different in the game code.

3 Likes

I have once added an Actionlistener I think Ctrl + Q to open a Quiet Menu from any Lemur screen. I did some individual combos in textfield to make Copy Paste and Copy Cut possible. I am not able to do any coding since > 2 months but I will try to look this up and post the code.
ActionListener is normal JME code the second thing requires to either change lemur source or to add something to the actionmap of the lemur element.

Right - could become a noudle salad

This is kind of off topic since this has nothing to do with double click.

Key combos where you are supposed to press the keys at the same time generally work fine in Lemur if you configure them correctly.

As to your issues, I cannot comment on code/problems that I haven’t seen.

Yeah meanwhile I switched my code for the player control to behavior tree implementation, which did clean the code base and makes it much easier for me to implement special behavior like dashing on double tab and other stuff. So I’m safe now, thanks a lot for your time to help and explain the reasoning, I understand it now as I had to answer some of the questions in your post for my self :smiley:

1 Like

Glad you got something nice working.

I hope it’s clear that I have given this some thought and still hope to think of something clever to do this in Lemur someday. I didn’t want to sound dismissive. It’s tough to build it into InputMapper because it has no concept of time but maybe there will be an add-on someday or something.

2 Likes

Yeah it feels a bit like the camera thing which in the end you will have to do on your own to meet the special conditions and game feel you want achieve in our game. So for me it is fine. I simply wasn’t aware in the beginning… and/or often start with something existing and replace it later on the way with my own implementation to meet my goals.
The behavor tree approach isn’t that bad as I even can model that double tab including timings and stuff and have even a graphical way to look at and fine tun or extend it. I found out that I can reduce complexity with behavor trees and ECS quite a bit. When ever the behavior needs mor than one counter/timer and ends in complicated if‘s I start to break it down in tasks and go from there. It even cleans the existing code and makes it unit testable as a side product.