How do I get input from Classic Controller?

support for the powerpc toolchain
Post Reply
Anakclusmos
Posts: 19
Joined: Mon Nov 01, 2010 2:05 am

How do I get input from Classic Controller?

Post by Anakclusmos » Tue May 22, 2012 9:36 pm

How do I check if the classic controller is plugged in and read input from it?

Anakclusmos
Posts: 19
Joined: Mon Nov 01, 2010 2:05 am

Re: How do I get input from Classic Controller?

Post by Anakclusmos » Wed May 23, 2012 4:52 am

is anyone gonna answer this?

Anakclusmos
Posts: 19
Joined: Mon Nov 01, 2010 2:05 am

Re: How do I get input from Classic Controller?

Post by Anakclusmos » Thu Sep 20, 2012 1:27 pm

wow. 4 months and still no reply. excellent support.

Anakclusmos
Posts: 19
Joined: Mon Nov 01, 2010 2:05 am

Re: How do I get input from Classic Controller?

Post by Anakclusmos » Thu Sep 20, 2012 2:24 pm

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;
      }
   }

Post Reply

Who is online

Users browsing this forum: No registered users and 39 guests