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

Refactor class JoyButtonSlot #376

Open
pktiuk opened this issue Feb 12, 2022 · 1 comment
Open

Refactor class JoyButtonSlot #376

pktiuk opened this issue Feb 12, 2022 · 1 comment
Labels
good first issue Good for newcomers refactor Issues connected with cleaning-up repository

Comments

@pktiuk
Copy link
Member

pktiuk commented Feb 12, 2022

Class JoyButtonSlot should be divided into several smaller classes with common ancestor.

It would help to avoid mess in code.

New classes should describe actions and execution of them.
It would help avoiding things like:

void sendevent(JoyButtonSlot *slot, bool pressed)
{
    JoyButtonSlot::JoySlotInputAction device = slot->getSlotMode();

    if (device == JoyButtonSlot::JoyKeyboard)
    {
        EventHandlerFactory::getInstance()->handler()->sendKeyboardEvent(slot, pressed);
    } else if (device == JoyButtonSlot::JoyMouseButton)
    {
        EventHandlerFactory::getInstance()->handler()->sendMouseButtonEvent(slot, pressed);
    } else if ((device == JoyButtonSlot::JoyTextEntry) && pressed && !slot->getTextData().isEmpty())
    {
        EventHandlerFactory::getInstance()->handler()->sendTextEntryEvent(slot->getTextData());
    } else if ((device == JoyButtonSlot::JoyExecute) && pressed && !slot->getTextData().isEmpty())
    {
        ///....

Or

if ((tempcode == static_cast<int>(JoyButtonSlot::MouseWheelUp)) ||
            (tempcode == static_cast<int>(JoyButtonSlot::MouseWheelDown)))
        {
            slot->getMouseInterval()->restart();
            wheelVerticalTime.restart();
            currentWheelVerticalEvent = slot;
            getActiveSlotsLocal().append(slot);
            wheelEventVertical();
            currentWheelVerticalEvent = nullptr;
        } else if ((tempcode == static_cast<int>(JoyButtonSlot::MouseWheelLeft)) ||
                   (tempcode == static_cast<int>(JoyButtonSlot::MouseWheelRight)))
        {
            slot->getMouseInterval()->restart();
            wheelHorizontalTime.restart();

Upvote & Fund

  • If you find this issue important, mark it with 👍. It lets us see which fixes and features are demanded by the most users.
  • We're using Polar.sh so you can upvote and help fund this issue. It may incentivize some developers to contribute to this project and fix some bugs.
  • Funded developer receives the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@pktiuk pktiuk added the refactor Issues connected with cleaning-up repository label Feb 12, 2022
@pktiuk pktiuk added the good first issue Good for newcomers label May 5, 2022
@pktiuk
Copy link
Member Author

pktiuk commented May 8, 2022

@jprokopczuk
Gdybyś kiedyś się nudził to ten task byłby dobry do ogarnięcia.
Przypomniałbyś sobie trochę obiektówki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers refactor Issues connected with cleaning-up repository
Projects
None yet
Development

No branches or pull requests

1 participant