[quote author=Kamjin link=board=homebrew;num=1103522346;start=0#1 date=12/20/04 at 02:38:36]
Code:
cont_cond_t cond1,cond2;
uint8 port,device,controller[4];
for(port=0;port<4;port++){
Â* Â*for(device=0;device<4;device++){
Â* Â* Â* if ( maple_device_func(port,device) == MAPLE_FUNC_CONTROLLER ) {
Â* Â* Â* Â* Â* Â* Â* controller[players]=maple_create_addr(port,device);
Â* Â* Â* Â* Â* Â* Â* players++;
Â* Â* Â* Â* Â* Â* Â* printf("found at %d,%d\n",port,device);
Â* Â* Â* }//end if
Â* Â* Â* }//end for device
Â* Â* Â* }//end for port
//for player1
cont_get_cond(controller[0], &cond1);
//for player2
cont_get_cond(controller[1], &cond2);
if(!(cond1.buttons & CONT_A)printf("P1 Pressed!\n");
if(!(cond2.buttons & CONT_A)printf("P2 Pressed!\n");
Â* Â* Â* Â*
[/quote]
This actually won't work anymore in KOS 1.3.x (the stuff that comes out of subversion). It's also problematic in that you have to scan for controllers periodically unless you don't want to allow hot-swapping. The new way is this:
Code:
// To do initial player count if you want
players = 0;
MAPLE_FOREACH_BEGIN(MAPLE_FUNC_CONTROLLER, cont_state_t, st)
players++;
printf("found at %c%d\n", __dev->port+'A', __dev->unit);
MAPLE_FOREACH_END()
// To actually do inputs
player = 0;
MAPLE_FOREACH_BEGIN(MAPLE_FUNC_CONTROLLER, cont_state_t, st)
if (st->buttons & CONT_A) {
printf("P%d PRESSED!\n", player);
}
player++;
MAPLE_FOREACH_END()
Or maybe I was going to take out the old compat functions and haven't yet... but they are soon to go, either way. Note that this works also in KOS 1.2.0, so it's the forward-compatible way to go now. maple.h has much more info (and lots of comments).
Those docs are pretty out of date now... seems like they always are.
The best source of up to date info, as always, as Kamjin mentions, is in the header files. Over time we've been working to get them into a doxygen compatible format so a reference doc can be automatically extracted, but it's still not there yet.
Also, KGL is pretty defunct -- I'd recommend grabbing KGL-X if you really want to use it. You can't just enable and disable blending unfortunately because it pretty much takes your input and goes straight to the PVR with it, with no DMA buffers. So you need to do it in lists like with the PVR functions.
Bookmarks