Пример #1
0
error_code cellPadPeriphGetData(u32 port_no, vm::ptr<CellPadPeriphData> data)
{
	sys_io.trace("cellPadPeriphGetData(port_no=%d, data=*0x%x)", port_no, data);
	const auto handler = fxm::get<pad_thread>();

	if (!handler)
		return CELL_PAD_ERROR_UNINITIALIZED;

	// port_no can only be 0-6 in this function
	if (port_no >= CELL_PAD_MAX_PORT_NUM || !data)
		return CELL_PAD_ERROR_INVALID_PARAMETER;

	const auto& pads = handler->GetPads();

	if (port_no >= pads.size() || port_no >= handler->GetInfo().max_connect)
		return CELL_PAD_ERROR_NO_DEVICE;

	const auto pad = pads[port_no];

	if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
		return CELL_PAD_ERROR_NO_DEVICE;

	// todo: support for 'unique' controllers, which goes in offsets 24+ in padData
	data->pclass_type = CELL_PAD_PCLASS_TYPE_STANDARD;
	data->pclass_profile = 0x0;

	return cellPadGetData(port_no, vm::get_addr(&data->cellpad_data));
}
Пример #2
0
void PS3Pad::update() {
  static CellPadInfo2 padInfo;
  int32_t ret;
  if ((ret = cellPadGetInfo2(&padInfo)) != CELL_OK) {
    return;
  }

  static CellPadData padData;

  for (int i = 0; i < MAX_PAD; i++) {
    ret = cellPadGetData(i, &padData);

    if (0 != ret) {
      continue;
    }

    if (padData.len > 0) {
      rightStickX_ = stickValue(padData, 4);
      rightStickY_ = stickValue(padData, 5);
      leftStickX_ = -stickValue(padData, 6);
      leftStickY_ = stickValue(padData, 7);

      int buttonData = padData.button[3];
      leftShoulder_ = buttonData & CELL_PAD_CTRL_L1;
      rightShoulder_ = buttonData & CELL_PAD_CTRL_R1;
    }
  }
}
Пример #3
0
static void frontend_ps3_salamander_init(void)
{
   CellPadData pad_data;
   cellPadInit(7);

   cellPadGetData(0, &pad_data);

   if(pad_data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_TRIANGLE)
   {
      //override path, boot first executable in cores directory
      RARCH_LOG("Fallback - Will boot first executable in RetroArch cores/ directory.\n");
      find_and_set_first_file();
   }
   else
   {
      //normal executable loading path
      char tmp_str[PATH_MAX];
      bool config_file_exists = false;

      if (path_file_exists(config_path))
         config_file_exists = true;

      //try to find CORE executable
      char core_executable[1024];
      fill_pathname_join(core_executable, default_paths.core_dir, "CORE.SELF", sizeof(core_executable));

      if(path_file_exists(core_executable))
      {
         //Start CORE executable
         strlcpy(libretro_path, core_executable, sizeof(libretro_path));
         RARCH_LOG("Start [%s].\n", libretro_path);
      }
      else
      {
         if (config_file_exists)
         {
            config_file_t * conf = config_file_new(config_path);
            config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str));
            config_file_free(conf);
            strlcpy(libretro_path, tmp_str, sizeof(libretro_path));
         }

         if (!config_file_exists || !strcmp(libretro_path, ""))
            find_and_set_first_file();
         else
            RARCH_LOG("Start [%s] found in retroarch.cfg.\n", libretro_path);

         if (!config_file_exists)
         {
            config_file_t *new_conf = config_file_new(NULL);
            config_set_string(new_conf, "libretro_path", libretro_path);
            config_file_write(new_conf, config_path);
            config_file_free(new_conf);
         }
      }
   }

   cellPadEnd();

}
Пример #4
0
s32 cellPadGetDataExtra(u32 port_no, vm::ptr<u32> device_type, vm::ptr<CellPadData> data)
{
	sys_io.trace("cellPadGetDataExtra(port_no=%d, device_type=*0x%x, device_type=*0x%x)", port_no, device_type, data);

	const auto handler = fxm::get<PadHandlerBase>();

	if (!handler)
		return CELL_PAD_ERROR_UNINITIALIZED;

	const PadInfo& rinfo = handler->GetInfo();

	if (port_no >= rinfo.max_connect)
		return CELL_PAD_ERROR_INVALID_PARAMETER;
	if (port_no >= rinfo.now_connect)
		return CELL_PAD_ERROR_NO_DEVICE;

	// TODO: This is used just to get data from a BD/CEC remote,
	// but if the port isnt a remote, device type is set to 0 and just regular cellPadGetData is returned

	*device_type = 0;

	// set BD data before just incase
	data->button[24] = 0x0;
	data->button[25] = 0x0;

	return cellPadGetData(port_no, data);
}
Пример #5
0
void				ESInput::Refresh						()
{
	cellPadGetInfo2(&PadInfo);

	if(!(PadInfo.system_info & CELL_PAD_INFO_INTERCEPTED))
	{
		for(int p = 0; p != PadCount(); p ++)
		{
			CellPadData newstate;
			cellPadGetData(p, &newstate);

			if(newstate.len != 0)
			{
				CurrentState[p] = newstate;

				for(int i = 0; i != BUTTONS - 8; i ++)
				{
					ESInputHelp::RefreshButton(CurrentState[p].button[ButtonIndex[i][0]] & ButtonIndex[i][1], HeldState[p][i], SingleState[p][i]);
				}

				for(int i = 0; i != 4; i ++)
				{
					ESInputHelp::RefreshButton(GetAxis(0, i) < -0x40, HeldState[p][16 + i * 2 + 0], SingleState[p][16 + i * 2 + 0]);
					ESInputHelp::RefreshButton(GetAxis(0, i) >  0x40, HeldState[p][16 + i * 2 + 1], SingleState[p][16 + i * 2 + 1]);
				}
			}
		}

		//TODO: Support rumble for more than 1 controller
		CellPadActParam param = {Small & 1, Large & 0xFF};
		cellPadSetActDirect(0, &param);
	}
}
Пример #6
0
/* Process all buttons and axes, called by SDL_Joystick code not by the SDL_Video */
void							CELL_PAD_JOYSTICK_Process			(SDL_Joystick* aJoystick, uint32_t aIndex)
{
#ifndef CELL_NO_SOFT_INPUT
	if(aIndex < NUM_PADS && CELL_Video.Pads.Pads[aIndex].Open && CELL_Video.Pads.Pads[aIndex].Mode == JOYSTICK)
#else
	if(aIndex < NUM_PADS && CELL_Video.Pads.Pads[aIndex].Open)
#endif
	{
		CellPadData newpadstate;
		if((CELL_OK == cellPadGetData(aIndex, &newpadstate)) && (newpadstate.len >= 8))
		{
			uint32_t newbuttons = newpadstate.button[2] | (newpadstate.button[3] << 8);

			/* Process buttons */
			if(newbuttons != CELL_Video.Pads.Pads[aIndex].OldButtons)
			{
				for(int i = 0; i != NUM_BUTTONS; i ++)
				{
					ProcessJoystickButton(aJoystick, aIndex, i, newbuttons & (1 << i), CELL_Video.Pads.Pads[aIndex].OldButtons & (1 << i));
				}

				CELL_Video.Pads.Pads[aIndex].OldButtons = newbuttons;
			}

			/* Process Axes */
			for(int i = 0; i != NUM_AXES; i ++)
			{
				if(CELL_Video.Pads.Pads[aIndex].OldAxes[i] != newpadstate.button[AxisIndex[i]])
				{
					int16_t value = (newpadstate.button[AxisIndex[i]] - 0x80) * 256;
					SDL_PrivateJoystickAxis(aJoystick, i, value);
				}
			}

			for(int i = 0; i != NUM_AXES; i ++)
			{
				CELL_Video.Pads.Pads[aIndex].OldAxes[i] = newpadstate.button[AxisIndex[i]];
			}
		}
	}

	return;
}
Пример #7
0
error_code cellPadGetDataExtra(u32 port_no, vm::ptr<u32> device_type, vm::ptr<CellPadData> data)
{
	sys_io.trace("cellPadGetDataExtra(port_no=%d, device_type=*0x%x, data=*0x%x)", port_no, device_type, data);

	const auto handler = fxm::get<pad_thread>();

	if (!handler)
		return CELL_PAD_ERROR_UNINITIALIZED;

	if (port_no >= CELL_MAX_PADS || !data)
		return CELL_PAD_ERROR_INVALID_PARAMETER;

	const auto& pads = handler->GetPads();

	if (port_no >= pads.size() || port_no >= handler->GetInfo().max_connect)
		return CELL_PAD_ERROR_NO_DEVICE;

	const auto pad = pads[port_no];

	if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
		return CELL_PAD_ERROR_NO_DEVICE;

	// TODO: This is used just to get data from a BD/CEC remote,
	// but if the port isnt a remote, device type is set to 0 and just regular cellPadGetData is returned

	if (device_type) // no error is returned on NULL
	{
		*device_type = 0;
	}

	// set BD data before just incase
	data->button[24] = 0x0;
	data->button[25] = 0x0;

	return cellPadGetData(port_no, data);
}
Пример #8
0
static void ps3_joypad_poll(void)
{
   unsigned port;
   CellPadInfo2 pad_info;
   uint64_t *lifecycle_state = (uint64_t*)&g_extern.lifecycle_state;

   for (port = 0; port < MAX_PADS; port++)
   {
      CellPadData state_tmp;
      cellPadGetData(port, &state_tmp);

      if (state_tmp.len != 0)
      {
         uint64_t *state_cur = &pad_state[port];
         *state_cur = 0;
#ifdef __PSL1GHT__
         *state_cur |= (state_tmp.BTN_LEFT)     ? (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
         *state_cur |= (state_tmp.BTN_DOWN)     ? (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
         *state_cur |= (state_tmp.BTN_RIGHT)    ? (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
         *state_cur |= (state_tmp.BTN_UP)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
         *state_cur |= (state_tmp.BTN_START)    ? (1ULL << RETRO_DEVICE_ID_JOYPAD_START) : 0;
         *state_cur |= (state_tmp.BTN_R3)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R3) : 0;
         *state_cur |= (state_tmp.BTN_L3)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L3) : 0;
         *state_cur |= (state_tmp.BTN_SELECT)   ? (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
         *state_cur |= (state_tmp.BTN_TRIANGLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_X) : 0;
         *state_cur |= (state_tmp.BTN_SQUARE)   ? (1ULL << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
         *state_cur |= (state_tmp.BTN_CROSS)    ? (1ULL << RETRO_DEVICE_ID_JOYPAD_B) : 0;
         *state_cur |= (state_tmp.BTN_CIRCLE)   ? (1ULL << RETRO_DEVICE_ID_JOYPAD_A) : 0;
         *state_cur |= (state_tmp.BTN_R1)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R) : 0;
         *state_cur |= (state_tmp.BTN_L1)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L) : 0;
         *state_cur |= (state_tmp.BTN_R2)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
         *state_cur |= (state_tmp.BTN_L2)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
#else
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_LEFT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_DOWN) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_RIGHT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_UP) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_START) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_START) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_R3) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R3) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_L3) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L3) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_SELECT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_TRIANGLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_X) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_SQUARE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_Y) : 0;

         if (g_extern.is_menu)
         {
            int value = 0;
            if (cellSysutilGetSystemParamInt(CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN, &value) == 0)
            {
               if (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CROSS)
                  *state_cur |=  (value == CELL_SYSUTIL_ENTER_BUTTON_ASSIGN_CROSS) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_A) : (1ULL << RETRO_DEVICE_ID_JOYPAD_B);
               if (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CIRCLE)
                  *state_cur |=  (value == CELL_SYSUTIL_ENTER_BUTTON_ASSIGN_CIRCLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_A) : (1ULL << RETRO_DEVICE_ID_JOYPAD_B);
            }
         }
         else
         {
            *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CROSS) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_B) : 0;
            *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CIRCLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_A) : 0;
         }
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_R1) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_L1) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_R2) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_L2) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_L2) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
         //RARCH_LOG("lsx : %d (%hd) lsy : %d (%hd) rsx : %d (%hd) rsy : %d (%hd)\n", lsx, ls_x, lsy, ls_y, rsx, rs_x, rsy, rs_y);
         uint8_t lsx = (uint8_t)(state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X]);
         uint8_t lsy = (uint8_t)(state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y]);
         uint8_t rsx = (uint8_t)(state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X]);
         uint8_t rsy = (uint8_t)(state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y]);
         analog_state[port][RETRO_DEVICE_INDEX_ANALOG_LEFT ][RETRO_DEVICE_ID_ANALOG_X] = convert_u8_to_s16(lsx);
         analog_state[port][RETRO_DEVICE_INDEX_ANALOG_LEFT ][RETRO_DEVICE_ID_ANALOG_Y] = convert_u8_to_s16(lsy);
         analog_state[port][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_X] = convert_u8_to_s16(rsx);
         analog_state[port][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_Y] = convert_u8_to_s16(rsy);

#if 0
         accelerometer_state[port].x = state_tmp.button[CELL_PAD_BTN_OFFSET_SENSOR_X];
         accelerometer_state[port].y = state_tmp.button[CELL_PAD_BTN_OFFSET_SENSOR_Y];
         accelerometer_state[port].z = state_tmp.button[CELL_PAD_BTN_OFFSET_SENSOR_Z];
#endif
#endif
      }

      for (int i = 0; i < 2; i++)
         for (int j = 0; j < 2; j++)
            if (analog_state[port][i][j] == -0x8000)
               analog_state[port][i][j] = -0x7fff;
   }

   uint64_t *state_p1 = &pad_state[0];

   *lifecycle_state &= ~((1ULL << RARCH_MENU_TOGGLE));

   if ((*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3)))
      *lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);

   cellPadGetInfo2(&pad_info);
   pads_connected = pad_info.now_connect; 
}
Пример #9
0
int main(int argc, char *argv[])
{
    int ret;
#if defined(_XBOX)
    XINPUT_STATE state;

    get_environment_settings();

    XInputGetState(0, &state);

    if(state.Gamepad.wButtons & XINPUT_GAMEPAD_Y)
    {
        //override path, boot first executable in cores directory
        RARCH_LOG("Fallback - Will boot first executable in RetroArch cores directory.\n");
        find_and_set_first_file();
    }
    else
    {
        //normal executable loading path
        init_settings();
    }

    XLaunchNewImage(libretro_path, NULL);
    RARCH_LOG("Launch libretro core: [%s] (return code: %x]).\n", libretro_path, ret);
#elif defined(__CELLOS_LV2__)
    CellPadData pad_data;
    char spawn_data[256], spawn_data_size[16];
    SceNpDrmKey * k_licensee = NULL;

    cellSysutilRegisterCallback(0, callback_sysutil_exit, NULL);

    cellSysmoduleLoadModule(CELL_SYSMODULE_IO);
    cellSysmoduleLoadModule(CELL_SYSMODULE_FS);
    cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_GAME);
    cellSysmoduleLoadModule(CELL_SYSMODULE_NET);

    cellSysmoduleLoadModule(CELL_SYSMODULE_SYSUTIL_NP);

    sys_net_initialize_network();

#ifdef HAVE_LOGGER
    logger_init();
#endif

    sceNpInit(NP_POOL_SIZE, np_pool);

    get_environment_settings();

    cellPadInit(7);

    cellPadGetData(0, &pad_data);

    if(pad_data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_TRIANGLE)
    {
        //override path, boot first executable in cores directory
        RARCH_LOG("Fallback - Will boot first executable in RetroArch cores/ directory.\n");
        find_and_set_first_file();
    }
    else
    {
        //normal executable loading path
        init_settings();
    }

    cellPadEnd();

#ifdef HAVE_LOGGER
    logger_shutdown();
#endif

    for(unsigned int i = 0; i < sizeof(spawn_data); ++i)
        spawn_data[i] = i & 0xff;

    snprintf(spawn_data_size, sizeof(spawn_data_size), "%d", 256);

    const char * const spawn_argv[] = {
        spawn_data_size,
        "test argv for",
        "sceNpDrmProcessExitSpawn2()",
        NULL
    };

    ret = sceNpDrmProcessExitSpawn2(k_licensee, libretro_path, (const char** const)spawn_argv, NULL, (sys_addr_t)spawn_data, 256, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M);
    RARCH_LOG("Launch libretro core: [%s] (return code: %x]).\n", libretro_path, ret);

    if(ret < 0)
    {
        RARCH_LOG("Executable file is not of NPDRM type, trying another approach to boot it...\n");
        sys_game_process_exitspawn2(libretro_path, NULL, NULL, NULL, 0, 1000, SYS_PROCESS_PRIMARY_STACK_SIZE_1M);
    }

    sceNpTerm();

    sys_net_finalize_network();

    cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_NP);

    cellSysmoduleUnloadModule(CELL_SYSMODULE_NET);
    cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME);
    cellSysmoduleLoadModule(CELL_SYSMODULE_FS);
    cellSysmoduleLoadModule(CELL_SYSMODULE_IO);
#endif

    return 1;
}
Пример #10
0
//-----------------------------------------------------------------------------
// Description: Updates this device
// Parameters:
// Returns:
// Notes:
//-----------------------------------------------------------------------------
void FWInputDevicePad::update()
{
	FWCellPadInfo	*pPadInfo = (FWCellPadInfo *)mpPlatformData;
	int device = pPadInfo->mDevice;

	if(sPadInfo.status[device])
	{
		// Device is plugged in
		if(sOldPadStatus[device] == 0)
		{
			bool bNewPad = false;

			// Device is new, see if it's supported by libusbpad
			int ret = cellPadGetData(device, &padData);

			if(ret == CELL_PAD_OK)
			{
				printf("libusbpad supported pad (%d) detected\n", device);
				printf("VENDOR_ID=(0x%x), PRODUCT_ID=(0x%x)\n", sPadInfo.vendor_id[device], sPadInfo.product_id[device]);
				pPadInfo->mPadId = 0;
				bNewPad = true;
			}
			else
			{
				pPadInfo->mPadId = -1;
				for(int i = 1; i < FWINPUT_MAX_PAD_IDS; i ++)
				{
					if(((int)sPadInfo.vendor_id[device] == sPadIds[i][0]) &&
						((int)sPadInfo.product_id[device] == sPadIds[i][1]))
					{
						// Found a matching device
						printf("framework supported pad (%d) detected\n", device);
						printf("VENDOR_ID=(0x%x), PRODUCT_ID=(0x%x)\n", sPadInfo.vendor_id[device], sPadInfo.product_id[device]);
						pPadInfo->mPadId = i;
						bNewPad = true;
						break;
					}
				}
			}

			if (bNewPad) {
				// enable sensor mode if each pad supports it
				if (cellPadInfoSensorMode(device) == CELL_PAD_INFO_SUPPORTED_SENSOR_MODE) {
					cellPadSetSensorMode(device, CELL_PAD_SENSOR_MODE_ON);
					printf("sensor supported pad\n");
				}
			}
		}

		int ret;
		if(pPadInfo->mPadId == 0)
			ret = cellPadGetData(device, &padData);
		else
			ret = cellPadGetRawData(device, &padData);

		if(ret == CELL_PAD_OK)
		{
			if((padData.len > 0) && (pPadInfo->mPadId != -1))
			{
				// Read the analog axes
				if(sPadMappings[pPadInfo->mPadId][0] >= 0)
				{
					mXAxis[0] = padData.button[sPadMappings[pPadInfo->mPadId][0]] * 2 - 255;
				}
				else
				{
					mXAxis[0] = 0;
				}

				if(sPadMappings[pPadInfo->mPadId][1] >= 0)
				{
					mYAxis[0] = padData.button[sPadMappings[pPadInfo->mPadId][1]] * 2 - 255;
				}
				else
				{
					mYAxis[0] = 0;
				}

				if(sPadMappings[pPadInfo->mPadId][2] >= 0)
				{
					mXAxis[1] = padData.button[sPadMappings[pPadInfo->mPadId][2]] * 2 - 255;
				}
				else
				{
					mXAxis[1] = 0;
				}

				if(sPadMappings[pPadInfo->mPadId][3] >= 0)
				{
					mYAxis[1] = padData.button[sPadMappings[pPadInfo->mPadId][3]] * 2 - 255;
				}
				else
				{
					mYAxis[1] = 0;
				}

				if(sPadMappings[pPadInfo->mPadId][36] >= 0)
				{
					mXAxis[2] = padData.button[sPadMappings[pPadInfo->mPadId][36]] * 2 - 1023;
				}
				else
				{
					mXAxis[2] = 0;
				}

				if(sPadMappings[pPadInfo->mPadId][37] >= 0)
				{
					mYAxis[2] = padData.button[sPadMappings[pPadInfo->mPadId][37]] * 2 - 1023;
				}
				else
				{
					mYAxis[2] = 0;
				}

				if(sPadMappings[pPadInfo->mPadId][38] >= 0)
				{
					mZAxis[2] = padData.button[sPadMappings[pPadInfo->mPadId][38]] * 2 - 1023;
				}
				else
				{
					mZAxis[2] = 0;
				}

				if(sPadMappings[pPadInfo->mPadId][39] >= 0)
				{
					mGyro = padData.button[sPadMappings[pPadInfo->mPadId][39]] * 2 - 1023;
				}
				else
				{
					mGyro = 0;
				}

				// Buttons
				for(int i = 0; i < 16; i ++)
				{
					if(sPadMappings[pPadInfo->mPadId][i * 2 + 4] >= 0)
					{				
						mButtons[i] = padData.button[sPadMappings[pPadInfo->mPadId][i * 2 + 4]] &
							(1 << sPadMappings[pPadInfo->mPadId][i * 2 + 5]) ? true : false;
					}
					else
					{
						mButtons[i] = false;
					}
				}

				// map pads which use discrete values for digital direction control
				// rather than a bit per button
				if(sPadIds[pPadInfo->mPadId][2] != -1)
				{
					switch(padData.button[sPadIds[pPadInfo->mPadId][2]] & 0xf)
					{
					// no direction
					case 0x0:
					default:
						mButtons[12] = false;
						mButtons[13] = false;
						mButtons[14] = false;
						mButtons[15] = false;
						break;
					// up
					case 0x1:
						mButtons[12] = true;
						mButtons[13] = false;
						mButtons[14] = false;
						mButtons[15] = false;
						break;
					// right-up
					case 0x2:
						mButtons[12] = true;
						mButtons[13] = true;
						mButtons[14] = false;
						mButtons[15] = false;
						break;
					// right
					case 0x3:
						mButtons[12] = false;
						mButtons[13] = true;
						mButtons[14] = false;
						mButtons[15] = false;
						break;
					// right-down
					case 0x4:
						mButtons[12] = false;
						mButtons[13] = true;
						mButtons[14] = true;
						mButtons[15] = false;
						break;
					// down
					case 0x5:
						mButtons[12] = false;
						mButtons[13] = false;
						mButtons[14] = true;
						mButtons[15] = false;
						break;
					// left-down
					case 0x6:
						mButtons[12] = false;
						mButtons[13] = false;
						mButtons[14] = true;
						mButtons[15] = true;
						break;
					// left
					case 0x7:
						mButtons[12] = false;
						mButtons[13] = false;
						mButtons[14] = false;
						mButtons[15] = true;
						break;
					// left-up
					case 0x8:
						mButtons[12] = true;
						mButtons[13] = false;
						mButtons[14] = false;
						mButtons[15] = true;
						break;
					}
				}
			}
		}
	}
	else
	{
		// No device, set all inputs to zero
		mXAxis[0] = mXAxis[1] = mYAxis[0] = mYAxis[1] = 0;

		for(int i = 0; i < 16; i ++)
		{
			mButtons[i] = false;
		}
	}

	// Update device status for next time
	sOldPadStatus[device] = sPadInfo.status[device];

	FWInputDevice::update();
}
Пример #11
0
static void ps3_input_poll(void *data)
{
   CellPadInfo2 pad_info;
   (void)data;

   for (unsigned i = 0; i < MAX_PADS; i++)
   {
      static CellPadData state_tmp;
      cellPadGetData(i, &state_tmp);

      if (state_tmp.len != 0)
      {
         uint64_t *state_cur = &state[i];
         bool dpad_emulation = (g_settings.input.dpad_emulation[i] != ANALOG_DPAD_NONE);
         *state_cur = 0;
#ifdef __PSL1GHT__
         *state_cur |= (state_tmp.BTN_LEFT)     ? (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
         *state_cur |= (state_tmp.BTN_DOWN)     ? (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
         *state_cur |= (state_tmp.BTN_RIGHT)    ? (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
         *state_cur |= (state_tmp.BTN_UP)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
         *state_cur |= (state_tmp.BTN_START)    ? (1ULL << RETRO_DEVICE_ID_JOYPAD_START) : 0;
         *state_cur |= (state_tmp.BTN_R3)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R3) : 0;
         *state_cur |= (state_tmp.BTN_L3)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L3) : 0;
         *state_cur |= (state_tmp.BTN_SELECT)   ? (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
         *state_cur |= (state_tmp.BTN_TRIANGLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_X) : 0;
         *state_cur |= (state_tmp.BTN_SQUARE)   ? (1ULL << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
         *state_cur |= (state_tmp.BTN_CROSS)    ? (1ULL << RETRO_DEVICE_ID_JOYPAD_B) : 0;
         *state_cur |= (state_tmp.BTN_CIRCLE)   ? (1ULL << RETRO_DEVICE_ID_JOYPAD_A) : 0;
         *state_cur |= (state_tmp.BTN_R1)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R) : 0;
         *state_cur |= (state_tmp.BTN_L1)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L) : 0;
         *state_cur |= (state_tmp.BTN_R2)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
         *state_cur |= (state_tmp.BTN_L2)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L2) : 0;

         if (dpad_emulation)
         {
            *state_cur |= (state_tmp.ANA_L_H <= DEADZONE_LOW) ? (1ULL << RARCH_ANALOG_LEFT_X_DPAD_LEFT) : 0;
            *state_cur |= (state_tmp.ANA_L_H >= DEADZONE_HIGH) ? (1ULL << RARCH_ANALOG_LEFT_X_DPAD_RIGHT) : 0;
            *state_cur |= (state_tmp.ANA_L_V <= DEADZONE_LOW) ? (1ULL << RARCH_ANALOG_LEFT_Y_DPAD_UP) : 0;
            *state_cur |= (state_tmp.ANA_L_V >= DEADZONE_HIGH) ? (1ULL << RARCH_ANALOG_LEFT_Y_DPAD_DOWN) : 0;
            *state_cur |= (state_tmp.ANA_R_H <= DEADZONE_LOW) ? (1ULL << RARCH_ANALOG_RIGHT_X_DPAD_LEFT) : 0;
            *state_cur |= (state_tmp.ANA_R_H >= DEADZONE_HIGH) ? (1ULL << RARCH_ANALOG_RIGHT_X_DPAD_RIGHT) : 0;
            *state_cur |= (state_tmp.ANA_R_V <= DEADZONE_LOW) ? (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_UP) : 0;
            *state_cur |= (state_tmp.ANA_R_V >= DEADZONE_HIGH) ? (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_DOWN) : 0;
         }
#else
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_LEFT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_DOWN) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_RIGHT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_UP) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_START) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_START) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_R3) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R3) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_L3) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L3) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_SELECT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_TRIANGLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_X) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_SQUARE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CROSS) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_B) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CIRCLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_A) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_R1) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_L1) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_R2) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_L2) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
         if (dpad_emulation)
         {
            *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X] <= DEADZONE_LOW) ? (1ULL << RARCH_ANALOG_LEFT_X_DPAD_LEFT) : 0;
            *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X] >= DEADZONE_HIGH) ? (1ULL << RARCH_ANALOG_LEFT_X_DPAD_RIGHT) : 0;
            *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y] <= DEADZONE_LOW) ? (1ULL << RARCH_ANALOG_LEFT_Y_DPAD_UP) : 0;
            *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y] >= DEADZONE_HIGH) ? (1ULL << RARCH_ANALOG_LEFT_Y_DPAD_DOWN) : 0;
            *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X] <= DEADZONE_LOW) ? (1ULL << RARCH_ANALOG_RIGHT_X_DPAD_LEFT) : 0;
            *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X] >= DEADZONE_HIGH) ? (1ULL << RARCH_ANALOG_RIGHT_X_DPAD_RIGHT) : 0;
            *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y] <= DEADZONE_LOW) ? (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_UP) : 0;
            *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y] >= DEADZONE_HIGH) ? (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_DOWN) : 0;
         }
#endif
      }
   }

   uint64_t *state_p1 = &state[0];
   uint64_t *lifecycle_state = &g_extern.lifecycle_state;
   bool dpad_emulation = (g_settings.input.dpad_emulation[0] != ANALOG_DPAD_NONE);

   *lifecycle_state &= ~(
         (1ULL << RARCH_FAST_FORWARD_HOLD_KEY) | 
         (1ULL << RARCH_LOAD_STATE_KEY) | 
         (1ULL << RARCH_SAVE_STATE_KEY) | 
         (1ULL << RARCH_STATE_SLOT_PLUS) | 
         (1ULL << RARCH_STATE_SLOT_MINUS) | 
         (1ULL << RARCH_REWIND) |
         (1ULL << RARCH_QUIT_KEY) |
         (1ULL << RARCH_MENU_TOGGLE));

   if (dpad_emulation)
   {
      if ((*state_p1 & (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_DOWN)) && !(*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R2)))
         *lifecycle_state |= (1ULL << RARCH_FAST_FORWARD_HOLD_KEY);
      if ((*state_p1 & (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_UP)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R2)))
         *lifecycle_state |= (1ULL << RARCH_LOAD_STATE_KEY);
      if ((*state_p1 & (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_DOWN)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R2)))
         *lifecycle_state |= (1ULL << RARCH_SAVE_STATE_KEY);
      if ((*state_p1 & (1ULL << RARCH_ANALOG_RIGHT_X_DPAD_RIGHT)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R2)))
         *lifecycle_state |= (1ULL << RARCH_STATE_SLOT_PLUS);
      if ((*state_p1 & (1ULL << RARCH_ANALOG_RIGHT_X_DPAD_LEFT)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R2)))
         *lifecycle_state |= (1ULL << RARCH_STATE_SLOT_MINUS);
      if ((*state_p1 & (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_UP)) && !(*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R2)))
         *lifecycle_state |= (1ULL << RARCH_REWIND);
   }

   if ((*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3)))
      *lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);

   cellPadGetInfo2(&pad_info);
   pads_connected = pad_info.now_connect; 
#ifdef HAVE_MOUSE
   mice_connected = ps3_mouse_input_mice_connected();
#endif
}
Пример #12
0
/*
 * Function:		art_thread()
 * File:			main.c
 * Project:			ArtemisPS3-PRX
 * Description:		Artemis PRX Thread start
 *					Interprets user input and calls art_process()
 * Arguments:		
 *	arg:			
 * Return:			void
 */
static void art_thread(uint64_t arg)
{
	int GameProcessID = 0, lastGameProcessID = 0;

	printf("Artemis PS3 :::: Thread Started!\n");
	
	sys_timer_sleep(10);
	sys_ppu_thread_yield();
	
	CellPadData data;
	CellPadInfo2 info;
	int delay = 0, delay2 = 0, hasDisplayed = 0, fd = 0;

	while (1)
	{
		if (exitThread)
		{
			destroy_heap();
			exitThread = 0;
			{ sys_ppu_thread_exit(0); }
			{ return; }
		}

		GameProcessID = GetGameProcessID();
		if (GameProcessID != 0)
		{
			if (!check_turnoff()) //exit
			{
				printf("Artemis PS3 :::: Process Exited\n");
				destroy_heap();
				attachedPID = 0;
			}
			else
			{
				if (GameProcessID != lastGameProcessID)
				{
					for (int x = 0; x < (10 * 100); x++) //10 second delay
					{
						sys_timer_usleep(10000);
						sys_ppu_thread_yield();
					}


					show_msg((char *)"Artemis PS3\nStart To Attach");
				}

				cellPadGetInfo2(&info);
				if (info.port_status[0] && (cellPadGetData(0, &data) | 1) && data.len > 0)
				{
					uint32_t pad = data.button[2] | (data.button[3] << 8);
					if (attachedPID) // Run codes
					{
						art_process(0);
					}

					if (pad & PAD_START)
					{
						attachedPID = GameProcessID;
						if (attachedPID)
						{
							show_msg((char *)"Artemis PS3\nAttached and Wrote");
							printf("Artemis PS3 :::: Attached to 0x%08X\n", attachedPID);

							if (get_heap() == 0)
								create_heap(1);
							check_syscall_api();
							art_process(1);

							while ((cellPadGetData(0, &data) | 1) && data.len > 0)
							{
								if (!((data.button[2] | (data.button[3] << 8)) & PAD_START))
									break;

								sys_timer_usleep(1000000);
								sys_ppu_thread_yield();
							}
						}
						else
						{
							show_msg((char *)"Artemis PS3\nFailed to Attach");
						}
					}
					else if (pad & PAD_SELECT && attachedPID)
					{
						show_msg((char *)"Artemis PS3\nDetached");
						reset_heap();
						attachedPID = 0;
					}

				}

				sys_timer_usleep(100 * 1000); //0.1 second delay
			}
		}
		else
		{
			if (attachedPID) // Disconnect
			{
				printf("Artemis PS3 :::: Process Exited\n");
				destroy_heap();
				attachedPID = 0;
			}
			else
				sys_timer_usleep(3 * 1000 * 1000); //3 second delay
		}

		lastGameProcessID = GameProcessID;
		sys_timer_usleep(1668);
		sys_ppu_thread_yield();
	}

	destroy_heap();
	sys_ppu_thread_exit(0);

}
Пример #13
0
static void ps3_joypad_poll(void)
{
   unsigned port;
   CellPadInfo2 pad_info;

   cellPadGetInfo2(&pad_info);

   for (port = 0; port < MAX_PADS; port++)
   {
      CellPadData state_tmp;

      if (pad_info.port_status[port] & CELL_PAD_STATUS_ASSIGN_CHANGES)
      {
         if ( (pad_info.port_status[port] & CELL_PAD_STATUS_CONNECTED) == 0 )
         {
            input_config_autoconfigure_disconnect(port, ps3_joypad.ident);
            pads_connected[port] = 0;
         }
         else if ((pad_info.port_status[port] & CELL_PAD_STATUS_CONNECTED) > 0 )
         {
            pads_connected[port] = 1;
            ps3_joypad_autodetect_add(port);
         }
      }
      
      if (pads_connected[port] == 0)
         continue;

      cellPadGetData(port, &state_tmp);

      if (state_tmp.len != 0)
      {
         uint64_t *state_cur = &pad_state[port];
         *state_cur = 0;
#ifdef __PSL1GHT__
         *state_cur |= (state_tmp.BTN_LEFT)     ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
         *state_cur |= (state_tmp.BTN_DOWN)     ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
         *state_cur |= (state_tmp.BTN_RIGHT)    ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
         *state_cur |= (state_tmp.BTN_UP)       ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
         *state_cur |= (state_tmp.BTN_START)    ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_START) : 0;
         *state_cur |= (state_tmp.BTN_R3)       ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R3) : 0;
         *state_cur |= (state_tmp.BTN_L3)       ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L3) : 0;
         *state_cur |= (state_tmp.BTN_SELECT)   ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
         *state_cur |= (state_tmp.BTN_TRIANGLE) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_X) : 0;
         *state_cur |= (state_tmp.BTN_SQUARE)   ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
         *state_cur |= (state_tmp.BTN_CROSS)    ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_B) : 0;
         *state_cur |= (state_tmp.BTN_CIRCLE)   ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_A) : 0;
         *state_cur |= (state_tmp.BTN_R1)       ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R) : 0;
         *state_cur |= (state_tmp.BTN_L1)       ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L) : 0;
         *state_cur |= (state_tmp.BTN_R2)       ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
         *state_cur |= (state_tmp.BTN_L2)       ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
#else
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_LEFT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_DOWN) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_RIGHT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_UP) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_START) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_START) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_R3) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R3) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_L3) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L3) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_SELECT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_TRIANGLE) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_X) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_SQUARE) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y) : 0;

         if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
         {
            int value = 0;
            if (cellSysutilGetSystemParamInt(CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN, &value) == 0)
            {
               if (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CROSS)
                  *state_cur |=  (value == CELL_SYSUTIL_ENTER_BUTTON_ASSIGN_CROSS) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_A) : (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_B);
               if (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CIRCLE)
                  *state_cur |=  (value == CELL_SYSUTIL_ENTER_BUTTON_ASSIGN_CIRCLE) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_A) : (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_B);
            }
         }
         else
         {
            *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CROSS) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_B) : 0;
            *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CIRCLE) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_A) : 0;
         }
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_R1) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_L1) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_R2) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_L2) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_L2) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
         //RARCH_LOG("lsx : %d (%hd) lsy : %d (%hd) rsx : %d (%hd) rsy : %d (%hd)\n", lsx, ls_x, lsy, ls_y, rsx, rs_x, rsy, rs_y);
         uint8_t lsx = (uint8_t)(state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X]);
         uint8_t lsy = (uint8_t)(state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y]);
         uint8_t rsx = (uint8_t)(state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X]);
         uint8_t rsy = (uint8_t)(state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y]);
         analog_state[port][RETRO_DEVICE_INDEX_ANALOG_LEFT ][RETRO_DEVICE_ID_ANALOG_X] = convert_u8_to_s16(lsx);
         analog_state[port][RETRO_DEVICE_INDEX_ANALOG_LEFT ][RETRO_DEVICE_ID_ANALOG_Y] = convert_u8_to_s16(lsy);
         analog_state[port][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_X] = convert_u8_to_s16(rsx);
         analog_state[port][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_Y] = convert_u8_to_s16(rsy);

#if 0
         accelerometer_state[port].x = state_tmp.button[CELL_PAD_BTN_OFFSET_SENSOR_X];
         accelerometer_state[port].y = state_tmp.button[CELL_PAD_BTN_OFFSET_SENSOR_Y];
         accelerometer_state[port].z = state_tmp.button[CELL_PAD_BTN_OFFSET_SENSOR_Z];
#endif
#endif
      }

      for (int i = 0; i < 2; i++)
         for (int j = 0; j < 2; j++)
            if (analog_state[port][i][j] == -0x8000)
               analog_state[port][i][j] = -0x7fff;
   }
}
Пример #14
0
static void ps3_input_poll(void *data)
{
   CellPadInfo2 pad_info;
   ps3_input_t *ps3 = (ps3_input_t*)data;
   uint64_t *lifecycle_state = (uint64_t*)&g_extern.lifecycle_state;

   if (!ps3)
      return;

   for (unsigned port = 0; port < MAX_PADS; port++)
   {
      static CellPadData state_tmp;
      cellPadGetData(port, &state_tmp);

      if (state_tmp.len != 0)
      {
         uint64_t *state_cur = &ps3->pad_state[port];
         *state_cur = 0;
#ifdef __PSL1GHT__
         *state_cur |= (state_tmp.BTN_LEFT)     ? (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
         *state_cur |= (state_tmp.BTN_DOWN)     ? (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
         *state_cur |= (state_tmp.BTN_RIGHT)    ? (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
         *state_cur |= (state_tmp.BTN_UP)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
         *state_cur |= (state_tmp.BTN_START)    ? (1ULL << RETRO_DEVICE_ID_JOYPAD_START) : 0;
         *state_cur |= (state_tmp.BTN_R3)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R3) : 0;
         *state_cur |= (state_tmp.BTN_L3)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L3) : 0;
         *state_cur |= (state_tmp.BTN_SELECT)   ? (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
         *state_cur |= (state_tmp.BTN_TRIANGLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_X) : 0;
         *state_cur |= (state_tmp.BTN_SQUARE)   ? (1ULL << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
         *state_cur |= (state_tmp.BTN_CROSS)    ? (1ULL << RETRO_DEVICE_ID_JOYPAD_B) : 0;
         *state_cur |= (state_tmp.BTN_CIRCLE)   ? (1ULL << RETRO_DEVICE_ID_JOYPAD_A) : 0;
         *state_cur |= (state_tmp.BTN_R1)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R) : 0;
         *state_cur |= (state_tmp.BTN_L1)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L) : 0;
         *state_cur |= (state_tmp.BTN_R2)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
         *state_cur |= (state_tmp.BTN_L2)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
#else
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_LEFT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_DOWN) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_RIGHT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_UP) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_START) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_START) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_R3) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R3) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_L3) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L3) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_SELECT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_TRIANGLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_X) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_SQUARE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_Y) : 0;

         if (*lifecycle_state & (1ULL << MODE_MENU))
         {
            int value = 0;
            if (cellSysutilGetSystemParamInt(CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN, &value) == 0)
            {
               if (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CROSS)
                  *state_cur |=  (value == CELL_SYSUTIL_ENTER_BUTTON_ASSIGN_CROSS) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_A) : (1ULL << RETRO_DEVICE_ID_JOYPAD_B);
               if (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CIRCLE)
                  *state_cur |=  (value == CELL_SYSUTIL_ENTER_BUTTON_ASSIGN_CIRCLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_A) : (1ULL << RETRO_DEVICE_ID_JOYPAD_B);
            }
         }
         else
         {
            *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CROSS) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_B) : 0;
            *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CIRCLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_A) : 0;
         }
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_R1) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_L1) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_R2) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_L2) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_L2) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
         //RARCH_LOG("lsx : %d (%hd) lsy : %d (%hd) rsx : %d (%hd) rsy : %d (%hd)\n", lsx, ls_x, lsy, ls_y, rsx, rs_x, rsy, rs_y);
         uint8_t lsx = (uint8_t)(state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X]);
         uint8_t lsy = (uint8_t)(state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y]);
         uint8_t rsx = (uint8_t)(state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X]);
         uint8_t rsy = (uint8_t)(state_tmp.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y]);
#if 0
         if (!(lsx < DEADZONE_LOW || DEADZONE_HIGH < lsx))
            lsx = 128;
         if (!(lsy < DEADZONE_LOW || DEADZONE_HIGH < lsy))
            lsy = 128;
         if (!(rsx < DEADZONE_LOW || DEADZONE_HIGH < rsx))
            rsx = 128;
         if (!(rsy < DEADZONE_LOW || DEADZONE_HIGH < rsy))
            rsy = 128;
#endif
         ps3->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_LEFT ][RETRO_DEVICE_ID_ANALOG_X] = convert_u8_to_s16(lsx);
         ps3->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_LEFT ][RETRO_DEVICE_ID_ANALOG_Y] = convert_u8_to_s16(lsy);
         ps3->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_X] = convert_u8_to_s16(rsx);
         ps3->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_Y] = convert_u8_to_s16(rsy);

         ps3->accelerometer_state[port].x = state_tmp.button[CELL_PAD_BTN_OFFSET_SENSOR_X];
         ps3->accelerometer_state[port].y = state_tmp.button[CELL_PAD_BTN_OFFSET_SENSOR_Y];
         ps3->accelerometer_state[port].z = state_tmp.button[CELL_PAD_BTN_OFFSET_SENSOR_Z];
#endif
         if (g_settings.input.autodetect_enable)
         {
            if (strcmp(g_settings.input.device_names[port], "DualShock3/Sixaxis") != 0)
               ps3_input_set_keybinds(NULL, DEVICE_SIXAXIS, port, 0, (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
         }
      }

      for (int i = 0; i < 2; i++)
         for (int j = 0; j < 2; j++)
            if (ps3->analog_state[port][i][j] == -0x8000)
               ps3->analog_state[port][i][j] = -0x7fff;
   }

   uint64_t *state_p1 = &ps3->pad_state[0];

   *lifecycle_state &= ~((1ULL << RARCH_MENU_TOGGLE));

   if ((*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3)))
      *lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);

   cellPadGetInfo2(&pad_info);
   ps3->pads_connected = pad_info.now_connect; 

#ifdef HAVE_MOUSE
   CellMouseInfo mouse_info;
   cellMouseGetInfo(&mouse_info);
   ps3->mice_connected = mouse_info.now_connect;
#endif
}
Пример #15
0
static void						CalculateUnderscan				()
{
	/* Setup libpad for our needs */
	CellPadData data;
	uint32_t buttons = 0;

	/* Get the current button state */
	if(CELL_OK == cellPadGetData(0, &data) && data.len >= 8)
	{
		buttons = data.button[2] | (data.button[3] << 8);
	}

	/* If we didn't get anything from the rcfile, or the user is holding select */
	if(!GotUnderscanValues || buttons & 1)
	{
		UnderscanX = 0;
		UnderscanY = 0;

		/* Get the screen size */
		uint32_t width, height;
		psglGetDeviceDimensions(psglGetCurrentDevice(), &width, &height);

		/* Generate image */
		uint32_t* img = malloc((width / 10) * (height / 10) * 4);
		for(int i = 0; i != height / 10; i ++)
		{
			for(int j = 0; j != width / 10; j ++)
			{
				img[i * (width / 10) + j] = (i == 0 || j == 0 || i == (height / 10 - 1) || j == (width / 10 - 1)) ? 0xFF0000FF : 0xFF000000;
			}
		}

		CELL_IMAGE_Load(&overimage, 0, 0, width, height, img, width / 10, height / 10);

		free(img);

		CELL_IMAGE_Load(&helpimage, width / 2 - OVER_WIDTH / 2, height / 2 - OVER_HEIGHT / 2, OVER_WIDTH, OVER_HEIGHT, OverscanHelpImage, OVER_WIDTH, OVER_HEIGHT);

		/* Setup drawing */
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glOrthof(0, width, height, 0, -1, 1);

		/* Loop */
		while(1)
		{
			/* Draw screen */
			float widthP = ((float)width) * (((float)(UnderscanX)) / 100.0f);
			float heightP = ((float)height) * (((float)(UnderscanY)) / 100.0f);
			glViewport(widthP, heightP, width - widthP * 2, height - heightP * 2);
			glClear(GL_COLOR_BUFFER_BIT);
			CELL_IMAGE_Draw(&overimage);
			CELL_IMAGE_Draw(&helpimage);
			psglSwap();

			/* Update buttons */
			if(CELL_OK == cellPadGetData(0, &data) && data.len >= 8)
			{
				buttons = data.button[2] | (data.button[3] << 8);
			}

			/* Update state */
			if(buttons & 0x4000)		break;
			if(buttons & 0x10)			UnderscanY --;
			if(buttons & 0x40)			UnderscanY ++;
			if(buttons & 0x20)			UnderscanX --;
			if(buttons & 0x80)			UnderscanX ++;

			UnderscanX = (UnderscanX < -5) ? -5 : UnderscanX;
			UnderscanY = (UnderscanY < -5) ? -5 : UnderscanY;
			UnderscanX = (UnderscanX > 25) ? 25 : UnderscanX;
			UnderscanY = (UnderscanY > 25) ? 25 : UnderscanY;

			SDL_Delay(50);
		}

		/* Release the image */
//		CELL_IMAGE_Free(&overimage);
		CELL_IMAGE_Free(&helpimage);
	}

	CELL_PSGL_SetUnderscan(UnderscanX, UnderscanY);
}
Пример #16
0
//-----------------------------------------------------------------------------
// Purpose: Message pump for OS messages
//-----------------------------------------------------------------------------
void CGameEnginePS3::MessagePump()
{
	cellSysutilCheckCallback();

	// Running callbacks may have triggered shutdown, if not run input
	if ( !m_bShuttingDown )
	{
		CellPadInfo2 padInfo;
		int ret = cellPadGetInfo2( &padInfo );
		if ( ret == CELL_OK )
		{
			if ( padInfo.system_info & CELL_PAD_INFO_INTERCEPTED )
			{
				// System has taken control of controller info, we can't currently access it.
			}
			
			bool bControllerFound = false;
			m_iCurrentPadIndex = -1;
			for( int i=0; i < CELL_PAD_MAX_PORT_NUM; ++i )
			{
				if ( padInfo.port_status[i] & CELL_PAD_STATUS_ASSIGN_CHANGES )
				{
					if ( (padInfo.port_status[i] & CELL_PAD_STATUS_CONNECTED) == 0 )
					{
						char rgchBuffer[512];
						_snprintf( rgchBuffer, 512, "Gamepad %d removed\n", i );
						OutputDebugString( rgchBuffer );
					}
					else if ( (padInfo.port_status[i] & CELL_PAD_STATUS_CONNECTED) > 0 )
					{
						char rgchBuffer[512];
						_snprintf( rgchBuffer, 512, "Gamepad %d connected\n", i );
						OutputDebugString( rgchBuffer );
					}
				}

				if ( (padInfo.port_status[i] & CELL_PAD_STATUS_CONNECTED ) > 0 && padInfo.device_type[i] == CELL_PAD_DEV_TYPE_STANDARD )
				{
					bControllerFound = true;
					m_iCurrentPadIndex = i;
					break;
				}
			}

			if ( !bControllerFound )
			{
				// Definitely no appropriate controller plugged in, can't do input
				static DWORD dwLastSpewTime = 0;
				if ( GetGameTickCount() - dwLastSpewTime > 1000 || dwLastSpewTime == 0 || dwLastSpewTime > GetGameTickCount() )
				{
					dwLastSpewTime = GetGameTickCount();
					OutputDebugString( "No supported controllers are active, activate one.\n" );
				}

				// Clear all keys 
				m_SetKeysDown.clear();
			}
			else
			{
				// Get status of the first found controller now
				CellPadData padData;
				int ret = cellPadGetData( m_iCurrentPadIndex, &padData );

				// If we got data ok, and if the data is new (len != 0) then process it
				if ( ret == CELL_OK && padData.len )
				{
					if ( padData.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_R2 )
					{
						m_SetKeysDown.insert( 0x57 ); // W key, thrusters, mapped to R2 on PS3
					}
					else
					{
						m_SetKeysDown.erase( 0x57 );
					}

					if ( padData.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_L2 )
					{
						m_SetKeysDown.insert( 0x53 ); // S key, reverse thrusters, mapped to L2 on PS3
					}
					else
					{
						m_SetKeysDown.erase( 0x53 );
					}

					if ( padData.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CROSS )
					{
						// Mapped to both enter in menus, and fire in game
						m_SetKeysDown.insert( VK_RETURN );
						m_SetKeysDown.insert( VK_SPACE );
					}
					else
					{
						m_SetKeysDown.erase( VK_RETURN );
						m_SetKeysDown.erase( VK_SPACE );
					}

					if ( padData.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CIRCLE )
					{
						m_SetKeysDown.insert( VK_ESCAPE );
					}
					else
					{
						m_SetKeysDown.erase( VK_ESCAPE );
					}

					if ( padData.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_UP || padData.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y] == 0x00 )
					{
						m_SetKeysDown.insert( VK_UP );
					}
					else
					{
						m_SetKeysDown.erase( VK_UP );
					}

					if ( padData.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_DOWN || padData.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y] == 0xFF )
					{
						m_SetKeysDown.insert( VK_DOWN );
					}
					else
					{
						m_SetKeysDown.erase( VK_DOWN );
					}

					if ( padData.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_LEFT || padData.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X] == 0x00 )
					{
						m_SetKeysDown.insert( 0x41 ); // A Key, mapped to left on PS3
					}
					else
					{
						m_SetKeysDown.erase( 0x41 );
					}

					if ( padData.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_RIGHT || padData.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X] == 0xFF )
					{
						m_SetKeysDown.insert( 0x44 ); // D key, mapped to right on PS3
					}
					else
					{
						m_SetKeysDown.erase( 0x44 );
					}
				}
			}
		}
	}
}
Пример #17
0
static void ps3_input_poll(void *data)
{
   CellPadInfo2 pad_info;
   (void)data;

   for (unsigned i = 0; i < MAX_PADS; i++)
   {
      static CellPadData state_tmp;
      cellPadGetData(i, &state_tmp);

      if (state_tmp.len != 0)
      {
         uint64_t *state_cur = &state[i];
         *state_cur = 0;
#ifdef __PSL1GHT__
         *state_cur |= (state_tmp.BTN_LEFT)     ? (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
         *state_cur |= (state_tmp.BTN_DOWN)     ? (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
         *state_cur |= (state_tmp.BTN_RIGHT)    ? (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
         *state_cur |= (state_tmp.BTN_UP)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
         *state_cur |= (state_tmp.BTN_START)    ? (1ULL << RETRO_DEVICE_ID_JOYPAD_START) : 0;
         *state_cur |= (state_tmp.BTN_R3)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R3) : 0;
         *state_cur |= (state_tmp.BTN_L3)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L3) : 0;
         *state_cur |= (state_tmp.BTN_SELECT)   ? (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
         *state_cur |= (state_tmp.BTN_TRIANGLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_X) : 0;
         *state_cur |= (state_tmp.BTN_SQUARE)   ? (1ULL << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
         *state_cur |= (state_tmp.BTN_CROSS)    ? (1ULL << RETRO_DEVICE_ID_JOYPAD_B) : 0;
         *state_cur |= (state_tmp.BTN_CIRCLE)   ? (1ULL << RETRO_DEVICE_ID_JOYPAD_A) : 0;
         *state_cur |= (state_tmp.BTN_R1)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R) : 0;
         *state_cur |= (state_tmp.BTN_L1)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L) : 0;
         *state_cur |= (state_tmp.BTN_R2)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
         *state_cur |= (state_tmp.BTN_L2)       ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
#else
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_LEFT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_DOWN) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_RIGHT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_UP) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_START) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_START) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_R3) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R3) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_L3) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L3) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL1] & CELL_PAD_CTRL_SELECT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_TRIANGLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_X) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_SQUARE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CROSS) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_B) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_CIRCLE) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_A) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_R1) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_L1) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_R2) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
         *state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_L2) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
#endif
      }
   }

   uint64_t *state_p1 = &state[0];
   uint64_t *lifecycle_state = &g_extern.lifecycle_state;

   *lifecycle_state &= ~(
         (1ULL << RARCH_FAST_FORWARD_HOLD_KEY) | 
         (1ULL << RARCH_LOAD_STATE_KEY) | 
         (1ULL << RARCH_SAVE_STATE_KEY) | 
         (1ULL << RARCH_STATE_SLOT_PLUS) | 
         (1ULL << RARCH_STATE_SLOT_MINUS) | 
         (1ULL << RARCH_REWIND) |
         (1ULL << RARCH_QUIT_KEY) |
         (1ULL << RARCH_MENU_TOGGLE));

   if ((*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3)))
      *lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE);

   cellPadGetInfo2(&pad_info);
   pads_connected = pad_info.now_connect; 
#ifdef HAVE_MOUSE
   CellMouseInfo mouse_info;
   cellMouseGetInfo(&mouse_info);
   mice_connected = mouse_info.now_connect;
#endif
}