Exemplo n.º 1
0
// TODO: This is such a mess...
void UpdateNativeMenuKeys() {
	std::vector<KeyDef> confirmKeys, cancelKeys;
	std::vector<KeyDef> tabLeft, tabRight;
	std::vector<KeyDef> upKeys, downKeys, leftKeys, rightKeys;

	int confirmKey = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CROSS : CTRL_CIRCLE;
	int cancelKey = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CIRCLE : CTRL_CROSS;

	KeyFromPspButton(confirmKey, &confirmKeys);
	KeyFromPspButton(cancelKey, &cancelKeys);
	KeyFromPspButton(CTRL_LTRIGGER, &tabLeft);
	KeyFromPspButton(CTRL_RTRIGGER, &tabRight);
	KeyFromPspButton(CTRL_UP, &upKeys);
	KeyFromPspButton(CTRL_DOWN, &downKeys);
	KeyFromPspButton(CTRL_LEFT, &leftKeys);
	KeyFromPspButton(CTRL_RIGHT, &rightKeys);

#ifdef ANDROID
	// Hardcode DPAD on Android
	upKeys.push_back(KeyDef(DEVICE_ID_ANY, NKCODE_DPAD_UP));
	downKeys.push_back(KeyDef(DEVICE_ID_ANY, NKCODE_DPAD_DOWN));
	leftKeys.push_back(KeyDef(DEVICE_ID_ANY, NKCODE_DPAD_LEFT));
	rightKeys.push_back(KeyDef(DEVICE_ID_ANY, NKCODE_DPAD_RIGHT));
#endif

	// Push several hard-coded keys before submitting to native.
	const KeyDef hardcodedConfirmKeys[] = {
		KeyDef(DEVICE_ID_KEYBOARD, NKCODE_SPACE),
		KeyDef(DEVICE_ID_KEYBOARD, NKCODE_ENTER),
		KeyDef(DEVICE_ID_ANY, NKCODE_BUTTON_A),
	};

	// If they're not already bound, add them in.
	for (size_t i = 0; i < ARRAY_SIZE(hardcodedConfirmKeys); i++) {
		if (std::find(confirmKeys.begin(), confirmKeys.end(), hardcodedConfirmKeys[i]) == confirmKeys.end())
			confirmKeys.push_back(hardcodedConfirmKeys[i]);
	}

	const KeyDef hardcodedCancelKeys[] = {
		KeyDef(DEVICE_ID_KEYBOARD, NKCODE_ESCAPE),
		KeyDef(DEVICE_ID_ANY, NKCODE_BACK),
		KeyDef(DEVICE_ID_ANY, NKCODE_BUTTON_B),
	};

	for (size_t i = 0; i < ARRAY_SIZE(hardcodedCancelKeys); i++) {
		if (std::find(cancelKeys.begin(), cancelKeys.end(), hardcodedCancelKeys[i]) == cancelKeys.end())
			cancelKeys.push_back(hardcodedCancelKeys[i]);
	}

	SetDPadKeys(upKeys, downKeys, leftKeys, rightKeys);
	SetConfirmCancelKeys(confirmKeys, cancelKeys);
	SetTabLeftRightKeys(tabLeft, tabRight);
}
Exemplo n.º 2
0
void UpdateConfirmCancelKeys() {
	std::vector<keycode_t> confirmKeys, cancelKeys;

	int confirmKey = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CROSS : CTRL_CIRCLE;
	int cancelKey = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CIRCLE : CTRL_CROSS;

	for(auto i = g_controllerMap[confirmKey].begin(); i != g_controllerMap[confirmKey].end(); ++i) {
		confirmKeys.push_back((keycode_t)i->keyCode);
	}

	for(auto i = g_controllerMap[cancelKey].begin(); i != g_controllerMap[cancelKey].end(); ++i) {
		cancelKeys.push_back((keycode_t)i->keyCode);
	}

	// Push several hard-coded keys before submitting to native.
	const keycode_t hardcodedConfirmKeys[] = { 
		NKCODE_SPACE, 
		NKCODE_ENTER,
	};

	// If they're not already bound, add them in.
	for(int i = 0; i < ARRAY_SIZE(hardcodedConfirmKeys); i++) {
		if(std::find(confirmKeys.begin(), confirmKeys.end(), hardcodedConfirmKeys[i]) == confirmKeys.end())
			confirmKeys.push_back(hardcodedConfirmKeys[i]);
	}

	const keycode_t hardcodedCancelKeys[] = { 
		NKCODE_ESCAPE, 
		NKCODE_BACK, 
	};

	for(int i = 0; i < ARRAY_SIZE(hardcodedCancelKeys); i++) {
		if(std::find(cancelKeys.begin(), cancelKeys.end(), hardcodedCancelKeys[i]) == cancelKeys.end())
			cancelKeys.push_back(hardcodedCancelKeys[i]);
	}

	SetConfirmCancelKeys(confirmKeys, cancelKeys);
}
Exemplo n.º 3
0
void UpdateConfirmCancelKeys() {
	std::vector<keycode_t> confirmKeys, cancelKeys;
	std::vector<keycode_t> tabLeft, tabRight;

	int confirmKey = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CROSS : CTRL_CIRCLE;
	int cancelKey = g_Config.iButtonPreference == PSP_SYSTEMPARAM_BUTTON_CROSS ? CTRL_CIRCLE : CTRL_CROSS;

	KeyCodesFromPspButton(confirmKey, &confirmKeys);
	KeyCodesFromPspButton(cancelKey, &cancelKeys);
	KeyCodesFromPspButton(CTRL_LTRIGGER, &tabLeft);
	KeyCodesFromPspButton(CTRL_RTRIGGER, &tabRight);

	// Push several hard-coded keys before submitting to native.
	const keycode_t hardcodedConfirmKeys[] = {
		NKCODE_SPACE,
		NKCODE_ENTER,
	};

	// If they're not already bound, add them in.
	for (size_t i = 0; i < ARRAY_SIZE(hardcodedConfirmKeys); i++) {
		if (std::find(confirmKeys.begin(), confirmKeys.end(), hardcodedConfirmKeys[i]) == confirmKeys.end())
			confirmKeys.push_back(hardcodedConfirmKeys[i]);
	}

	const keycode_t hardcodedCancelKeys[] = {
		NKCODE_ESCAPE,
		NKCODE_BACK,
	};

	for (size_t i = 0; i < ARRAY_SIZE(hardcodedCancelKeys); i++) {
		if (std::find(cancelKeys.begin(), cancelKeys.end(), hardcodedCancelKeys[i]) == cancelKeys.end())
			cancelKeys.push_back(hardcodedCancelKeys[i]);
	}

	SetConfirmCancelKeys(confirmKeys, cancelKeys);
	SetTabLeftRightKeys(tabLeft, tabRight);
}