Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Using AHK to control vJoy


  • Please log in to reply
51 replies to this topic
evilc
  • Members
  • 340 posts
  • Last active: Oct 27 2015 11:07 PM
  • Joined: 17 Nov 2005

I found an issue with this library..
 
connect to virtual stick 1
disconnect from virtual stick 1
connect to virtual stick 2
disconnect from virtual stick 2
connect to virtual stick 1
 
you do not get control back of stick 1.
 
I had to add a new function to the library:
 

; Acquire device - added by evilC
VJoy_AcquireVJD(id) {
    Global VJDev
    if (VJoy_DeviceErr(id))
        return False
    return DllCall("vJoyInterface\AcquireVJD", "UInt", id)
}
 

I found that I had to VJoy_RelinquishVJD(vjoy_id) on one stick before I could control another, but when I did a VJoy_Init in the same stick again, it went OK but trying to manipulate the stick had no effect.

 

Calling my VJoy_AcquireVJD() function solves this for me.

 

I managed to update UJR to be able to switch virtual sticks on the fly.

It can even detect a change in the virtual stick capabilities - ie if you change the virtual stick from 32 to 16 buttons using the vjoy app, UJR detects this in real-time and disables buttons 17-32.

 

So with this code added, I can confirm that just about any action works with this library. I can even run multiple copies of my app and have each control a different stick, with each copy able to detect if the other is controlling a given stick.

 

The copy of this library included in my UJR project contains this change, it can be found here.



DAOWAce
  • Members
  • 13 posts
  • Last active:
  • Joined: 31 Jan 2010

Edit: Finally found the solution, details here: http://www.autohotke...e-4#entry630138

 

Well, I finally got the functionality I wanted..

But now I need to somehow map my entire pad to be identical to the vJoy one.

I was using UJR, but I can't use it with my macro, nor do I even know how to edit the config to implement my macro, if even possible.

 

#include %A_ScriptDir%\VJoy_lib.ahk

    VJoy_Init()
    nButtons := VJoy_GetVJDButtonNumber(iInterface)

~*3Joy3::
loop
{
   If !GetKeyState("3Joy3","p")
{
      break
}
else
   {
    VJoy_SetBtn(1, 1, 3)
    Sleep, 100
    VJoy_SetBtn(0, 1, 3)
      sleep, 500
      }
}
Return

Any help? :(


I don't mean to sound rude, but I can't help the way people interpret my words.

thebunnyrules
  • Members
  • 15 posts
  • Last active: Jun 09 2017 02:26 AM
  • Joined: 09 Jan 2015
I'm trying to merge my xbox controller and g27 steering wheel into one XBox like vjoy device (meaning vjoy device will have the same button and axis configs as a regular xbox controller). I'm using EvilC's UJR but it only supports 1 axis to 1 axis mapping whereas if I am to map the pedals as triggers I need to map each of them (and they each have their own axis) as a half axis (which is what a trigger is). 
 
I'm trying to find the right AHK script that would do this which I would then integrate into the UJR ahk script, maybe even mod the gui to add pedal to trigger support.
 
Can anyone help me out with the code needed to map 1 axis to 1/2 axis in ahk? Thanks guys!


evilc
  • Members
  • 340 posts
  • Last active: Oct 27 2015 11:07 PM
  • Joined: 17 Nov 2005

First, UJR does support axis merging, but it is a bit cumbersome.

Second, you might want to try the CvJoyInterface library, as it is easier to use than this one.



thebunnyrules
  • Members
  • 15 posts
  • Last active: Jun 09 2017 02:26 AM
  • Joined: 09 Jan 2015

I'll give it a go thanks!



thebunnyrules
  • Members
  • 15 posts
  • Last active: Jun 09 2017 02:26 AM
  • Joined: 09 Jan 2015

Hey, I saw in a post from a year and some back that you were thinking of implementing UJR in C. Is that something you're still going to do?



evilc
  • Members
  • 340 posts
  • Last active: Oct 27 2015 11:07 PM
  • Joined: 17 Nov 2005

No, the successor to UJR is well underway and it is still AutoHotkey.