Jump to content
Sign in to follow this  
Shafayat

GamePadEx UDF

Recommended Posts

Shafayat

As the title suggests, with this UDF library, you can receive all sorts of input from an standard GamePad.

I had one logitech USB gamepad and it Works great with it.

I've added lots of samples. They are almost everything you'll ever need when working with a gamepad.

Features

  • X,Y,Z,R,U,V Axis
  • GPExGetAxisEx command makes it easy to get direction and speed.
  • get POV (Point of View)
  • Get Buttons (API-ish. you don't even need to remember button values)

ToDo

  • Vibration
  • SciTE highlighting

History

7/11/2010 > First release

Comments/Suggestions are very much welcome.

Regards

Shafayat

GamePadEx.zip


[Not using this account any more. Using "iShafayet" instead]

Share this post


Link to post
Share on other sites
Ascend4nt

Very cool. Nice job. Works fine with my Cordless Rumblepad 2 :blink:

Share this post


Link to post
Share on other sites
Shafayat

Thanks for commenting guys.

I know that there are other udfs that lets you get GamePad inputs. But when you'll try all of them out, you'll find this one much more standard and easy to use. Besides, you don't have to manually learn how to process the data, Let the udf do the messy stuffs. Taking a look at the samples will suffice.


[Not using this account any more. Using "iShafayet" instead]

Share this post


Link to post
Share on other sites
FuryCell

Very cool. Maybe I can integrate this into joytunes (control itunes with gamepad/joystick) as some point (providing you don't mind)

Edit:Removed quote

Edited by FuryCell

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
Shafayat

Furycell, ofcourse I don't mind.

Why else would I publish it as opensource if I didn't want it to be used?


[Not using this account any more. Using "iShafayet" instead]

Share this post


Link to post
Share on other sites
BinaryBrother

Ok, so I got bored? This sample was modified to cause mouse movements based on the Left Analog stick. (On mine anyway).

Haha, fun stuff. :blink:

#include "GamePadEx.au3"
#include <Constants.au3>
#Include <WinAPI.au3>

HotKeySet("{ESC}", "_Quit") ; Just for the demo

Global $myGamePadHandle = GPExInitialize() ; Get a handle. This doesn't have to be global but needs to be passed to all the other functions.
Global $myID = 0 ; We want to monitor the default GamePad

While 1
    Sleep(10)
    $testrawdata = GPExGetRawData($myGamePadHandle, $myID) ; Get almost every data possible from the gamepad. Returns in an array with 8 elements.
    ;
    ; Display the RAW output.
    ; --->
    ; ---> Resize the console area so that you can have all the outputs and then move the gamepad. <---
    ; --->
    ConsoleWrite(@CRLF & "==========================================================")
    ConsoleWrite(@CRLF & "[0]" & $testrawdata[0]) ; X Axis
    ConsoleWrite(@CRLF & "[1]" & $testrawdata[1]) ; Y Axis
    ConsoleWrite(@CRLF & "[2]" & $testrawdata[2]) ; Z Axis
    ConsoleWrite(@CRLF & "[3]" & $testrawdata[3]) ; R Axis
    ConsoleWrite(@CRLF & "[4]" & $testrawdata[4]) ; U Axis
    ConsoleWrite(@CRLF & "[5]" & $testrawdata[5]) ; V Axis
    ConsoleWrite(@CRLF & "[6]" & $testrawdata[6]) ; Point of View
    ConsoleWrite(@CRLF & "[7]" & $testrawdata[7]) ; Buttons
    ConsoleWrite(@CRLF & "==========================================================")
    If $testrawdata[0] > 32767 Then
        _WinAPI_Mouse_Event($MOUSEEVENTF_MOVE, ($testrawdata[0] - 32767)/4000)
    EndIf
    If $testrawdata[1] > 32767 Then
        _WinAPI_Mouse_Event($MOUSEEVENTF_MOVE, 0, ($testrawdata[1] - 32767)/4000)
    EndIf
    If $testrawdata[0] < 32767 Then
        _WinAPI_Mouse_Event($MOUSEEVENTF_MOVE, -(32767 - $testrawdata[0])/4000)
    EndIf
    If $testrawdata[1] < 32767 Then
        _WinAPI_Mouse_Event($MOUSEEVENTF_MOVE, 0, -(32767 - $testrawdata[1])/4000)
    EndIf
WEnd

Func _Quit()
    GPExTerminate($myGamePadHandle) ; Just for good manners.
    Exit
EndFunc   ;==>_Quit
Edited by BinaryBrother

Share this post


Link to post
Share on other sites
AdmiralAlkex

Here's links to the other UDF's I know about, if anyone is curious:

_Joystick.au3 (take the code form post #4)

Joystick.au3

SDL.au3

Note that the one by elgabionline doesn't work in it's current state, but the others is fine. I prefer my own UDF of course, since among other things, it's the most advanced one (it can get the device's name :blink:)

#Include "SDL.au3"

_SDL_Init($_SDL_INIT_JOYSTICK)

For $X = 0 To _SDL_NumJoysticks() -1
    ConsoleWrite("Joystick " & $X & ": " & _SDL_JoystickName($X) & @CRLF)
Next

Share this post


Link to post
Share on other sites
Shafayat

I prefer my own UDF of course, since among other things, it's the most advanced one (it can get the device's name )

- You like embedding the SDL dll file and increasing the size? :blink:

Then, maybe I'll try and use DirectX to get Game Input Device's name. lol ;) . All the computers have directX installed. So, you won't even have to embed anything if directX is used. But implementing it might be a bit tricky though. Gonna look into it in a few days.


[Not using this account any more. Using "iShafayet" instead]

Share this post


Link to post
Share on other sites
AdmiralAlkex

I don't think an extra 243 KB is the end of the world, after all AutoItSC.bin is 631 KB, so if you want low size you shouldn't be using AutoIt at all.

And SDL reads the name from the registry, so that's easy as pie to get. Or so I imagine, maybe I will give it a try later tonight... :blink:

Share this post


Link to post
Share on other sites
MeMeMe

I've downloaded this, and tried to run GamePadEx and nothing happens.

How do I use this?

Share this post


Link to post
Share on other sites
MeMeMe

Wow, that's helpful. You're not in tech support, by any chance?

I do have a wired xbox360 controller attached to my computer at all times.

Share this post


Link to post
Share on other sites
AdmiralAlkex

Is it really so hard to give us any information about your problem so we can help you instead of give wild guesses? Do you really run around IRL and shouts "How do I use, How do I use, How do I use??" all the time? I hope not.

Now write down a nice post where you tell us exactly what is happening, and what your question really is, and we can go from there.

Also test the other 2 udf's I listed above.

Edit:

Wow, that's helpful. You're not in tech support, by any chance?

Oh yeah, like you were more helpful when you gave us nothing to work on. At least I gave a valid answer that was the most likely cause of the scripts not working. Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites
MeMeMe

That post is a little more constructive, but the tone could be less offputting. If we got off on the wrong foot because you inferred some criticism in my question, "How do I use it," please don't - there wasn't any. It was a neutral question.

My problem is this:

I downloaded the package, GamePadEx, extracted it into its own folder.

I double clicked the GamePadEx.au3 file, with an xbox controller attached to my pc (as always), and nothing happened.

I opened up each of the *.au3 files, to see if there was any instructions on configuration needed, and didn't see anything I understood.

I'm a newbie to AutoIt, so it may be that getting this working is not plug-and-play and requires a level of technical expertise I don't have yet. I don't mind if that is the case. So I asked how to use it, to find out if that was the case.

Is there more information you need?

Edited by MeMeMe

Share this post


Link to post
Share on other sites
nikitanova

MeMeMe, You should have been running other au3 files in the archive. (i.e. right click and select "run script")

GamePadEx.au3 = Core file of UDF. It doesn't do anything but let's the other scripts do things easily. (That's what UDF libs are for)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.