Feedback for set selectors

Post Reply
pier4r
Posts: 52
Joined: 02 Mar 2013, 18:09

Feedback for set selectors

Post by pier4r »

I'm sorry if the problem is already discussed, i did a search but i found nothing.

Since xpadder doesn't allow (actually) a custom curve for mouse speed emulation, i solved (partially) my problem with 2 sets. One with a base mouse speed and another with a lower speed for precise aiming (in war thunder).

To do this with an xbox360 pad and i click RB to switch from the set "base" to the set "fine aim". Anyway sometimes i'm not sure, and i would like to receive a feedback. Since the game doesn't allow a screen popup, can i play a (custom) sound when i click a button? I would like to register sounds like "Fine aim!" or "Normal aim" with some programs and then use these as feedback in xpadder.

Best solution so far. Since xpadder should focus on problems about emulation of kb and mouse (and not other) let use other programs (well-sized in term of resource usage and effort) to do the rest. We can use autoit (since xpadder is only for Windows)

Download autoit, create a new text file with the following code and rename it's extension to .au3

Code: Select all

#include <Misc.au3>

#comments-start
Program to give a feedback for xpadder set selectors. Xpadder is a program focused on keyboard and
mouse emulation and should optimize that features, not others. So it doesn not give any feedback for set selectors and it is ok.
Anyway, at least now in 2013, there are tons of scripting languages that can be combined with xpadder
to produce a powerful suite of gaming tools. So let xpadder focus on emulation and do other things with other languages

Then we simply associate a key combo to a set selector and listen for it and then produce the right feedback
(in this case, a beep)
#comments-end

dim const $sleepDuration_int = 50; in milliseconds
dim const $maxSleepCountsForUsefulCombo_int = 2 
dim const $ctrl = 11
dim const $shift = 10
dim const $alt = 12
dim const $one = 31
dim const $two = 32
dim $keyCombo_arr[40] ;just large enought to capture the keys 
resetKeyComboArr()
dim $sleepCountsPassedFromLastUsefulkey_int = 0 ; count sleep passed from the useful keypress, else is not a combination
dim $comboStarted_bool=0

Local $hDLL = DllOpen("user32.dll")

While 1
    If _IsPressed(String($ctrl), $hDLL) Then
        ;set or overwrite
        $keyCombo_arr[$ctrl] = 1
        $comboStarted_bool = 1
    endif
    
    if _IsPressed(String($shift), $hDLL) Then
        $keyCombo_arr[$shift] = 1
        $comboStarted_bool = 1
    EndIf
    
    if _IsPressed(String($alt), $hDLL) Then
        $keyCombo_arr[$alt] = 1
        $comboStarted_bool = 1
    EndIf
    
    if _IsPressed(String($one), $hDLL) Then
        $keyCombo_arr[$one] = 1
        $comboStarted_bool = 1
    EndIf
    
    if _IsPressed(String($two), $hDLL) Then
        $keyCombo_arr[$two] = 1
        $comboStarted_bool = 1
    EndIf
    
    ;before the sleep
    if $comboStarted_bool = 1 _
        and $sleepCountsPassedFromLastUsefulkey_int <= $maxSleepCountsForUsefulCombo_int _
        and checkKeyComb() _
        then ;reset
        $comboStarted_bool = 0
        $sleepCountsPassedFromLastUsefulkey_int = 0
    endif
    
    Sleep($sleepDuration_int) ;else the program listen continuosly
    
    ;updates
    if $comboStarted_bool = 1 _
        and $sleepCountsPassedFromLastUsefulkey_int <= $maxSleepCountsForUsefulCombo_int _
        then
        $sleepCountsPassedFromLastUsefulkey_int += 1
    elseif $sleepCountsPassedFromLastUsefulkey_int > $maxSleepCountsForUsefulCombo_int then ;reset
        $comboStarted_bool = 0
        $sleepCountsPassedFromLastUsefulkey_int = 0
        resetKeyComboArr()       
    endif
WEnd

DllClose($hDLL)

func oneBeep()
    Beep( 500 , 50)
endfunc

func longBeep()
    Beep( 500 , 150)
endfunc

func checkKeyComb()
    if $keyCombo_arr[$ctrl] = 1 _
       and $keyCombo_arr[$shift] = 1 _
       and $keyCombo_arr[$alt] = 1 _
       and $keyCombo_arr[$one] = 1 _
       Then
       oneBeep()
       resetKeyComboArr()
       return 1
    elseif $keyCombo_arr[$ctrl] = 1 _
       and $keyCombo_arr[$shift] = 1 _
       and $keyCombo_arr[$alt] = 1 _
       and $keyCombo_arr[$two] = 1 _
       Then
       longBeep()
       resetKeyComboArr()
       return 1
    endif
endfunc

func resetKeyComboArr()
    for $i=0 to (Ubound($keyCombo_arr)-1)
        $keyCombo_arr[$i]=0
    next
endfunc
Note that this script works only with the combo ctrl+alt+shift+1 or ctrl+alt+shift+2 . Feel free to change it using that script as example (for keycodes see http://www.autoitscript.com/autoit3/doc ... s/Send.htm )
Last edited by pier4r on 23 Apr 2013, 08:25, edited 2 times in total.

pier4r
Posts: 52
Joined: 02 Mar 2013, 18:09

Re: Feedback for set selectors

Post by pier4r »

Solved! (in windows xp)

Using: http://www.xpadder.com/forum4/viewtopic.php?f=180 (to exec a program thanks to windows shortcuts)

I have done 2 batch files and shortcuts to these batches (note that shortcuts execute the bat minimized, to avoid conflicts with current game). One batch contains 1 beep and the other one contains 2 beeps. ( http://www.computing.net/answers/progra ... 27669.html )

Then i set, in the shortcuts to these batches, a key combo short cut. ctrl+shift+1 for 1 beep and ctrl+shift+2 for 2 beep. So in xpadder i set the set selector button:

Code: Select all

...
Set1Button6Slots=Left Control,Left Shift,2
...
Set2Button6Slots=Left Control,Left Shift,1
...
and it is working.

note: if you have only one cpu (better: a monocore), the beeps can be delayed if the game took all the cpu (then the bats should be executed with high priority using the command "start" and its options). If you have more than one core, and you do not have a operating system with a good multicpu scheduler (as windows xp. While vista/seven/8 are ok), then assing xpadder fixed to one cpu (i don't know why but the process called by xpadder are excuted on that cpu too) before enter in the match or by imagecfg (google it) .

Now i can switch faster without an high focus :)

pier4r
Posts: 52
Joined: 02 Mar 2013, 18:09

Re: Feedback for set selectors

Post by pier4r »

A new simpler and better solution, since windows sometimes take time to check the pressed shortcut, then it's better to use low level simple feedback. Using "caps lock" led on the keyboard!

pier4r
Posts: 52
Joined: 02 Mar 2013, 18:09

Re: Feedback for set selectors

Post by pier4r »

A better solution with autoIt as xpadder helper. (see first post)

Darkitow
Posts: 29
Joined: 02 Apr 2013, 17:56

Re: Feedback for set selectors

Post by Darkitow »

[EDIT] Ok I've been checking the program's documentation and I found out the problem. You're missing the string "#include <Misc.au3>" before the "if" statement, and without it, the program doesn't recognize the function _IsPressed. So the working code would be:

Code: Select all

#comments-start
Program to give a feedback for xpadder set selectors. Xpadder is a program focused on keyboard and
mouse emulation and should optimize that features, not others. So it doesn not give any feedback for set selectors and it is ok.
Anyway, at least now in 2013, there are tons of scripting languages that can be combined with xpadder
to produce a powerful suite of gaming tools. So let xpadder focus on emulation and do other things with other languages

Then we simply associate a key combo to a set selector and listen for it and then produce the right feedback
(in this case, a beep)
#comments-end

dim const $sleepDuration_int = 50; in milliseconds
dim const $maxSleepCountsForUsefulCombo_int = 2 
dim const $ctrl = 11
dim const $shift = 10
dim const $alt = 12
dim const $one = 31
dim const $two = 32
dim $keyCombo_arr[40] ;just large enought to capture the keys 
resetKeyComboArr()
dim $sleepCountsPassedFromLastUsefulkey_int = 0 ; count sleep passed from the useful keypress, else is not a combination
dim $comboStarted_bool=0

#include <Misc.au3>

Local $hDLL = DllOpen("user32.dll")

While 1
    If _IsPressed(String($ctrl), $hDLL) Then
        ;set or overwrite
        $keyCombo_arr[$ctrl] = 1
        $comboStarted_bool = 1
    endif
    
    if _IsPressed(String($shift), $hDLL) Then
        $keyCombo_arr[$shift] = 1
        $comboStarted_bool = 1
    EndIf
    
    if _IsPressed(String($alt), $hDLL) Then
        $keyCombo_arr[$alt] = 1
        $comboStarted_bool = 1
    EndIf
    
    if _IsPressed(String($one), $hDLL) Then
        $keyCombo_arr[$one] = 1
        $comboStarted_bool = 1
    EndIf
    
    if _IsPressed(String($two), $hDLL) Then
        $keyCombo_arr[$two] = 1
        $comboStarted_bool = 1
    EndIf
    
    ;before the sleep
    if $comboStarted_bool = 1 _
        and $sleepCountsPassedFromLastUsefulkey_int <= $maxSleepCountsForUsefulCombo_int _
        and checkKeyComb() _
        then ;reset
        $comboStarted_bool = 0
        $sleepCountsPassedFromLastUsefulkey_int = 0
    endif
    
    Sleep($sleepDuration_int) ;else the program listen continuosly
    
    ;updates
    if $comboStarted_bool = 1 _
        and $sleepCountsPassedFromLastUsefulkey_int <= $maxSleepCountsForUsefulCombo_int _
        then
        $sleepCountsPassedFromLastUsefulkey_int += 1
    elseif $sleepCountsPassedFromLastUsefulkey_int > $maxSleepCountsForUsefulCombo_int then ;reset
        $comboStarted_bool = 0
        $sleepCountsPassedFromLastUsefulkey_int = 0
        resetKeyComboArr()       
    endif
WEnd

DllClose($hDLL)

func oneBeep()
    Beep( 500 , 50)
endfunc

func longBeep()
    Beep( 500 , 150)
endfunc

func checkKeyComb()
    if $keyCombo_arr[$ctrl] = 1 _
       and $keyCombo_arr[$shift] = 1 _
       and $keyCombo_arr[$alt] = 1 _
       and $keyCombo_arr[$one] = 1 _
       Then
       oneBeep()
       resetKeyComboArr()
       return 1
    elseif $keyCombo_arr[$ctrl] = 1 _
       and $keyCombo_arr[$shift] = 1 _
       and $keyCombo_arr[$alt] = 1 _
       and $keyCombo_arr[$two] = 1 _
       Then
       longBeep()
       resetKeyComboArr()
       return 1
    endif
endfunc

func resetKeyComboArr()
    for $i=0 to (Ubound($keyCombo_arr)-1)
        $keyCombo_arr[$i]=0
    next
endfunc
Also, just to clarify an issue: the "beep" sound uses the system sounds bar in the volume mixer, that in my computer was muted by default. I though the program wasn't working properly because I couldn't hear the sound, but it was just that, so I post it here so nobody does the idiot like me tinkering with the program because of that. <_<

Thanks for the code, anyways, I'll be making use of this from now on. =) I gotta tweak it to use a different sound file that suits the game better, but that seems easy. ;)

rockeumel
Posts: 39
Joined: 12 Jul 2012, 07:34

Re: Feedback for set selectors

Post by rockeumel »

Autohotkey/Autoit is capable to use gui elements, maybe it is possible to create an overlay display to show which set is active?
Instead of beep sounds or playing soundfiles, show a text.

Darkitow
Posts: 29
Joined: 02 Apr 2013, 17:56

Re: Feedback for set selectors

Post by Darkitow »

I though about something like that too, but the problem is that it's a very erratic function whatever the feedback system you try to use.

The main problem is that the Set selector function is applied separatedly instead of as part of the succession of commands, so it's possible that if you tap the button too fast, it will regster the set change but not AutoIt's hotkey. Also, since it requires to use the turbo function for the While-held glitch workaround, I suppose that's also part of the problem. I'm not sure if it would work the 100% of the times if we used the real while-held set command, but considering that this one causes the program to glitch more often , it would be a counterproductive solution.

One possible solution I suppose it would be to "listen" to Xpadder's movements instead of setting it as a hotkey for it to use, but I'm not even sure if that's possible. If it was, we could theoretically even create a "patch" that resetted Xpadder automatically when it was stuck at a different set when no button is being held, so this idea might be worth investigating.

But to be honest, in my opinion the best solution would be that Xpadder integrated all of its "non-assignment" type functions (toggle, turbo, rumble, set selector) as assignments. If for example there was a set selector assignment, you could put it after a Hold Zone and absolutely resolve any glitch involving tap timing, because the main problem here is that the set selectors detect even the slightest tap.

But as far as I know, the set selector glith is not going to be adressed any time soon, as Primal Fear told me. So the "patch" for Xpadder might be something interesting to look into. I guess I could try opening a thread about it.

pier4r
Posts: 52
Joined: 02 Mar 2013, 18:09

Re: Feedback for set selectors

Post by pier4r »

Darkitow wrote: But to be honest, in my opinion the best solution would be that Xpadder integrated all of its "non-assignment" type functions (toggle, turbo, rumble, set selector) as assignments. If for example there was a set selector assignment, you could put it after a Hold Zone and absolutely resolve any glitch involving tap timing, because the main problem here is that the set selectors detect even the slightest tap.
Nice point

edit: about #include <misc.au3> i didn't copy the entire script, sorry :P

@overlay: that need a gui, but basically an OSD (overlay screen display ) is a nice idea too.

pier4r
Posts: 52
Joined: 02 Mar 2013, 18:09

Re: Feedback for set selectors

Post by pier4r »

Alright, got it running and tried to test it in the game. To do that, I added a "ctrl + alt + shift + 1" command to the set selectors in set 1... And it works half the time. Apparently sometimes the set selector triggers too fast (since it uses the turbo function), so I'm not really sure about how to make it work 100% of the times. Any suggestions?
play with these

Code: Select all

dim const $sleepDuration_int = 50; in milliseconds
dim const $maxSleepCountsForUsefulCombo_int = 2 

Darkitow
Posts: 29
Joined: 02 Apr 2013, 17:56

Re: Feedback for set selectors

Post by Darkitow »

I don't think the solution lies in AutoIt in this case. The problem is not the feedback app, the problem is that the time for the set switch is not too consistent. Sometimes Xpadder has time to activate the shortcut, sometimes it doesn't. You need to keep the button pressed a bit longer to make it happen more consistently, but what I want is the opposite: to know when the button was pressed too fast to be registered in the target set.

The most optimal solution, as far as I know, would be to find a way to "listen" to Xpadder's state wo we can monitor in which set it is already.

pier4r
Posts: 52
Joined: 02 Mar 2013, 18:09

Re: Feedback for set selectors

Post by pier4r »

Darkitow wrote:I don't think the solution lies in AutoIt in this case. The problem is not the feedback app, the problem is that the time for the set switch is not too consistent. Sometimes Xpadder has time to activate the shortcut, sometimes it doesn't. You need to keep the button pressed a bit longer to make it happen more consistently, but what I want is the opposite: to know when the button was pressed too fast to be registered in the target set.
Didn't know that! Thx
The most optimal solution, as far as I know, would be to find a way to "listen" to Xpadder's state wo we can monitor in which set it is already.
Yup but this is not simple, maybe an internal solution will be better.

Darkitow
Posts: 29
Joined: 02 Apr 2013, 17:56

Re: Feedback for set selectors

Post by Darkitow »

Is it even possible to do that? I have no idea of AutoIt yet, so I can't really think of a way. Would it be possible to create an application with it that was able to read some internal settings in Xpadder, such as the current set and the state of the buttons?

Also, of course an internal solution would be the best, but unfortunately this issue doesn't seem to be of top priority on Jonathan's update list. Is not like people make profiles THAT complicated all the time, let's be honest. :roll:

pier4r
Posts: 52
Joined: 02 Mar 2013, 18:09

Re: Feedback for set selectors

Post by pier4r »

Darkitow wrote:Is it even possible to do that? I have no idea of AutoIt yet, so I can't really think of a way. Would it be possible to create an application with it that was able to read some internal settings in Xpadder, such as the current set and the state of the buttons?
Yes but it is really difficult. Like a sort of hack of the program. maybe it is easier to do a new xpadder from scratch xD.

rockeumel
Posts: 39
Joined: 12 Jul 2012, 07:34

Re: Feedback for set selectors

Post by rockeumel »

Is it not a detour to work with Autohotkey or AutoIt and Xpadder?
Autohotkey as example recognizes controller entries by it self.
The disadvantage of this two programs is the lag of a good UserInterface to bind keys, it is all script/code based.

pier4r
Posts: 52
Joined: 02 Mar 2013, 18:09

Re: Feedback for set selectors

Post by pier4r »

Yep, it's always a detour.

Post Reply

Return to “Sets”