1 /*
2  * ============================================================================
3  *  Title:    Event interface.
4  *  Author:   J. Zbiciak
5  * ============================================================================
6  *
7  * ============================================================================
8  *
9  * ============================================================================
10  */
11 #ifndef EVENT_H_
12 #define EVENT_H_
13 
14 /* ======================================================================== */
15 /*  EVENT_T          -- Event Subsystem object                              */
16 /* ======================================================================== */
17 typedef struct evt_pvt_t evt_pvt_t;
18 typedef struct event_t
19 {
20     periph_t    periph;         /* Yes, it's a peripheral.  Surprise!       */
21     evt_pvt_t  *pvt;            /* Private structure                        */
22 } event_t;
23 
24 /* ======================================================================== */
25 /*  EVENT_INIT       -- Initializes the Event subsystem.                    */
26 /* ======================================================================== */
27 int event_init
28 (
29     event_t *const event,
30     const bool     enable_mouse,
31     const int      initial_event_map
32 );
33 
34 /* ======================================================================== */
35 /*  EVENT_MAP        -- Maps an event to a particular AND/OR mask set       */
36 /* ======================================================================== */
37 int event_map
38 (
39     event_t    *event,          /* Event_t structure being set up.          */
40     const char *name,           /* Name of event to map.                    */
41     int         map_num,        /* Keyboard mapping number                  */
42     uint32_t   *word,           /* Word modified by event, (NULL to ignore) */
43     uint32_t    and_mask[2],    /* AND masks for event up/down.             */
44     uint32_t    or_mask[2]      /* OR masks for event up/down.              */
45 );
46 
47 /* ======================================================================== */
48 /*  EVENT_COMBINE    -- Register a combo event as COMBOxx                   */
49 /* ======================================================================== */
50 int event_combine
51 (
52     event_t     *const event,
53     const char  *const event_name1,
54     const char  *const event_name2,
55     const int          combo_num
56 );
57 
58 /* ======================================================================== */
59 /*  EVENT_SET_COMBO_COALESCE                                                */
60 /*  Adjust the coalesce timer for combo matching.                           */
61 /* ======================================================================== */
62 void event_set_combo_coalesce
63 (
64     event_t     *const event,
65     const double       coalesce_time
66 );
67 
68 typedef enum
69 {
70     EV_MAP_NOP = 0,
71     EV_MAP_SET_0, EV_MAP_SET_1, EV_MAP_SET_2, EV_MAP_SET_3,
72     EV_MAP_NEXT,  EV_MAP_PREV,  EV_MAP_POP,
73     EV_MAP_PSH_0, EV_MAP_PSH_1, EV_MAP_PSH_2, EV_MAP_PSH_3
74 } ev_map_change_req;
75 
76 /* ======================================================================== */
77 /*  EVENT_CHANGE_ACTIVE_MAP  -- Change the current input mapping.           */
78 /* ======================================================================== */
79 void event_change_active_map(event_t *const event,
80                              const ev_map_change_req map_change_req);
81 
82 #endif /*EVENT_H*/
83 /* ======================================================================== */
84 /*  This program is free software; you can redistribute it and/or modify    */
85 /*  it under the terms of the GNU General Public License as published by    */
86 /*  the Free Software Foundation; either version 2 of the License, or       */
87 /*  (at your option) any later version.                                     */
88 /*                                                                          */
89 /*  This program is distributed in the hope that it will be useful,         */
90 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of          */
91 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       */
92 /*  General Public License for more details.                                */
93 /*                                                                          */
94 /*  You should have received a copy of the GNU General Public License along */
95 /*  with this program; if not, write to the Free Software Foundation, Inc., */
96 /*  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.             */
97 /* ======================================================================== */
98 /*                 Copyright (c) 1998-2020, Joseph Zbiciak                  */
99 /* ======================================================================== */
100