Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions src/org/blockinger/game/activities/GameActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import android.widget.ImageButton;
import android.widget.Button;
import android.view.View.OnTouchListener;
import android.view.KeyEvent;


public class GameActivity extends FragmentActivity {
Expand Down Expand Up @@ -221,6 +222,60 @@ public boolean onTouch(View v, MotionEvent event) {
((BlockBoardView)findViewById(R.id.boardView)).init();
((BlockBoardView)findViewById(R.id.boardView)).setHost(this);
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_DOWN:
{
controls.downButtonPressed();
return true;
}
case KeyEvent.KEYCODE_DPAD_LEFT:
{
controls.leftButtonPressed();
return true;
}
case KeyEvent.KEYCODE_DPAD_RIGHT:
{
controls.rightButtonPressed();
return true;
}
case KeyEvent.KEYCODE_DPAD_UP:
{
controls.rotateRightPressed();
return true;
}
}
return super.onKeyDown(keyCode, event);
}

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_DOWN:
{
controls.downButtonReleased();
return true;
}
case KeyEvent.KEYCODE_DPAD_LEFT:
{
controls.leftButtonReleased();
return true;
}
case KeyEvent.KEYCODE_DPAD_RIGHT:
{
controls.rightButtonReleased();
return true;
}
case KeyEvent.KEYCODE_DPAD_UP:
{
controls.rotateRightReleased();
return true;
}
}
return super.onKeyDown(keyCode, event);
}

/**
* Called by BlockBoardView upon completed creation
Expand Down