Here is a little Autohotkey script that can help you, if you want to use a gamepad or xbox contoller for analog nudging. As a bonus it also allows you to use the d-pad of your controller for your service buttons. Copy the code into an empty text file and rename it to whatever you like. JusT make sure it has the filename extension ".ahk".
I have included all information of how to use the script in the comment section of the script:
;VpinballX is only configured to use accelerometers for nudging.
;Therefore I wrote this little script which converts the absolute data from joystick input to an accelertion value
;This script allows you to use the left (and right, if configured in script below) joystick of the gamepad controller for nudging in VPinballX
;Do not expect a completely realistic nudging behavior, because nudging with a controller will always be different from real nudging.
;
;
; HOW to install and use this script:
;
; - Download and install Autohotkey from www.autohotkey.com
; - Download and install vjoy from vjoystick.sourceforge.net
; - set up and configure a vjoy joystick
; start "configure vJoystick" from the Windows start menu
; During the setup process of your vjoy: check "Slider" and "Dial/Slider2"
; Keep all other axes unchecked
; Confirm that your vJoy Device ID is 1
;if it is not 1, change the vjoy_id in the "Settings" section of this script accordingly
; - Download VJoy_lib.ahk library FROM github.com/AHKScript/AHK-vjoy-Library and put this library file
;into the same folder together with this script
; - Change the setting in Visual Pinball:
; Go to the "Preferences-Configure Keys,Nugde and DOF" section of Visual Pinball
; and set "X Axis(L/R)" to "Slider 1"
; and "Y Axis(U/D)" to "Slider 2"
;check "Enable Analog Nudge" and check "Tilt Sentitivity"
; Uncheck "Legacy/VP 9 style...", "Enable Nudge Filter...", "Normal Board..." and "Acclerometer Rotation"
; Set X-Max,Y-Max,X-Gain,Y-Gain and Tilt Sensitivity to whatever feels good for your purpose
;
; To give you a good starting point for your tweakings, here are the values I currently use:
; X-Max.....100,Y-Max....100,X-Gain...60%,Y-Gain....60% and Tilt Sensitivity 860
; Disclaimer: I am still experimenting with these values and I am by no means a pinball expert.
; So I am sure you can come up with better values by yourself.
; - Once you have completed all steps above you can start this script by double-clicking on it.
;If you see now a green tray icon with a white "H" ,
;you have sucessfully started the script and the script is running.
; Now you shoud be able to use your left joystick of the gamepad for nudging
; TROUBLESHOOTING:
; For some reason the script occasionally may crash or not work properly.
; In this case a restart of the script should help:
; - right click on the green tray icon and choose exit
; - then restart the script again by doubbleclicking the script file.
; A bonus feature I have included:
; it sends service button keystokes, if you press the buttons of the D-pad of the gamepad.
; This allows you to use the service buttons with your gamepad on most tables.
; However, unfortunately you cannot press two service buttons at the same time with your D-pad.
; In this case you can still use the keyboard.
; If you want wo disable this feature, add ";" before "SetTimer, WatchPOV, 5" in the script below
; Happy pinballing!!!
;License Information: I do not care. Do whatever you want with this script.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;;;;;;;;;;;; SETTINGS ;;;;;;;;;;;;;;;
; Set the vjoy id of the stick to control
vjoy_id := 1
; Make sure your VJoy_lib.ahk script is in the same folder
#Include VJoy_lib.ahk
; Enable (true) or disable (false) left-right nudging with right controller stick
leftJoystickNudge :=false
;;;;;;;;;;;;;;; END OF SETTINGS ;;;;;;;;;;;;;;
Starttimer:
SetTimer, WatchAxis, 15
SetTimer, WatchPOV, 5
OldX:=32767/2
OldY:=32767/2
OldZ:=0
; Init the vJoy stick
vjoy_init(vjoy_id)
Main:
goto Main
WatchPOV:
POV := GetKeyState("JoyPOV")
KeyToHoldDownPrev := KeyToHoldDown
if (POV < 0) ; No D-pad keys
KeyToHoldDown := ""
else if (POV > 31500) ; Forward
KeyToHoldDown := "7"
else if POV between 0 and 4500 ; Forward
KeyToHoldDown := "7"
else if POV between 4501 and 13500 ; Right
KeyToHoldDown := "9"
else if POV between 13501 and 22500 ; Down
KeyToHoldDown := "vk0x30"
else ; Left
KeyToHoldDown := "8"
if (KeyToHoldDown = KeyToHoldDownPrev)
return ; Do nothing.
SetKeyDelay -1
if KeyToHoldDownPrev
Send, {%KeyToHoldDownPrev% up} ; release
if KeyToHoldDown
Send, {%KeyToHoldDown% down} ; press down
return
WatchAxis:
JoyX := GetKeyState("JoyX")*327.67
JoyY := GetKeyState("JoyY")*327.67
JoyZ := GetKeyState("JoyZ")*327.67
DeltaX:=JoyX-OldX+32767/2
DeltaY:=JoyY-OldY+32767/2
DeltaZ:=JoyZ-OldZ
if(leftJoystickNudge)
{
DeltaXZ:=DeltaX+DeltaZ
}
else
{
DeltaXZ:=DeltaX
}
OldX:=JoyX
OldY:=JoyY
OldZ:=JoyZ
; Set axis value
VJoy_SetAxis(DeltaXZ, vjoy_id, HID_USAGE_SL0)
VJoy_SetAxis(DeltaY, vjoy_id, HID_USAGE_SL1)
return
Edited by magnasaver, 28 July 2020 - 10:23 AM.




Top










are all trademarks of VPFORUMS.