1 /* 2 * ============================================================================ 3 * Title: Private platform event interface 4 * Author: J. Zbiciak 5 * ============================================================================ 6 * This describes the interface between Event and Event Plat. It is a 7 * bidirectional interface. 8 * 9 * Functions that start with "event_plat_" are implemented by the platform 10 * specific code. Functions that start with just "event_" are implemented in 11 * event.c as part of the core. 12 * ============================================================================ 13 */ 14 15 #ifndef EVENT_PLAT_H_ 16 #define EVENT_PLAT_H_ 17 18 #ifndef EVENT_H_ 19 typedef struct evt_pvt_t evt_pvt_t; 20 #endif /* EVENT_H_ */ 21 22 typedef enum { EV_DOWN = 1, EV_UP = 0 } event_updn_t; 23 24 /* ======================================================================== */ 25 /* EVENT_PLAT_INIT -- Initializes the platform-specific code. */ 26 /* ======================================================================== */ 27 int event_plat_init 28 ( 29 const bool enable_mouse, /* Enable mouse events? */ 30 evt_pvt_t *const evt_pvt, /* Pass back to event core. */ 31 void **const ptr_plat_pvt /* For plat-specifc private struct. */ 32 ); 33 34 /* ======================================================================== */ 35 /* EVENT_PLAT_DTOR -- Shuts down the platform-specific code. */ 36 /* ======================================================================== */ 37 void event_plat_dtor(void *const plat_pvt); 38 39 /* ======================================================================== */ 40 /* EVENT_PLAT_PUMP -- Pump events, even if we're not going to consume. */ 41 /* Called at the start of a tick, but before we decide to "cork." */ 42 /* ======================================================================== */ 43 void event_plat_pump(evt_pvt_t *const pvt, void *const plat_pvt); 44 45 /* ======================================================================== */ 46 /* EVENT_PLAT_TICK -- Performs the bulk of the tick cycle. */ 47 /* */ 48 /* Returns true if we should make an early exit before dequeuing. This */ 49 /* typically happens when we need to "cork" for a combo. */ 50 /* ======================================================================== */ 51 bool event_plat_tick(evt_pvt_t *const pvt, void *const plat_pvt); 52 53 /* ======================================================================== */ 54 /* EVENT_PLAT_TICK_LATE -- Performs deferred tick cycle tasks, after we */ 55 /* have drained our internal event queue. */ 56 /* */ 57 /* Currently this is only used by SDL's experimental mouse processing. */ 58 /* Not sure if this is really necessary. */ 59 /* ======================================================================== */ 60 void event_plat_tick_late(evt_pvt_t *const pvt, void *const plat_pvt); 61 62 /* ======================================================================== */ 63 /* EVENT_QUEUE_HAS_ROOM -- Returns true if there's room for N events. */ 64 /* ======================================================================== */ 65 int event_queue_has_room(evt_pvt_t *const pvt, const int count); 66 67 /* ======================================================================== */ 68 /* EVENT_ENQUEUE -- Internal event queue containing expanded events. */ 69 /* ======================================================================== */ 70 void event_enqueue 71 ( 72 evt_pvt_t *const pvt, 73 const event_updn_t event_updn, 74 const event_num_t event_num 75 ); 76 77 /* ======================================================================== */ 78 /* EVENT_ENQUEUE_CHECK_COMBO */ 79 /* */ 80 /* Enqueues an event, or combo-related events associated with this event. */ 81 /* Returns "true" if we need to cork further inputs. Callers should stop */ 82 /* draining event queue at this time and wait until the next "tick." */ 83 /* ======================================================================== */ 84 bool event_enqueue_check_combo 85 ( 86 evt_pvt_t *const pvt, 87 const event_updn_t event_updn, 88 const event_num_t event_num 89 ); 90 91 /* ======================================================================== */ 92 /* EVENT_NUM_OFS -- Compute an event_num_t as an offset from a base. */ 93 /* ======================================================================== */ 94 #define EVENT_NUM_OFS(base, ofs) ((event_num_t)((base) + (ofs))) 95 96 #endif /* EVENT_PLAT_H_ */ 97 98 /* ======================================================================== */ 99 /* This program is free software; you can redistribute it and/or modify */ 100 /* it under the terms of the GNU General Public License as published by */ 101 /* the Free Software Foundation; either version 2 of the License, or */ 102 /* (at your option) any later version. */ 103 /* */ 104 /* This program is distributed in the hope that it will be useful, */ 105 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 106 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 107 /* General Public License for more details. */ 108 /* */ 109 /* You should have received a copy of the GNU General Public License along */ 110 /* with this program; if not, write to the Free Software Foundation, Inc., */ 111 /* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ 112 /* ======================================================================== */ 113 /* Copyright (c) 2020-+Inf, Joseph Zbiciak */ 114 /* ======================================================================== */ 115