Help with code for centering aim with psmove
Posted: Tue Jul 11, 2017 2:06 pm
[EDIT: G0 TO THIRD POST]
I have found a code here to use the psmove as some sort of gun controller (it basically just controls the mouse) I'm using it for doom 3 fully possessed, it only uses the gyroscope, and it works pretty well. It does only activate when you hold the trigger button though, which is a good thing, since you have to repostion your gun now and then to get some good aiming going on.
My only problem is that I would want it to activate it when I click the trigger button not when holding it. So basically it would have to be some sort of toggle command.
this is the code
def update():
#define globals
#define constants
mag = 1000
dz = 0.005
i=0
j=0
#bind left mouse to cross button
#Right mouse to circle button
#Middle mouse to move
mouse.leftButton = joystick[j].getDown(14)
mouse.rightButton = joystick[j].getDown(13)
mouse.middleButton = joystick[j].getDown(19)
#Mouse movement using Gryoscope
# Only moves when the trigger is held down
mdX = -1 * filters.deadband(filters.delta(freePieIO.yaw),dz) * mag
mdY = -1 * filters.deadband(filters.delta(freePieIO.pitch),dz) * mag
if joystick[j].getDown(20):
mouse.deltaX = mdX
mouse.deltaY = mdY
if starting:
freePieIO[0].update += update
Now it does say joystick[j].getdown(20) for the trigger, but it does use the same command to activate the leftmouse button as well. The trigger (joystick[j].getdown(20)) uses some sort of 'if' statement here but I can't seem to figure out. As you can see i'm not a programmer but I do understand some basic principles though and I'm not an idiot, so if you could point in me the right direction I would be very happy.
I have found a code here to use the psmove as some sort of gun controller (it basically just controls the mouse) I'm using it for doom 3 fully possessed, it only uses the gyroscope, and it works pretty well. It does only activate when you hold the trigger button though, which is a good thing, since you have to repostion your gun now and then to get some good aiming going on.
My only problem is that I would want it to activate it when I click the trigger button not when holding it. So basically it would have to be some sort of toggle command.
this is the code
def update():
#define globals
#define constants
mag = 1000
dz = 0.005
i=0
j=0
#bind left mouse to cross button
#Right mouse to circle button
#Middle mouse to move
mouse.leftButton = joystick[j].getDown(14)
mouse.rightButton = joystick[j].getDown(13)
mouse.middleButton = joystick[j].getDown(19)
#Mouse movement using Gryoscope
# Only moves when the trigger is held down
mdX = -1 * filters.deadband(filters.delta(freePieIO.yaw),dz) * mag
mdY = -1 * filters.deadband(filters.delta(freePieIO.pitch),dz) * mag
if joystick[j].getDown(20):
mouse.deltaX = mdX
mouse.deltaY = mdY
if starting:
freePieIO[0].update += update
Now it does say joystick[j].getdown(20) for the trigger, but it does use the same command to activate the leftmouse button as well. The trigger (joystick[j].getdown(20)) uses some sort of 'if' statement here but I can't seem to figure out. As you can see i'm not a programmer but I do understand some basic principles though and I'm not an idiot, so if you could point in me the right direction I would be very happy.