#ifndef KEYCONTROL_LEGACY_H
#define KEYCONTROL_LEGACY_H

   #include <stdint.h>
   #include <stdbool.h>

   typedef uint16_t tKeySwitchStateLegacy_t;
   typedef uint32_t tKeySwitchState_t;
   typedef uint32_t tKeySwitchCode_t;
   typedef struct
   {
       bool ( * Init)();
       bool ( * SetKeyState)( tKeySwitchState_t state );
       bool ( * GetKeyState)( tKeySwitchState_t * pstate );
       bool ( * GetKeyCode) ( tKeySwitchCode_t * pcode );
       void ( * DeInit)();
   }
   sKeySwitchControl_t;

   #define KEYSWITCH_LEGACYSTATE_2_STATE(ls) ((tKeySwitchState_t)(ls)) 
   #define KEYSWITCH_STATE_2_LEGACYSTATE(s)  ((tKeySwitchStateLegacy_t)(s)) 

   #define KEYCONTROL_STATE_INVALID  0x00000000   //        
   #define KEYCONTROL_STATE_SHORTALL 0x00000009   // 9    Short All   
   #define KEYCONTROL_STATE_OPENALL  0x00000012   // 18   Open All  
   #define KEYCONTROL_STATE_LOADALL  0x00000024   // 36   Load All  
   #define KEYCONTROL_STATE_THRUAB   0x00000040   // 64   Thru A-B  
   #define KEYCONTROL_STATE_LDASHALL 0x0000000C   // 12   Load A, Short ALL  
   #define KEYCONTROL_STATE_LDBSHALL 0x00000021   // 33   Load B, Short ALL   
   #define KEYCONTROL_STATE_CHECK    0x00000080   // 128  Check State     
   #define KEYCONTROL_STATE_DEFAULT  KEYCONTROL_STATE_LOADALL

   extern const sKeySwitchControl_t KeySwitchHandle;
#endif