Browse Source

ps3: check for newly plugged pads at each frame.

legacy
Sam Hocevar sam 11 years ago
parent
commit
1dee9a6633
1 changed files with 21 additions and 17 deletions
  1. +21
    -17
      src/platform/ps3/ps3input.cpp

+ 21
- 17
src/platform/ps3/ps3input.cpp View File

@@ -76,23 +76,6 @@ Ps3Input::Ps3Input()
cellPadFilterIIRInit(&m_data->filter_sos[i][j], cellPadFilterIIRInit(&m_data->filter_sos[i][j],
CELL_PADFILTER_IIR_CUTOFF_2ND_LPF_BT_010); CELL_PADFILTER_IIR_CUTOFF_2ND_LPF_BT_010);


/* Try to detect connected pads. We should do this each frame. */
CellPadInfo2 pad_info2;
ret = cellPadGetInfo2(&pad_info2);
if (ret == CELL_PAD_OK)
{
for (int i = 0; i < NUM_PADS; i++)
{
if (!(pad_info2.port_status[i] & CELL_PAD_STATUS_CONNECTED))
continue;

Stick *stick = Input::CreateStick();
stick->SetAxisCount(4);
stick->SetButtonCount(16);
m_data->m_joysticks.Push(i, stick);
}
}

m_data->mousepos = vec2(320.0f, 240.0f); m_data->mousepos = vec2(320.0f, 240.0f);
m_data->mousebuttons = ivec3(0, 0, 0); m_data->mousebuttons = ivec3(0, 0, 0);


@@ -110,6 +93,27 @@ void Ps3Input::TickGame(float seconds)
if (ret != CELL_PAD_OK) if (ret != CELL_PAD_OK)
return; return;


/* Try to detect newly connected pads. */
for (int i = 0; i < NUM_PADS; i++)
{
if (!(pad_info2.port_status[i] & CELL_PAD_STATUS_CONNECTED))
continue;

bool new_stick = true;
for (int j = 0; j < m_data->m_joysticks.Count(); ++j)
if (m_data->m_joysticks[j].m1 == i)
new_stick = false;

if (new_stick)
{
Stick *stick = Input::CreateStick();
stick->SetAxisCount(4);
stick->SetButtonCount(16);
m_data->m_joysticks.Push(i, stick);
}
}

/* Update pad status */
for (int i = 0; i < m_data->m_joysticks.Count(); i++) for (int i = 0; i < m_data->m_joysticks.Count(); i++)
{ {
int j = m_data->m_joysticks[i].m1; int j = m_data->m_joysticks[i].m1;


Loading…
Cancel
Save