Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

controller: Add seadController, Base and Mgr #89

Merged
merged 2 commits into from
Dec 10, 2021

Conversation

MonsterDruide1
Copy link
Contributor

@MonsterDruide1 MonsterDruide1 commented Dec 9, 2021

This PR adds some part of the input-related stuff into the decomp. These are the "frontend-classes", so the ones that games will most likely interact with. SMO uses another bunch of utility functions to read specific bits from the seadControllerBase->mButtonTrigger/... fields, so probably there is a similar system in place for other games too.


This change is Reviewable

Copy link
Contributor

@leoetlino leoetlino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1, 3 of 3 files at r2, all commit messages.
Reviewable status: all files reviewed, 13 unresolved discussions (waiting on @MonsterDruide1)


include/controller/seadController.h, line 21 at r2 (raw file):

class Controller : public ControllerBase
{
    SEAD_RTTI_BASE(Controller)

Shouldn't this be OVERRIDE?


include/controller/seadController.h, line 27 at r2 (raw file):

    virtual void calc();
    virtual bool isConnected();
    virtual void calcImpl_() = 0;

These 3 functions should probably be marked protected. (The _ suffix usually indicates protected/private members.)


include/controller/seadControllerBase.h, line 18 at r2 (raw file):

    void updateDerivativeParams_(u32, bool);
    void setRightStickCrossThreshold(float, float);
    void setPointerWithBound_(bool, bool, const sead::Vector2f&);

No need to qualify Vector2f — you're already in the sead namespace. Also you can give a name to the vector; it's obvious it should be called bound.


include/controller/seadControllerBase.h, line 24 at r2 (raw file):

    void setIdleBase_();
    bool isIdleBase_();
    u32 getStickHold_(u32, const sead::Vector2f&, float, float, int); //unknown return type

This kind of comment should go above the line it is commenting because the line is already a bit long and clang-format tries to align trailing comments.


include/controller/seadControllerBase.h, line 33 at r2 (raw file):

    unsigned int mButtonsRepeat;
    unsigned int mFlags;
    int field_18;

_18


include/controller/seadControllerBase.h, line 34 at r2 (raw file):

    unsigned int mFlags;
    int field_18;
    int field_1C;

_1c (notice: lowercase c — this is important for consistency reasons and to avoid accidentally using reserved names)


include/controller/seadControllerBase.h, line 37 at r2 (raw file):

    sead::BoundBox2<float> mPointerBound;
    int mPadHoldCounts[32];
    char field_B0[32];

_b0


include/controller/seadControllerBase.h, line 38 at r2 (raw file):

    int mPadHoldCounts[32];
    char field_B0[32];
    unsigned char field_D0[32];

_d0 (also just make this a char array if this is just padding/filler)


include/controller/seadControllerBase.h, line 43 at r2 (raw file):

    float mLeftStickThresholdY;
    float mRightStickThresholdY;
    int field_100;

_100 and so on below


include/controller/seadControllerBase.h, line 49 at r2 (raw file):

    unsigned int mIdleCounter;
    unsigned int mButtonsHold;
    sead::Vector2<float> mTouchScreenPos;

no need to qualify


include/controller/seadControllerMgr.h, line 19 at r2 (raw file):

    SEAD_TASK_SINGLETON(ControllerMgr)
public:
    ControllerMgr(const TaskConstructArg&);

explicit. also please name the parameters wherever the name is obvious


include/controller/seadControllerMgr.h, line 27 at r2 (raw file):

    int findControllerPort(const Controller*);
    NinJoyNpadDevice* getControlDevice(ControllerDefine::DeviceId);
    void* getControllerAddon(int, ControllerDefine::AddonId);              // unknown return type

comment position


include/controller/seadControllerMgr.h, line 43 at r2 (raw file):

};

}  // namespace sead

This is missing a trailing newline.

@leoetlino
Copy link
Contributor

Also please (re?)run clang-format.

Copy link
Contributor Author

@MonsterDruide1 MonsterDruide1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 4 files reviewed, 13 unresolved discussions (waiting on @leoetlino)


include/controller/seadController.h, line 21 at r2 (raw file):

Previously, leoetlino (Léo Lam) wrote…

Shouldn't this be OVERRIDE?

Done.


include/controller/seadController.h, line 27 at r2 (raw file):

Previously, leoetlino (Léo Lam) wrote…

These 3 functions should probably be marked protected. (The _ suffix usually indicates protected/private members.)

Done.


include/controller/seadControllerBase.h, line 18 at r2 (raw file):

Previously, leoetlino (Léo Lam) wrote…

No need to qualify Vector2f — you're already in the sead namespace. Also you can give a name to the vector; it's obvious it should be called bound.

Done.


include/controller/seadControllerBase.h, line 24 at r2 (raw file):

Previously, leoetlino (Léo Lam) wrote…

This kind of comment should go above the line it is commenting because the line is already a bit long and clang-format tries to align trailing comments.

Done.


include/controller/seadControllerBase.h, line 33 at r2 (raw file):

Previously, leoetlino (Léo Lam) wrote…

_18

Done.


include/controller/seadControllerBase.h, line 34 at r2 (raw file):

Previously, leoetlino (Léo Lam) wrote…

_1c (notice: lowercase c — this is important for consistency reasons and to avoid accidentally using reserved names)

Done.


include/controller/seadControllerBase.h, line 37 at r2 (raw file):

Previously, leoetlino (Léo Lam) wrote…

_b0

Done.


include/controller/seadControllerBase.h, line 38 at r2 (raw file):

Previously, leoetlino (Léo Lam) wrote…

_d0 (also just make this a char array if this is just padding/filler)

Done.


include/controller/seadControllerBase.h, line 43 at r2 (raw file):

Previously, leoetlino (Léo Lam) wrote…

_100 and so on below

Done.


include/controller/seadControllerBase.h, line 49 at r2 (raw file):

Previously, leoetlino (Léo Lam) wrote…

no need to qualify

Done.


include/controller/seadControllerMgr.h, line 19 at r2 (raw file):

Previously, leoetlino (Léo Lam) wrote…

explicit. also please name the parameters wherever the name is obvious

Done.


include/controller/seadControllerMgr.h, line 27 at r2 (raw file):

Previously, leoetlino (Léo Lam) wrote…

comment position

Done.


include/controller/seadControllerMgr.h, line 43 at r2 (raw file):

Previously, leoetlino (Léo Lam) wrote…

This is missing a trailing newline.

Done.

Copy link
Contributor

@leoetlino leoetlino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: all files reviewed, 12 unresolved discussions (waiting on @MonsterDruide1)


include/controller/seadControllerBase.h, line 17 at r3 (raw file):

    void setRightStickCrossThreshold(float, float);
    void setPointerBound(const BoundBox2<float>&);

BoundBox2f (also this is still missing the parameter name)


include/controller/seadControllerBase.h, line 21 at r3 (raw file):

    void setLeftStickCrossThreshold(float, float);
    // unknown return type
    u32 getPadHoldCount(int);

should be const


include/controller/seadControllerBase.h, line 23 at r3 (raw file):

    u32 getPadHoldCount(int);

    int getButtonsTrigger() { return mButtonsTrigger; }

const (ditto below)


include/controller/seadControllerBase.h, line 27 at r3 (raw file):

    int getButtonsRepeat() { return mButtonsRepeat; }
    int getButtonsHold() { return mButtonsHold; }
    Vector2<float>* getTouchScreenPos() { return &mTouchScreenPos; }

Vector2f -- also I'd expect this to return a const-ref and be const-qualified. Same remarks below.


include/controller/seadControllerBase.h, line 48 at r3 (raw file):

    int _18;
    int _1c;
    BoundBox2<float> mPointerBound;

BoundBox2f


include/controller/seadControllerBase.h, line 62 at r3 (raw file):

    unsigned int mIdleCounter;
    unsigned int mButtonsHold;
    Vector2<float> mTouchScreenPos;

Vector2f


include/controller/seadControllerMgr.h, line 26 at r3 (raw file):

    void finalizeDefault();
    int findControllerPort(const Controller* controller);
    NinJoyNpadDevice* getControlDevice(ControllerDefine::DeviceId deviceId);

device_id


include/controller/seadControllerMgr.h, line 28 at r3 (raw file):

    NinJoyNpadDevice* getControlDevice(ControllerDefine::DeviceId deviceId);
    // unknown return type
    void* getControllerAddon(int, ControllerDefine::AddonId addonId);

addon_id


include/controller/seadControllerMgr.h, line 30 at r3 (raw file):

    void* getControllerAddon(int, ControllerDefine::AddonId addonId);
    // unknown return type
    void* getControllerAddonByOrder(int, ControllerDefine::AddonId addonId, int);

addon_id


include/controller/seadControllerMgr.h, line 31 at r3 (raw file):

    // unknown return type
    void* getControllerAddonByOrder(int, ControllerDefine::AddonId addonId, int);
    Controller* getControllerByOrder(ControllerDefine::ControllerId controllerId, int);

controller_id


include/controller/seadControllerMgr.h, line 34 at r3 (raw file):

    // unknown return type, probably inherited from TaskBase
    void* getFramework();
    void initialize(int, Heap*);

parameter name for heap


include/controller/seadControllerMgr.h, line 35 at r3 (raw file):

    void* getFramework();
    void initialize(int, Heap*);
    void initializeDefault(Heap*);

parameter name for heap

Copy link
Contributor Author

@MonsterDruide1 MonsterDruide1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 12 unresolved discussions (waiting on @leoetlino)


include/controller/seadControllerBase.h, line 17 at r3 (raw file):

Previously, leoetlino (Léo Lam) wrote…

BoundBox2f (also this is still missing the parameter name)

Done.


include/controller/seadControllerBase.h, line 21 at r3 (raw file):

Previously, leoetlino (Léo Lam) wrote…

should be const

Done.


include/controller/seadControllerBase.h, line 23 at r3 (raw file):

Previously, leoetlino (Léo Lam) wrote…

const (ditto below)

Done.


include/controller/seadControllerBase.h, line 27 at r3 (raw file):

Previously, leoetlino (Léo Lam) wrote…

Vector2f -- also I'd expect this to return a const-ref and be const-qualified. Same remarks below.

Done.


include/controller/seadControllerBase.h, line 48 at r3 (raw file):

Previously, leoetlino (Léo Lam) wrote…

BoundBox2f

Done.


include/controller/seadControllerBase.h, line 62 at r3 (raw file):

Previously, leoetlino (Léo Lam) wrote…

Vector2f

Done.


include/controller/seadControllerMgr.h, line 26 at r3 (raw file):

Previously, leoetlino (Léo Lam) wrote…

device_id

Done.


include/controller/seadControllerMgr.h, line 28 at r3 (raw file):

Previously, leoetlino (Léo Lam) wrote…

addon_id

Done.


include/controller/seadControllerMgr.h, line 30 at r3 (raw file):

Previously, leoetlino (Léo Lam) wrote…

addon_id

Done.


include/controller/seadControllerMgr.h, line 31 at r3 (raw file):

Previously, leoetlino (Léo Lam) wrote…

controller_id

Done.


include/controller/seadControllerMgr.h, line 34 at r3 (raw file):

Previously, leoetlino (Léo Lam) wrote…

parameter name for heap

Done.


include/controller/seadControllerMgr.h, line 35 at r3 (raw file):

Previously, leoetlino (Léo Lam) wrote…

parameter name for heap

Done.

Copy link
Contributor

@leoetlino leoetlino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 2 files at r4.
Reviewable status: 3 of 4 files reviewed, 1 unresolved discussion (waiting on @leoetlino and @MonsterDruide1)


include/controller/seadControllerBase.h, line 27 at r3 (raw file):

Previously, MonsterDruide1 wrote…

Done.

Why does this return a pointer instead of a reference?

@leoetlino
Copy link
Contributor

#54, #55, #56

Copy link
Contributor Author

@MonsterDruide1 MonsterDruide1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 2 of 4 files reviewed, 1 unresolved discussion (waiting on @leoetlino)


include/controller/seadControllerBase.h, line 27 at r3 (raw file):

Previously, leoetlino (Léo Lam) wrote…

Why does this return a pointer instead of a reference?

Good question... fixed, changed to a reference.

Copy link
Contributor

@leoetlino leoetlino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 2 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @MonsterDruide1)

@leoetlino leoetlino merged commit 9231381 into open-ead:master Dec 10, 2021
@MonsterDruide1 MonsterDruide1 deleted the controller branch December 10, 2021 12:17
leoetlino added a commit to leoetlino/sead that referenced this pull request Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants