Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
446 andreas 1
/*
2
 * Copyright (C) 2023 by Andreas Theofilu <andreas@theosys.at>
3
 *
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software Foundation,
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
18
 
19
#ifndef __TSYSTEMBUTTON_H__
20
#define __TSYSTEMBUTTON_H__
21
 
22
#include <string>
23
#include <vector>
24
#include "tbutton.h"
25
 
26
#define BANK_1      1       // Keyboard keys bank1: lower case letters
27
#define BANK_2      2       // Keyboard keys bank2: upper case letters (shift pressed)
28
#define BANK_3      3       // Keyboard keys bank3: Special characters (AltGr pressed)
29
 
30
class TSystemButton
31
{
32
    public:
33
        typedef enum SYS_BUUTON_TYPE
34
        {
35
            KEY_UNDEFINED,
36
            KEY_KEY,            // A keyboard button e.g. printable symbol
37
            KEY_INPUT_SINGLE,   // Single input line
38
            KEY_INPUT_MULTI,    // Multi line input object
39
            KEY_BUTTON          // A normal system button (increase/decrease volume, ...)
40
        }SYS_BUTTON_TYPE;
41
 
42
        typedef struct SYS_BUTTONS
43
        {
44
            int channel{0};         // The channel number (cp)
45
            int port{0};            // The port number (ad)
46
            SYS_BUTTON_TYPE type;   // The type of the button
47
        }SYS_BUTTONS;
48
 
49
        TSystemButton();
50
        ~TSystemButton();
51
 
52
        void addSysButton(Button::TButton *bt);
53
        Button::TButton *getSysButton(int channel, int port);
54
        void dropButton(Button::TButton *bt);
55
        void setBank(int bank);     // The bank (instance) of keyboard buttons
56
        int getActualBank() { return mBank; }
57
        void setCursorPosition(ulong handle, int oldPos, int newPos);
58
        int getCursorPosition() { return mCursorPosition; }
59
        void setInputFocus(ulong handle, bool in);
60
 
61
    protected:
62
        SYS_BUTTON_TYPE getSystemButtonType(int channel, int port);
63
        Button::TButton *getSystemInputLine();
64
        Button::TButton *getSystemKey(int channel, uint handle=0);
65
        void buttonPress(int channel, uint handle, bool pressed);      // Callback for buttons
66
 
67
    private:
68
        void setKeysToBank(int bank, uint handle);   // The handle is the key who should be highlighted
69
        void handleDedicatedKeys(int channel, bool pressed);
70
        void sendDedicatedKey(int channel, const std::string str, bool pressed);
71
        std::string typeToString(SYS_BUUTON_TYPE type);
72
        void setDistinctFocus(ulong handle);
73
 
74
        int mBank{1};                       // The activated bank (1 - 3)
75
        int mStateKeyActive{0};             // If the system button is a key button, it can have a state between 0 and 5
76
        std::string mInputText;             // Contains the text typed over system keyboard
77
        std::vector<Button::TButton *> mButtons;    // Vector array holding all system buttons
78
        bool mCapsLock{false};              // TRUE = Key CAPS LOCK was pressed and is active
79
        bool mBank3{false};                 // TRUE = 3rd bank was activated for one key press
80
        bool mShift{false};                 // TRUE = Key shift was pressed for one key press
81
        bool isKeyboard{false};             // TRUE = A keyboard was detected, FALSE = A keypad was detected
82
        int mCursorPosition{0};             // The cursor position of the focused input line, if there is one
83
        ulong mLineHandle{0};               // The handle of the actual input line, if there is one.
84
};
85
 
86
#endif