/****************************************************************************** 版权所有 (C), 2018-2099, Radkil ****************************************************************************** 文 件 名 : msp_MK32.h 版 本 号 : 初稿 作 者 : radkil 生成日期 : 2026年9月22日 最近修改 : 功能描述 : msp_MK32.c 的头文件 修改历史 : 1.日 期 : 2026年9月22日 作 者 : radkil 修改内容 : 创建文件 ******************************************************************************/ /*----------------------------------------------* * 外部变量说明 * *----------------------------------------------*/ /*----------------------------------------------* * 外部函数原型说明 * *----------------------------------------------*/ /*----------------------------------------------* * 内部函数原型说明 * *----------------------------------------------*/ /*----------------------------------------------* * 全局变量 * *----------------------------------------------*/ /*----------------------------------------------* * 模块级变量 * *----------------------------------------------*/ /*----------------------------------------------* * 常量定义 * *----------------------------------------------*/ /*----------------------------------------------* * 宏定义 * *----------------------------------------------*/ #ifndef __MSP_MK32_H__ #define __MSP_MK32_H__ #ifdef __cplusplus #if __cplusplus extern "C"{ #endif #endif /* __cplusplus */ /*==============================================* * include header files * *----------------------------------------------*/ /*==============================================* * constants or macros define * *----------------------------------------------*/ typedef enum { MODE_NULL = 0, MODE_DEFAULT, MODE_VERTICAL_LEFT, MODE_VERTICAL_RIGHT, MODE_MAX } E_BHBF_RBMode; typedef enum { SUB_MODE_NULL = 0, SUB_MODE_DEFAULT, SUB_MODE_MAX } E_BHBF_RBSubMode; typedef void (*ActionFunc)(void); typedef struct{ E_BHBF_RBMode m_iMode; //主模式 E_BHBF_RBSubMode m_iSubMode; //副模式 ActionFunc m_ptFunc; //执行函数 } TKeyTree; typedef struct { TKeyTree E_Stop[MODE_MAX*SUB_MODE_MAX]; TKeyTree SA_Up[MODE_MAX*SUB_MODE_MAX]; TKeyTree SA_Down[MODE_MAX*SUB_MODE_MAX]; TKeyTree SA_Default[MODE_MAX*SUB_MODE_MAX]; TKeyTree SB_Up[MODE_MAX*SUB_MODE_MAX]; TKeyTree SB_Down[MODE_MAX*SUB_MODE_MAX]; TKeyTree SC_Up[MODE_MAX*SUB_MODE_MAX]; TKeyTree SC_Down[MODE_MAX*SUB_MODE_MAX]; TKeyTree SC_Default[MODE_MAX*SUB_MODE_MAX]; TKeyTree Joy_Default[MODE_MAX*SUB_MODE_MAX]; TKeyTree Joy_Left_Up[MODE_MAX*SUB_MODE_MAX]; TKeyTree Joy_Left_Down[MODE_MAX*SUB_MODE_MAX]; TKeyTree Joy_Left_Left[MODE_MAX*SUB_MODE_MAX]; TKeyTree Joy_Left_Right[MODE_MAX*SUB_MODE_MAX]; } TKeyForest; extern const TKeyForest g_ActionTable; static inline void SafeDispatch(const TKeyTree *table, int count, int mode, int sub_mode) { for (int i = 0; i < count; i++) { if (table[i].m_iMode == mode && table[i].m_iSubMode == sub_mode) { if (table[i].m_ptFunc != NULL) { table[i].m_ptFunc(); } return; } } #ifdef TREE_SUPPORT_NULL // 如果不显式写NULL则表示空无动作 for (int i = 0; i < count; i++) { if (table[i].m_iMode == MODE_VERTICAL_LEFT && table[i].m_iSubMode == SUB_MODE_DEFAULT) { if (table[i].m_ptFunc != NULL) { table[i].m_ptFunc(); } return; } } for (int i = 0; i < count; i++) { if (table[i].m_iMode == MODE_DEFAULT && table[i].m_iSubMode == SUB_MODE_DEFAULT) { if (table[i].m_ptFunc != NULL) { table[i].m_ptFunc(); } return; } } #endif } #define SAFE_DISPATCH(field) \ SafeDispatch(g_ActionTable.field, \ sizeof(g_ActionTable.field) / sizeof(TKeyTree), \ _iMode, _iSubMode) /*==============================================* * project-wide global variables * *----------------------------------------------*/ /*==============================================* * routines' or functions' implementations * *----------------------------------------------*/ void MK32_Key_Func(SP_MSP_MK32_Button *_pstMK32, int _iMode, int _iSubMode); #ifdef __cplusplus #if __cplusplus } #endif #endif /* __cplusplus */ #endif /* __MSP_MK32_H__ */