1 /*************************************************************************** 2 * Copyright (c) 2024 Microsoft Corporation 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the MIT License which is available at 6 * https://opensource.org/licenses/MIT. 7 * 8 * SPDX-License-Identifier: MIT 9 **************************************************************************/ 10 11 12 /**************************************************************************/ 13 /**************************************************************************/ 14 /** */ 15 /** GUIX Component */ 16 /** */ 17 /** System Management (System) */ 18 /** */ 19 /**************************************************************************/ 20 21 #define GX_SOURCE_CODE 22 23 24 /* Include necessary system files. */ 25 26 #include "gx_api.h" 27 #include "gx_system.h" 28 29 /**************************************************************************/ 30 /* */ 31 /* FUNCTION RELEASE */ 32 /* */ 33 /* _gx_system_event_fold PORTABLE C */ 34 /* 6.1 */ 35 /* AUTHOR */ 36 /* */ 37 /* Kenneth Maxwell, Microsoft Corporation */ 38 /* */ 39 /* DESCRIPTION */ 40 /* */ 41 /* This service folds GUIX events. */ 42 /* */ 43 /* INPUT */ 44 /* */ 45 /* event Pointer to event */ 46 /* */ 47 /* OUTPUT */ 48 /* */ 49 /* status Completion status */ 50 /* */ 51 /* CALLS */ 52 /* */ 53 /* TX_DISABLE */ 54 /* TX_RESTORE */ 55 /* _gx_system_pen_speed_update */ 56 /* _gx_system_event_send Send GUIX events */ 57 /* */ 58 /* CALLED BY */ 59 /* */ 60 /* GUIX Internal Code */ 61 /* */ 62 /* RELEASE HISTORY */ 63 /* */ 64 /* DATE NAME DESCRIPTION */ 65 /* */ 66 /* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ 67 /* 09-30-2020 Kenneth Maxwell Modified comment(s), */ 68 /* resulting in version 6.1 */ 69 /* */ 70 /**************************************************************************/ _gx_system_event_fold(GX_EVENT * in_event)71UINT _gx_system_event_fold(GX_EVENT *in_event) 72 { 73 #ifdef GX_THREADX_BINDING 74 TX_INTERRUPT_SAVE_AREA 75 76 GX_EVENT *pEvent; 77 ULONG *pSrc; 78 TX_QUEUE *pQueue; 79 80 TX_DISABLE 81 82 pQueue = &_gx_system_event_queue; 83 84 if (pQueue -> tx_queue_enqueued) 85 { 86 pSrc = pQueue -> tx_queue_read; 87 88 do 89 { 90 pEvent = (GX_EVENT *)pSrc; 91 92 if (pEvent -> gx_event_type == in_event -> gx_event_type && 93 pEvent -> gx_event_target == in_event -> gx_event_target) 94 { 95 /* we found a matching event, just update the existing event data 96 rather than posting a new event 97 */ 98 99 /* for timer event, update tick count */ 100 if (pEvent -> gx_event_type == GX_EVENT_TIMER) 101 { 102 pEvent -> gx_event_payload.gx_event_ulongdata++; 103 } 104 else 105 { 106 /* for all other event types, just copy payload */ 107 pEvent -> gx_event_payload.gx_event_ulongdata = in_event -> gx_event_payload.gx_event_ulongdata; 108 } 109 TX_RESTORE 110 111 if (pEvent -> gx_event_type == GX_EVENT_PEN_DRAG) 112 { 113 _gx_system_pen_speed_update(&pEvent -> gx_event_payload.gx_event_pointdata); 114 } 115 return GX_SUCCESS; 116 } 117 118 pSrc += pQueue -> tx_queue_message_size; 119 120 if (pSrc >= pQueue -> tx_queue_end) 121 { 122 pSrc = pQueue -> tx_queue_start; 123 } 124 } while (pSrc != pQueue->tx_queue_write); 125 } 126 127 TX_RESTORE 128 129 /* we didn't find a matching event, so post a new event */ 130 return _gx_system_event_send(in_event); 131 #else 132 return(GX_EVENT_FOLD(in_event)); 133 #endif 134 } 135 136