示例#1
0
文件: main.c 项目: shorti006/CN-Cheat
static int initializePad(int port, int slot)
{

    int ret;
    int modes;
    int i;

    waitPadReady(port, slot);
    modes = padInfoMode(port, slot, PAD_MODETABLE, -1);
    if (modes > 0) {
        for (i = 0; i < modes; i++) {
        }

    }
    if (modes == 0) {
        return 1;
    }

    i = 0;
    do {
        if (padInfoMode(port, slot, PAD_MODETABLE, i) == PAD_TYPE_DUALSHOCK)
            break;
        i++;
    } while (i < modes);
    if (i >= modes) {
        return 1;
    }

    ret = padInfoMode(port, slot, PAD_MODECUREXID, 0);
    if (ret == 0) {
        return 1;
    }
    padSetMainMode(port, slot, PAD_MMODE_DUALSHOCK, PAD_MMODE_LOCK);

    waitPadReady(port, slot);
    padInfoPressMode(port, slot);

    waitPadReady(port, slot);
    padEnterPressMode(port, slot);

    waitPadReady(port, slot);
    actuators = padInfoAct(port, slot, -1, 0);

    if (actuators != 0) {
        actAlign[0] = 0;
        actAlign[1] = 1;
        actAlign[2] = 0xff;
        actAlign[3] = 0xff;
        actAlign[4] = 0xff;
        actAlign[5] = 0xff;

        waitPadReady(port, slot);

       padSetActAlign(port, slot, actAlign);
    }
    else {
        //printf("Did not find any actuators.\n");
    }
    return 1;
}
示例#2
0
/** Tries to start a single pad.
* @param pad The pad data holding structure 
* @return 0 Error, != 0 Ok */
static int startPad(struct pad_data_t* pad) {
	if(padPortOpen(pad->port, pad->slot, pad->padBuf) == 0) {
		return 0;
	}
	
	if(!initializePad(pad)) {
	        return 0;
	}

	waitPadReady(pad);
	return 1;
}
示例#3
0
static int initializePad(struct pad_data_t* pad) {
	int tmp;
	int modes;
	int i;
	
	// is there any device connected to that port?
	if (waitPadReady(pad) == PAD_STATE_DISCONN) {
		return 1; // nope, don't waste your time here!
	}
	
	// How many different modes can this device operate in?
	// i.e. get # entrys in the modetable
	modes = padInfoMode(pad->port, pad->slot, PAD_MODETABLE, -1);
	LOG("PAD: The device has %d modes\n", modes);

	if (modes > 0) {
		LOG("( ");
		
		for (i = 0; i < modes; i++) {
			tmp = padInfoMode(pad->port, pad->slot, PAD_MODETABLE, i);
			LOG("%d ", tmp);
		}
	        
	        LOG(")");
	}

	tmp = padInfoMode(pad->port, pad->slot, PAD_MODECURID, 0);
	LOG("PAD: It is currently using mode %d\n", tmp);

	// If modes == 0, this is not a Dual shock controller 
	// (it has no actuator engines)
	if (modes == 0) {
		LOG("PAD: This is a digital controller?\n");
		return 1;
	}

	// Verify that the controller has a DUAL SHOCK mode
	i = 0;
	do {
		if (padInfoMode(pad->port, pad->slot, PAD_MODETABLE, i) == PAD_TYPE_DUALSHOCK)
			break;
		i++;
	} while (i < modes);
	
	if (i >= modes) {
		LOG("PAD: This is no Dual Shock controller\n");
		return 1;
	}

	// If ExId != 0x0 => This controller has actuator engines
	// This check should always pass if the Dual Shock test above passed
	tmp = padInfoMode(pad->port, pad->slot, PAD_MODECUREXID, 0);
	if (tmp == 0) {
	        LOG("PAD: This is no Dual Shock controller??\n");
	        return 1;
	}

	LOG("PAD: Enabling dual shock functions\n");

	// When using MMODE_LOCK, user cant change mode with Select button
	padSetMainMode(pad->port, pad->slot, PAD_MMODE_DUALSHOCK, PAD_MMODE_LOCK);

	waitPadReady(pad);
	tmp = padInfoPressMode(pad->port, pad->slot);
	LOG("PAD: infoPressMode: %d\n", tmp);

	waitPadReady(pad);        
	tmp = padEnterPressMode(pad->port, pad->slot);
	LOG("PAD: enterPressMode: %d\n", tmp);

	waitPadReady(pad);
	pad->actuators = padInfoAct(pad->port, pad->slot, -1, 0);
	LOG("PAD: # of actuators: %d\n", pad->actuators);

	if (pad->actuators != 0) {
		pad->actAlign[0] = 0;   // Enable small engine
		pad->actAlign[1] = 1;   // Enable big engine
		pad->actAlign[2] = 0xff;
		pad->actAlign[3] = 0xff;
		pad->actAlign[4] = 0xff;
		pad->actAlign[5] = 0xff;

		waitPadReady(pad);
		tmp = padSetActAlign(pad->port, pad->slot, pad->actAlign);
		LOG("PAD: padSetActAlign: %d\n", tmp);
	} else {
		LOG("PAD: Did not find any actuators.\n");
	}

	waitPadReady(pad);

	return 1;
}