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.

DarkBASIC Professional Discussion / xbox 360 controller demo project

Author
Message
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 26th Apr 2010 22:34 Edited at: 2nd May 2010 11:10
After goofing around with the FSone controller, I decided to try and see how the xBox 360 controller works. I bought the Windows one from Walmart, 35.00. It had no software, but when I plugged it in, it automatically detected and downloaded the software. It shows up in Control Panel as a normal game controller. So, I wrote a test app to check it out, using my Fokker model as a bone test.
I like it. A little to twitchy, but I think those things can be smoothed out with some math. Here is the project, its not pretty, but it should be readable. If you have an xBox controller, try it out and let me know if it works for you.

here is how the controller maps out:



edit:
added a little bit of terrain, based on real terrain (will be implementing USGS terrains)
added auto zoom to camera when model gets too far away. I will make this optional, and, it still needs some work.
added sparky's collision. Only collides with the nose of the plane, atm.

no more source code, atm. I think I might want to sell this, for a small, very small price, when it is done. (I could use money!)
NickH
18
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 27th Apr 2010 19:38
Theres a proper dll to use all functions. I forget it's name.
Non Sequitur M
17
Years of Service
User Offline
Joined: 28th Oct 2008
Location: Where am I!? Where are YOU?
Posted: 27th Apr 2010 20:16
I too have messed with the XB controller. My only two problems are that A) you can't use the center button, and B) that the triggers are on the same Z axis with one positive and one negative. You pull them both all the way in, and the program reads it as joystick z()=0. I've been trying to figure a work around for this.

If life were like a box of chocolates, I'd know what I would get... The one that got dropped on the floor and put back in the box.

Iye nehvur yoose spehl chehk, ahn mie tippyng izz fiyne.
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 27th Apr 2010 20:53 Edited at: 27th Apr 2010 23:59
I think it is meant for throttle/braking type setups. As for center button, do you mean on the D-pad or the power button?
Still, alot of functionality and ver comfortable.
The Viking
17
Years of Service
User Offline
Joined: 21st Oct 2008
Location: Asgard
Posted: 27th Apr 2010 22:40
Actually, there is a way around that left and right trigger problem. When I get home I'll send you the info for it. But, I am able to pull both at the same time. And yes, there is a dll for it, though I can't remember if I use the dll, or a different code. I'll check when I get home.

www.myspace.com/norseblod
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 27th Apr 2010 23:58 Edited at: 28th Apr 2010 00:01
but what does the dll do that the normal commands don't do already?
I'm saying, everything works fine without any extra dll.

this is the one I am using:
http://www.microsoft.com/hardware/gaming/ProductDetails.aspx?pid=091&active_tab=overview
The Viking
17
Years of Service
User Offline
Joined: 21st Oct 2008
Location: Asgard
Posted: 28th Apr 2010 01:51 Edited at: 28th Apr 2010 01:54
I'm sure using it works fine. The db commands are good for most general purposes, though it lacks in one area. Using the standard dark basic commands does not allow for the left and right triggers to be pressed simultaneously. I found this to be a complication for making fps, as I like to have the left trigger designated for zoom, and right trigger for firing. Using the standard dark basic commands as you have, if you press the left to zoom, it will, if you press the right to fire it will... but, if you press the left to zoom, followed by the right to fire when in zoom mode, it'll revert to the standard view, and neither zoom, nor fire.

I believe this is the dll for it, if you want to look at it. It allows up to 4 controllers, and also the rumble feature.

http://forum.thegamecreators.com/?m=forum_view&t=71107&b=18
hmmm, just noticed an update to it... cool.

www.myspace.com/norseblod
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 28th Apr 2010 02:47
ok, thanks. I will check it out.
It would be nice to have the rumble and the seperate axis, like you said.
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 28th Apr 2010 10:04 Edited at: 28th Apr 2010 10:29
ok, I figured it out.
First, you need to download the xbcd driver from this site:
http://www.redcl0ud.com/xbcd.html#v106

Then, you need to get this, its a mod to make the utility in the first download actually work in Windows. Go figure.
http://matt-land.com/xbcd/

I just unistalled the stock driver in control panel, then installed the first package. Then, I installed the second package.

Now, there is a utility that you can open up and assign the buttons and levers however you wish, so it is possible to have the trigger buttons split.
And it appears force feedback is working, it does in the test, and my app shows a 1 for feedback. Still playing, but, I think this is it.
yee haw!

also, you can save controller profiles, so, I think it would be possible to redistribute the controller settings with a game...

edit:
yup feedback for sure works now.
Todd Riggins
21
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 29th Apr 2010 20:26 Edited at: 12th May 2010 06:55
Quote: "but what does the dll do that the normal commands don't do already?
I'm saying, everything works fine without any extra dll."


Normal commands don't allow you to use the left/right triggers independently and use Rumble effects as you guys talked about. That is what the XBox360 controller driver and the DirectX XInput dll is for.

The extra dll I created works off the DirectX XInput dll which fully utilizes the XBox360 controllers( gamepad, guitars, etc..).

Using a dll that runs off of the XInput library, IMHO, would be the easiest way for someone to use the full functionality of a XBox controller with your game/app on the PC. As you have experienced, once you plug-in the xbox controller in the PC, windows will download the drivers for it. All that, to me IMHO, is better then trying to get people to uninstall the PC xbox 360 driver, download and install a third pary driver, xbcd, and a mod in hopes to get to work.

With using the XInput library, you get to use the xbox controller like you do when using it on the Xbox360 console minus the center xbox button. The dll I have created even allows you to capture mic sound where you can send that data through your multiplayer networking stuff and play it for your opponent to hear. That center xbox button is designed for the power button as The Viking said and for bringing the Xbox dashboard up on the XBox360 specifically. And, somehow Microsoft uses that button for its Games for Windows stuff( I never used if for that yet ). But, even the XInput library does not contain any functionality to use that specific button.

I am familiar with Ravens dll to use the XInput library, but for whatever reason he never did complete it. I wanted a complete dll. So I did one for both DBPro and the GDK.

http://forum.thegamecreators.com/?m=forum_view&t=155264&b=8

If your way works with the xbcd perfect for your application then cool. I just wanted to point out that however you access the XInput libray, it will allow you to use the full functionality the specific xbox controller has to offer they way you would expect using it on the xbox360 console.

ExoDev.Com |XBOX360 CONTROLLER LIBRARY|USE DARK GDK WITH LATEST DIRECTX| C2Q2.66, 8G RAM, GeFORCE 9800 X2, VISTA 64Bit
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 29th Apr 2010 23:25
@Todd,
I will try your .dll out. I think that is a great idea, like you said, so other people don't have to fuss with the xbcd driver and mod. But it does work, and works flawlessly. I am able to reassign the triggers to be independant, and, I also have the rumble. But, I'll try your out tonight, and let you know how it goes. Thanks.
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 2nd May 2010 10:02 Edited at: 2nd May 2010 10:22
@Todd
I tried your .dll. I was unable to run the demos. I get an error, see the image.


@everyone
I have decided I am finally going to make a game. I think I am ready now. The game is going to be an r/c airplane simulator. It will run in two modes, simulation and arcade. In simulation mode, I am going to try to use real flight physics to simulate what an r/c airplane will fly like. I have been flying r/c airplanes for over 15 years, and I know how they work. I think I can do this but if I can't then:
Arcade mode. You can fly any number of different r/c airplanes and play various r/c games. I want to keep an online database of highscores. The games I have in mind will be quick, and challenging, but not to frustrating.

The only catch here is it will require an XBOX 360 controller. I am requiring this because it can actually teach you how to fly a real r/c airplane, and, its way more comfortable and easier to use than keyboards and mice and joysticks.
So, watch this thread. At some point, I will move it to the WIP thread, and, hopefully, to the Program Announcements thread.

edit:
I was thinking about why Microsoft would not include the Rumble feature in their driver, and it occured to me it might me a legal thing. Since the rumble devices are probably motors, motors draw some amps from the usb circuit. Since there is probably no way to determine how many usb devices are plugged into a PC and how much current they are drawing, it could be possible to overload the USB circuit. This is just my guess, here. But on an XBOX, they have total control on that. So, in my game, I may support rumble, but, at the users risk.
Todd Riggins
21
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 2nd May 2010 19:29 Edited at: 12th May 2010 06:56
Yeah, that has something to do with how the editor is trying to open that project. It's works for me when I open other people's projects. I do remember at one point I had that problem with other peoples projects. Sry for the trouble. Unfortunately, I have no power over that.

That url is my computer's path to the exe( which is saved in the project's project file created by the IDE). The only solution is to create your own project so it can compile right. The example1.dba is the only file needed to compile to test the library with.



Quote: "edit:
I was thinking about why Microsoft would not include the Rumble feature in their driver, and it occured to me it might me a legal thing. Since the rumble devices are probably motors, motors draw some amps from the usb circuit. Since there is probably no way to determine how many usb devices are plugged into a PC and how much current they are drawing, it could be possible to overload the USB circuit. This is just my guess, here. But on an XBOX, they have total control on that. So, in my game, I may support rumble, but, at the users risk. "



Where ya get that from??? the Microsoft's DirectX XInput library gives you full crontrol over the "rumble" feature.

* Edit: BTW, your RC project sounds mighty interesting

ExoDev.Com |XBOX360 CONTROLLER LIBRARY|USE DARK GDK WITH LATEST DIRECTX| C2Q2.66, 8G RAM, GeFORCE 9800 X2, VISTA 64Bit
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 2nd May 2010 20:40
@Todd,
ok, I'll try that.

And I was only speculating why the stock driver might not support rumble. And you are right, someone else can program that feature into their app, and now they have to support it.
Dr Tank
17
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 15th May 2010 03:15 Edited at: 15th May 2010 03:18
I'd like to use the 360 controller when I return to my main project. I have tried Todd Riggins' DLL but it seems there is no support for d-pad diagonals. However, it is still possible to read the d-pad diagonals using standard DBP controller commands.

Also, here, it says that d-pad states are accessible using the xinput thing. From the above link:


It would be awesome to have a complete DLL, will full d-pad support. With that said I realise the D-Pad is not the 360's best feature and my game doesn't use it.

BTW thanks for the DLL - other thread was closed due to inactivity.
Todd Riggins
21
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 15th May 2010 06:12
Hi Dr Tank, I'll take a second look, but I know I return the raw values directly from what the latest DirectX's XInput dll gives. The Raw data for the DPad is either up/down OR left/right. But just in case, I will gladly dust off the code and take another look at it to make sure I didn't do something silly though. It might take a bit for me to get to it though. Also, don't feel shy about starting a new thread to ask questions about the dll. I always try to keep my eyes open for anything related.

----------

While I'm here, I have to ask the golden question: How's your RC project coming along, Visigoth?

ExoDev.Com |XBOX360 CONTROLLER LIBRARY|USE DARK GDK WITH LATEST DIRECTX| C2Q2.66, 8G RAM, GeFORCE 9800 X2, VISTA 64Bit
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 15th May 2010 06:41
@Todd,
coming along. Been working on the menus, and cleaning up the code to make it more modular. I've decided to break it up into smaller execuatables; The menu program, the simulation program, and the minigames programs. Decided on a few things. Game will be free, and source code will be freely available. I'm going to go with the stock DBPro input commands and the stock XBox driver, for now, since I don't really need the triggers, yet. I just want to make it as hassle free as possible for people to play it.(and mod it, if they want).
Eventually, I want to support all three methods, stock, XBCD, and your dll. Honestly, your dll is probably the best way to go, since it ignores any drivers already loaded.
Fix the dpad thing, and, it'll be perfect.
(the DBPro dpad maps to the Joystick Hat Angle command, btw. In the windows game controller settings, its the POV Hat angle)
I'm almost ready, I think, to move to the WIP board, but I'll check in here first to see if folks agree or not.
I am commited to finish this, but, might take some time since my day job is kicking into high gear.
Flatlander
FPSC Tool Maker
19
Years of Service
User Offline
Joined: 22nd Jan 2007
Location: The Flatlands
Posted: 15th May 2010 10:17 Edited at: 15th May 2010 10:20
Here's how I use the XBox Controller for my FPGC RPG Mod game development engine powered by FPSC.

[href][/href] - Image by BlackFox

You noticed it is conventional but yet not conventional. RPG Mod requires the possibility of paging through short documents of information. It also requires at times to press 'Y' for Yes or 'N' for no when responding to a question from a character. I provide these more common functions. I believe the ENTER/SELECT button is where it usually is and the Fire button seems to always be where it is. This is all done in DBPro.

Anyway, looking forward to see what you complete, Visigoth.

Todd Riggins
21
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 15th May 2010 23:54
Quote: "I'm going to go with the stock DBPro input commands and the stock XBox driver, for now, since I don't really need the triggers, yet."


That's cool. I just wanted to let ya know that there was an option. It's hard to advertise something free that not everybody can make use of( ie: they may not have a xbox360 with controllers ).

Quote: "Fix the dpad thing"


?? Yeah, I just looked again at the XInput functionality and my source code I have for my library. My dll returns exactly whatever the raw data is given. I don't make any conditional statement or filter results in any way. Trying to remember how DPad works with XBox Games itself, I don't recall anytime that left/right and up/down can be used at the same time either. There is nothing anybody can do as this is the way the XInput dll itself works.

-----

Anyways, still anxious to play it. With the left/right thumb sticks, that should make it feel just right playing it.

ExoDev.Com |XBOX360 CONTROLLER LIBRARY|USE DARK GDK WITH LATEST DIRECTX| C2Q2.66, 8G RAM, GeFORCE 9800 X2, VISTA 64Bit
Dr Tank
17
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 16th May 2010 02:26 Edited at: 16th May 2010 02:31
Quote: "?? Yeah, I just looked again at the XInput functionality and my source code I have for my library. My dll returns exactly whatever the raw data is given. I don't make any conditional statement or filter results in any way. Trying to remember how DPad works with XBox Games itself, I don't recall anytime that left/right and up/down can be used at the same time either. There is nothing anybody can do as this is the way the XInput dll itself works."


Have you posted the source code anywhere? The link I gave previously contains information from MSDN about XInput- here I link to the source. It should contain info about how to get the dpad info. It has on/off bits for each of the 4 directions.

http://msdn.microsoft.com/en-us/library/microsoft.directx_sdk.reference.xinput_gamepad%28v=VS.85%29.aspx

(sorry - linking won't work)

I'm sure XBox games can use diagonals: I have Soul Calibur and Tekken for the 360 and they definitely do use d-pad diagonals.

Visigoth - sorry for hijacking your thread! Radio Control Simulation thing could be fun, although you need a bit more gravity, momentum and all that business.
Todd Riggins
21
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 16th May 2010 04:16 Edited at: 16th May 2010 06:30
AHHH... I stand corrected. I think I see the error now as I was constantly looking at the wrong thing. Let me test it out and if it works, I'll try to reopen my locked thread via a moderator and update it.

Quote: "Have you posted the source code anywhere?"


Sry, I was talking about the source code to my dll (library). That I will not release.


EDIT: I was updating my structure right, but indeed not returning it right. Will update both the DBPro and DarkGDK as soon as I can.

EDIT: Uploaded new versions. Thread is still locked. I sent an email about it. But the links to the new library version is here:
http://forum.thegamecreators.com/?m=forum_view&t=155264&b=8&p=0

ExoDev.Com |XBOX360 CONTROLLER LIBRARY|USE DARK GDK WITH LATEST DIRECTX| C2Q2.66, 8G RAM, GeFORCE 9800 X2, VISTA 64Bit
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 16th May 2010 09:16 Edited at: 16th May 2010 12:48
@Todd,
I'm testing that out now. I get these results, is this correct?
North = 1
East = 8
South = 2
West = 4
NE = 9
SE = 10
SW = 6
NW = 5
I assigned a dword var for the return and just used a text command to print to the screen. Also, this is interesting, seems that you can get info from the DBPro command AND your dll at the same time.

edit:
I wrote a little app to test Todd's .dll, but it appears I can't use rumble using the stock Microsoft driver. I haven't tried xbcd yet, I'll do that in a bit.
Unless I'm doing something wrong. Everything else works great.




edit:
ok, my mistake. I was confused about the values to input into the motor speed. I was thinking it was 0 to 100, but its 0 to 65535.
So, it works fine!
So, thanks Todd for all your hard work. It works great with the stock driver. I'll be using your .dll, if thats ok!
Dr Tank
17
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 16th May 2010 23:45 Edited at: 16th May 2010 23:46
Excellent! Thanks Todd, and thanks Visigoth for posting the test code. I can confirm that it totally works.

Really cool to get a mention in the help file! I'll return the favour when I get around to making my game.
Todd Riggins
21
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 17th May 2010 00:30
Thanks guys! My Thread in the WIP forum is now unlocked to post in if you guys need any more help.

Quote: "I'm testing that out now. I get these results, is this correct?"


Yes. The dll documentation now shows how I get the values. They are derived from hexadecimal values, so when you press up and left you will get ( up:0x00000001 + left:0x00000004 = 0x00000005 ( or the value 5 as you see in decimal format ) ).

Quote: "I'll be using your .dll, if thats ok! "

lol I beg you to use it! I need it promoted

Quote: "Really cool to get a mention in the help file! I'll return the favour when I get around to making my game."

That's cool and thanks again

ExoDev.Com |XBOX360 CONTROLLER LIBRARY|USE DARK GDK WITH LATEST DIRECTX| C2Q2.66, 8G RAM, GeFORCE 9800 X2, VISTA 64Bit

Login to post a reply

Server time is: 2026-07-25 23:50:19
Your offset time is: 2026-07-25 23:50:19