ControlsConfig_bin::ControlsConfig_bin(QWidget *parent, Qt::WFlags flags)
	: QMainWindow(parent, flags)
{
	PlayerAI::LoadBindings();

	ui.setupUi(this);
	
	ui.conf_MoveLeft->SetDetails("Left", "Move left", Action::MoveLeft);
	ui.conf_MoveRight->SetDetails("Right", "Move right", Action::MoveRight);
	ui.conf_MoveUp->SetDetails("Up", "Move up", Action::MoveUp);
	ui.conf_MoveDown->SetDetails("Down", "Move down", Action::MoveDown);
	

	ui.conf_LookXAxis->SetDetails("X look", "Set direction in X", Action::LookXAxis);
	ui.conf_LookYAxis->SetDetails("Y look", "Set direction in Y", Action::LookYAxis);
	ui.conf_MoveXAxis->SetDetails("X Move", "Analogue x movement", Action::XMovement);
	ui.conf_MoveYAxis->SetDetails("Y Move", "Analogue y movement", Action::YMovement);
	
	ui.conf_Fire->SetDetails("Fire", "Fires all weapons", Action::Fire);
	ui.conf_Boost->SetDetails("Boost", "Moves faster", Action::Boost);
	ui.conf_Target->SetDetails("Target", "Sets target", Action::Target);

	ui.conf_LookBack->SetDetails("Look back", "Looks backwards while held", Action::LookBackwards);
	ui.conf_LockAngle->SetDetails("Lock angle", "Prevents changes to angle while held", Action::LockAngle);
	ui.conf_LockMovement->SetDetails("Lock position", "Prevents changes to position while held", Action::LockMovement);

	QObject::connect(ui.cbox_player_id, SIGNAL(activated(int)), this, SLOT(player_id_changed(int)));
	QObject::connect(ui.actionExit_without_Saving, SIGNAL(triggered()), this, SLOT(exit_no_save()));
	QObject::connect(ui.actionSave_and_Exit, SIGNAL(triggered()), this, SLOT(exit_and_save()));
	QObject::connect(ui.actionReset_to_default, SIGNAL(triggered()), this, SLOT(reset_to_default()));

	old_player_id = -1;
	player_id_changed(0);
	menu_exit = false;
}
int do_tftpd(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
	const int press_times = 1;
	int i = 0;

	asus_gpio_init();
	if (DETECT())		/* Reset button */
	{
		printf(" \n## Enter Rescue Mode ##\n");
		printf("   \n3: System Boot system code via TFTP.\n");
		setenv("autostart", "no");
		/* Wait forever for an image */
		if (NetLoop(TFTPD) < 0) 
			return 1;
	}
	else if (DETECT_WPS())	/* WPS button */
	{
		/* Make sure WPS button is pressed at least press_times * 0.01s. */
		while (DETECT_WPS() && i++ < press_times) {
			udelay(10000);
		}

		if (i >= press_times) {
			while (DETECT_WPS()) {
				udelay(90000);
				i++;
				if (i & 1)
					LEDON();
				else
					LEDOFF();
			}
			LEDOFF();
			asus_gpio_uninit();

			reset_to_default();
			do_reset (NULL, 0, 0, NULL);
		}
	}
	else
	{
		if(check_trx(argc, argv))
		{
			printf(" \nEnter Recuse Mode for trx error\n");
			printf("   \n3: System Boot system code via TFTP.\n");
			if (NetLoop(TFTPD) < 0) 
				return 1;
		}
		
		printf("   \n3: System Boot system code via Flash.\n");
		do_bootm(cmdtp, 0, argc, argv);
	}
	
	return 0;
}