Changeset 2563


Ignore:
Timestamp:
Mar 7, 2013, 12:33:49 PM (7 years ago)
Author:
sam
Message:

ps3: check for newly plugged pads at each frame.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/platform/ps3/ps3input.cpp

    r2216 r2563  
    7777                                 CELL_PADFILTER_IIR_CUTOFF_2ND_LPF_BT_010);
    7878
    79     /* Try to detect connected pads. We should do this each frame. */
    80     CellPadInfo2 pad_info2;
    81     ret = cellPadGetInfo2(&pad_info2);
    82     if (ret == CELL_PAD_OK)
    83     {
    84         for (int i = 0; i < NUM_PADS; i++)
    85         {
    86             if (!(pad_info2.port_status[i] & CELL_PAD_STATUS_CONNECTED))
    87                 continue;
    88 
    89             Stick *stick = Input::CreateStick();
    90             stick->SetAxisCount(4);
    91             stick->SetButtonCount(16);
    92             m_data->m_joysticks.Push(i, stick);
    93         }
    94     }
    95 
    9679    m_data->mousepos = vec2(320.0f, 240.0f);
    9780    m_data->mousebuttons = ivec3(0, 0, 0);
     
    11194        return;
    11295
     96    /* Try to detect newly connected pads. */
     97    for (int i = 0; i < NUM_PADS; i++)
     98    {
     99        if (!(pad_info2.port_status[i] & CELL_PAD_STATUS_CONNECTED))
     100            continue;
     101
     102        bool new_stick = true;
     103        for (int j = 0; j < m_data->m_joysticks.Count(); ++j)
     104            if (m_data->m_joysticks[j].m1 == i)
     105                new_stick = false;
     106
     107        if (new_stick)
     108        {
     109            Stick *stick = Input::CreateStick();
     110            stick->SetAxisCount(4);
     111            stick->SetButtonCount(16);
     112            m_data->m_joysticks.Push(i, stick);
     113        }
     114    }
     115
     116    /* Update pad status */
    113117    for (int i = 0; i < m_data->m_joysticks.Count(); i++)
    114118    {
Note: See TracChangeset for help on using the changeset viewer.