www.pudn.com > headset.rar > checkButtons.c
#include "demohs.h" #include/* handleButtonChange Called by the button library when the buttons may have changed. */ ButtonChangeResult handleButtonChange(uint16 pressed, uint16 changed) { #ifdef DEV_BOARD_HS uint16 tmp_set = pressed & changed; if (tmp_set & PIO_DEEP_SLEEP_NOW) { if (!hsState.turnOffHs) { /* If on/off button pressed go into deep sleep and ignore the other buttons */ enterDeepSleepAsap(); return ButtonChangeStop; } else { /* If we're already in deep sleep then wake everything up */ enterActiveStateAsap(); } } else { /* Only allow wake up if on/ off button pressed */ if (hsState.turnOffHs) return ButtonChangeStop; } #endif /* Check for chords first */ if((pressed & RESET_CONDITION) == RESET_CONDITION && (changed &RESET_CONDITION) != 0) { if (hsState.connectState != connected) { resetReq(); } } if((pressed & MUTE_CONDITION) == MUTE_CONDITION && (changed & MUTE_CONDITION) != 0) { if (hsState.connectState == connected) { /* Chord is down, and wasn't before */ muteRequest(); } } else { uint16 new_set = pressed & changed; /* Try single buttons */ if (new_set & PIO_TALK) { /* Process the talk button press */ talkButton(); } else if(new_set & PIO_VOLUME_DOWN) { /* Process the volume DOWN button press */ onVolumeDown(); } else if(new_set & PIO_VOLUME_UP) { /* Process the volume UP button press */ onVolumeUp(); } } return ButtonChangeContinue; }