Sign in to follow this  
Followers 0
elgabionline

Take Your Joystick Control!

18 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



is there a way to emulate a mouse as a joystick for this


[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Share this post


Link to post
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?

#)

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

I can't get the demo test to work.

I'm using a USB Microsoft Sidewinder Precision 2 and I'm on Windows XP.

Looks nice hopefully I can get this to work. :whistle:


MUHAHAHAHAHA

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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! :)

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites

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=----=========================>

Share this post


Link to post
Share on other sites

Joystick mapping works like charm :) but can this be done for simulating Joy movings??? i need something to control joystick move

Share this post


Link to post
Share on other sites

Why is this not working for me? Everytime I close the first dialog, on the test, it crashs, it says: AutoIt has encoutered an error and needs to close. Why?

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

Reading about Joystick and AI interactions...

Now i'm inoffice so i can't try, but udf is capable to detect also analog stick ? (and their diagonals?)

Thank you for any info,

m.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0