Jump to content

Take Your Joystick Control!


elgabionline
 Share

Recommended Posts

Hello, here I want to share with you this script, that contains some functions to use the Joystick. I already proved all the functions and they are well, so I wait that to you also.

Those functions are:

JoyMoveLeft ($joy_number,$sensivity)

JoyMoveRight ($joy_number,$sensivity)

JoyMoveUp ($joy_number,$sensivity)

JoyMoveDown ($joy_number,$sensivity)

$sensivity is a percent value (for analogic Joysticks) 90% is default

(All functions for joystick directional moves)

JoyButtonPressed ($joy_number,$joy_button) $joy_button is a numeric input as 1, 2, 3... n)

JoyGetID ($joy_number) $joy_number is a numeric input as 1,2... n)

JoyMaxNumber () Maximum number of joysticks supported by your system

[iMPORTANT!!] These scripts needed to run, the beta version 3.1.111 of autoit.

[EDIT] 4 April 2006: I added new parameters to the functions.

I hope comments and if it was them useful. Bye...

Joystick.au3

Joystick_Test.au3

Edited by elgabionline
Link to comment
Share on other sites

So, these functions control a joystick.

1 question: Can I control a joystick which has its drivers installed but is not attached to my computer?

#)

Link to comment
Share on other sites

So, these functions control a joystick.

1 question: Can I control a joystick which has its drivers installed but is not attached to my computer?

#)

What do you mean with "attached"? Use Joystick Plug in your computer, of course! :)

This script read a system driver of Win98, not a manufacturer software included with your Joystick. Did I answer your question, or didn't I understand well?

Link to comment
Share on other sites

To emulate a mouse in windows with Joystick control, I put this simple script, for example:

Press first button and open "Programs folder". Or hold this button and directional movements of joysticks, and mouse emulate it.

Press second button (while hold first button of joystick) for decrease mouse speed.

#include <GuiConstants.au3>
#include <Joystick.au3>
    
Opt ("Trayicondebug",1)

While 1
    
    If JoyMoveLeft () Then
        Send ("{LEFT}")
        Sleep (50)
    EndIf

    if JoyMoveRight () Then
        Send ("{RIGHT}")
        Sleep (50)
    EndIf
    
    If JoyMoveUp () Then
        Send ("{UP}")
        Sleep (50)
    EndIf
    
    If JoyMoveDown () Then
        Send ("{DOWN}")
        Sleep (50)
    EndIf

    If JoyButtonPressed (1,1) Then Boton1 ()
    
WEnd

Func Boton1 ()
     
    Local $Activ=0,$XMouseCoord,$YMouseCoord
    
    While JoyButtonPressed (1,1)
        $MouseCoord=MouseGetPos ()
        $Vel=13

        If JoyButtonPressed (1,2) Then $Vel=3
            
        Select
        Case JoyMoveLeft ()
            $XMouseCoord =$MouseCoord[0]-$Vel
            $Activ=1
        Case JoyMoveRight ()
            $XMouseCoord = $MouseCoord[0]+$Vel
            $Activ=1
        Case Else
            Sleep (50)
        EndSelect
        
        Select
        Case JoyMoveUp ()
            $YMouseCoord =$MouseCoord[1]-$Vel
            $Activ=1
        Case JoyMoveDown ()
            $YMouseCoord= $MouseCoord[1]+$Vel
            $Activ=1
        Case Else
            Sleep (50)
        EndSelect
    
        MouseMove ($XMouseCoord,$YMouseCoord,0)
        
    WEnd

    Select
    Case $Activ=1
        MouseClick ("primary")
    Case Else
        Send ("{LWIN}")
    EndSelect
    

EndFunc

;BETA VERSION!!! 3.1.1.111

Edited by elgabionline
Link to comment
Share on other sites

  • 3 months later...

he means the other way.

so if i move my mouse up, the joystick moves up.

might be handy for games that support a mous and a joystick, but you want 2 mouses

*If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip...
Link to comment
Share on other sites

  • 2 months later...
  • 3 months later...
  • 1 month later...

Your program looped without sleep, causing 100% cpu usage.

To emulate a mouse in windows with Joystick control, I put this simple script, for example:

Press first button and open "Programs folder". Or hold this button and directional movements of joysticks, and mouse emulate it.

Press second button (while hold first button of joystick) for decrease mouse speed.

;by elgabionline
#include <GuiConstants.au3>
#include <Joystick.au3>
    
Opt ("Trayicondebug",1)

While 1
    
    If JoyMoveLeft () Then
        Send ("{LEFT}")
        Sleep (50)
    EndIf

    if JoyMoveRight () Then
        Send ("{RIGHT}")
        Sleep (50)
    EndIf
    
    If JoyMoveUp () Then
        Send ("{UP}")
        Sleep (50)
    EndIf
    
    If JoyMoveDown () Then
        Send ("{DOWN}")
        Sleep (50)
    EndIf

    If JoyButtonPressed (1,1) Then Boton1 ()
    sleep(100); - Looping without sleep is a waste and uses 100% cpu Adam1213
WEnd

Func Boton1 ()
     
    Local $Activ=0,$XMouseCoord,$YMouseCoord
    
    While JoyButtonPressed (1,1)
        $MouseCoord=MouseGetPos ()
        $Vel=13

        If JoyButtonPressed (1,2) Then $Vel=3
            
        Select
        Case JoyMoveLeft ()
            $XMouseCoord =$MouseCoord[0]-$Vel
            $Activ=1
        Case JoyMoveRight ()
            $XMouseCoord = $MouseCoord[0]+$Vel
            $Activ=1
        Case Else
            Sleep (50)
        EndSelect
        
        Select
        Case JoyMoveUp ()
            $YMouseCoord =$MouseCoord[1]-$Vel
            $Activ=1
        Case JoyMoveDown ()
            $YMouseCoord= $MouseCoord[1]+$Vel
            $Activ=1
        Case Else
            Sleep (50)
        EndSelect
    
        MouseMove ($XMouseCoord,$YMouseCoord,0)
        
    WEnd

    Select
    Case $Activ=1
        MouseClick ("primary")
    Case Else
        Send ("{LWIN}")
    EndSelect
    

EndFunc
Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...

Is there a way to when I Press a Key on the Keyboard, It do a Joystick InPut ?

Example: Press the UP key on the Keyboard = the UP with a stick on a Joystick.

Hi, I was wondering If I can Send joystick movements to a Window without actually moving the Joystick.. Can this be done with your script?

Hi to all members here. Thanks for their comments and replies.

I was thinking about your ideas. While I was analyzing this, the biggest problem that I found is get to be able to simulate Joystick commands "Send", at the game. There were not problems in attempting "record" the movements with a script logger (like a "Joysticks catches"), but: how to carry out the commands to the window?

That would be hindering me the things (and for the time being, I don't see solution).

I try with some calls to the functions built in winmm.dll but all attempts failed. I think that it could also be some protection in the games, although I'm not sure. It's a pain for me that I couldn't find this problem to "solve it in advance".

Well, I'll be searching for any ideas.. (or if I devised something) Bye! :)

Link to comment
Share on other sites

Anyone able to run this on Vista? I tried both the mouse script and the default test and all I get is a stack error. :)

Posted Image

Edited by P5ych0Gigabyte
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
Share on other sites

  • 2 months later...

i Want to say its Wonderfull. i think that u made this tool for me :)

i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Link to comment
Share on other sites

  • 5 months later...
  • 8 months later...

heya i would like to ask if someone could tell me or just give me a hint or something...how could i make that i control joystick buttons with keyboard...like with autoit i likely pressing 2 buttons all the time and those 2 buttons are clicking 2 joystick buttons...

thanks for your help!

Link to comment
Share on other sites

  • 3 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...