Hello. I am running into a logical problem. If you aim with a controller, Z goes negative. If you shoot, it goes positiv. It is 0 if you press neither. But if you aim and shoot, it is 0 aswell...
How do games like Far Cry or basically any egoshooters and racing games detect, that you have pressed both?
I remember, I had a problem, when trying to map SNES9X to my Asus controller, because I needed Z axis. It was not supporting to press both of course, because it returns value 0...
What do I need to do, to come around this? Is it switching between negative and positive as fast as it can or is there a "proper" way to archive this?
Thanks so far. I don't get it... If you guys also know a solution how to detect "Aim+Shoot" or "Break+Gas" separately for other applications, it would be an amazing bonus.
Just to say: I am amazed a lot by this tool, even though I am not getting results as intended. It however is the first tool that succesfully did something like "When pressing 'G' on keyboard, press Button number "..." on controller". It basically just seems to work as I want it to. Very amazing. Thanks for dev. <3
How to program Z-Axis for Aim+Shoot?
-
- One Eyed Hopeful
- Posts: 7
- Joined: Fri Dec 28, 2018 5:35 pm
-
- One Eyed Hopeful
- Posts: 7
- Joined: Fri Dec 28, 2018 5:35 pm
Re: How to program Z-Axis for Aim+Shoot?
Ok, can be closed or deleted. I found it all out. I am happy with the results. Other Problem occours that is to much offtopic, so I'll open new thread.
1 or 2 snippets in there that are unneccesary. Started with another ones code. Basically nothing left. But no cleanup was done. Hope it helps someone. Feel free to use it in ANY way.
Code: Select all
from System import Int16
def update():
global yaw
global pitch
global roll
global lastYaw
global x
global y
global z
if starting:
zswitch = 0
system.threadExecutionInterval = 5
enabled = False
global mouse_sensitivity, steering_center
# mouse to vJoy
vJoy[0].rx = mouse.deltaX*400
vJoy[0].ry = mouse.deltaY*400
if keyboard.getKeyDown(Key.D) and not keyboard.getKeyDown(Key.A):
vJoy[0].x = 16500
if keyboard.getKeyDown(Key.A) and not keyboard.getKeyDown(Key.D):
vJoy[0].x = -16500
if keyboard.getKeyDown(Key.W) and not keyboard.getKeyDown(Key.S):
vJoy[0].y = -16500
if keyboard.getKeyDown(Key.S) and not keyboard.getKeyDown(Key.W):
vJoy[0].y = 16500
if not keyboard.getKeyDown(Key.A) and not keyboard.getKeyDown(Key.D):
vJoy[0].x = 0
if not keyboard.getKeyDown(Key.S) and not keyboard.getKeyDown(Key.W):
vJoy[0].y = 0
if keyboard.getKeyDown(Key.DownArrow) and keyboard.getKeyDown(Key.LeftArrow) and not keyboard.getKeyDown(Key.UpArrow) and not keyboard.getKeyDown(Key.RightArrow):
vJoy[0].setAnalogPov(0, 22500)
elif keyboard.getKeyDown(Key.UpArrow) and keyboard.getKeyDown(Key.LeftArrow) and not keyboard.getKeyDown(Key.RightArrow) and not keyboard.getKeyDown(Key.DownArrow):
vJoy[0].setAnalogPov(0, 31500)
elif keyboard.getKeyDown(Key.UpArrow) and keyboard.getKeyDown(Key.RightArrow) and not keyboard.getKeyDown(Key.DownArrow) and not keyboard.getKeyDown(Key.LeftArrow):
vJoy[0].setAnalogPov(0, 4500)
elif keyboard.getKeyDown(Key.RightArrow) and keyboard.getKeyDown(Key.DownArrow) and not keyboard.getKeyDown(Key.UpArrow) and not keyboard.getKeyDown(Key.LeftArrow):
vJoy[0].setAnalogPov(0, 13500)
elif keyboard.getKeyDown(Key.DownArrow) and not keyboard.getKeyDown(Key.UpArrow):
vJoy[0].setAnalogPov(0, 18000)
elif keyboard.getKeyDown(Key.UpArrow) and not keyboard.getKeyDown(Key.DownArrow):
vJoy[0].setAnalogPov(0, 0)
elif keyboard.getKeyDown(Key.LeftArrow) and not keyboard.getKeyDown(Key.RightArrow):
vJoy[0].setAnalogPov(0, 27000)
elif keyboard.getKeyDown(Key.RightArrow) and not keyboard.getKeyDown(Key.LeftArrow):
vJoy[0].setAnalogPov(0, 9000)
else:
vJoy[0].setAnalogPov(0, -1)
if mouse.leftButton and not mouse.rightButton:
vJoy[0].z = 16500
elif mouse.rightButton and not mouse.leftButton:
vJoy[0].z = -16500
elif mouse.rightButton and mouse.leftButton and (zswitch < 5) and (zswitch > -1):
zswitch = zswitch+1
vJoy[0].z = 10000
elif mouse.rightButton and mouse.leftButton and (zswitch == 5):
zswitch = -100
elif mouse.rightButton and mouse.leftButton and (zswitch < 0):
zswitch = zswitch+1
else:
vJoy[0].z = 0
if (zswitch == 5):
zswitch = -5
if (zswitch > -1) and mouse.leftButton and mouse.rightButton:
vJoy[0].z = -6500
elif (zswitch < 0) and mouse.leftButton and mouse.rightButton:
vJoy[0].z = 6500
# assign button
vJoy[0].setButton(0,int(keyboard.getKeyDown(Key.Space)))#jump
vJoy[0].setButton(1,int(keyboard.getKeyDown(Key.C)))#back
vJoy[0].setButton(2,int(keyboard.getKeyDown(Key.R)))#reload
vJoy[0].setButton(3,int(keyboard.getKeyDown(Key.D1)))#changeweapon
vJoy[0].setButton(4,int(keyboard.getKeyDown(Key.F)))#specialgrenade
vJoy[0].setButton(5,int(keyboard.getKeyDown(Key.G)))#fraggrenade
vJoy[0].setButton(6,int(keyboard.getKeyDown(Key.P)))
vJoy[0].setButton(7,int(keyboard.getKeyDown(Key.O)))
vJoy[0].setButton(8,int(keyboard.getKeyDown(Key.V)))
vJoy[0].setButton(9,int(keyboard.getKeyDown(Key.T)))