FileDocCategorySizeDatePackage
HdmiCecKeycode.javaAPI DocAndroid 5.1 API25099Thu Mar 12 22:22:42 GMT 2015com.android.server.hdmi

HdmiCecKeycode

public final class HdmiCecKeycode extends Object
Helper class to translate android keycode to hdmi cec keycode and vice versa.

Fields Summary
public static final int
UNSUPPORTED_KEYCODE
public static final int
NO_PARAM
public static final int
CEC_KEYCODE_SELECT
public static final int
CEC_KEYCODE_UP
public static final int
CEC_KEYCODE_DOWN
public static final int
CEC_KEYCODE_LEFT
public static final int
CEC_KEYCODE_RIGHT
public static final int
CEC_KEYCODE_RIGHT_UP
public static final int
CEC_KEYCODE_RIGHT_DOWN
public static final int
CEC_KEYCODE_LEFT_UP
public static final int
CEC_KEYCODE_LEFT_DOWN
public static final int
CEC_KEYCODE_ROOT_MENU
public static final int
CEC_KEYCODE_SETUP_MENU
public static final int
CEC_KEYCODE_CONTENTS_MENU
public static final int
CEC_KEYCODE_FAVORITE_MENU
public static final int
CEC_KEYCODE_EXIT
public static final int
CEC_KEYCODE_MEDIA_TOP_MENU
public static final int
CEC_KEYCODE_MEDIA_CONTEXT_SENSITIVE_MENU
public static final int
CEC_KEYCODE_NUMBER_ENTRY_MODE
public static final int
CEC_KEYCODE_NUMBER_11
public static final int
CEC_KEYCODE_NUMBER_12
public static final int
CEC_KEYCODE_NUMBER_0_OR_NUMBER_10
public static final int
CEC_KEYCODE_NUMBERS_1
public static final int
CEC_KEYCODE_NUMBERS_2
public static final int
CEC_KEYCODE_NUMBERS_3
public static final int
CEC_KEYCODE_NUMBERS_4
public static final int
CEC_KEYCODE_NUMBERS_5
public static final int
CEC_KEYCODE_NUMBERS_6
public static final int
CEC_KEYCODE_NUMBERS_7
public static final int
CEC_KEYCODE_NUMBERS_8
public static final int
CEC_KEYCODE_NUMBERS_9
public static final int
CEC_KEYCODE_DOT
public static final int
CEC_KEYCODE_ENTER
public static final int
CEC_KEYCODE_CLEAR
public static final int
CEC_KEYCODE_NEXT_FAVORITE
public static final int
CEC_KEYCODE_CHANNEL_UP
public static final int
CEC_KEYCODE_CHANNEL_DOWN
public static final int
CEC_KEYCODE_PREVIOUS_CHANNEL
public static final int
CEC_KEYCODE_SOUND_SELECT
public static final int
CEC_KEYCODE_INPUT_SELECT
public static final int
CEC_KEYCODE_DISPLAY_INFORMATION
public static final int
CEC_KEYCODE_HELP
public static final int
CEC_KEYCODE_PAGE_UP
public static final int
CEC_KEYCODE_PAGE_DOWN
public static final int
CEC_KEYCODE_POWER
public static final int
CEC_KEYCODE_VOLUME_UP
public static final int
CEC_KEYCODE_VOLUME_DOWN
public static final int
CEC_KEYCODE_MUTE
public static final int
CEC_KEYCODE_PLAY
public static final int
CEC_KEYCODE_STOP
public static final int
CEC_KEYCODE_PAUSE
public static final int
CEC_KEYCODE_RECORD
public static final int
CEC_KEYCODE_REWIND
public static final int
CEC_KEYCODE_FAST_FORWARD
public static final int
CEC_KEYCODE_EJECT
public static final int
CEC_KEYCODE_FORWARD
public static final int
CEC_KEYCODE_BACKWARD
public static final int
CEC_KEYCODE_STOP_RECORD
public static final int
CEC_KEYCODE_PAUSE_RECORD
public static final int
CEC_KEYCODE_RESERVED
public static final int
CEC_KEYCODE_ANGLE
public static final int
CEC_KEYCODE_SUB_PICTURE
public static final int
CEC_KEYCODE_VIDEO_ON_DEMAND
public static final int
CEC_KEYCODE_ELECTRONIC_PROGRAM_GUIDE
public static final int
CEC_KEYCODE_TIMER_PROGRAMMING
public static final int
CEC_KEYCODE_INITIAL_CONFIGURATION
public static final int
CEC_KEYCODE_SELECT_BROADCAST_TYPE
public static final int
CEC_KEYCODE_SELECT_SOUND_PRESENTATION
public static final int
CEC_KEYCODE_PLAY_FUNCTION
public static final int
CEC_KEYCODE_PAUSE_PLAY_FUNCTION
public static final int
CEC_KEYCODE_RECORD_FUNCTION
public static final int
CEC_KEYCODE_PAUSE_RECORD_FUNCTION
public static final int
CEC_KEYCODE_STOP_FUNCTION
public static final int
CEC_KEYCODE_MUTE_FUNCTION
public static final int
CEC_KEYCODE_RESTORE_VOLUME_FUNCTION
public static final int
CEC_KEYCODE_TUNE_FUNCTION
public static final int
CEC_KEYCODE_SELECT_MEDIA_FUNCTION
public static final int
CEC_KEYCODE_SELECT_AV_INPUT_FUNCTION
public static final int
CEC_KEYCODE_SELECT_AUDIO_INPUT_FUNCTION
public static final int
CEC_KEYCODE_POWER_TOGGLE_FUNCTION
public static final int
CEC_KEYCODE_POWER_OFF_FUNCTION
public static final int
CEC_KEYCODE_POWER_ON_FUNCTION
public static final int
CEC_KEYCODE_F1_BLUE
public static final int
CEC_KEYCODE_F2_RED
public static final int
CEC_KEYCODE_F3_GREEN
public static final int
CEC_KEYCODE_F4_YELLOW
public static final int
CEC_KEYCODE_F5
public static final int
CEC_KEYCODE_DATA
public static final int
UI_BROADCAST_TOGGLE_ALL
public static final int
UI_BROADCAST_TOGGLE_ANALOGUE_DIGITAL
public static final int
UI_BROADCAST_ANALOGUE
public static final int
UI_BROADCAST_ANALOGUE_TERRESTRIAL
public static final int
UI_BROADCAST_ANALOGUE_CABLE
public static final int
UI_BROADCAST_ANALOGUE_SATELLITE
public static final int
UI_BROADCAST_DIGITAL
public static final int
UI_BROADCAST_DIGITAL_TERRESTRIAL
public static final int
UI_BROADCAST_DIGITAL_CABLE
public static final int
UI_BROADCAST_DIGITAL_SATELLITE
public static final int
UI_BROADCAST_DIGITAL_COMMNICATIONS_SATELLITE
public static final int
UI_BROADCAST_DIGITAL_COMMNICATIONS_SATELLITE_2
public static final int
UI_BROADCAST_IP
public static final int
UI_SOUND_PRESENTATION_SOUND_MIX_DUAL_MONO
public static final int
UI_SOUND_PRESENTATION_SOUND_MIX_KARAOKE
public static final int
UI_SOUND_PRESENTATION_SELECT_AUDIO_DOWN_MIX
public static final int
UI_SOUND_PRESENTATION_SELECT_AUDIO_AUTO_REVERBERATION
public static final int
UI_SOUND_PRESENTATION_SELECT_AUDIO_AUTO_EQUALIZER
public static final int
UI_SOUND_PRESENTATION_BASS_STEP_PLUS
public static final int
UI_SOUND_PRESENTATION_BASS_NEUTRAL
public static final int
UI_SOUND_PRESENTATION_BASS_STEP_MINUS
public static final int
UI_SOUND_PRESENTATION_TREBLE_STEP_PLUS
public static final int
UI_SOUND_PRESENTATION_TREBLE_NEUTRAL
public static final int
UI_SOUND_PRESENTATION_TREBLE_STEP_MINUS
private static final KeycodeEntry[]
KEYCODE_ENTRIES
Constructors Summary
private HdmiCecKeycode()


      
    
Methods Summary
static byte[]androidKeyToCecKey(int keycode)
Translate Android keycode to Hdmi Cec keycode and params.

param
keycode Android keycode. For details, refer {@link KeyEvent}
return
byte array of CEC keycode and params if matched. Otherwise, return null.


                                        
        
        for (int i = 0; i < KEYCODE_ENTRIES.length; ++i) {
            byte[] cecKeycodeAndParams = KEYCODE_ENTRIES[i].toCecKeycodeAndParamIfMatched(keycode);
            if (cecKeycodeAndParams != null) {
                return cecKeycodeAndParams;
            }
        }
        return null;
    
static intcecKeycodeAndParamsToAndroidKey(byte[] cecKeycodeAndParams)
Translate Hdmi CEC keycode with params to Android keycode.

param
cecKeycodeAndParams CEC keycode and params
return
cec keycode corresponding to the given android keycode. If finds no matched keycode, return {@link #UNSUPPORTED_KEYCODE}

        for (int i = 0; i < KEYCODE_ENTRIES.length; ++i) {
            int androidKey = KEYCODE_ENTRIES[i].toAndroidKeycodeIfMatched(cecKeycodeAndParams);
            if (androidKey != UNSUPPORTED_KEYCODE) {
                return androidKey;
            }
        }
        return UNSUPPORTED_KEYCODE;
    
private static byte[]intToSingleByteArray(int value)

        return new byte[] {
                (byte) (value & 0xFF) };
    
static booleanisRepeatableKey(int androidKeycode)
Whether the given {@code androidKeycode} is repeatable key or not.

param
androidKeycode keycode of android
return
false if the given {@code androidKeycode} is not supported key code

        for (int i = 0; i < KEYCODE_ENTRIES.length; ++i) {
            Boolean isRepeatable = KEYCODE_ENTRIES[i].isRepeatableIfMatched(androidKeycode);
            if (isRepeatable != null) {
                return isRepeatable;
            }
        }
        return false;
    
static booleanisSupportedKeycode(int androidKeycode)
Returns {@code true} if given Android keycode is supported, otherwise {@code false}.

        return HdmiCecKeycode.androidKeyToCecKey(androidKeycode) != null;