From e1f496d0251afee5b7802885bffaa91f7d28e1bc Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 23 Aug 2011 12:14:16 +0000 Subject: [PATCH] ps3: fix the pad handling code that was ignoring the pad information when its state hadn't changed. --- src/ps3input.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/ps3input.cpp b/src/ps3input.cpp index 7b3cc122..761a6d69 100644 --- a/src/ps3input.cpp +++ b/src/ps3input.cpp @@ -42,6 +42,7 @@ class Ps3InputData vec2 mousepos; vec3i mousebuttons; + CellPadData pad_data[NUM_PADS]; CellPadFilterIIRSos filter_sos[NUM_PADS][4]; bool circle_validates; #endif @@ -95,34 +96,35 @@ void Ps3Input::TickGame(float deltams) if (!(pad_info2.port_status[i] & CELL_PAD_STATUS_CONNECTED)) continue; - CellPadData pad_data; - ret = cellPadGetData(i, &pad_data); - if (ret != CELL_PAD_OK || pad_data.len == 0) + /* Get Pad status. If the data hasn't changed since the last call, + * data->pad[i].len will be 0 but we carry on anyway. */ + ret = cellPadGetData(i, &data->pad_data[i]); + if (ret != CELL_PAD_OK) continue; - /* L1 or R1 for mouse button */ - int but = (pad_data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] - == CELL_PAD_CTRL_L1) - || (pad_data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] - == CELL_PAD_CTRL_R1); - if (but && !data->mousebuttons.x) - Input::SetMouseButton(0); - else if (!but && data->mousebuttons.x) - Input::UnsetMouseButton(0); - - data->mousebuttons.x = but; - /* Right stick moves the mouse */ if (!(pad_info2.system_info & CELL_PAD_INFO_INTERCEPTED)) { - int x = pad_data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X]; - int y = pad_data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X + 1]; + int x = data->pad_data[i].button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X]; + int y = data->pad_data[i].button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X + 1]; vec2 delta(4e-3f * (abs(x - 127) < 16 ? 0 : x - 127), -4e-3f * (abs(y - 127) < 16 ? 0 : y - 127)); data->mousepos += delta * deltams; Input::SetMousePos((vec2i)data->mousepos); } + /* L1 or R1 for mouse button */ + int but = (data->pad_data[i].button[CELL_PAD_BTN_OFFSET_DIGITAL2] + & CELL_PAD_CTRL_L1) + || (data->pad_data[i].button[CELL_PAD_BTN_OFFSET_DIGITAL2] + & CELL_PAD_CTRL_R1); + if (but && !data->mousebuttons.x) + Input::SetMouseButton(0); + else if (!but && data->mousebuttons.x) + Input::UnsetMouseButton(0); + + data->mousebuttons.x = but; + /* Only handle the first pad we meet */ break; }