MODULE: DoubleClick + KeyListener: detect double clicks and more

Started by Crimson Wizard, Wed 10/02/2016 01:39:17

Previous topic - Next topic

rongel

Quote from: Crimson Wizard on Fri 29/01/2021 10:05:13
But with Display command it's different, in AGS key presses won't be registered at all while Display is active on screen. What you may probably do is to set special key to skip Display right before starting one and set it back to your normal defaults right after.

Thanks for the quick answer! Yes, I've been thinking to use a GUI if the Display command causes troubles.

I tried using your code, but got an error "skip_speech_specific_key' is not a public member of 'GameState'". I'm not sure if I used it correctly...
Dreams in the Witch House on Steam & GOG

Crimson Wizard

Quote from: rongel on Fri 29/01/2021 10:24:24
I tried using your code, but got an error "skip_speech_specific_key' is not a public member of 'GameState'". I'm not sure if I used it correctly...

Oh sorry, I got confused, this variable was turned into Speech.SkipKey property, but it's not applied to Display anyway, so won't be useful here.

rongel

Ok, no problem. I tried to use this when pressing spacebar, but got nowhere:
   
Code: ags

      int old_skip_display = game.skip_display;
      int old_skip_key = Speech.SkipKey;
    
      game.skip_display = eSkipKey;
      Speech.SkipKey = eKeyA;
    
      Display("GAME PAUSED %s",
      "[[Press any key to continue");
      game.skip_display = old_skip_display;
      Speech.SkipKey = old_skip_key;     


It doesn't give any errors, but I can't see any effect either. I'm probably using this wrong! I may have to change the pause system, so that it uses a GUI. Just annoying because the simple Display works almost perfect.
Dreams in the Witch House on Steam & GOG

Crimson Wizard

Like I said, Speech.SkipKey does not apply to Display (it applies only to speech). So this method won't work.

Display have many problems in AGS, notably it blocks every script event, even repeatedly_execute_always. This is why it is practically impossible to customize its behavior.

rongel

Ok, thanks for the clarification! I know now not to spend anymore time fighting this issue, and switch to Gui.

Dreams in the Witch House on Steam & GOG

Vincent

Hi @Crimson Wizard I was wondering to ask you if it's possible with this module to have some sort of key pushed combination? For example if you push 'A' it goes with punch1, if you push another time 'A' (within a range of time) it goes with punch2 and so on? If that's possible how to do something like that?

Crimson Wizard

Quote from: Vincent on Wed 31/07/2024 09:53:35Hi @Crimson Wizard I was wondering to ask you if it's possible with this module to have some sort of key pushed combination? For example if you push 'A' it goes with punch1, if you push another time 'A' (within a range of time) it goes with punch2 and so on? If that's possible how to do something like that?

This module only detects presses, but it does not know what they are for. You'll have to script that yourself.

In fact, when I wrote this module, i had plans to make a fighting game. This module was a start, and the next module should be "action sequencer", but I never wrote it. The idea was that ActionSequencer would read information from KeyListener, and record a list of key presses.
You can do something like that, in your way.

Vincent

Okay thanks a lot for the info. I'll try to make something myself while still using your module because is an huge help. Also I hope one day you will write the ActionSequencer as well.


:EDIT: @Crimson Wizard I managed to make it work (with your module) by using a couple of functions like KeyListener.KeySequenceLength and KeyListener.EvtKeyAutoRepeated they really came in handy.

DS

@Crimson Wizard, I have recently come upon your module here while attempting to accomplish some specific behavior in a "Sierra-style" game base project I'm beginning.

It seems like the "KeyAutoRepeatDelay" piece of your module should do what I want, but so far it isn't, and I'm wondering if you could perhaps readjust any misunderstandings I have of its method and function?

My end goal is to have a held-down key not clear a display box that has opened.  So, for example, if I have the "S" key held down while I click on an object with the "Look At" cursor functionality, the display box giving the description of the object I clicked on opens, but then instantly closes because the "S" key (or any key, really, it seems, in this game style) being held down causes the display box to close.

Based on other message threads here in the forums, I have tried many things before finding your module (global variables to monitor keypresses being up or down, on_key_press things, IsKeyPressed things, keycode set to 0, claimevent() in the room script, etc), and none of it has helped me accomplish my task as of yet.  I'm basically trying to "deaden" a key where it is just treated as one keypress when it is held down.

It seemed like I could "simulate" this behavior I'm looking for with "KeyAutoRepeatDelay" in your module by setting it to a very high amount ("30000", or 30 seconds, say) before it repeats, but that hasn't worked.

I have this in game_start() --

  KeyListener.ListenKey(eKeyS);
  KeyListener.Enabled = true;
  KeyListener.KeyAutoRepeatDelay = 30000;

Should this work to do what I'm trying to do?  And/Or am I using it incorrectly?

Crimson Wizard

Quote from: DS on Mon 17/02/2025 14:00:43My end goal is to have a held-down key not clear a display box that has opened.

This module only provides information about key events, it does nothing else. How to use this information then is entirely up to you. So the primary question here is how do you control the "display box" exactly.

If you are speaking of a standard display box shown with Display command, then there's no way you can override its behavior, because it is hardcoded and it is also blocking all scripts while shown. If you prefer to have a display box with a different behavior, then you should script one yourself, write a new command that displays a message using a GUI or a textual Overlay. Then you will be able to also control how it's removed.

DS

@Crimson Wizard, thanks for the reply.  I was indeed referring to the box from the "display" command, so will angle towards creating a custom display box of some kind, as it sounds like that will give me the most control over the functionality I'm looking for.

QuoteThis module only provides information about key events, it does nothing else.

I did have one further question though, based on that sentence -- what is "KeyAutoRepeatDelay" used for then?  Because it seems that I can set it, based on the available functions.  Or is the setting of KeyAutoRepeatDelay just something "internal" to the module that is not supposed to be used directly?  (Apologies for any continued confusion on my part, but I'm newer to the AGS scene and am still familiarizing myself with what can and can't be done within this engine.)

Crimson Wizard

As noted in the comments to this property:
Quote/// Get/set minimal time (in milliseconds) for a held down key to be down to be considered "repeating"
import static attribute int KeyAutoRepeatDelay;

This means the time after which this module starts raising "repeated key" events.

But any events that this module raises are not AGS engine events, they are only this module's events, accessible by checking Evt* properties.
See "Signal properties" paragraph in the first post, it explains how these events are used. There are also couple of examples in the end of that post.

SMF spam blocked by CleanTalk