~fitzsim/Main_MiSTer

Hard-code inputs 1 and 2 for MiSTercade

On an arcade cabinet you never want the right controls to control player
1 or the left controls to control player 2.  This patch hard-codes the
player assignments (controller assignments) so that no matter what
button one presses first, player 1 is always on the left, and player 2
is always on the right.
1 files changed, 34 insertions(+), 21 deletions(-)

M input.cpp
M input.cpp => input.cpp +34 -21
@@ 2366,37 2366,50 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int 

	if (!input[dev].num)
	{
		int assign_btn = ((input[dev].quirk == QUIRK_PDSP || input[dev].quirk == QUIRK_MSSP) && (ev->type == EV_REL || ev->type == EV_KEY));
		if (!assign_btn && ev->type == EV_KEY && ev->value >= 1 && ev->code >= 256)
		if (dev == 0)
		{
			for (int i = SYS_BTN_RIGHT; i <= SYS_BTN_START; i++) if (ev->code == input[dev].mmap[i]) assign_btn = 1;
			input[dev].num = 2;
			store_player(input[dev].num, dev);
		}

		if (assign_btn)
		else if (dev == 1)
		{
			for (uint8_t num = 1; num < NUMDEV + 1; num++)
			input[dev].num = 1;
			store_player(input[dev].num, dev);
		}
		else
		{
			int assign_btn = ((input[dev].quirk == QUIRK_PDSP || input[dev].quirk == QUIRK_MSSP) && (ev->type == EV_REL || ev->type == EV_KEY));
			if (!assign_btn && ev->type == EV_KEY && ev->value >= 1 && ev->code >= 256)
			{
				int found = 0;
				for (int i = 0; i < NUMDEV; i++)
				for (int i = SYS_BTN_RIGHT; i <= SYS_BTN_START; i++) if (ev->code == input[dev].mmap[i]) assign_btn = 1;
			}

			if (assign_btn)
			{
				for (uint8_t num = 1; num < NUMDEV + 1; num++)
				{
					if (input[i].quirk != QUIRK_TOUCHGUN)
					int found = 0;
					for (int i = 0; i < NUMDEV; i++)
					{
						// paddles/spinners overlay on top of other gamepad
						if (!((input[dev].quirk == QUIRK_PDSP || input[dev].quirk == QUIRK_MSSP) ^ (input[i].quirk == QUIRK_PDSP || input[i].quirk == QUIRK_MSSP)))
						if (input[i].quirk != QUIRK_TOUCHGUN)
						{
							found = (input[i].num == num);
							if (found) break;
							// paddles/spinners overlay on top of other gamepad
							if (!((input[dev].quirk == QUIRK_PDSP || input[dev].quirk == QUIRK_MSSP) ^ (input[i].quirk == QUIRK_PDSP || input[i].quirk == QUIRK_MSSP)))
							{
								found = (input[i].num == num);
								if (found) break;
							}
						}
					}
				}

				if (!found)
				{
					input[dev].num = num;
					if (JOYCON_COMBINED(dev)) input[input[dev].bind].num = num;
					store_player(num, dev);
					printf("Device %s assigned to player %d\n", input[dev].id, input[dev].num);
					break;
					if (!found)
					{
						input[dev].num = num;
						if (JOYCON_COMBINED(dev)) input[input[dev].bind].num = num;
						store_player(num, dev);
						printf("Device %s assigned to player %d\n", input[dev].id, input[dev].num);
						break;
					}
				}
			}
		}