Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / XBOX360 Controller for Windows

Author
Message
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 13th May 2006 03:07 Edited at: 13th May 2006 03:09
This is in a similar strain to the DLL I released a while back, just doesn't have all the functionality pre-mapped.



It'll load the XInput DLL, and you can then use the GetState to get what the controller is currently doing, (stored in XInput(User).State.Gamepad) and SetState to set the Rumble (your store that in XInput(User).Vibration)

I mean some features are cut out as I've ported the API directly so you can use it with code rather than a DLL, should make your source about 20kb smaller as a result; but won't run as quickly or is quite a simple to use.

Still I'm sure someone will find some use for it.

[edit] Almost forgot to add... to use this straight, just add the line:

GoSub Using_XInput

to the top of your code. before End you'll want to use XInputRelease()

Drew G
User Banned
Posted: 13th May 2006 03:28
Great code...
Chris Franklin
19
Years of Service
User Offline
Joined: 2nd Aug 2005
Location: UK
Posted: 13th May 2006 11:18
Wow nice

Theme park simulator wip boards

Doctor Duddits
19
Years of Service
User Offline
Joined: 9th Feb 2005
Location:
Posted: 23rd May 2006 15:32
okkkkkkkkk...

I see you...I think...with me anything is possible...and you can do anything with me...its time to...do anything...
entomophobiac
22
Years of Service
User Offline
Joined: 1st Nov 2002
Location: United States
Posted: 11th Jul 2006 13:51
I'm not getting this to work. Has anyone used this code?

As the .DLL version crashes, I thought that I'd give this a try, but honestly, I don't quite get how it's supposed to be used.

Anyone?
Lover of games
19
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 21st Sep 2006 07:18
I tried it but it didn't work either. I got it to compile but it said "Can't understand command" when i tried and it pointed to controller connected

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
da king
User Banned
Posted: 23rd Sep 2006 05:06
I couldent get it to work either lol

Hi Mom!
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 5th Oct 2006 04:38
The code won't work with DarkBASIC Professional 1.6 or above I'm afraid as TGC decided to correct a bug that was actually very useful.

I'll see about recoding this so that it'll work, but if you really want support for the XBOX360 controller; I did release a plug-in DLL a while back that supported all the features that this source did.

Intel Pentium-D 2.8GHz, 512MB DDR2 433, Ati Radeon X1600 Pro 256MB PCI-E, Windows Vista RC1 / XP Professional SP2
entomophobiac
22
Years of Service
User Offline
Joined: 1st Nov 2002
Location: United States
Posted: 5th Oct 2006 09:46
Greetings!

For a long time, I thought you'd never show up. Anyway. On the DLL, I didn't get it to work fully on some of the machines I worked with. It works perfectly now, but I was thinking if there was any compatibility issues with later upgrades of DBPro?
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 12th Oct 2006 07:55
It should run fine with DBPro 5.0+ unless they've changed the GlobStruct again.
You will however require DirectX 9.0c and XBOX 360 Controller for Windows Drivers on the system you want it to be able to run on.

I'll probably be releasing a new version of the DLL soon, depends when I can get a computer that doesn't overheat and die every 10minutes doing anything remotely difficult.
(having issues installing PDK and DirectX9 SDK on this computer atm)

Intel Pentium-D 2.8GHz, 512MB DDR2 433, Ati Radeon X1600 Pro 256MB PCI-E, Windows Vista RC1 / XP Professional SP2
Format C
18
Years of Service
User Offline
Joined: 26th Mar 2006
Location:
Posted: 13th Nov 2006 02:40
Um... I have an XBOX 360 controller...

Which is the only thing I use in DBP aside from debugging input from keyboard.


My XBOX 360 Controller works fine without any of this.
Just use the Windows Driver Microsoft released.

Here are my GamePad Input Wrapper Functions (Still in development)

`Joy Up
Function Button_Up()
If UpKey() then RetVal# = 1
If JoyStick Y() < -200 then RetVal# = abs(JoyStick Y()) / 1000.0
EndFunction RetVal#

`Joy Down
Function Button_Dn()
If DownKey() then RetVal# = 1
If JoyStick Y() > 200 then RetVal# = abs(JoyStick Y()) / 1000.0
EndFunction RetVal#

`Joy Right
Function Button_Rt()
If RightKey() then RetVal# = 1
If JoyStick X() > 210 then RetVal# = abs(JoyStick X()) / 1000.0
EndFunction RetVal#

`JoyLeft
Function Button_Lt()
If LeftKey() then RetVal# = 1
If JoyStick X() < -210 then RetVal# = abs(JoyStick X()) / 1000.0
EndFunction RetVal#

`DPad/Hat up
Function Button_Hu()
RetVal = 0
Value = JoyStick Hat Angle(0)
If Value = 0 then RetVal = 1
If Value = 4500 then RetVal = 1
If Value = 31500 then RetVal = 1
EndFunction RetVal

`DPad/Hat Down
Function Button_Hd()
RetVal = 0
Value = JoyStick Hat Angle(0)
If Value = 18000 then RetVal = 1
If Value = 22500 then RetVal = 1
If Value = 13500 then RetVal = 1
EndFunction RetVal

`DPad/Hat Right
Function Button_Hr()
RetVal = 0
Value = JoyStick Hat Angle(0)
If Value = 9000 then RetVal = 1
If Value = 4500 then RetVal = 1
If Value = 13500 then RetVal = 1
EndFunction RetVal

`DPad/Hat Left
Function Button_Hl()
RetVal = 0
Value = JoyStick Hat Angle(0)
If Value = 27000 then RetVal = 1
If Value = 22500 then RetVal = 1
If Value = 31500 then RetVal = 1
EndFunction RetVal

`XBOX360s A Button
Function Button_Crawl()
If Keystate(29) then RetVal = 1
If JoyStick Fire X(0) = 1 then RetVal = 1
EndFunction RetVal

`Run Button/mechanism based on Joy Up Value
Function Button_Run()
rem If Keystate(42) then RetVal = 1
If UpKey() then RetVal = 1
rem If JoyStick Fire X(0) = 1 then RetVal = 1
If abs(JoyStick Y()) > 600 then RetVal = 1
EndFunction RetVal

`XBOX360s X Button
Function Button_Attack()
rem If Keystate(29) then RetVal = 1
If JoyStick Fire X(1) = 1 then RetVal = 1
EndFunction RetVal

`XBOX360s Y Button
Function Button_Jump()
If Keystate(57) then RetVal = 1
If JoyStick Fire X(3) = 1 then RetVal = 1
EndFunction RetVal

`XBOX360s Start Button (or is button listed below)
Function Button_Camera()
If Keystate(46) then RetVal = 1
If JoyStick Fire X(7) = 1 then RetVal = 1
EndFunction RetVal

`XBOX360s Back Button (or is button listed above)
Function Button_SquadMenu()
If Keystate(48) then RetVal = 1
If JoyStick Fire X(6) = 1 then RetVal = 1
EndFunction RetVal

`XBOX360s B Button
Function Button_Action()
If Keystate(28) then RetVal = 1
If JoyStick Fire X(2) = 1 then RetVal = 1
EndFunction RetVal

`XBOX360s A Button (also listed above)
Function Button_Cancel()
If Keystate(14) then RetVal = 1
If JoyStick Fire X(0) = 1 then RetVal = 1
EndFunction RetVal
[/Code]

Missing is the 4 trigger buttons (two are analog)
Missing is the second Joystick (Using the DPad instead)

Functions are missing because I haven't gotten around to needing them as of yet.

Here is code to show all Joy Input to Screen:
[Code]
Function Hud_JoyStick()
Text 10, 10, "X: " + Str$(JoyStick X())
Text 10, 20, "Y: " + Str$(JoyStick Y())
Text 10, 30, "Z: " + Str$(JoyStick Z())
Text 10, 50, "tX: " + Str$(JoyStick Twist X())
Text 10, 60, "tY: " + Str$(JoyStick Twist Y())
Text 10, 70, "tZ: " + Str$(JoyStick Twist Z())
Text 10, 90, "H: " + Str$(JoyStick Hat Angle(0))
Text 10, 110, "sA: " + Str$(JoyStick Slider A())
Text 10, 120, "sB: " + Str$(JoyStick Slider B())
Text 10, 130, "sC: " + Str$(JoyStick Slider C())
Text 10, 140, "sD: " + Str$(JoyStick Slider D())
For i = 0 to 32
Text 10, 150 + (i * 10), "f" + str$(i) + ": " + Str$(JoyStick Fire X(i))
next i
EndFunction
[/Code]

Login to post a reply

Server time is: 2024-11-22 23:49:03
Your offset time is: 2024-11-22 23:49:03