summaryrefslogtreecommitdiffstats
path: root/src/core/frontend/applets/software_keyboard.h
blob: f9b202664255044a76339429b0c5fe8c1ceeeac7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2018 yuzu emulator team
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#pragma once

#include <functional>
#include <optional>
#include <string>
#include "common/bit_field.h"
#include "common/common_types.h"

namespace Core::Frontend {
struct SoftwareKeyboardParameters {
    std::u16string submit_text;
    std::u16string header_text;
    std::u16string sub_text;
    std::u16string guide_text;
    std::u16string initial_text;
    std::size_t max_length;
    bool password;
    bool cursor_at_beginning;

    union {
        u8 value;

        BitField<1, 1, u8> disable_space;
        BitField<2, 1, u8> disable_address;
        BitField<3, 1, u8> disable_percent;
        BitField<4, 1, u8> disable_slash;
        BitField<6, 1, u8> disable_number;
        BitField<7, 1, u8> disable_download_code;
    };
};

class SoftwareKeyboardApplet {
public:
    virtual ~SoftwareKeyboardApplet();

    virtual void RequestText(std::function<void(std::optional<std::u16string>)> out,
                             SoftwareKeyboardParameters parameters) const = 0;
    virtual void SendTextCheckDialog(std::u16string error_message,
                                     std::function<void()> finished_check) const = 0;
};

class DefaultSoftwareKeyboardApplet final : public SoftwareKeyboardApplet {
public:
    void RequestText(std::function<void(std::optional<std::u16string>)> out,
                     SoftwareKeyboardParameters parameters) const override;
    void SendTextCheckDialog(std::u16string error_message,
                             std::function<void()> finished_check) const override;
};

} // namespace Core::Frontend