Page 1 of 1

Issue with Controller....?

PostPosted: Sat Oct 23, 2010 10:07 pm
by Hblade
Alrighty guys, I have a lot of code so I cant show all of it.

My question is, howcome the controller only works for 1 actor.

here we go:

Menu - Button 2(On controller is pressed) - Create Actor - DialogBox

The dialog box shows up with this code in the draw-actor of the menu.
Code: Select all
double JOYS = GetJoystick1Axis(1);
int ii;
int TEMP;
for (ii=0;ii<17;ii++) {
    PAD[ii] = GetJoystick1Button(ii);
                   }
if (PAD[B_B] == 1 && TEMP == 0) {
    TEMP = 1;
    PlaySound2("data/conferm.wav", 1.000000, 1, 0.000000);
    press = index;
                                }
if (PAD[B_B] == 0 && TEMP == 1) {
    TEMP = 0;
                                }
 
switch(press) {
    case 0:
    break;
    case 1:
    if (SAVEEXISTS == 0) {
        CreateActor("D_MENU", "dark_menu", "(none)", "(none)", 0, 0, true);
        focus = 999;
                         }
    break;
    case 2:
    break;
    case 3:
    musicvol-=.02;
    TIMER++;
    if (TIMER>=60) {
        ExitGame();
                   }
    EventDisable("Event Actor", EVENTKEYDOWN);
    break;
              }
if (JOYS>=1000 && tmp == 0) {
    tmp = 1;
    if (index<4) {
        index++;
        y+=20;
                 }
    if (index == 4) {
        index = 0;
        y-=80;
                    }
                    PlaySound2("data/cursor.wav", 1.000000, 1, 0.000000);
                           }
if (JOYS<=-1000 && tmp == 0) {
    tmp = 1;
    if (index>-1) {
        index--;
        y-=20;
                  }
    if (index==-1) {
        index = 3;
        y+=80;
                   }
                   PlaySound2("data/cursor.wav", 1.000000, 1, 0.000000);
                            }
if (JOYS<1000 && JOYS>-1000 && tmp == 1) {
    tmp = 0;
                                       }


Now in the draw_actor of the dialog box:
Code: Select all

int TEMP;
if (PAD[B_B] == 1 && TEMP == 0) {
    TEMP = 1;
    PlaySound2("data/conferm.wav", 1.000000, 1, 0.000000);
    DestroyActor("Event Actor");
                                }
if (PAD[B_B] == 0 && TEMP == 1) {
    TEMP = 0;
                                }


I have also tried this:
Code: Select all
for (ii=0;ii<17;ii++) {
    PAD[ii] = GetJoystick1Button(ii);
                   }

Adding that to the code with int ii of course, (Why not i you ask? i does nothing for some strange reason)

anyway, the problem is, it doesnt register. I have no idea whats going on!!

Re: Issue with Controller....?

PostPosted: Sun Oct 24, 2010 3:13 am
by DST
Things like input should be grabbed globally - I would create a 'controller' actor, and dump all input to that actor. Once the snapshot of the current frame's controller input is in an array, you can do what you want with it from there.

Any other actor can access that array at any time.... in most games, input is a global thing.

Re: Issue with Controller....?

PostPosted: Sun Oct 24, 2010 7:15 pm
by Hblade
Thanks DST for the info :) However, I think mines a little more complicated than that. See, my variabels are read from a file. I have a seperate application (made with GE) where you can set up the controller buttons just the way you want to. Besides, as long as I've been with game editor, I often take breaks which make me forget a lot of the code I used to know xD Thus, making it global seems a bit confusing. I do remember arrays though, which I think I'm already doing that :/ (Not too sure though)
Code: Select all
PAD[B_B]

B_B is equal to what ever button you set it to with the controller calibrator.

B_A is Button_A, etc.

If I gave you the ged you think you can set up a function for me that will make things a lot easier?