104 lines
3.9 KiB
C
Executable file
104 lines
3.9 KiB
C
Executable file
|
|
/*
|
|
* This program source code file is part of SystemK, a library in the KTag project.
|
|
*
|
|
* 🛡️ <https://ktag.clubk.club> 🃞
|
|
*
|
|
* Copyright © 2016-2025 Joseph P. Kearney and the KTag developers.
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify it under
|
|
* the terms of the GNU Affero General Public License as published by the Free
|
|
* Software Foundation, either version 3 of the License, or (at your option) any
|
|
* later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
* details.
|
|
*
|
|
* There should be a copy of the GNU Affero General Public License in the LICENSE
|
|
* file in the root of this repository. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/** \file
|
|
* \brief This file defines the events used by the KTag system (SystemK).
|
|
*
|
|
*/
|
|
|
|
#ifndef EVENTS_H
|
|
#define EVENTS_H
|
|
|
|
//! Event identifiers used by the SystemK.
|
|
typedef enum
|
|
{
|
|
KEVENT_NO_EVENT = 0,
|
|
KEVENT_AUTOMATIC_TRANSITION = 1,
|
|
KEVENT_CAPSENSE_ONE_PRESSED = 2,
|
|
KEVENT_CAPSENSE_ONE_RELEASED = 3,
|
|
KEVENT_CAPSENSE_TWO_PRESSED = 4,
|
|
KEVENT_CAPSENSE_TWO_RELEASED = 5,
|
|
KEVENT_TRIGGER_SWITCH_PRESSED = 6,
|
|
KEVENT_CENTER_SWITCH_PRESSED = KEVENT_TRIGGER_SWITCH_PRESSED,
|
|
KEVENT_TRIGGER_SWITCH_RELEASED = 7,
|
|
//! For #KEVENT_CENTER_SWITCH_RELEASED, #KEvent_T::Data contains the duration of the press in milliseconds.
|
|
KEVENT_CENTER_SWITCH_RELEASED = KEVENT_TRIGGER_SWITCH_RELEASED,
|
|
KEVENT_UP_SWITCH_PRESSED = 8,
|
|
KEVENT_UP_SWITCH_LONG_PRESSED = 9,
|
|
KEVENT_UP_SWITCH_RELEASED = 10,
|
|
KEVENT_DOWN_SWITCH_PRESSED = 11,
|
|
KEVENT_DOWN_SWITCH_LONG_PRESSED = 12,
|
|
KEVENT_DOWN_SWITCH_RELEASED = 13,
|
|
KEVENT_FORWARD_SWITCH_PRESSED = 14,
|
|
KEVENT_FORWARD_SWITCH_LONG_PRESSED = 15,
|
|
KEVENT_FORWARD_SWITCH_RELEASED = 16,
|
|
KEVENT_BACKWARD_SWITCH_PRESSED = 17,
|
|
KEVENT_BACKWARD_SWITCH_LONG_PRESSED = 18,
|
|
KEVENT_BACKWARD_SWITCH_RELEASED = 19,
|
|
KEVENT_TAG_SENT = 20,
|
|
//! For #KEVENT_TAG_RECEIVED, #KEvent_T::Data points to #TagPacket_T.
|
|
KEVENT_TAG_RECEIVED = 21,
|
|
KEVENT_TAGGED_OUT = 22,
|
|
KEVENT_MISFIRE = 23,
|
|
KEVENT_NEAR_MISS = 24,
|
|
//! For #KEVENT_BLE_PACKET_RECEIVED, #KEvent_T::Data points to #COMM_BLE_Packet_T.
|
|
KEVENT_BLE_PACKET_RECEIVED = 25,
|
|
//! For #KEVENT_COMMAND_RECEIVED, #KEvent_T::Data points to #CommandPacket_T.
|
|
KEVENT_COMMAND_RECEIVED = 26,
|
|
KEVENT_MENU_ENTER = 27,
|
|
KEVENT_MENU_SELECT = 28,
|
|
KEVENT_MENU_BACK = 29,
|
|
KEVENT_MENU_UP = 30,
|
|
KEVENT_MENU_DOWN = 31,
|
|
KEVENT_MENU_EXIT = 32,
|
|
KEVENT_REPROGRAM = 33,
|
|
//! For #KEVENT_ACCESSORY_SWITCH_PRESSED, #KEvent_T::Data contains the duration the switch has not been pressed in milliseconds.
|
|
KEVENT_ACCESSORY_SWITCH_PRESSED = 34,
|
|
//! For #KEVENT_ACCESSORY_SWITCH_PRESSED, #KEvent_T::Data contains the duration of the press in milliseconds.
|
|
KEVENT_ACCESSORY_SWITCH_RELEASED = 35,
|
|
//! For #KEVENT_AUDIO_COMPLETED, #KEvent_T::Data contains the AudioActionID_T of the completed action.
|
|
KEVENT_AUDIO_COMPLETED = 36,
|
|
KEVENT_GAME_OVER = 37,
|
|
KEVENT_PLAY_PRESSED_ON_REMOTE = 38,
|
|
// KEVENT_IS_OUT_OF_RANGE is one more than the last valid event.
|
|
KEVENT_IS_OUT_OF_RANGE
|
|
} KEvent_ID_T;
|
|
|
|
//! Events used by the SystemK.
|
|
/*!
|
|
* The #Data is event-dependent.
|
|
*/
|
|
typedef struct
|
|
{
|
|
KEvent_ID_T ID;
|
|
void *Data;
|
|
} KEvent_T;
|
|
|
|
// Verify the pointer size, since sometime we store uint32_t's in the KEvent_T::Data pointer.
|
|
_Static_assert(sizeof(uintptr_t) >= sizeof(uint32_t), "Pointer size is less than 32 bits! KEvents will not work properly on this system.");
|
|
|
|
void Init_KEvents(void);
|
|
void Post_KEvent(KEvent_T *event);
|
|
void Post_KEvent_From_ISR(KEvent_T *event, portBASE_TYPE *xHigherPriorityTaskWoken);
|
|
portBASE_TYPE Receive_KEvent(KEvent_T *event);
|
|
|
|
#endif // EVENTS_H
|