Example usage for android.view KeyEvent KEYCODE_DPAD_CENTER

List of usage examples for android.view KeyEvent KEYCODE_DPAD_CENTER

Introduction

In this page you can find the example usage for android.view KeyEvent KEYCODE_DPAD_CENTER.

Prototype

int KEYCODE_DPAD_CENTER

To view the source code for android.view KeyEvent KEYCODE_DPAD_CENTER.

Click Source Link

Document

Key code constant: Directional Pad Center key.

Usage

From source file:org.ligi.gobandroid_hd.ui.GoActivity.java

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        final Cell ensuredTouchPosition = interaction_scope.getEnsuredTouchPosition();
        final BoardCell boardCell = getGame().getCalcBoard().getCell(ensuredTouchPosition);

        switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_UP:
            if (boardCell.up != null) {
                interaction_scope.touch_position = boardCell.up;
            } else {
                return false;
            }/*from   w ww .  j  a v  a 2 s.c  o m*/
            break;

        case KeyEvent.KEYCODE_DPAD_LEFT:
            if (boardCell.left != null) {
                interaction_scope.touch_position = boardCell.left;
            } else {
                return false;
            }
            break;

        case KeyEvent.KEYCODE_DPAD_DOWN:
            if (boardCell.down != null) {
                interaction_scope.touch_position = boardCell.down;
            } else {
                return false;
            }
            break;

        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if (boardCell.right != null) {
                interaction_scope.touch_position = boardCell.right;
            } else {
                return false;
            }
            break;

        case KeyEvent.KEYCODE_DPAD_CENTER:
            doMoveWithUIFeedback(boardCell);
            break;

        default:

            return false;

        }

        go_board.postInvalidate();
        refreshZoomFragment();
        return true;
    }
    return false;
}

From source file:com.bitflake.counter.HorizontalPicker.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (!isEnabled()) {
        return super.onKeyDown(keyCode, event);
    }//  www. ja  v  a 2s.c o  m

    switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_ENTER:
        selectItem();
        return true;
    case KeyEvent.KEYCODE_DPAD_LEFT:
        smoothScrollBy(-1);
        return true;
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        smoothScrollBy(1);
        return true;
    default:
        return super.onKeyDown(keyCode, event);
    }

}

From source file:info.bartowski.easteregg.LLand.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent ev) {
    if (DEBUG)//from w w  w  .  ja v  a2s . c  om
        L("keyDown: %d", keyCode);
    switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_DPAD_UP:
    case KeyEvent.KEYCODE_SPACE:
    case KeyEvent.KEYCODE_ENTER:
    case KeyEvent.KEYCODE_BUTTON_A:
        poke();
        return true;
    }
    return false;
}

From source file:ca.nehil.rter.streamingapp.StreamingActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (recording) {
            stopRecording();//w  w w  .j  av  a2 s  .  c o m
        }
        finish();
        return true;

    } else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
        createBeacon();
    } else if (keyCode == KeyEvent.KEYCODE_CAMERA) {
        // Camera button clicked.
    }

    return super.onKeyDown(keyCode, event);
}

From source file:info.bartowski.easteregg.LLand.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent ev) {
    if (DEBUG)/*from  w w w .  j  a  v a  2  s.  co  m*/
        L("keyDown: %d", keyCode);
    switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_DPAD_UP:
    case KeyEvent.KEYCODE_SPACE:
    case KeyEvent.KEYCODE_ENTER:
    case KeyEvent.KEYCODE_BUTTON_A:
        unpoke();
        return true;
    }
    return false;
}

From source file:com.malgon.applecrunch.Game3.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (loaded) {
        if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
            canonSprite.moveX(-moveCanonX);
        } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
            canonSprite.moveX(moveCanonX);
        } else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
            Sprite laserSprite = new Sprite(180, 80, laserTexture);
            Hotspot laserHotspot = new Hotspot(laserSprite);

            rokon.addSprite(laserSprite);
            rokon.addHotspot(laserHotspot);

            laserSprite.setXY(canonSprite.getX() + 20, canonSprite.getY());
            laserSprite.setVisible(true);

            laserSprite.setVelocityY(-laserVelocity);

            laserSprite.setCollisionHandler(collisionHandler);

            for (int i = 0; i < appleSpriteList.size(); i++)
                laserSprite.addCollisionSprite(appleSpriteList.get(i));

            for (int i = 0; i < androidSpriteList.size(); i++)
                laserSprite.addCollisionSprite(androidSpriteList.get(i));

            laserSpriteList.add(laserSprite);
            laserHotspotList.add(laserHotspot);
        }//from w  w  w  .j a  v  a2  s. c  o  m
    }

    return super.onKeyDown(keyCode, event);
}

From source file:net.sourceforge.servestream.activity.MediaPlayerActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    int repcnt = event.getRepeatCount();

    if ((seekmethod == 0) ? seekMethod1(keyCode) : seekMethod2(keyCode))
        return true;

    switch (keyCode) {
    case KeyEvent.KEYCODE_SLASH:
        seekmethod = 1 - seekmethod;/*from w  w  w .  j  a  v  a2  s . co  m*/
        return true;

    case KeyEvent.KEYCODE_DPAD_LEFT:
        if (!useDpadMusicControl()) {
            break;
        }
        if (!mPrevButton.hasFocus()) {
            mPrevButton.requestFocus();
        }
        scanBackward(repcnt, event.getEventTime() - event.getDownTime());
        return true;
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        if (!useDpadMusicControl()) {
            break;
        }
        if (!mNextButton.hasFocus()) {
            mNextButton.requestFocus();
        }
        scanForward(repcnt, event.getEventTime() - event.getDownTime());
        return true;

    case KeyEvent.KEYCODE_S:
        toggleShuffle();
        return true;

    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_SPACE:
        doPauseResume();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:net.evendanan.android.thumbremote.ui.RemoteUiActivity.java

/**
 * Handler an android keypress and send it to boxee if appropriate.
 */// w w  w.ja  v  a  2  s.c o m
@Override
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_BACK:
        if (RemoteApplication.getConfig().getHandleBack()) {
            Log.d(TAG, "Will handle back");
            if (mBoundService != null)
                mBoundService.remoteBack();
            return true;
        } else {
            Log.d(TAG, "Will NOT handle back");
            return super.onKeyDown(keyCode, event);
        }

    case KeyEvent.KEYCODE_DPAD_CENTER:
        if (mBoundService != null)
            mBoundService.remoteSelect();
        return true;

    case KeyEvent.KEYCODE_DPAD_DOWN:
        if (mBoundService != null)
            mBoundService.remoteDown();
        return true;

    case KeyEvent.KEYCODE_DPAD_UP:
        if (mBoundService != null)
            mBoundService.remoteUp();
        return true;

    case KeyEvent.KEYCODE_DPAD_LEFT:
        if (mBoundService != null)
            mBoundService.remoteLeft();
        return true;

    case KeyEvent.KEYCODE_DPAD_RIGHT:
        if (mBoundService != null)
            mBoundService.remoteRight();
        return true;

    case KeyEvent.KEYCODE_VOLUME_UP:
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        final int volumeFactor = (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) ? -1 : 1;
        final int volumeOffset = (volumeFactor * RemoteApplication.getConfig().getVolumeStep());
        if (mBoundService != null)
            mBoundService.remoteVolumeOffset(volumeOffset);
        return true;
    case KeyEvent.KEYCODE_DEL:
        if (mBoundService != null)
            mBoundService.remoteKeypress((char) 8);
        return true;
    default:
        final char unicodeChar = (char) event.getUnicodeChar();

        // Log.d(TAG, "Unicode is " + ((char)unicodeChar));

        if (Character.isLetterOrDigit(unicodeChar) || msPunctuation.contains(unicodeChar)) {
            // Log.d(TAG, "handling " + ((char)unicodeChar));
            if (mBoundService != null)
                mBoundService.remoteKeypress(unicodeChar);
            return true;
        } else {
            return super.onKeyDown(keyCode, event);
        }
    }
}

From source file:org.peterbaldwin.vlcremote.app.PlaybackActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    int c = event.getUnicodeChar();
    if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
        if (mVolumeLevel != VOLUME_LEVEL_UNKNOWN) {
            setVolume(mVolumeLevel + 20);
        } else {//  www  .  ja  v  a2 s.c om
            mMediaServer.status().command.volumeUp();
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
        if (mVolumeLevel != VOLUME_LEVEL_UNKNOWN) {
            setVolume(mVolumeLevel - 20);
        } else {
            mMediaServer.status().command.volumeDown();
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
        if (event.isAltPressed()) {
            mMediaServer.status().command.seek(Uri.encode("-".concat(Preferences.get(this).getSeekTime())));
            return true;
        } else if (event.isShiftPressed()) {
            mMediaServer.status().command.seek(Uri.encode("-3"));
            return true;
        } else {
            mMediaServer.status().command.key("nav-left");
            return true;
        }
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
        if (event.isAltPressed()) {
            mMediaServer.status().command.seek(Uri.encode("+".concat(Preferences.get(this).getSeekTime())));
            return true;
        } else if (event.isShiftPressed()) {
            mMediaServer.status().command.seek(Uri.encode("+3"));
            return true;
        } else {
            mMediaServer.status().command.key("nav-right");
            return true;
        }
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
        mMediaServer.status().command.key("nav-up");
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
        mMediaServer.status().command.key("nav-down");
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
        mMediaServer.status().command.key("nav-activate");
        return true;
    } else if (c == ' ') {
        mMediaServer.status().command.playback.pause();
        return true;
    } else if (c == 's') {
        mMediaServer.status().command.playback.stop();
        return true;
    } else if (c == 'p') {
        mMediaServer.status().command.playback.previous();
        return true;
    } else if (c == 'n') {
        mMediaServer.status().command.playback.next();
        return true;
    } else if (c == '+') {
        // TODO: Play faster
        return super.onKeyDown(keyCode, event);
    } else if (c == '-') {
        // TODO: Play slower
        return super.onKeyDown(keyCode, event);
    } else if (c == 'f') {
        mMediaServer.status().command.fullscreen();
        return true;
    } else if (c == 'm') {
        mute();
        return true;
    } else {
        return super.onKeyDown(keyCode, event);
    }
}