コード例 #1
0
//FIXME: Cellframework2 input stuff needs to be changed
static int CellinpState(int nCode)
{
	uint32_t numPadsConnected = 0;

	uint64_t pads_connected = cell_pad_input_pads_connected();
	uint64_t new_state_p1 = cell_pad_input_poll_device(0);
	uint64_t pausemenu_condition = ArcadeJoystick ? (CTRL_SELECT(new_state_p1) && CTRL_START(new_state_p1)) : (CTRL_L2(new_state_p1) && CTRL_R2(new_state_p1) && CTRL_R1(new_state_p1));

	if (nCode < 0)
		return 0;

	if (DoReset)
	{

		if (nCode == FBK_F3)
		{
			audio_stop();
			is_running = 0;
			DoReset = false;
			return 1;
		}

	}

	numPadsConnected = cell_pad_input_pads_connected();

	switch (nCode)
	{
		case P1_COIN:
			return CTRL_SELECT(new_state_p1);
		case P1_START:
			return CTRL_START(new_state_p1);
		case P1_UP:
			return ((CTRL_UP(new_state_p1) | CTRL_LSTICK_UP(new_state_p1)) != 0);
		case P1_DOWN: 
			return ((CTRL_DOWN(new_state_p1) | CTRL_LSTICK_DOWN(new_state_p1)) != 0);
		case P1_LEFT:
			return ((CTRL_LEFT(new_state_p1) | CTRL_LSTICK_LEFT(new_state_p1)) != 0);
		case P1_RIGHT:
			return ((CTRL_RIGHT(new_state_p1) | CTRL_LSTICK_RIGHT(new_state_p1)) != 0);
		case P1_FIRE1:
			return CTRL_CROSS(new_state_p1);
		case P1_FIRE2:
			return CTRL_CIRCLE(new_state_p1);
		case P1_FIRE3:
			return CTRL_SQUARE(new_state_p1);
		case P1_FIRE4: 
			return CTRL_TRIANGLE(new_state_p1);
		case P1_FIRE5:
			return CTRL_L1(new_state_p1);
		case P1_FIRE6:
			return CTRL_R1(new_state_p1);
		case 0x88:
			return CTRL_L2(new_state_p1);
		case 0x8A:			 
			return CTRL_R2(new_state_p1);
		case 0x3b:
			return CTRL_L3(new_state_p1);
		case P1_SERVICE:
			return CTRL_R3(new_state_p1);
		case 0x21:
			return CTRL_R2(new_state_p1);
		default:
			break;
	}

	if (numPadsConnected > 1)
	{
		uint64_t new_state_p2 = cell_pad_input_poll_device(1);

		switch (nCode)
		{
			case P2_COIN:
				return CTRL_SELECT(new_state_p2);
			case P2_START:
				return CTRL_START(new_state_p2);
			case P2_UP:
				return ((CTRL_UP(new_state_p2) | CTRL_LSTICK_UP(new_state_p2)) != 0);
			case P2_DOWN:
				return ((CTRL_DOWN(new_state_p2) | CTRL_LSTICK_DOWN(new_state_p2)) != 0);
			case P2_LEFT:
				return ((CTRL_LEFT(new_state_p2) | CTRL_LSTICK_LEFT(new_state_p2)) != 0);
			case P2_RIGHT:
				return ((CTRL_RIGHT(new_state_p2) | CTRL_LSTICK_RIGHT(new_state_p2)) != 0);
			case P2_FIRE1:
				return CTRL_CROSS(new_state_p2);
			case P2_FIRE2:
				return CTRL_CIRCLE(new_state_p2);
			case P2_FIRE3:
				return CTRL_SQUARE(new_state_p2);
			case P2_FIRE4: 
				return CTRL_TRIANGLE(new_state_p2);
			case P2_FIRE5:
				return CTRL_L1(new_state_p2);
			case P2_FIRE6:
				return CTRL_R1(new_state_p2);
			case 0x4088:
				return CTRL_L2(new_state_p2);
			case 0x408A:			 
				return CTRL_R2(new_state_p2);
			case 0x408b:
				return CTRL_L3(new_state_p2);
			case 0x408c:
				return CTRL_R3(new_state_p2);
		}
	}


	if (numPadsConnected > 2)
	{
		uint64_t new_state_p3 = cell_pad_input_poll_device(2);

		switch (nCode)
		{ 
			case P3_COIN:
				return CTRL_SELECT(new_state_p3);
			case P3_START:
				return CTRL_START(new_state_p3);
			case P3_UP:
				return ((CTRL_UP(new_state_p3) | CTRL_LSTICK_UP(new_state_p3)) != 0);
			case P3_DOWN:
				return ((CTRL_DOWN(new_state_p3) | CTRL_LSTICK_DOWN(new_state_p3)) != 0);
			case P3_LEFT:
				return ((CTRL_LEFT(new_state_p3) | CTRL_LSTICK_LEFT(new_state_p3)) != 0);
			case P3_RIGHT:
				return ((CTRL_RIGHT(new_state_p3) | CTRL_LSTICK_RIGHT(new_state_p3)) != 0);
			case P3_FIRE1:
				return CTRL_CROSS(new_state_p3);
			case P3_FIRE2:
				return CTRL_CIRCLE(new_state_p3);
			case P3_FIRE3:
				return CTRL_SQUARE(new_state_p3);
			case P3_FIRE4:
				return CTRL_TRIANGLE(new_state_p3);
			case P3_FIRE5:
				return CTRL_L1(new_state_p3);
			case P3_FIRE6:
				return CTRL_R1(new_state_p3);
			case 0x4188:
				return CTRL_L2(new_state_p3);
			case 0x418A:			 
				return CTRL_R2(new_state_p3);
			case 0x418b:
				return CTRL_L3(new_state_p3);
			case 0x418c:
				return CTRL_R3(new_state_p3);
		}
	}

	if (numPadsConnected > 3)
	{
		uint64_t new_state_p4 = cell_pad_input_poll_device(3);

		switch (nCode)
		{
			case P4_COIN:
				return CTRL_SELECT(new_state_p4);
			case P4_START:
				return CTRL_START(new_state_p4);
			case P4_UP:
				return ((CTRL_UP(new_state_p4) | CTRL_LSTICK_UP(new_state_p4)) != 0);
			case P4_DOWN:
				return ((CTRL_DOWN(new_state_p4) | CTRL_LSTICK_DOWN(new_state_p4)) != 0);
			case P4_LEFT:
				return ((CTRL_LEFT(new_state_p4) | CTRL_LSTICK_LEFT(new_state_p4)) != 0);
			case P4_RIGHT:
				return ((CTRL_RIGHT(new_state_p4) | CTRL_LSTICK_RIGHT(new_state_p4)) != 0);
			case P4_FIRE1:
				return CTRL_CROSS(new_state_p4);
			case P4_FIRE2:
				return CTRL_CIRCLE(new_state_p4);
			case P4_FIRE3:
				return CTRL_SQUARE(new_state_p4);
			case P4_FIRE4:
				return CTRL_TRIANGLE(new_state_p4);
			case P4_FIRE5:
				return CTRL_L1(new_state_p4);
			case P4_FIRE6:
				return CTRL_R1(new_state_p4);
			case 0x4288:
				return CTRL_L2(new_state_p4);
			case 0x428A:			 
				return CTRL_R2(new_state_p4);
			case 0x428b:
				return CTRL_L3(new_state_p4);
			case 0x428c:
				return CTRL_R3(new_state_p4);

		} 
	}

	return 0;
}
コード例 #2
0
ファイル: menu.cpp プロジェクト: magicseb/vba-next
static void browser_update(filebrowser_t * b)
{
	static uint64_t old_state = 0;
	uint64_t state, diff_state, button_was_pressed;

	state = cell_pad_input_poll_device(0);
	diff_state = old_state ^ state;
	button_was_pressed = old_state & diff_state;

	if(frame_count < special_action_msg_expired)
	{
	}
	else
	{
		if (CTRL_LSTICK_DOWN(state))
		{
			if(b->currently_selected < b->file_count-1)
			{
				FILEBROWSER_INCREMENT_ENTRY_POINTER(b);
				set_text_message("", 4);
			}
		}

		if (CTRL_DOWN(state))
		{
			if(b->currently_selected < b->file_count-1)
			{
				FILEBROWSER_INCREMENT_ENTRY_POINTER(b);
				set_text_message("", 7);
			}
		}

		if (CTRL_LSTICK_UP(state))
		{
			if(b->currently_selected > 0)
			{
				FILEBROWSER_DECREMENT_ENTRY_POINTER(b);
				set_text_message("", 4);
			}
		}

		if (CTRL_UP(state))
		{
			if(b->currently_selected > 0)
			{
				FILEBROWSER_DECREMENT_ENTRY_POINTER(b);
				set_text_message("", 7);
			}
		}

		if (CTRL_RIGHT(state))
		{
			b->currently_selected = (MIN(b->currently_selected + 5, b->file_count-1));
			set_text_message("", 7);
		}

		if (CTRL_LSTICK_RIGHT(state))
		{
			b->currently_selected = (MIN(b->currently_selected + 5, b->file_count-1));
			set_text_message("", 4);
		}

		if (CTRL_LEFT(state))
		{
			if (b->currently_selected <= 5)
				b->currently_selected = 0;
			else
				b->currently_selected -= 5;

			set_text_message("", 7);
		}

		if (CTRL_LSTICK_LEFT(state))
		{
			if (b->currently_selected <= 5)
				b->currently_selected = 0;
			else
				b->currently_selected -= 5;

			set_text_message("", 4);
		}

		if (CTRL_R1(state))
		{
			b->currently_selected = (MIN(b->currently_selected + NUM_ENTRY_PER_PAGE, b->file_count-1));
			set_text_message("", 7);
		}

		if (CTRL_R2(state))
		{
			b->currently_selected = (MIN(b->currently_selected + 50, b->file_count-1));
			set_text_message("", 7);
		}

		if (CTRL_L2(state))
		{
			if (b->currently_selected <= NUM_ENTRY_PER_PAGE)
				b->currently_selected= 0;
			else
				b->currently_selected -= 50;

			set_text_message("", 7);
		}

		if (CTRL_L1(state))
		{
			if (b->currently_selected <= NUM_ENTRY_PER_PAGE)
				b->currently_selected= 0;
			else
				b->currently_selected -= NUM_ENTRY_PER_PAGE;

			set_text_message("", 7);
		}

		if (CTRL_CIRCLE(button_was_pressed))
		{
			old_state = state;
			filebrowser_pop_directory(b);
		}


		if (CTRL_L3(state) && CTRL_R3(state))
		{
			/* if a rom is loaded then resume it */
			if (emulator_initialized)
			{
				menu_is_running = 0;
				is_running = 1;
				mode_switch = MODE_EMULATION;
				set_text_message("", 15);
			}
		}

		old_state = state;
	}
}