I need to use a gamepad (physical joystick and button) to opeate my android application. I check the related offical documentation:enter link description here. and my code: but no toast when I connect and operate the gamepad. Do I need other related libraries? I didn't make any set-up action, nor did we set the manifest. I found that most joystick related examples are virtual joystick on the phone, but in my case, I am connecting a physical gamepad to my android application.
private View.OnKeyListener mCorkyListener = new View.OnKeyListener() {
public boolean onKey(View v, int i, KeyEvent event) {
// do something when the button is clicked
Toast.makeText(getApplicationContext(), event.getKeyCode() ,Toast.LENGTH_SHORT).show();
switch (event.getAction()){
case KeyEvent.ACTION_UP:
break;
case KeyEvent.ACTION_DOWN:
break;
}
return true;
}
};