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 Discussion / Multiple Controllers

Author
Message
DARKHALO2K
21
Years of Service
User Offline
Joined: 4th Sep 2003
Location: UK
Posted: 27th May 2008 17:52
Hi there. I have a multiplayer game up and running with one player using the keyboard and the other a wired 360 controller, but would like to offer the option of both players being able to use a joypad.

Searching the forum kicked up a solution in the form of a plugin called "multijoy", but that thread is around three years old so I don't wanna risk paying out for a download I may never receive.

Anybody know of an easy solution, or if multijoy is still attainable? Thanks in advance for any help or advice.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 27th May 2008 19:25
Perhaps after PERFORMING CHECKLIST FOR CONTROL DEVICES, you can get the names of the joypads. Then you'll have a loop assigning each device (one at a time) using SET CONTROL DEVICE <name> and then returning the control positions or fire buttons, control those aspects for each player.

Enjoy your day.
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 28th May 2008 11:46 Edited at: 28th May 2008 12:14
If you want access to all four possible XBox360 controllers at the same time, you have a couple of options already that are simply not obvious to you at this point.

The first is to use the DLL that Microsoft provides for XBox360 controllers, xinput1_3.dll There are only 6 function calls in that dll, and only a couple of them are needed to get you 4 simultaneous controllers. Here is a source file that I use for getting at them in my programs in DBPro. I think it is compatible to some extent with DBC. Certainly, you can already load the dll and make the calls, anyway:



That's a lot of code, and I'd apologize, but...there's alot in there for someone willing to give it the once over. At the top in the first comment are the globals I use in DBPro...you will have to sort that, but...I think global is probably superfluous to your programs in DBC.

Basically, to use XInput is quite simple, you don't even need to get an interface to DirectX....too simple, really. The function jzDoXBox360GameControl returns a DWORD that is the basis of creating a control unit that any sort of input can define, so that the game loop looks more state oriented, so as to eliminate alot of device-specific code in the game loop.

Next, there are third party options, but TBH...there is nearly always a catch of some sort with those, the most immutable of those is the fact that most generic options require another bit of code that is not geared to your game and generally unavailable for direct exchange of information. This is both difficult for casual gamers to get installed and working, and slower in general than what we already have, or can get at through the tools we were given by TGC when we bought their products.

XInput and DirectInput are great options for DB users because they are standard with DX9 and work across all of our code and systems very well. Other solutions, particularly ones based on .NET have less compatibility, and are onerous, to say the least.

I am hoping to change that drastically in the near term.

Here is an early version of that code above that might be easier on the eyes:



...And here is a bonus function for you, in case you are actually reading this:



btw, the ... is to continue the line, you can edit it out and combine the lines if that is necessary. If you have any questions, ask...I will answer if I can.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th May 2008 23:39
There are no Globals in DBC, though variables in functions are still local

But that's the least of the problems if anyone is considering converting those DBPro snippets to DBC.

In DBC you get three types of variables - Integer, Float and String. Any of the others like byte, Word and DWord, you can forget it...

There's no such thing as Types in Classic either.

Believe me, many of us like stretching DBC to it's limits, but it's a wonder we ever write anything at all sometimes...

TDK_Man

jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 28th May 2008 23:53
I was afraid of that TDK and apologize profusely for my ignorance. I really am not trying to tie you up so, despite the appearance of that.
DARKHALO2K
21
Years of Service
User Offline
Joined: 4th Sep 2003
Location: UK
Posted: 29th May 2008 10:48 Edited at: 29th May 2008 10:49
Many thanks for the input, jinzai. That is a fair bit of code, but should be added to the code snippets as i'm sure that'd be useful to someone. In fact, it makes interesting reading, but the amount of code means I wont likely try to convert it.

I'm going to e-mail the author of the "multijoy" plugin today in the hope that he's still around, but many thanks to everybody who has taken the time to reply to this topic.

Login to post a reply

Server time is: 2025-06-05 21:23:06
Your offset time is: 2025-06-05 21:23:06