AutoHotkey Community

It is currently May 27th, 2012, 10:01 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: joystick-as-mouse
PostPosted: April 5th, 2005, 6:19 am 
Offline

Joined: March 29th, 2005, 7:36 pm
Posts: 17
Still working on it...
http://home.ripway.com/2005-4/284589/HotSteam.ahk
sorry toralf, I didnt check the forum, and i kind of figured it out on my own, but thanks for the help.

However, I made a script that spits out the morse code as you type, but unfortunatley, the sound skips and messes up if you type too fast.
http://home.ripway.com/2005-4/284589/MorseCode.ahk


Last edited by Famkee on April 14th, 2005, 6:53 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 5th, 2005, 8:06 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Try to use this, let me know if so,

Code:
WatchJoystick:
  SetFormat, Float, 03
  GetKeyState, joyz, %JoystickNumber%Joyz
  GetKeyState, joyr, %JoystickNumber%Joyr

  If joyz > %JoyThresholdUpper%
      DeltaX := joyz - JoyThresholdUpper
  Else if joyz < %JoyThresholdLower%
      DeltaX := JoyThresholdLower - joyz
  Else
      DeltaX = 0
 
  If joyy > %JoyThresholdUpper%
      DeltaY := joyr - JoyThresholdUpper
  Else if joyy < %JoyThresholdLower%
      DeltaY := JoyThresholdLower - joyr
  Else
      DeltaY = 0

  If ( DeltaX <> 0 or DeltaY <> 0 )
    {
      DeltaX *= %JoyMultiplier%
      DeltaY *= %JoyMultiplier%
      SetMOUSEDelay, -1 ; Makes movement smoother.
      MOUSEMove, %DeltaX%, %DeltaY%, 0, R
    }
Return


I didn't test it, since I don't own a joystick.

And please use indentations and the code tag, when you post the next time. It helps all other usress to read your code and therefore to help you. Thanks

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 5th, 2005, 12:33 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
I edited the first post to link to the joystick-as-mouse script.

If anyone sees a way to improve the script to handle this issue or any others, please let me know the specifics.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 5th, 2005, 2:12 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Hi Chris,
I didn't know the script was from the showcase.
But I assume that the problem Famkee is describing is related to subtraction to get DeltaX and DeltaY.

joyr and joyz are between 0 and 100, right?
So to get DeltaX/Y AHK has to check if it is outside the threshold.
if so, joyr/z is between 0 and 35 or between 65 and 100.
But 0 and 100 represent the highest amplitude, right?

If my above assumptions are correct the DeltaX/Y have to be calculated
like this
value := joyr/z - 65 (for above threshold)
value := 35 - joyr/z (for below threshold)

With these expressions the value is increasing the higher the amplitude of the joystick.

I think the
value -= 65 (for above threshold)
value -= 35 (for below threshold)
of the original script don't do the trick for values below threshold. Because it represents
value := joyr/z - 35
which is a negative value for low amplitudes and zero for full amplitude of the joystick (joyr/z = 0)

Or am I completely on the wrong track.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 6th, 2005, 4:13 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
You're probably on the right track and you've certainly made every effort to explain it clearly. My problem is I'm just not getting it.

I do know that the current joystick-to-mouse script works with most common joysticks. But if there's an easy way to improve it to work for more joysticks, I'd certainly like to do so.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: sks and 21 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group