Example #1
0
void MenuProcessChangeKey(menu_t *menu)
{
	int key = GetKey(&gEventHandlers);	// wait until user has pressed a new button

	if (key == SDLK_ESCAPE)
	{
		MenuPlaySound(MENU_SOUND_BACK);
	}
	else if (KeyAvailable(
		key,
		menu->u.normal.changeKeyMenu->u.changeKey.code,
		menu->u.normal.changeKeyMenu->u.changeKey.keys,
		menu->u.normal.changeKeyMenu->u.changeKey.keysOther))
	{
		if (menu->u.normal.changeKeyMenu->u.changeKey.code != KEY_CODE_MAP)
		{
			InputSetKey(
				menu->u.normal.changeKeyMenu->u.changeKey.keys,
				key,
				menu->u.normal.changeKeyMenu->u.changeKey.code);
		}
		else
		{
			gConfig.Input.PlayerKeys[0].Keys.map = key;
		}
		MenuPlaySound(MENU_SOUND_ENTER);
	}
	else
	{
		MenuPlaySound(MENU_SOUND_ERROR);
	}
	menu->u.normal.changeKeyMenu = NULL;
}
Example #2
0
void MenuProcessChangeKey(menu_t *menu)
{
	int key = GetKey(&gKeyboard);	// wait until user has pressed a new button

	if (key == keyEsc)
	{
		SoundPlay(&gSoundDevice, SND_PICKUP);
	}
	else if (KeyAvailable(
		key,
		menu->u.normal.changeKeyMenu->u.changeKey.code,
		menu->u.normal.changeKeyMenu->u.changeKey.keys,
		menu->u.normal.changeKeyMenu->u.changeKey.keysOther))
	{
		if (menu->u.normal.changeKeyMenu->u.changeKey.code != KEY_CODE_MAP)
		{
			InputSetKey(
				menu->u.normal.changeKeyMenu->u.changeKey.keys,
				key,
				menu->u.normal.changeKeyMenu->u.changeKey.code);
		}
		else
		{
			gConfig.Input.PlayerKeys[0].Keys.map = key;
		}
		SoundPlay(&gSoundDevice, SND_EXPLOSION);
	}
	else
	{
		SoundPlay(&gSoundDevice, SND_KILL4);
	}
	menu->u.normal.changeKeyMenu = NULL;
}