Author Topic: How can I detect if I used a key or a button to start the command?  (Read 5150 times)

HardyHero

  • Guest
Imagine this situation:

Joystick button A = fire weapons
Keyboard key "V" = fire weapons
Voice command "fire" = fire weapons

If I say "fire" voice attack will use the command "V" to send to the game this key press.

But in game, the joystick button A and the key "V" are configured to fire.
This mean if I press these buttons my plane will fire.
But VoiceAttack also will detect this keys, so the hardware will fire and VoiceAttac will fire.
How can avoid this?
I want to detect if commands came from joystick/keyboard, VoiceAttack will give a audio feedback but will not fire.
If commands came from my voice,  VoiceAttack will give a audio feedback and will fire.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: How can I detect if I used a key or a button to start the command?
« Reply #1 on: January 15, 2017, 01:41:46 PM »
Quote
{CMDACTION} - The method by which the current command was executed.
The possible results are, 'Spoken', 'Keyboard', 'Joystick', 'Mouse', 'Profile', 'External', 'Unrecognized' and 'Other'.
The value will be, 'Spoken' if the command was executed by a spoken phrase, 'Keyboard' if the command was executed using a keyboard shortcut, 'Joystick' if executed by a joystick button, 'Mouse' if executed by a mouse button click and 'Profile' if the command was executed on profile load (from the command indicated in the profile options screen).
The value will be 'External' if the command is executed from a command line.
'Unrecognized' will be the value if the command was executed using the unrecognized phrase catch-all command in the profile options screen.
'Other' is reserved.

If the sound always plays, you don't have to include a check for it, only the keypress:
Code: [Select]
Play sound, '{VA_SOUNDS}\fireweapons.wav'
Begin Text Compare : [{CMDACTION}] Equals 'Spoken'
    Press V key and hold for 0,06 seconds and release
End Condition

HardyHero

  • Guest
Re: How can I detect if I used a key or a button to start the command?
« Reply #2 on: January 16, 2017, 07:15:25 AM »
Perfect!
I didnt know the CMDACTION method.
I will check more about the list of supported methods.
Thank you veyr much! ;D

HardyHero

  • Guest
Re: How can I detect if I used a key or a button to start the command?
« Reply #3 on: January 16, 2017, 04:17:56 PM »
Also, do you know if is possible to {LASTSPOKENCMD} detects more than one word by time?
I mean... Put a list of word and {LASTSPOKENCMD} detects if I said any of these words.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: How can I detect if I used a key or a button to start the command?
« Reply #4 on: January 16, 2017, 06:13:53 PM »
Also, do you know if is possible to {LASTSPOKENCMD} detects more than one word by time?
That token will always contain the last recognized spoken command phrase(Not commands triggered by any other method), and only that. So no.

HardyHero

  • Guest
Re: How can I detect if I used a key or a button to start the command?
« Reply #5 on: January 16, 2017, 06:16:23 PM »
oh  :-\

And about AND / OR / NOR? I didnt find anithing... I'd like to use at least the "OR" to avoid create multiple commands...

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4747
  • RTFM
Re: How can I detect if I used a key or a button to start the command?
« Reply #6 on: January 16, 2017, 07:43:23 PM »
And about AND / OR / NOR?

Search the documentation for "{EXP:expression}". It's a highly versatile token, and allows evaluating multiple statements/expressions in one conditional block:
Code: [Select]
Begin Text Compare : [{EXP: '{TXT:Input}' LIKE 'One' Or '{TXT:Input}' LIKE 'Two'}] Equals '1'
End Condition

HardyHero

  • Guest
Re: How can I detect if I used a key or a button to start the command?
« Reply #7 on: January 17, 2017, 12:43:11 PM »
Perfect! Thank you very much!