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 __TBUTTONSTATES_H__
20
#define __TBUTTONSTATES_H__
21
 
22
#include <cstdint>
23
#include "tsystem.h"
24
 
25
class TButtonStates
26
{
27
    public:
28
        TButtonStates(const TButtonStates& bs);
29
        TButtonStates(BUTTONTYPE t, int rap, int rad, int rch, int rcp, int rlp, int rlv);
30
        ~TButtonStates();
31
 
32
        bool isButton(uint32_t ID) { return ID == mID; }
33
        bool isButton(BUTTONTYPE t, uint32_t ID);
34
        bool isButton(BUTTONTYPE t, int rap, int rad, int rch, int rcp, int rlp, int rlv);
35
        bool isButton(const TButtonStates& bs);
36
        bool isButton(BUTTONTYPE t, int rap, int rad, int rch, int rcp);
37
        bool isButton(BUTTONTYPE t, int rlp, int rlv);
38
        void setLastLevel(int level) { mLastLevel = level; }
39
        int getLastLevel() { return mLastLevel; }
40
        void setLastJoyX(int x) { mLastJoyX = x; }
41
        int getLastJoyX() { return mLastJoyX; }
42
        void setLastJoyY(int y) { mLastJoyY = y; }
43
        int getLastJoyY() { return mLastJoyY; }
44
        void setLastSendLevelX(int x) { mLastSendLevelX = x; }
45
        int getLastSendLevelX() { return mLastSendLevelX; }
46
        void setLastSendLevelY(int y) { mLastSendLevelY = y; }
47
        int getLastSendLevelY() { return mLastSendLevelY; }
48
 
49
        uint32_t getID() { return mID; }
50
        BUTTONTYPE getType() { return type; }
51
 
52
    private:
53
        void init();
54
 
55
        uint32_t mID{0};        // The button ID
56
        BUTTONTYPE type;        // The type of the button
57
 
58
        int ap{1};              // Address port (default: 1)
59
        int ad{0};              // Address channel
60
        int ch{0};              // Channel number
61
        int cp{1};              // Channel port (default: 1)
62
        int lp{1};              // Level port (default: 1)
63
        int lv{0};              // Level code
64
 
65
        int mLastLevel{0};      // The last level value for a bargraph
66
        int mLastJoyX{0};       // The last x position of the joystick curser
67
        int mLastJoyY{0};       // The last y position of the joystick curser
68
        int mLastSendLevelX{0}; // This is the last level send from a bargraph or the X level of a joystick
69
        int mLastSendLevelY{0}; // This is the last Y level from a joystick
70
 
71
};
72
 
73
#endif  // __TBUTTONSTATES_H__