How do I get input from Classic Controller?
-
- Posts: 19
- Joined: Mon Nov 01, 2010 2:05 am
How do I get input from Classic Controller?
How do I check if the classic controller is plugged in and read input from it?
-
- Posts: 19
- Joined: Mon Nov 01, 2010 2:05 am
Re: How do I get input from Classic Controller?
is anyone gonna answer this?
-
- Posts: 19
- Joined: Mon Nov 01, 2010 2:05 am
Re: How do I get input from Classic Controller?
wow. 4 months and still no reply. excellent support.
-
- Posts: 19
- Joined: Mon Nov 01, 2010 2:05 am
Re: How do I get input from Classic Controller?
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
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:
1. create an expansion_t variable
2. at the start of your main loop, call
Code: Select all
WPAD_Expansion(WPAD_CHAN_0, &e);
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;
}
}
Who is online
Users browsing this forum: No registered users and 6 guests