Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Different input based on JoyPOV?



  • Please log in to reply
1 reply to this topic
SputnikDX
  • Members
  • 9 posts
  • Last active: Nov 05 2015 02:48 PM
  • Joined: 15 Oct 2015

Right now I'm working on a script mostly to test myself, and I want it to do a specific thing when I hit a button on my joystick but ONLY when my joystick's POV is 9000 (forwards). For some reason I can't get this to work.

#Persistent

SetTimer, WatchPOV, 5
return

WatchPOV:
GetKeyState, POV, 2JoyPOV

if POV != 9000
{
 2Joy8::msgbox, s.HK
 return
}
else if POV = 9000
{
 2Joy8::msgbox, Overhead
 return
}


return

This is just the skeleton, but whenever I try to run it I get an error saying that I can't have 2Joy8 twice because it's a duplicate hotkey. To restate, I want 2Joy8 to do something different if my Joystick is forward as opposed to any other direction.

 

Does anyone know a way to accomplish this?

 



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012
✓  Best Answer

Switching it around is my recommendation.

#Persistent
 
SetTimer, WatchPOV, 5
return

WatchPOV:
GetKeyState, POV, 2JoyPOV
return
 
2Joy8::
If POV != 9000
MsgBox, s.HK "`n" %POV%
else if POV = 9000
MsgBox, Overhead
return

It's untested code, but no glaring errors are popping out at me. I included in the MsgBox for when POV is not 9000 the value of 9000 be displayed. As you said you're measuring your Joystick (on my Xbox 360 controller I thought POV was for the d-pad), you may not have it perfectly lined up at 9000 and it might be 8999 or 9001, maybe. Depends on the controller I suppose, so I just wanted to make it clear when testing if it is reading the values correctly.

 

---

 

You can use something like you were trying to do before with duplicate hotkeys by using #If instead.