Page 1 of 1

How do I get input from Classic Controller?

Posted: Tue May 22, 2012 9:36 pm
by Anakclusmos
How do I check if the classic controller is plugged in and read input from it?

Re: How do I get input from Classic Controller?

Posted: Wed May 23, 2012 4:52 am
by Anakclusmos
is anyone gonna answer this?

Re: How do I get input from Classic Controller?

Posted: Thu Sep 20, 2012 1:27 pm
by Anakclusmos
wow. 4 months and still no reply. excellent support.

Re: How do I get input from Classic Controller?

Posted: Thu Sep 20, 2012 2:24 pm
by Anakclusmos
I figured it out. Just in case anybody else is having trouble, I'm gonna post the solution here:

1. create an expansion_t variable
2. at the start of your main loop, call

Code: Select all

WPAD_Expansion(WPAD_CHAN_0, &e);
to check the expansion (e is the expansion_t variable you created)
3. if e.type == EXP_CLASSIC then the classic controller is plugged in
4. use e.classic.ljs = to get the left joystick, e.classic.rjs to get the right joystick, and e.buttons to get the buttons.

example:

Code: Select all

   expansion_t e;
   while (1) {
      WPAD_ScanPads();
      WPAD_Expansion(WPAD_CHAN_0, &e);
      if (e.type == EXP_CLASSIC) {
         printf("\x1b[2;2H");
         printf("Left JS={%i,%i}     RightJ JS={%i,%i}\n", (int)e.classic.ljs.pos.x, (int)e.classic.ljs.pos.y, (int)e.classic.rjs.pos.x, (int)e.classic.rjs.pos.y);
         if (e.classic.btns & CLASSIC_CTRL_BUTTON_HOME)
            break;
      }
   }