Changeset 853


Ignore:
Timestamp:
Aug 23, 2011, 2:14:16 PM (8 years ago)
Author:
sam
Message:

ps3: fix the pad handling code that was ignoring the pad information when
its state hadn't changed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ps3input.cpp

    r845 r853  
    4343    vec3i mousebuttons;
    4444
     45    CellPadData pad_data[NUM_PADS];
    4546    CellPadFilterIIRSos filter_sos[NUM_PADS][4];
    4647    bool circle_validates;
     
    9697            continue;
    9798
    98         CellPadData pad_data;
    99         ret = cellPadGetData(i, &pad_data);
    100         if (ret != CELL_PAD_OK || pad_data.len == 0)
     99        /* Get Pad status. If the data hasn't changed since the last call,
     100         * data->pad[i].len will be 0 but we carry on anyway. */
     101        ret = cellPadGetData(i, &data->pad_data[i]);
     102        if (ret != CELL_PAD_OK)
    101103            continue;
    102104
     105        /* Right stick moves the mouse */
     106        if (!(pad_info2.system_info & CELL_PAD_INFO_INTERCEPTED))
     107        {
     108            int x = data->pad_data[i].button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X];
     109            int y = data->pad_data[i].button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X + 1];
     110            vec2 delta(4e-3f * (abs(x - 127) < 16 ? 0 : x - 127),
     111                       -4e-3f * (abs(y - 127) < 16 ? 0 : y - 127));
     112            data->mousepos += delta * deltams;
     113            Input::SetMousePos((vec2i)data->mousepos);
     114        }
     115
    103116        /* L1 or R1 for mouse button */
    104         int but = (pad_data.button[CELL_PAD_BTN_OFFSET_DIGITAL2]
    105                                                           == CELL_PAD_CTRL_L1)
    106                || (pad_data.button[CELL_PAD_BTN_OFFSET_DIGITAL2]
    107                                                           == CELL_PAD_CTRL_R1);
     117        int but = (data->pad_data[i].button[CELL_PAD_BTN_OFFSET_DIGITAL2]
     118                                                          & CELL_PAD_CTRL_L1)
     119               || (data->pad_data[i].button[CELL_PAD_BTN_OFFSET_DIGITAL2]
     120                                                          & CELL_PAD_CTRL_R1);
    108121        if (but && !data->mousebuttons.x)
    109122            Input::SetMouseButton(0);
     
    112125
    113126        data->mousebuttons.x = but;
    114 
    115         /* Right stick moves the mouse */
    116         if (!(pad_info2.system_info & CELL_PAD_INFO_INTERCEPTED))
    117         {
    118             int x = pad_data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X];
    119             int y = pad_data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X + 1];
    120             vec2 delta(4e-3f * (abs(x - 127) < 16 ? 0 : x - 127),
    121                        -4e-3f * (abs(y - 127) < 16 ? 0 : y - 127));
    122             data->mousepos += delta * deltams;
    123             Input::SetMousePos((vec2i)data->mousepos);
    124         }
    125127
    126128        /* Only handle the first pad we meet */
Note: See TracChangeset for help on using the changeset viewer.