Page 2 of 3

Re: Tutorial - Setting up a controller

PostPosted: Wed Jan 25, 2012 10:00 pm
by SuperSonic
Ok, the controller works with the new drivers but still nothing happens when I run your example :(

Have you ever had problems like this?

Re: Tutorial - Setting up a controller

PostPosted: Wed Jan 25, 2012 10:05 pm
by Hblade
not really o-o

I'l try and help as much as possible. o-o see if the buttons work.

Re: Tutorial - Setting up a controller

PostPosted: Thu Jan 26, 2012 8:48 pm
by SuperSonic
Ok, will do. I'll let you know what happens :)

Re: Tutorial - Setting up a controller

PostPosted: Fri Jan 27, 2012 3:49 pm
by SuperSonic
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;
}

Re: Tutorial - Setting up a controller

PostPosted: Fri Jan 27, 2012 3:56 pm
by SuperSonic
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:

Re: Tutorial - Setting up a controller

PostPosted: Fri Jan 27, 2012 8:15 pm
by Hblade
Thanks ^^

Re: Tutorial - Setting up a controller

PostPosted: Thu Jun 26, 2014 11:30 pm
by Zivouhr
This controller layout programming Tutorial is helpful, thanks!

Re: Tutorial - Setting up a controller

PostPosted: Sat Jul 05, 2014 2:51 pm
by Zivouhr
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.

Re: Tutorial - Setting up a controller

PostPosted: Thu Aug 14, 2014 12:34 am
by knucklecrunchgames
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

Re: Tutorial - Setting up a controller

PostPosted: Wed Oct 29, 2014 2:06 am
by Zivouhr
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.

Re: Tutorial - Setting up a controller

PostPosted: Wed Oct 29, 2014 10:02 am
by lcl
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

Re: Tutorial - Setting up a controller

PostPosted: Sun Nov 02, 2014 3:13 pm
by Zivouhr
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.

Re: Tutorial - Setting up a controller

PostPosted: Thu Nov 06, 2014 8:48 pm
by RippeR7420
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?

Re: Tutorial - Setting up a controller

PostPosted: Sat Nov 08, 2014 7:13 am
by Zivouhr
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).

Re: Tutorial - Setting up a controller

PostPosted: Sat Nov 08, 2014 3:09 pm
by RippeR7420
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!