~aleteoryx/muditaos

226e9e4c0b29d3bb1f4a1a9dbad28dbbdf9b7ff2 — Marek Niepieklo 5 years ago 39be357
[EGD-6515] Answer/reject calls using headset

Clean up propagation of headset keys events
Clean up volume control with headset keys
Update key mappings for simulator
Use headset OK key to answer/reject calls
M doc/host_keyboard_bindings.md => doc/host_keyboard_bindings.md +10 -2
@@ 7,7 7,7 @@
- [Battery "buttons"](#battery-buttons)

### Functional buttons
- Volume up         - key [ `R` ] 
- Volume up         - key [ `R` ]
- Volume down 		- key [ `F` ]
- Functional left 	- key [ `Q` ]
- Functional right 	- key [ `E` ]


@@ 20,6 20,9 @@
- Slider mid		- key [ `B` ]
- Slider down 		- key [ `N` ]
- Torch button 		- key [ `T` ]
- Headset OK        - key [ `U` ]
- Headset Vol +     - key [ `J` ]
- Headset Vol -     - key [ `M` ]

### Numeric buttons
- Numeric 0		- key [ `0` ]


@@ 38,4 41,9 @@
### Battery buttons
 - Connect/disconnect wall adapter		- key [ `P` ]
 - Decrease battery level		- key [ `[` ]
 - Increase battery level		- key [ `]` ]
\ No newline at end of file
 - Increase battery level		- key [ `]` ]

### Charger type selection
 - Standard Downstream Port (SDP) - key [ `L` ]
 - Charging Downstream Port (CDP) - key [ `;` ]
 - Dedicated Charging Port  (DCP) - key [ `'` ]

M module-apps/application-call/windows/CallWindow.cpp => module-apps/application-call/windows/CallWindow.cpp +22 -0
@@ 338,6 338,25 @@ namespace gui
        return false;
    }

    bool CallWindow::handleHeadsetOkButton()
    {
        switch (getState()) {
        case State::INCOMING_CALL:
            interface->answerIncomingCall();
            return true;
        case State::OUTGOING_CALL:
            [[fallthrough]];
        case State::CALL_IN_PROGRESS:
            interface->hangupCall();
            return true;
        case State::IDLE:
        case State::CALL_ENDED:
            break;
        }

        return false;
    }

    bool CallWindow::handleDigit(const uint32_t digit)
    {
        interface->transmitDtmfTone(digit);


@@ 364,6 383,9 @@ namespace gui
            case KeyCode::KEY_RF:
                handled = handleRightButton();
                break;
            case KeyCode::HEADSET_OK:
                handled = handleHeadsetOkButton();
                break;
            default:
                break;
            }

M module-apps/application-call/windows/CallWindow.hpp => module-apps/application-call/windows/CallWindow.hpp +1 -0
@@ 45,6 45,7 @@ namespace gui

        bool handleLeftButton();
        bool handleRightButton();
        bool handleHeadsetOkButton();
        void setState(app::call::State state);
        [[nodiscard]] auto getState() const noexcept -> app::call::State;


M module-apps/windows/AppWindow.cpp => module-apps/windows/AppWindow.cpp +4 -0
@@ 156,9 156,13 @@ namespace gui

        if ((inputEvent.isShortPress())) {
            switch (inputEvent.keyCode) {
            case KeyCode::HEADSET_VOLUP:
                [[fallthrough]];
            case KeyCode::KEY_VOLUP: {
                return application->increaseCurrentVolume();
            }
            case KeyCode::HEADSET_VOLDN:
                [[fallthrough]];
            case KeyCode::KEY_VOLDN: {
                return application->decreaseCurrentVolume();
            }

M module-bsp/bsp/keyboard/key_codes.hpp => module-bsp/bsp/keyboard/key_codes.hpp +11 -1
@@ 33,7 33,11 @@ namespace bsp {

        SSwitchUp = 34,
        SSwitchDown = 54,
        SSwitchMid = 44
        SSwitchMid = 44,

        HeadsetOk      = 71,
        HeadsetVolUp   = 72,
        HeadsetVolDown = 73
    };
}



@@ 92,6 96,12 @@ inline const char *c_str(bsp::KeyCodes code)
        return "SSwitchDown";
    case bsp::KeyCodes::SSwitchMid:
        return "SSwitchMid";
    case bsp::KeyCodes::HeadsetOk:
        return "HeadsetOk";
    case bsp::KeyCodes::HeadsetVolUp:
        return "HeadsetVolUp";
    case bsp::KeyCodes::HeadsetVolDown:
        return "HeadsetVolDown";
    }
    return "";
}

M module-gui/gui/input/InputEvent.hpp => module-gui/gui/input/InputEvent.hpp +11 -1
@@ 1,4 1,4 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once


@@ 41,6 41,10 @@ namespace gui
        SWITCH_UP  = static_cast<int>(bsp::KeyCodes::SSwitchUp),
        SWITCH_MID = static_cast<int>(bsp::KeyCodes::SSwitchMid),
        SWITCH_DN  = static_cast<int>(bsp::KeyCodes::SSwitchDown),

        HEADSET_OK    = static_cast<int>(bsp::KeyCodes::HeadsetOk),
        HEADSET_VOLUP = static_cast<int>(bsp::KeyCodes::HeadsetVolUp),
        HEADSET_VOLDN = static_cast<int>(bsp::KeyCodes::HeadsetVolDown),
    };

    static const int InvalidNumericKeyCode = -1;


@@ 181,6 185,12 @@ namespace gui
        return "SWITCH_MID";
    case gui::KeyCode::SWITCH_DN:
        return "SWITCH_DN";
    case gui::KeyCode::HEADSET_OK:
        return "HEADSET_OK";
    case gui::KeyCode::HEADSET_VOLUP:
        return "HEADSET_VOLUP";
    case gui::KeyCode::HEADSET_VOLDN:
        return "HEADSET_VOLDN";
    }
    return "";
}

M module-gui/gui/input/Translator.cpp => module-gui/gui/input/Translator.cpp +10 -1
@@ 1,4 1,4 @@
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "Translator.hpp"


@@ 137,6 137,15 @@ namespace gui
        case bsp::KeyCodes::SSwitchMid:
            return gui::KeyCode::SWITCH_MID;
            break;
        case bsp::KeyCodes::HeadsetOk:
            return gui::KeyCode::HEADSET_OK;

        case bsp::KeyCodes::HeadsetVolUp:
            return gui::KeyCode::HEADSET_VOLUP;

        case bsp::KeyCodes::HeadsetVolDown:
            return gui::KeyCode::HEADSET_VOLDN;

        default:
            LOG_ERROR("Unhandled bsp key!");
            return gui::KeyCode::KEY_UNDEFINED;

M module-services/service-eink/board/linux/renderer/src/RWindow.cpp => module-services/service-eink/board/linux/renderer/src/RWindow.cpp +4 -0
@@ 58,6 58,10 @@ void RWindow::keyMapInit(void)
    keyMap.insert(std::pair<int8_t, uint32_t>('b', static_cast<uint32_t>(bsp::KeyCodes::SSwitchMid)));
    keyMap.insert(std::pair<int8_t, uint32_t>('n', static_cast<uint32_t>(bsp::KeyCodes::SSwitchUp)));

    keyMap.insert(std::pair<int8_t, uint32_t>('u', static_cast<uint32_t>(bsp::KeyCodes::HeadsetOk)));
    keyMap.insert(std::pair<int8_t, uint32_t>('j', static_cast<uint32_t>(bsp::KeyCodes::HeadsetVolUp)));
    keyMap.insert(std::pair<int8_t, uint32_t>('m', static_cast<uint32_t>(bsp::KeyCodes::HeadsetVolDown)));

    batteryKeyMap.insert(std::pair<int8_t, uint32_t>('[', 1));
    batteryKeyMap.insert(std::pair<int8_t, uint32_t>(']', 2));
    batteryKeyMap.insert(std::pair<int8_t, uint32_t>('p', 3));

M module-services/service-evtmgr/WorkerEvent.cpp => module-services/service-evtmgr/WorkerEvent.cpp +3 -6
@@ 335,16 335,13 @@ bsp::KeyCodes WorkerEvent::headsetKeyToKeyboardKey(uint8_t headsetKeyCode)
{
    switch (headsetKeyCode) {
    case static_cast<uint8_t>(bsp::headset::KeyCode::Key1):
        return bsp::KeyCodes::JoystickEnter;

    case static_cast<uint8_t>(bsp::headset::KeyCode::Key2):
        return bsp::KeyCodes::Undefined;
        return bsp::KeyCodes::HeadsetOk;

    case static_cast<uint8_t>(bsp::headset::KeyCode::Key3):
        return bsp::KeyCodes::VolUp;
        return bsp::KeyCodes::HeadsetVolUp;

    case static_cast<uint8_t>(bsp::headset::KeyCode::Key4):
        return bsp::KeyCodes::VolDown;
        return bsp::KeyCodes::HeadsetVolDown;
    }
    return bsp::KeyCodes::Undefined;
}