Changeset 839


Ignore:
Timestamp:
Aug 20, 2011, 1:35:15 AM (8 years ago)
Author:
sam
Message:

ps3: get rid of the useless and convoluted padutil dependency; the
standard pad API is perfect for us.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/monsterz/ps3/Makefile

    r838 r839  
    66SUBDIRS :=
    77
    8 GFX_COMMON = $(CELL_SDK)/samples/sdk/graphics/psgl/Common
    98LOL_SRC = ../../src
    109MONSTERZ_SRC = ..
    1110
    1211PPU_INCDIRS += -I$(LOL_SRC) -I$(MONSTERZ_SRC)
    13 PPU_CPPFLAGS += -DPSGL -DHAVE_GLES_2X
     12PPU_CPPFLAGS += -DHAVE_GLES_2X
    1413PPU_CXXSTDFLAGS += -fno-exceptions
    1514PPU_SRCS := \
    16     $(addprefix $(LOL_SRC)/, $(filter-out %.h sdl%, ps3app.cpp $(liblol_a_SOURCES))) \
     15    $(addprefix $(LOL_SRC)/, $(filter-out %.h sdl%, $(liblol_a_SOURCES))) \
    1716    $(addprefix $(MONSTERZ_SRC)/, $(filter %.cpp, $(monsterz_SOURCES)))
    18  
    19 PPU_TARGET := monsterz.elf
    20 PPU_LDLIBS := $(GRAPHICS_SAMPLE_CORE_LIBS)
     17
     18PPU_TARGET := monsterz.elf
     19PPU_LDLIBS := -lsysmodule_stub -lsysutil_stub -lresc_stub
     20
     21# For PSGL
     22PPU_LDLIBS += -lPSGL -lgcm_cmd -lgcm_sys_stub
    2123
    2224# For the runtime Cg compiler
     
    2628PPU_LDLIBS += -lpngdec_stub
    2729
    28 # For the PadUtil lib (to remove later)
    29 PPU_LDLIBS += -lpadfilter
    30 PPU_CPPFLAGS += -I$(CELL_SDK)/samples/common/padutil
    31 PPU_SRCS += $(CELL_SDK)/samples/common/padutil/padutil.cpp ../../src/ps3input.cpp
     30# For the pad library
     31PPU_LDLIBS += -lio_stub -lusbd_stub -lpadfilter
    3232
    3333include $(CELL_SDK)/samples/sdk/graphics/psgl/MakeRules
  • trunk/src/Makefile.am

    r838 r839  
    1717    eglapp.cpp eglapp.h \
    1818    \
    19     ps3app.cpp ps3app.h \
     19    ps3app.cpp ps3app.h ps3input.cpp ps3input.h \
    2020    \
    2121    shader/shader.cpp shader/shader.h \
  • trunk/src/ps3input.cpp

    r838 r839  
    1313#endif
    1414
     15#include <cstdlib>
     16
    1517#if defined __CELLOS_LV2__
    16 #   include <padutil.h>
     18#   include <cell/pad.h>
     19#   include <cell/padfilter.h>
     20#   include <sysutil/sysutil_sysparam.h>
    1721#endif
    1822
     
    2024#include "ps3input.h"
    2125
     26using namespace std;
     27
    2228namespace lol
    2329{
     30
     31static int const NUM_PADS = 7; /* CellPadUtil also has 7 */
    2432
    2533/*
     
    3341    vec2 mousepos;
    3442    vec3i mousebuttons;
     43
     44    CellPadFilterIIRSos filter_sos[NUM_PADS][4];
     45    bool circle_validates;
    3546};
    3647
     
    4354{
    4455#if defined __CELLOS_LV2__
    45     cellPadUtilPadInit();
    46     cellPadUtilSetSensorMode(true);
    47     cellPadUtilSetPressMode(true);
    48     cellPadUtilSetSensorFilter(CELL_PADFILTER_IIR_CUTOFF_2ND_LPF_BT_010);
     56    int32_t ret = cellPadInit(NUM_PADS);
     57    if (ret != CELL_OK && ret != CELL_PAD_ERROR_ALREADY_INITIALIZED)
     58    {
     59        Log::Error("could not initialise PS3 pad library\n");
     60        exit(1);
     61    }
     62
     63    int tmp;
     64    ret = cellSysutilGetSystemParamInt(
     65                        CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN, &tmp);
     66    data->circle_validates =
     67            (ret == CELL_OK && tmp == CELL_SYSUTIL_ENTER_BUTTON_ASSIGN_CIRCLE);
     68
     69    for (int i = 0; i < NUM_PADS; i++)
     70        for (int j = 0; j < 4; j++)
     71            cellPadFilterIIRInit(&data->filter_sos[i][j],
     72                                 CELL_PADFILTER_IIR_CUTOFF_2ND_LPF_BT_010);
    4973
    5074    data->mousepos = vec2(320.0f, 240.0f);
     
    6084
    6185#if defined __CELLOS_LV2__
    62     cellPadUtilUpdate();
     86    CellPadInfo2 pad_info2;
     87    int32_t ret = cellPadGetInfo2(&pad_info2);
     88    if (ret != CELL_PAD_OK)
     89        return;
    6390
    64     int pad = cellPadUtilGetFirstConnectedPad();
    65     if (pad >= 0)
     91    for (int i = 0; i < NUM_PADS; i++)
    6692    {
    67         CellPadUtilAxis axis = cellPadUtilGetAxisValue(pad, CELL_UTIL_ANALOG_RIGHT);
    68         vec2 delta(4e-3f * (abs(axis.x - 127) < 16 ? 0 : axis.x - 127),
    69                    -4e-3f * (abs(axis.y - 127) < 16 ? 0 : axis.y - 127));
    70         data->mousepos += delta * deltams;
    71         Input::SetMousePos((vec2i)data->mousepos);
     93        if (!(pad_info2.port_status[i] & CELL_PAD_STATUS_CONNECTED))
     94            continue;
    7295
    73         // L1 for mouse button
    74         uint32_t paddata = cellPadUtilGetDigitalData(pad);
    75         int but = cellPadUtilDigitalButtonPressed(paddata, CELL_UTIL_BUTTON_L1)
    76                || cellPadUtilDigitalButtonPressed(paddata, CELL_UTIL_BUTTON_R1);
    77        
     96        CellPadData pad_data;
     97        ret = cellPadGetData(i, &pad_data);
     98        if (ret != CELL_PAD_OK || pad_data.len == 0)
     99            continue;
     100
     101        /* L1 or R1 for mouse button */
     102        int but = (pad_data.button[CELL_PAD_BTN_OFFSET_DIGITAL2]
     103                                                          == CELL_PAD_CTRL_L1)
     104               || (pad_data.button[CELL_PAD_BTN_OFFSET_DIGITAL2]
     105                                                          == CELL_PAD_CTRL_R1);
    78106        if (but && !data->mousebuttons.x)
    79107            Input::SetMouseButton(0);
     
    82110
    83111        data->mousebuttons.x = but;
     112
     113        /* Right stick moves the mouse */
     114        if (!(pad_info2.system_info & CELL_PAD_INFO_INTERCEPTED))
     115        {
     116            int x = pad_data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X];
     117            int y = pad_data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X + 1];
     118            vec2 delta(4e-3f * (abs(x - 127) < 16 ? 0 : x - 127),
     119                       -4e-3f * (abs(y - 127) < 16 ? 0 : y - 127));
     120            data->mousepos += delta * deltams;
     121            Input::SetMousePos((vec2i)data->mousepos);
     122        }
     123
     124        /* Only handle the first pad we meet */
     125        break;
    84126    }
    85127#endif
Note: See TracChangeset for help on using the changeset viewer.