If you are trying to effectively do this: Send {Joy1} or a::Joy1 then please note that AHK does not support this, and what you want is actually technically very complex, with numerous IFs and BUTs.
I am having to repeat myself a lot on this, so I am going to make one post where I lay it all out and explain what is possible, what is not possible, and what tools can help you.
Primer
First off, I will clarify some terms I will be using...
"XInput" or "XI" - This refers to any Xbox/XbOne pad. Specifically xbox. Playstation pads are different.
"DirectInput" or "DI" - This refers to any non-xbox joystick. Flight sticks, Playstation pads, steering wheels etc all fall into this category.
"Physical stick" - A real joystick or joypad that you are using to control the game. If you want to use the stick to play the game as normal, but alter how just one button behaves, then you are trying to alter how the game sees your physical stick.
"Virtual stick" - A fake (software) joystick created by the likes of vJoy.
A note on Playstation pads:
PS pads are basically DirectInput, but not ALL of their inputs work via DirectInput. Gyro, Touchpad and accelerometers are NOT supported when reading a PS pad via DirectInput.
The Skinny
Vanilla AHK (Without any addon code libraries or third party software) does not support sending as a stick, period.
Basically NOTHING supports sending as a "Physical" stick.
The only case that I am aware of in which you can alter how a game sees your physical stick is using x360CE with an XInput controller. However, this is effectively a hack, as it requires placing a fake XInput.dll in the game folder.
In all other cases, the way this is done is:
1) Create a virtual controller (eg using vJoy)
2) Remap all input from the physical to the virtual controller (With any desired changes in mappings etc)
3) Force the game to only take input from the virtual controller
Below is a more detailed description as how to achieve each step (Both using AHK and with other solutions)
1. Creating virtual controllers
2. Remapping input from the physical controller to the virtual controller
To create a virtual controller, you will need a bit of software which can create fake controllers and allow them to be controlled by our code. There are two main players:
vJoy
http://vjoystick.sourceforge.net
Emulates DirectInput controllers. There is also a variant (Called "vXBox" or "vGen") that can create virtual XInput controllers.
I have a library for AHK that lets you control virtual DirectInput sticks using vJoy here: https://autohotkey.com/boards/viewtopic.php?t=5705
This library does not support vXBox/vGen, so no virtual XInput controllers using this library. I do not plan on updating it as vXBox is dead now we have ViGEm
ViGEm
http://ViGEm.org
Emulates various gamepads (XInput, Playstation etc). Does not emulate DirectInput yet.
There is currently no AHK library for driving ViGEm, but it is technically possible, and in fact quite easy if you used CLR and the C# interface to ViGEm.
I do plan on doing this at some point, but I am waiting for ViGEm to mature a little more.
So AHK scripts are currently a little limited for this part of the equation. Add into the fact that AHK's support for reading physical joysticks is littered with issues which will never be fixed (Support for only 6 axes, 32 buttons / Joystick button bindings do not work properly - Joy1::a releases a as soon as you press Joy1, not when you release it) so as a newbie, I would advise forgetting about using AHK scripts for remapping joysticks if at all possible. It *is* possible to work around these issues in an AHK script, but it is not trivial.
However, there are a couple of applications that can save you having to do any coding at all:
UCR-AHK
https://autohotkey.com/boards/viewtopic ... 19&t=12249
A remapping application written in AutoHotkey. Yes, it can control virtual xbox controllers, I just did not rip out that code and make it stand-alone, so it only exists in UCR-AHK.
It is worth noting that the "Code Runner" plugin can run some AHK script in response to you pressing a button, so some things other than plain remaps might be possible using this.
UCR-C# (AKA UCR2)
https://github.com/Snoothy/UCR
A rewrite of UCR-AHK in C#. This supports ViGEm as well as vJoy.
3. Hiding physical controllers
This is the one that tends to be the problem.
For XInput controllers, there is no known software-only solution to hide the controller from the game (A Titan device can do it, but you need to buy one).
As previously mentioned, X360ce can alter how the game sees the controller, so this is your only real choice if you must use a physical XInput controller.
However, it is worth noting that if your game expects an xbox controller, there is no reason you actually need to be using one. You can use a Playstation controller (which we *can* hide) as your physical controller, and output as a virtual XInput controller.
For DirectInput controllers, we can use HidGuardian ("HG"). I have written a little utility in AHK called https://autohotkey.com/boards/viewtopic ... hiteKnight that can install HG for you and help you setting it up.
However, if using a DirectInput controller, many games let you select which controller to use, so you can just select the virtual one when in normal use. The main reason you need to hide is if you need to use the bind menu in the game - if the physical controller is not hidden, when you press a button it will bind to the physical controller not the virtual one.
Trying to remap or "send" as a joystick? READ THIS BEFORE POSTING
-
- Posts: 7
- Joined: 16 Feb 2020, 08:49
Re: Trying to remap or "send" as a joystick? READ THIS BEFORE POSTING
Wow all those views without any replies Okay
-
- Posts: 1
- Joined: 04 May 2020, 13:53
Re: Trying to remap or "send" as a joystick? READ THIS BEFORE POSTING
Hey,
I'm new to AutoHotkey, so please excuse my ignorance. I (sorta) understand what you've laid out in this post, but I'd like to clarify something.
I play Elite: Dangerous with a Saitek X52 flight stick. I've recently started using Nvidia Geforce NOW to play it on a low-end laptop. GeForce NOW resets the keybindings every time, requiring flight sticks to be remapped to default controls every time the game is launched. Is it possible to write a script that re-maps the flight stick in the game's keybindings menu? No fancy stuff, just mapping the flight stick? I'm expecting a simple "no", but I'm hopeful...
Thank you in advance for any help!
I'm new to AutoHotkey, so please excuse my ignorance. I (sorta) understand what you've laid out in this post, but I'd like to clarify something.
I play Elite: Dangerous with a Saitek X52 flight stick. I've recently started using Nvidia Geforce NOW to play it on a low-end laptop. GeForce NOW resets the keybindings every time, requiring flight sticks to be remapped to default controls every time the game is launched. Is it possible to write a script that re-maps the flight stick in the game's keybindings menu? No fancy stuff, just mapping the flight stick? I'm expecting a simple "no", but I'm hopeful...
Thank you in advance for any help!
Re: Trying to remap or "send" as a joystick? READ THIS BEFORE POSTING
@evilC
Thanks a lot for the handy tools. Can you please tell if it is possible to connect to an already created virtual device in UCR2 instead of creating a new one via "controller: = new ViGEmXb360()", just to add additional macros?
Thanks a lot for the handy tools. Can you please tell if it is possible to connect to an already created virtual device in UCR2 instead of creating a new one via "controller: = new ViGEmXb360()", just to add additional macros?
Re: Trying to remap or "send" as a joystick? READ THIS BEFORE POSTING
As I got into here with google and forum request, are there yet new solutions for xbox controllers ? Maybe because of AHKv2 ?
I am not main English so wich possibility here can I use to build up a autoclicker (rapidfire) for ps4 and xbox and maybe other controllers?
I got one for ps4 working but I am not sure if that is the solution I should took
Tanks for your work btw, as you see you even get relinked in 2023
I am not main English so wich possibility here can I use to build up a autoclicker (rapidfire) for ps4 and xbox and maybe other controllers?
I got one for ps4 working but I am not sure if that is the solution I should took
Code: Select all
#Requires AutoHotkey v2.0
#SingleInstance Force
InstallMouseHook
InstallKeybdHook
SendMode "Event"
; Note Double Keys did occur Errors, so if u are using Controller Fire-Key (in my example R2),
; together with Mouse Fire Key (in my example Left Mouse Button)
; to realise a RapidFire Function,
; then u have to "Unbind" the "R2" in Controller Settings, so the Signal is not send Double to the Game
; i changed at Keyboard´n Mouse Settings "Left Mouse Button for Melee Attack" to a Random free Button ("V"),
; and in Contrl Settings "R2 for Shoot" to the Empty Slot i found "D-Pad Down"
Joy11:: { ; DualShock4 Button "L3" for Toggle On Off the Variable and play the Sound
Static on := False
SoundBeep 1000 + 500 * on ; Plays when Variable gets Toggled On / OFF
SetTimer(RapidFireController, 25 * on := !on)
}
Joy8:: { ; DS4 "R2" Button
Send '{LButton Down}' ; Choosen this to prevent the "GhostBullets" Error somehow
Sleep(30) ; Unclear why other Sends like "Click" occur the "GhostBullets" Error in "SpacePunks" yet
Send '{LButton Up}'
}
RapidFireController() { ; DS4 "R2" RapidFire Part (Using Left Mouse Button "LButton")
If GetKeyState("Joy8", "P") {
Send "{LButton}" ; in RapidiFire Mode this works on Single Fire i get Ghost Bullets
}
}
F10::ExitApp
Who is online
Users browsing this forum: No registered users and 33 guests