Tutorial - Setting up a controller

Learn how to make certain types of games and use gameEditor.

Re: Tutorial - Setting up a controller

Postby SuperSonic » Wed Jan 25, 2012 10:00 pm

Ok, the controller works with the new drivers but still nothing happens when I run your example :(

Have you ever had problems like this?
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Tutorial - Setting up a controller

Postby Hblade » Wed Jan 25, 2012 10:05 pm

not really o-o

I'l try and help as much as possible. o-o see if the buttons work.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Tutorial - Setting up a controller

Postby SuperSonic » Thu Jan 26, 2012 8:48 pm

Ok, will do. I'll let you know what happens :)
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Tutorial - Setting up a controller

Postby SuperSonic » Fri Jan 27, 2012 3:49 pm

It didn't work. I tried all of my buttons and even the analog sticks again. Nothing :(

Here's the code I used on my actor's draw code:
Code: Select all
float ls_XAxis = GetJoystick1Axis(0);
float ls_YAxis = GetJoystick1Axis(1);
int i;
int Button[14];
for(i=0; i<14; i++){
Button[i] = GetJoystick1Button(i);
}


xvelocity=ls_XAxis/10000;
yvelocity=ls_YAxis/10000;
if (Button[0])
{
    r = 89;
    g = 0;
    b = 0;
}
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Tutorial - Setting up a controller

Postby SuperSonic » Fri Jan 27, 2012 3:56 pm

Never mind. It works now :shock: I don't even know what I did :lol:

Ok cool. I'm gonna finish your tutorial Hblade :D

*edit: Whoops, I didn't realize that that was the end of the tutorial haha :lol: Plus one for you Hblade :wink:
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Tutorial - Setting up a controller

Postby Hblade » Fri Jan 27, 2012 8:15 pm

Thanks ^^
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Tutorial - Setting up a controller

Postby Zivouhr » Thu Jun 26, 2014 11:30 pm

This controller layout programming Tutorial is helpful, thanks!
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score

Re: Tutorial - Setting up a controller

Postby Zivouhr » Sat Jul 05, 2014 2:51 pm

Hblade wrote:I doubt it o-o Try this code in a simple draw actor


Global Code:
Code: Select all
int BTN[10];
double AXIS[2];
void SetupPad() {
    int i; for(i=0;i<9;i++) {
        BTN[i]=GetJoystick1Button(i);
        }
    AXIS[0]=GetJoystick1Axis(0);
    AXIS[1]=GetJoystick1Axis(1);
}


Now for Draw Actor:
Code: Select all
SetupPad();
if (AXIS[0]>10000) {
    x+=5;
}

Move the joystick (Or Dpad) to the right and see if he moves :)


Thanks for all of the good information for coding a controller HBlade.
I have a USB PC/Mac SuperNintendo Controller hooked up with the D Pad and 8 buttons including select and start. So far, all of the buttons respond and work, but the D-Pad to control the character's movements is totally unresponsive no matter what code I have entered so far.
I tried setting it up as suggested, then tried setting it up as a button only with the Axis instead, and then tried assuming it might be an additional button beyond the original 8. Sadly, I can't get that D-Pad to register any response even though the other buttons work perfect.

Any ideas how to get it working with some new coding? Thanks. I wonder if this has happened to others with a similar pad.
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score

Re: Tutorial - Setting up a controller

Postby knucklecrunchgames » Thu Aug 14, 2014 12:34 am

Hey. Is there a ged file with this example? And can you make a multiplayer game with other controllers? If possible I will make my new game with game editor. :D
User avatar
knucklecrunchgames
 
Posts: 1071
Joined: Wed Nov 21, 2012 8:01 pm
Location: In gameEditor.exe
Score: 17 Give a positive score

Re: Tutorial - Setting up a controller

Postby Zivouhr » Wed Oct 29, 2014 2:06 am

knucklecrunchgames wrote:Hey. Is there a ged file with this example? And can you make a multiplayer game with other controllers? If possible I will make my new game with game editor. :D


A GED controller setup example would be very helpful, agreed. One where we can press play, and it'll allow us to control the item with the controller and buttons to jump, etc. I think maybe my controller is broken or incompatible, even though the buttons can be assigned and work (DPad still not moving the character). He just floats to the right and gets stuck on the wall.
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score

Re: Tutorial - Setting up a controller

Postby lcl » Wed Oct 29, 2014 10:02 am

Zivouhr, does your controller have a button for changing between different controlling modes?
My controller has a mode button for changing whether to use the D-pad or the left analog stick. My D-pad doesn't response if the Mode settings is on the wrong state (obviously). You may have the same kind of a problem.

Also, it really may be that your D-pad is is treated as extra buttons. Have you tried accessing the buttons up to number 14? It depends on the controller, which number is tied to which button. Also, if you want, you can have a look at this: viewtopic.php?f=4&t=11212
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Tutorial - Setting up a controller

Postby Zivouhr » Sun Nov 02, 2014 3:13 pm

lcl wrote:Zivouhr, does your controller have a button for changing between different controlling modes?
My controller has a mode button for changing whether to use the D-pad or the left analog stick. My D-pad doesn't response if the Mode settings is on the wrong state (obviously). You may have the same kind of a problem.

Also, it really may be that your D-pad is is treated as extra buttons. Have you tried accessing the buttons up to number 14? It depends on the controller, which number is tied to which button. Also, if you want, you can have a look at this: viewtopic.php?f=4&t=11212


Thanks Lcl. I was able to try that method too, thanks. The only thing is, it's one of those Super Nintendo controllers for PC/Mac with no mode since it only has the DPad (4 direction points), two shoulder buttons, 4 green, blue, yellow and red buttons and start and select. I was able to get every one of them to work, but still can't get the DPad to properly respond.

It's almost as if they forgot to program the DPad into the controller since I checked numbers 0 through 30 and still can't locate a response on it. If I had a game that used a DPad input, I'd be able to test it, but all of the games I've played are keyboard only, as my Tomb of Twelve game currently is also. I have to look into getting an xbox 360 controller to test that out first.

Thanks!

EDIT: I'm going to try my PS3 controller again and read some tutorials to learn how to connect it to a computer. The PS4 controller isn't regular USB I see, so it won't fit.

PS3 CONTROLLER WITH GAME EDITOR SUCCESS!!!
PS3gamepadGE2014.ged
(8.21 KiB) Downloaded 205 times

Here's the GED Game Editor file for all to test a PS3 Controller with.
Includes functioning for:
DPad
All buttons (excluding the PS Power on button)
Analog (have yet to figure out how to get both functioning at same time, but can get either one plus Dpad at same time working, just need to figure out how to have an Analog without the character slowly floating; any tips appreciated on how to do this). To have the character stop floating, I have to "//" the ANALOG code in this file, and just use the DPad to control your character.
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score

Re: Tutorial - Setting up a controller

Postby RippeR7420 » Thu Nov 06, 2014 8:48 pm

Hmm, that's strange. When I plug in my Ps3 Controller the GetJoystick1Button(x) codes goes as follows;

1: Circle
2: X
3: Square
4: L1
5: R1
6: L2
7: R2
8: Select
9: Start
10: L3
11: R3
12: PS button

I wonder why they are different. Zivouhr, Do you use an official PlayStation Controller?
CURRENT PROJECTS:

-Olo: The Sword Shaman http://game-editor.com/forum/viewtopic.php?f=4&t=12919

-The Wrath of Blob: (On the back burner)

-StickMcGee - Blast to the Future http://game-editor.com/forum/viewtopic.php?f=4&t=13660
User avatar
RippeR7420
 
Posts: 391
Joined: Mon Apr 27, 2009 4:16 pm
Location: Salt Lake City, Utah.
Score: 23 Give a positive score

Re: Tutorial - Setting up a controller

Postby Zivouhr » Sat Nov 08, 2014 7:13 am

RippeR7420 wrote:Hmm, that's strange. When I plug in my Ps3 Controller the GetJoystick1Button(x) codes goes as follows;

I wonder why they are different. Zivouhr, Do you use an official PlayStation Controller?


Hey RipperR, thanks for the add on GameJolt! You have some very cool games created. Nice work!

That is weird. I'm using a wireless PS3 controller originally included with the PS3 slim (1st slim version).

I need to figure out how to get the walk animations to stop when I stop pushing the DPad or analog. Not sure how to code a Key Up event script editor for right Pad "key up" since everything relates to the keys on the keyboard.

Wish there was a Key Up (key released) script that I knew about as there are scripts for Key Down (key pressed).
City of Rott Game created on Game Editor http://cityofrott.wordpress.com/
User avatar
Zivouhr
 
Posts: 549
Joined: Sat May 17, 2014 2:12 pm
Score: 59 Give a positive score

Re: Tutorial - Setting up a controller

Postby RippeR7420 » Sat Nov 08, 2014 3:09 pm

Thanks man! Tomb of Twelve is epic :D Here is an example of how you can use the Dpad(The way do at least haha);

Player -> Draw Actor -> Script Editor ->
Code: Select all
float Xaxis = GetJoystick1Axis(0);
float Yaxis = GetJoystick1Axis(1);

if(Xaxis > 2500) //D-Pad or analog stick is pushed to the RIGHT.
{
    switch(STATE)
    {
        case 0:
        ChangeAnimation("Player", "Player Walk Right", NO_CHANGE);
        STATE = 2;
        break;

        case 1:
        ChangeAnimation("Player", "Player Walk Right", NO_CHANGE);
        STATE = 2;
        break;

        case 2:
        x += 4;
        break;
    }
}

else

if(Xaxis < -2500) //D-Pad or analog stick is pushed to the LEFT.
{
    switch(STATE)
    {
        case 0:
        ChangeAnimation("Player", "Player Walk Left", NO_CHANGE);
        STATE = 3;
        break;

        case 1:
        ChangeAnimation("Player", "Player Walk Left", NO_CHANGE);
        STATE = 3;
        break;

        case 3:
        x -= 4;
        break;
    }
}

//Here is the standing still code ya want :)

else

if(Xaxis < 2500 && Xaxis > -2500) //D-Pad or analog stick Is not being pressed LEFT or RIGHT. Motionless!
{
    switch(STATE)
    {
        case 2:
        ChangeAnimation("Player", "Stand Right", NO_CHANGE);
        STATE = 0;
        break;

        case 3:
        ChangeAnimation("Player", "Stand Left", NO_CHANGE);
        STATE = 1;
        break;
    }
}


I don't know if I should be using the Joystick Functions like this(Super Simplified), But it works perfectly.

FYI- I just typed up this code, so there may be errors. But you should try it and let me know if it works for ya!
CURRENT PROJECTS:

-Olo: The Sword Shaman http://game-editor.com/forum/viewtopic.php?f=4&t=12919

-The Wrath of Blob: (On the back burner)

-StickMcGee - Blast to the Future http://game-editor.com/forum/viewtopic.php?f=4&t=13660
User avatar
RippeR7420
 
Posts: 391
Joined: Mon Apr 27, 2009 4:16 pm
Location: Salt Lake City, Utah.
Score: 23 Give a positive score

PreviousNext

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest