Remap joystick (axis) to turn around how to use

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Ataricx
Posts: 34
Joined: 24 Feb 2019, 06:12

Remap joystick (axis) to turn around how to use

24 May 2019, 03:53

I am 49 years old and got used to holding an joystick upside down on an early age. Now i am playing games again with a snes controler (see picture)

I know, i better get use to the proper way, but i can't anymore, it's too much of an headach to learn, so i want to have an script which remaps the axis upside down in W10

I already got this script to remap the axis to do cursor keys, so i know it is possible

I will upload the picture just the way i want to use the joystick.

Code: Select all

#Persistent  ; Keep this script running until the user explicitly exits it.
SetTimer, WatchAxis, 5
return

WatchAxis:
JoyX := GetKeyState("JoyX")  ; Get position of X axis.
JoyY := GetKeyState("JoyY")  ; Get position of Y axis.
KeyToHoldDownPrev := KeyToHoldDown  ; Prev now holds the key that was down before (if any).

if (JoyX > 70)
    KeyToHoldDown := "Left"
else if (JoyX < 30)
    KeyToHoldDown := "Right"
else if (JoyY > 70)
    KeyToHoldDown := "Up"
else if (JoyY < 30)
    KeyToHoldDown := "Down"
else
    KeyToHoldDown := ""

if (KeyToHoldDown = KeyToHoldDownPrev)  ; The correct key is already down (or no key is needed).
    return  ; Do nothing.

; Otherwise, release the previous key and press down the new key:
SetKeyDelay -1  ; Avoid delays between keystrokes.
if KeyToHoldDownPrev   ; There is a previous key to release.
    Send, {%KeyToHoldDownPrev% up}  ; Release it.
if KeyToHoldDown   ; There is a key to press down.
    Send, {%KeyToHoldDown% down}  ; Press it down.
return
Attachments
joystick gamepad .PNG
joystick gamepad .PNG (68.91 KiB) Viewed 4701 times
Ataricx
Posts: 34
Joined: 24 Feb 2019, 06:12

Re: Remap joystick (axis) to turn around how to use

24 May 2019, 12:48

so unlucky for me, this isnt possible?
nevertheless, thanx for reading :)
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: Remap joystick (axis) to turn around how to use

24 May 2019, 21:48

Ataricx wrote:
24 May 2019, 03:53
I already got this script to remap the axis to do cursor keys, so i know it is possible
Hi Ataricx,

If I understand correctly, what you're trying to do is slightly different and more problematic: you're trying to remap or "send" as a joystick (correct me if I'm wrong).
If so, you might be interested in Trying to remap or "send" as a joystick?.
my scripts
Ataricx
Posts: 34
Joined: 24 Feb 2019, 06:12

Re: Remap joystick (axis) to turn around how to use

25 May 2019, 04:05

Thank you for your reaction, i've tried the link out and downloaded the file, but mainly is for Xbox and the other (ucr) is much to complicated

I will explain more detailed.

On the 1st picture you'll see X-as and y-as, it's x-as is to the left middle but i want it to go to the right middle, so just the opposite
The same with the Y-as, when i press top, it will go to the top of the y-as box.

If i would succeed all the x-as and y-as are the opposite of where it should be in W10.

But in my case that is to be prefered because i got use to holding the gamepad upside down like i am used to since 1990... i tried to 'reprogram myself' but thats very difficult.

In picture 3 it shows how i wish to use the gamepad, but before i can, it must be remapped with just the x-as and y- as.

* I dont want to remap any keyboard or mouse to an button
* I dont want to remap any button, buttons are ok, no problem

Hopefully this is more clear now.. Maybe it can be done with the Registry, but i search on that through google and was unsuccesfull.
Attachments
joystick remap 1.jpg
joystick remap 1.jpg (49.6 KiB) Viewed 4628 times
joystick remap 2.jpg
joystick remap 2.jpg (43.28 KiB) Viewed 4628 times
Ataricx
Posts: 34
Joined: 24 Feb 2019, 06:12

Re: Remap joystick (axis) to turn around how to use

25 May 2019, 05:19

Sorry about the confussion.. I've edited the picture and merged the 2 pictures together so it's more obvious hopefully...
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Remap joystick (axis) to turn around how to use

25 May 2019, 17:11

Recalibrate the joystick, but switch the directions ;)
If you have trouble doing it using the windows calibration tool, then use DIView
There is a slight bug in the DIView manual calibration, you cannot type in negative values. To work around it, copy the value to the clipboard and paste.

If you really want to do it using AHK...
As mentioned in the "Trying to remap" link, it is not possible to alter how windows sees a device using AHK - all you can do is spin up a virtual vJoy stick (See CvJoyInterface linked in that thread), and route all the input from the physical stick to the virtual stick

What's too complicated about UCR? It would be orders of magnitude simpler (Like less than an hour to get to grips with it) compared to coding the equivalent functionality in AHK. Even remapping an joystick button to a keyboard key in AHK is a pain in the arse, due to bugs in AHK that will never be fixed - 1Joy1::a does NOT properly remap joystick button 1 to a - it maps press of joystick button 1 to press *and release* of a - ie with that hotkey, you cannot hold the a key by holding joystick button 1
Ataricx
Posts: 34
Joined: 24 Feb 2019, 06:12

Re: Remap joystick (axis) to turn around how to use

26 May 2019, 03:58

I've tried DLview, but i dont understand how i should enter the values......

Thanks for the reply, i guess i am stuck with this and must adjust i to work with a gamepad
Attachments
snipaste_20190526_105748.png
snipaste_20190526_105748.png (6.23 KiB) Viewed 4580 times
scriptor2016
Posts: 860
Joined: 21 Dec 2015, 02:34

Re: Remap joystick (axis) to turn around how to use

27 May 2019, 09:03

I have been working all weekend on getting a Nintendo Joy Con controller to work on my Windows7 system... all new territory for me. Happily, I have it working now. So I have a bit of practice with this joystick thing now.

Concerning your code, it might seem to easy, but it looks like all you have to do is swap the "Left" and "Right" words, and also swap the "Up" and "Down" words. Or I could be totally wrong in this particular case. But does this work?

Code: Select all

#Persistent  ; Keep this script running until the user explicitly exits it.
SetTimer, WatchAxis, 5
return

WatchAxis:
JoyX := GetKeyState("JoyX")  ; Get position of X axis.
JoyY := GetKeyState("JoyY")  ; Get position of Y axis.
KeyToHoldDownPrev := KeyToHoldDown  ; Prev now holds the key that was down before (if any).

if (JoyX > 70)
    KeyToHoldDown := "Right" ;this was originally "Left"
else if (JoyX < 30)
    KeyToHoldDown := "Left" ;this was originally "Right"
else if (JoyY > 70)
    KeyToHoldDown := "Down" ;this was originally "Up"
else if (JoyY < 30)
    KeyToHoldDown := "Up" ;this was originally "Down"
else
    KeyToHoldDown := ""

if (KeyToHoldDown = KeyToHoldDownPrev)  ; The correct key is already down (or no key is needed).
    return  ; Do nothing.

; Otherwise, release the previous key and press down the new key:
SetKeyDelay -1  ; Avoid delays between keystrokes.
if KeyToHoldDownPrev   ; There is a previous key to release.
    Send, {%KeyToHoldDownPrev% up}  ; Release it.
if KeyToHoldDown   ; There is a key to press down.
    Send, {%KeyToHoldDown% down}  ; Press it down.
return
Ataricx
Posts: 34
Joined: 24 Feb 2019, 06:12

Re: Remap joystick (axis) to turn around how to use

27 May 2019, 12:24

thanx @scriptor2016 but this only remaps keyboard keys to joystick, it doenst do anything with the joystick itself
Ataricx
Posts: 34
Joined: 24 Feb 2019, 06:12

Re: Remap joystick (axis) to turn around how to use

28 May 2019, 13:00

just to make sure we talking about the same stuff, do you mean this program?

if i adjust the values the x as doesnt do anything anymore.
Attachments
cal01.png
cal01.png (58.5 KiB) Viewed 4516 times
Ataricx
Posts: 34
Joined: 24 Feb 2019, 06:12

Re: Remap joystick (axis) to turn around how to use

29 May 2019, 03:49

Thanx for your reaction Evilc

I downloaded vjoy but instantly got an install error on the end of the process bar...

i will search for an solution...
Ataricx
Posts: 34
Joined: 24 Feb 2019, 06:12

Re: Remap joystick (axis) to turn around how to use

29 May 2019, 03:59

i tried to install older versions, but with same result : failed to install on the end of installation process
Ataricx
Posts: 34
Joined: 24 Feb 2019, 06:12

Re: Remap joystick (axis) to turn around how to use

29 May 2019, 05:56

no 1903... i guess thats the problem...
Ataricx
Posts: 34
Joined: 24 Feb 2019, 06:12

Re: Remap joystick (axis) to turn around how to use

29 May 2019, 13:12

np :)

the program got me into 'test mode' and i was supprised with an watermark on my desktop..... so better not install this on 1903

thanx anyway !
Ataricx
Posts: 34
Joined: 24 Feb 2019, 06:12

Re: Remap joystick (axis) to turn around how to use

30 May 2019, 13:36

That program did get me into test mode... i got it from the original site... i will try it in a few weeks, hopefully it will be updated then

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Joey5 and 277 guests