Jump to content

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

Using a joystick as a mouse


  • Please log in to reply
65 replies to this topic
Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Using a joystick as though it were a mouse seems to be a common request. Therefore, I've made this script which demonstrates that capability. Corrections and improvements are welcome: http://www.autohotke... ... kMouse.htm

If you downloaded v1.0.10 prior to the timestamp of this message, you'll need to download and reinstall to get this script to work, since it relies on Rajat's relative-MoveMove enhancement:

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
probably ur first new thread here Chris?! :)


just wondering... as the movement and keys (i think) run in separate threads, then y can't we use dragging? (holding joystick button & moving cursor)

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
It should work as a complete mouse replacement, including the following features:

Joystick buttons can drag just like a mouse button.
Uses very little CPU time (0% on my system)
Cursor moves faster depending on how far you push the joystick from center.

If you get a chance, give it a try. I'm sure there's room for improvement.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
i couldn't get this to work: press joy button 1 and move axis to cause mouse drag.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
It might be a difference in our joysticks. On my system, both left-click drag and right-click drag work with the joystick. If you haven't already, download it exactly as is and run it with no other scripts running.

Maybe someone else can give it a try so that we can have more than 2 results.

Download link: http://www.autohotke... ... kMouse.ahk

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
With Rajat's patient help, I've revised the Joystick-to-Mouse script to allow the joystick buttons to work for mouse-drags. However, this has only been tested on one system, so any other testing would be appreciated: http://www.autohotke... ... kMouse.ahk

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
I've made a couple improvements to the joystick-as-mouse script:

1) A button can be assigned to act as the middle button.
2) The POV control can be used as a mouse wheel. Set POV forward to scroll up. Set it backward to scroll down.

I don't have a POV control on my ancient joystick, so if anyone has time, I'd appreciate a few tests and comments about it. In particular, does the default scrolling frequency of 250 ms seem good? Also, is POV-forward and backward the most ergonomic way to turn the wheel? Perhaps POV shouldn't be used at all; maybe the Z axis or some other axis would be better?

Thanks.

Joystick-as-Mouse script: http://www.autohotke... ... kMouse.ahk

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
I know everyone is busy. But if you get a little spare time and you have a joystick with a POV control, I'd appreciate at least one test to confirm the basic operation.

Thanks.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
i missed the earlier post :oops:
the pov works fine as mouse wheel.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Thanks; it's good to know it works.

If anyone else gets time to try it, I'd appreciate more feedback such as whether the default scrolling frequency of 250 ms seems good, and whether POV-forward and backward is the most ergonomic way to turn the wheel.

I'm planning to add a small timer that does horizontal scrolling via POV-left and POV-right. It might be convenient for some apps.

Joystick-as-Mouse script: http://www.autohotke... ... kMouse.ahk

nyanimefool
  • Members
  • 13 posts
  • Last active: Jul 29 2005 03:45 PM
  • Joined: 04 Jul 2005
Hi, I'm a newbie and a n00b so please direct me with a link to where this belongs.

I have the JoystickMouse.ahk. I have a DualShock Playstation controller and I put it to a USB to PSX and turned on this script. Most of what I wanted to do can be done, just a few minor problems. it works good I guess. Messed around with some of the settings and added this

Joy7::
Send, {Enter} ; Makes the L1 button press enter
return

Joy5::
Send, {Alt down} ; Hold down L2 key for AltTab and ShiftAltTab
KeyWait, Joy5
Send, {Joy9 down}
Keywait, Joy9
Send, {Joy10 down}
Keywait, Joy10
Send, {Alt up}
return

Joy9::
Send, {Tab down} ; Select button for Alt-Tabbing
Keywait, Joy9
Send, {Tab up}
return

Joy10::
Send, {Shift down} ; Start button for ShiftAlt-Tabbing
Keywait, Joy10
Send, {Shift up}
return

So many complicated things I want to do with it. I just frustrates me why I can't figure it out myself. Anyway. First, is there an easier way to do that?

2nd, I go to 4chan alot and I use Firefox 5.0 so I want to right click -> open in new tab, go to that tab, and then right click -> save pic. The shortcut keys I use is right click t for a new tab and right click v for saving. Can I compress all that into 2 buttons on my controller?

3rd, line 43 or so has JoyStickNumber = 1 which I can change if I wanted more joysticks. If I add another controller, would the 2nd controller have the same button arrangements? If so, can I change those to do something else? I know I'm running out of buttons on one controller so I want to use a 2nd one. How can I control Winamp's Previous, Play, Pause, Stop, Next, Repeat, and to do all that while it's still in the system tray.

4th when I turn the analog off, the direction keys move the mouse pointer. When the analog is on, the analog stick moves the mouse. The mouse was moving too fast so I changed JoyMultiplier = 0.10. Also sometimes with the analog on, the mouse cursor tends to move on its own so I changed JoyThreshold = 6. It still moves but less often. Is there another way to correct this?

4.1 With the analog on, the direction keys can be used like page up and down which is great for web browsing but it's not exactly like page up and page down. Why is it disabled to do something else when I turn the analog on? And how can I make those buttons to page up and down when the analog is turned on?

This is on my laptop and touchpad can get annoying sometimes so my playstation controller is a usb mouse hehe. Thanks for reading all this and again I do apologize if this is the wrong place to post this or the info is already out there. A simple link will do if there is a simple link I'm failing to find because I Am simple.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
One thing to keep in mind is that AutoHotkey cannot simulate joystick button presses or axis movement. It can only read what you're doing with the joystick and respond to it. Therefore, things like Send, {Joy10 down} would have no effect.

right click t for a new tab and right click v for saving. Can I compress all that into 2 buttons on my controller?

It sounds feasible. If you haven't already read it, the Quick-start Tutorial can help you create simple macros like these (as can AutoScriptWriter, a utility included with AutoHotkey, located in the Start Menu).

If I add another controller, would the 2nd controller have the same button arrangements? If so, can I change those to do something else? I know I'm running out of buttons on one controller so I want to use a 2nd one.

I'm not sure, but you could use the joystick test script to find out what the button numbers are.

How can I control Winamp's Previous, Play, Pause, Stop, Next, Repeat, and to do all that while it's still in the system tray.

There are quite a few topics on the forum about this, so try doing a forum-search for Winamp. There is also a topic in the FAQ about it.

the mouse cursor tends to move on its own so I changed JoyThreshold = 6. It still moves but less often. Is there another way to correct this?

Try calibrating the joystick using the control panel or the software that came with the stick.

4.1 With the analog on, the direction keys can be used like page up and down which is great for web browsing but it's not exactly like page up and page down. Why is it disabled to do something else when I turn the analog on?

I'm cloudy on the concept of "switching to analog" since I don't use joysticks regularly.

And how can I make those buttons to page up and down when the analog is turned on?

If they're actual buttons, you might try disabling their built-in paging behavior using the software that came with the stick. Then you can remap the buttons to perform actions of your choice. For example: Joy16::Send {PgUp}

nyanimefool
  • Members
  • 13 posts
  • Last active: Jul 29 2005 03:45 PM
  • Joined: 04 Jul 2005
No software came with the adapter. It's USB so it's plug and play.

Also what I forgot to add was that, I use programs like Photoshop. Can I use Windows Spy to find the coordinate to what i'm clicking and assigning buttons to those exact positions?

It sounds feasible. If you haven't already read it, the Quick-start Tutorial can help you create simple macros like these (as can AutoScriptWriter, a utility included with AutoHotkey, located in the Start Menu).

I've tried reading it. Maybe I'm writting in the wrong commands. I've tried

Joy6::
Send, {Joy2 down}
Send, {Joy2 up}
Send t
return

I just really don't get it. Sorry.

One thing to keep in mind is that AutoHotkey cannot simulate joystick button presses or axis movement. It can only read what you're doing with the joystick and respond to it. Therefore, things like Send, {Joy10 down} would have no effect.

It works though. It just seems repeatative and congested.

Again I'm a newbie and a n00b so please forgive my questions if they seems too simple that I don't understand it.

--Fragman--
  • Guests
  • Last active:
  • Joined: --
I added a joystick button to toggle this script on or off (with a simple var that makes it ignore all joystick input).
Probably not the best way, but works for me. Can be useful in games when you only want to have this in menus.

http://mitglied.lyco... ... kMouse.ahk

--Fragman--
  • Guests
  • Last active:
  • Joined: --
Someone else on another forum just noticed me that this script screws up if there's no joystick connected.
Does anyone have any idea how to check if there's a connected joystick?