libretro / RetroArch

Cross-platform, sophisticated frontend for the libretro API. Licensed GPLv3.
http://www.libretro.com
GNU General Public License v3.0
10.21k stars 1.82k forks source link

Retroarch menu does not work with normal USB wired keyboard on Android TV #8031

Open unaiast opened 5 years ago

unaiast commented 5 years ago

Description

Retroarch menu does not work with a USB keyboard on Android TV (nvidia shield tv 2017) using the "android" input driver. I've plugged in a USB keyboard (wired) to the AndroidTV. It's detected and it works in apps and desktop (using arrow keys I can move through apps and use Intro to enter). I launch Retroarch, and the keyboard does not work to navigate the menu. If i use the arrow keys, the menu options do not move up/down/left/right. I've tried every other key and none of them works. I've used online updater to download the last joypad profiles also. I've then tried the same with a Logitech K400 keyboard (wireless), and it's detected correctly and i can navigate the menus with the arrow keys.

Expected behavior

Using the normal USB keyboard keys I expected to be able to navigate through the menu options up/down/left/right, select...etc.

Actual behavior

The menu doesn't seem to be aware of the key strokes. Nothing happens if I press the arrow keys nor with the rest of the keys.

As there are only a few logs in that part of the code, I've downloaded the source code, built it and added some logs to obtain more information, in case it helps. Tried to put the method name in the logs to be more descriptive.

This is what I see when i start retroarch with the normal USB keyboard (wired) plugged in, and i push the "arrow down" key

WindowManager: handleComboKeys keyCode: 20, keyAction: 0 RetroArch: is_keyboard_id 134 return false RetroArch: handle_hotplug port -1 id 134 source: 257. RetroArch: Device model: (SHIELD Android TV RetroArch: ). RetroArch: Using new lookup RetroArch: device name: Barcode Reader RetroArch: device vendor id: 5050 RetroArch: device product id: 24 RetroArch: Its a keyboard only id 134 kbd_num 0.

The usb keyboard is detected as AINPUT_SOURCE_KEYBOARD only so it's not configured as a joypad but as a keyboard due to this code else if(source == AINPUT_SOURCE_KEYBOARD && kbd_num < MAX_NUM_KEYBOARDS) { RARCH_LOG("Its a keyboard only id %d kbd_num %d. \n", id, kbd_num); kbd_id[kbd_num] = id; kbd_num++; return; }

(this is different from the Logitech K400, as the k400 is detected as keyboard+gamepad so it's doesn't go through that code and it's configured as a joypad instead of a normal keyboard) The keystrokes of the normal USB keyboard are received by the input driver correctly and processed, This is what i've logged when i push the "arrow down" key:

-i can see that the keycode 20 is received, and it's handled as coming from a keyboard

RetroArch: android_input_poll_input type_event 1 RetroArch: android_input_poll_input EVENT_TYPE_KEY keycode 20 RetroArch: is_keyboard_id 134 return true RetroArch: android_input_poll_input predispatched RetroArch: is_keyboard_id 134 return true RetroArch: android_input_poll_input type_event 1 RetroArch: android_input_poll_input EVENT_TYPE_KEY keycode 20 RetroArch: is_keyboard_id 134 return true RetroArch: android_input_poll_input not predispatched RetroArch: input_keyboard_event down 1 code 274 character 274 mod 0 device 3

RetroArch: menu down: 1, keycode: 274, mod: 0, character: 274 RetroArch: menu_event_kb_set down 1 key 274 RetroArch: menu_event_kb_set_internal idx 274 key 1 RetroArch: called key_event

RetroArch: android_input_poll_event_type_keyboard keycode 20 keydown 1 handled 1 Retroarch: AInputQueue_finishEvent called handled 1

and here I've not been able to see where it should handle that key and move the menu one option down. I've put some logs in the menu_event function for each line like this (for up, down, left...etc)

if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_DOWN))...

but no logs appeared, so it's not going through any of those conditions, and after those logs,and the finish event, the menu has not moved down.

The same steps with the Logitech K400 have a very different result, as it is detected as Keyboard+pad (i think due to the integrated mouse touch screen), and instead of configuring it as a keyboard, it loads an autoconfig file, maps it to a joypad, and when I push the "arrow down" key the input driver receives the exact same keystroke

RetroArch: android_input_poll_input EVENT_TYPE_KEY keycode 20

but as is_keyboard_id returns false, it goes through a different code path, and it ends also in the menu_event function, but the K400 keystroke goes through this code and ends being processed as "RETRO_DEVICE_ID_JOYPAD_DOWN"

  else if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_DOWN))
  { 
RARCH_LOG("RETRO_DEVICE_ID_JOYPAD_DOWN MENU_ACTION_DOWN\n");      
    ret = MENU_ACTION_DOWN;
  }

and the menu moves one option down, as it should.

So my guess is that there's something in the code that handles the keyboard presses for a keyboard only device that it's not working as it should.

some notes:

If you need me to do more tests or get more logs, just ask.

Lastly, here are the logs from retroarch start process:

1-17 19:59:41.711 8978 8998 I RetroArch: [ENV] Android version (major : 8, minor : 0, rel : 0) 01-17 19:59:41.711 8978 8998 I RetroArch: [ENV] Checking arguments passed from intent ... 01-17 19:59:41.711 8978 8998 I RetroArch: [ENV]: config file: [/storage/emulated/0/Android/data/com.retroarch/files/retroarch.cfg] 01-17 19:59:41.711 8978 8998 I RetroArch: [ENV]: current IME: [com.google.android.leanback.ime/com.google.leanback.ime.LeanbackImeService] 01-17 19:59:41.711 8978 8998 I RetroArch: [ENV]: libretro path: [/data/user/0/com.retroarch/cores/] 01-17 19:59:41.711 8978 8998 I RetroArch: [ENV]: android internal storage location: [/storage/emulated/0] 01-17 19:59:41.711 8978 8998 I RetroArch: [ENV]: android picture folder location [/storage/emulated/0/Pictures] 01-17 19:59:41.711 8978 8998 I RetroArch: [ENV]: android download folder location [/storage/emulated/0/Download] 01-17 19:59:41.711 8978 8998 I RetroArch: [ENV]: APK location [/data/app/com.retroarch-FXTWx9HFAhQcZqaMYhQq2g==/base.apk] 01-17 19:59:41.711 8978 8998 I RetroArch: [ENV]: android external files location [/storage/emulated/0/Android/data/com.retroarch/files] 01-17 19:59:41.711 8978 8998 I RetroArch: [ENV]: app dir: [/data/user/0/com.retroarch] 01-17 19:59:41.711 8978 8998 I RetroArch: Testing permissions for /storage/emulated/0 01-17 19:59:41.711 682 708 I ActivityManager: Displayed com.retroarch/.browser.retroactivity.RetroActivityFuture: +191ms (total +771ms) 01-17 19:59:41.713 8978 8998 I RetroArch: Create /storage/emulated/0/.retroarch in /storage/emulated/0 true 01-17 19:59:41.714 8978 8998 I RetroArch: [ENV]: application location: [/data/user/0/com.retroarch] 01-17 19:59:41.714 8978 8998 I RetroArch: [ENV]: default download folder: [] 01-17 19:59:41.714 8978 8998 I RetroArch: [ENV]: default savefile folder: [/storage/emulated/0/RetroArch/saves] 01-17 19:59:41.714 8978 8998 I RetroArch: [ENV]: default savestate folder: [/storage/emulated/0/RetroArch/states] 01-17 19:59:41.714 8978 8998 I RetroArch: [ENV]: default system folder: [/storage/emulated/0/RetroArch/system] 01-17 19:59:41.714 8978 8998 I RetroArch: [ENV]: default screenshot folder: [/storage/emulated/0/RetroArch/screenshots] 01-17 19:59:41.715 8978 8998 I RetroActivity: isAndroidTV == true 01-17 19:59:42.102 8978 8998 I RetroActivity: isSustainedPerformanceModeSupported? false 01-17 19:59:42.102 8978 8998 I RetroArch: [recording] twitch streaming key empty 01-17 19:59:42.104 8978 8998 W RetroArch: Using old --libretro behavior. Setting libretro_directory to "/data/user/0/com.retroarch/cores/" instead. 01-17 19:59:42.104 8978 8998 I RetroArch: RetroArch 1.7.5 (Git 9b801ae) 01-17 19:59:42.104 8978 8998 I RetroArch: === Build ======================================= 01-17 19:59:42.104 8978 8998 I RetroArch: Version: 1.7.5 01-17 19:59:42.104 8978 8998 I RetroArch: Git: 9b801ae 01-17 19:59:42.104 8978 8998 I RetroArch: ================================================= 01-17 19:59:42.106 8978 8998 I RetroArch: Environ SET_PIXEL_FORMAT: RGB565. 01-17 19:59:42.106 8978 8998 I RetroArch: Redirecting save file to "/storage/emulated/0/RetroArch/saves/.srm". 01-17 19:59:42.106 8978 8998 I RetroArch: Redirecting savestate to "/storage/emulated/0/RetroArch/states/.state". 01-17 19:59:42.106 8978 8998 I RetroArch: Version of libretro API: 1 01-17 19:59:42.106 8978 8998 I RetroArch: Compiled against API: 1 01-17 19:59:42.106 8978 8998 I RetroArch: [Audio]: Set audio input rate to: 30000.00 Hz. 01-17 19:59:42.106 8978 8998 I RetroArch: [Video]: Video @ 960x720 01-17 19:59:42.106 8978 8998 I RetroArch: [Video]: Starting threaded video driver ... 01-17 19:59:42.107 8978 9009 I RetroArch: Android EGL: GLES version = 2. 01-17 19:59:42.107 8978 9009 I RetroArch: [EGL] Falling back to eglGetDisplay 01-17 19:59:42.132 8978 9009 I vndksupport: sphal namespace is not configured for this process. Loading /vendor/lib/hw/gralloc.tegra.so from the current namespace instead. 01-17 19:59:42.177 8978 9009 I RetroArch: [EGL]: EGL version: 1.4 01-17 19:59:42.177 8978 9009 I RetroArch: [GL]: Found GL context: android 01-17 19:59:42.177 8978 9009 I RetroArch: [GL]: Detecting screen resolution 0x0. 01-17 19:59:42.229 8978 9009 I vndksupport: sphal namespace is not configured for this process. Loading /vendor/lib/hw/gralloc.tegra.so from the current namespace instead. 01-17 19:59:42.230 8978 9009 I vndksupport: sphal namespace is not configured for this process. Loading /vendor/lib/hw/gralloc.tegra.so from the current namespace instead. 01-17 19:59:42.252 8978 9009 I RetroArch: [EGL]: Current context: 0x58269fc0. 01-17 19:59:42.261 8978 9009 I RetroArch: [GL]: Vendor: NVIDIA Corporation, Renderer: NVIDIA Tegra. 01-17 19:59:42.261 8978 9009 I RetroArch: [GL]: Version: OpenGL ES 3.2 NVIDIA 390.00. 01-17 19:59:42.262 8978 9009 I RetroArch: [GL]: Using resolution 1920x1080 01-17 19:59:42.262 8978 9009 I RetroArch: [GL]: Default shader backend found: glsl. 01-17 19:59:42.262 8978 9009 I RetroArch: [Shader driver]: Using GLSL shader backend. 01-17 19:59:42.262 8978 9009 W RetroArch: [GL]: Stock GLSL shaders will be used. 01-17 19:59:42.262 8978 9009 I RetroArch: [GLSL]: Found GLSL vertex shader. 01-17 19:59:42.264 8978 9009 I RetroArch: [GLSL]: Found GLSL fragment shader. 01-17 19:59:42.264 8978 9009 I RetroArch: [GLSL]: Linking GLSL program. 01-17 19:59:42.265 8978 9009 I RetroArch: [GLSL]: Found GLSL vertex shader. 01-17 19:59:42.265 8978 9009 I RetroArch: [GLSL]: Found GLSL fragment shader. 01-17 19:59:42.265 8978 9009 I RetroArch: [GLSL]: Linking GLSL program. 01-17 19:59:42.266 8978 9009 I RetroArch: [GLSL]: Found GLSL vertex shader. 01-17 19:59:42.266 8978 9009 I RetroArch: [GLSL]: Found GLSL fragment shader. 01-17 19:59:42.266 8978 9009 I RetroArch: [GLSL]: Linking GLSL program. 01-17 19:59:42.266 8978 9009 I RetroArch: Setting up menu pipeline shaders for XMB ... 01-17 19:59:42.266 8978 9009 I RetroArch: [GLSL]: Compiling ribbon shader.. 01-17 19:59:42.266 8978 9009 I RetroArch: [GLSL]: Found GLSL vertex shader. 01-17 19:59:42.266 8978 9009 I RetroArch: [GLSL]: Found GLSL fragment shader. 01-17 19:59:42.266 8978 9009 I RetroArch: [GLSL]: Linking GLSL program. 01-17 19:59:42.267 8978 9009 I RetroArch: [GLSL]: Compiling simple ribbon shader.. 01-17 19:59:42.267 8978 9009 I RetroArch: [GLSL]: Found GLSL vertex shader. 01-17 19:59:42.267 8978 9009 I RetroArch: [GLSL]: Found GLSL fragment shader. 01-17 19:59:42.267 8978 9009 I RetroArch: [GLSL]: Linking GLSL program. 01-17 19:59:42.268 8978 9009 I RetroArch: [GLSL]: Compiling snow shader.. 01-17 19:59:42.268 8978 9009 I RetroArch: [GLSL]: Found GLSL vertex shader. 01-17 19:59:42.268 8978 9009 I RetroArch: [GLSL]: Found GLSL fragment shader. 01-17 19:59:42.268 8978 9009 I RetroArch: [GLSL]: Linking GLSL program. 01-17 19:59:42.269 8978 9009 I RetroArch: [GLSL]: Compiling modern snow shader.. 01-17 19:59:42.269 8978 9009 I RetroArch: [GLSL]: Found GLSL vertex shader. 01-17 19:59:42.269 8978 9009 I RetroArch: [GLSL]: Found GLSL fragment shader. 01-17 19:59:42.269 8978 9009 I RetroArch: [GLSL]: Linking GLSL program. 01-17 19:59:42.271 8978 9009 I RetroArch: [GLSL]: Compiling bokeh shader.. 01-17 19:59:42.271 8978 9009 I RetroArch: [GLSL]: Found GLSL vertex shader. 01-17 19:59:42.271 8978 9009 I RetroArch: [GLSL]: Found GLSL fragment shader. 01-17 19:59:42.271 8978 9009 I RetroArch: [GLSL]: Linking GLSL program. 01-17 19:59:42.272 8978 9009 I RetroArch: [GLSL]: Compiling snowflake shader.. 01-17 19:59:42.272 8978 9009 I RetroArch: [GLSL]: Found GLSL vertex shader. 01-17 19:59:42.272 8978 9009 I RetroArch: [GLSL]: Found GLSL fragment shader. 01-17 19:59:42.272 8978 9009 I RetroArch: [GLSL]: Linking GLSL program. 01-17 19:59:42.273 8978 9009 I RetroArch: Resetting shader to defaults ... 01-17 19:59:42.273 8978 9009 I RetroArch: [GL]: Using 4 textures. 01-17 19:59:42.273 8978 9009 I RetroArch: [GL]: Loaded 1 program(s). 01-17 19:59:42.274 8978 9009 I RetroArch: [Joypad]: Found joypad driver: "android". 01-17 19:59:42.289 8978 9009 I RetroArch: sdk version: 26 01-17 19:59:42.290 8978 9009 I RetroArch: Set engine_handle_dpad to 'Get Axis Value' (for reading extra analog sticks) 01-17 19:59:42.296 8978 9009 I RetroArch: [Font]: Using font rendering backend: stb-unicode. 01-17 19:59:42.297 8978 8998 I RetroArch: [Video]: Found display server: null 01-17 19:59:42.299 8978 8998 I RetroArch: [OpenSL]: Requested audio latency: 128 ms. 01-17 19:59:42.302 8978 8998 I RetroArch: [OpenSL]: Setting audio latency: Block size = 1024, Blocks = 24, Total = 24576 ... 01-17 19:59:42.303 8978 8998 D : PlayerBase::PlayerBase() 01-17 19:59:42.303 8978 8998 D : TrackPlayerBase::TrackPlayerBase() 01-17 19:59:42.303 8978 8998 I libOpenSLES: Emulating old channel mask behavior (ignoring positional mask 0x3, using default mask 0x3 based on channel count of 2) 01-17 19:59:42.303 8978 8998 W AudioTrack: notificationFrames=-24 clamped to the range -1 to -8 01-17 19:59:42.304 435 479 I NvAudioPolicyManager: getOutputForAttr() device 0x400, samplingRate 48000, format 1, channelMask 3, flags 104 strategy 0x0 01-17 19:59:42.305 435 1014 W AudioFlinger: createTrack_l(): mismatch between requested flags (00000104) and output flags (00000006) 01-17 19:59:42.305 435 1014 I AudioFlinger: AUDIO_OUTPUT_FLAG_FAST accepted: frameCount=2048 mFrameCount=256 01-17 19:59:42.305 8978 8998 I AudioTrack: AUDIO_OUTPUT_FLAG_FAST successful; frameCount 2048 -> 2048 01-17 19:59:42.305 8978 8998 D AudioTrack: Client defaulted notificationFrames to 256 for frameCount 2048 01-17 19:59:42.345 8978 8998 I RetroArch: [Menu]: Found menu display driver: "gl". 01-17 19:59:42.363 8978 9009 I RetroArch: [Font]: Using font rendering backend: stb-unicode. 01-17 19:59:42.370 8978 9009 I RetroArch: [Font]: Using font rendering backend: stb-unicode. 01-17 19:59:42.410 8978 9013 D AudioTrack: stop() called with 6144 frames delivered 01-17 19:59:42.410 8978 9013 D : PlayerBase::stop() from IPlayer 01-17 19:59:42.530 8978 8998 I RetroArch: [LED]: LED driver = 'null' 0x65da075c 01-17 19:59:42.531 8978 8998 I RetroArch: [MIDI]: Initializing ... 01-17 19:59:42.531 8978 8998 I RetroArch: [MIDI]: Input disabled. 01-17 19:59:42.531 8978 8998 I RetroArch: [MIDI]: Output disabled. 01-17 19:59:42.531 8978 8998 I RetroArch: [MIDI]: Initialized "null" driver. 01-17 19:59:42.531 8978 8998 I RetroArch: SRAM will not be saved. 01-17 19:59:42.531 8978 8998 I RetroArch: Loading history file: [/data/user/0/com.retroarch/content_history.lpl]. 01-17 19:59:42.531 8978 8998 I RetroArch: Loading history file: [/data/user/0/com.retroarch/content_favorites.lpl]. 01-17 19:59:42.531 8978 8998 I RetroArch: Loading history file: [/data/user/0/com.retroarch/content_music_history.lpl]. 01-17 19:59:42.531 8978 8998 I RetroArch: Loading history file: [/data/user/0/com.retroarch/content_image_history.lpl]. 01-17 19:59:42.531 8978 8998 D : PlayerBase::stop() from IPlayer 01-17 19:59:42.539 8978 9009 I RetroArch: [Font]: Using font rendering backend: stb-unicode. 01-17 19:59:42.544 8978 9009 I RetroArch: [Font]: Using font rendering backend: stb-unicode. 01-17 19:59:42.561 8978 9009 D phs:ipc-binder-client: phs: RegisterClient(): transact returned 0, NO_ERROR=0 01-17 19:59:42.561 8978 9009 D phs:ipc-binder-client: phs: RegisterClient() timeout is 5000 01-17 19:59:42.561 8978 9008 I RetroActivity: power state = 2 01-17 19:59:42.562 8978 9008 I RetroActivity: battery: level = 100, scale = 100, percent = 100.0

Steps to reproduce the bug

  1. Plug in a USB keyboard to Nvidia shield (android tv)
  2. Launch retroarch
  3. Try to move through the menu pushing the keyboard keys (arrow keys or any other key)

Bisect Results

Version/Commit

Tried with

Environment information

unaiast commented 5 years ago

Adding a some more info.

When I push a key in the keyboard and the input driver maps it to the corresponding RETRO_X key, the method "menu_event" is fired (from menu_input.c). This method checks for joypad events, but I think that it doesn't handle the keyboard events. I've only seen the code that handles the F11 key

if (menu_event_kb_is_set(RETROK_F11))
{
   command_event(CMD_EVENT_GRAB_MOUSE_TOGGLE, NULL);
   menu_event_kb_set_internal(RETROK_F11, 0);
}

if I add there some code to handle the RETROK_UP/DOWN/LEFT/RIGHT/RETURN, the keystrokes are handled and the menu starts responding to the keyboard events

for example, adding this code there:

if (menu_event_kb_is_set(RETROK_DOWN))
{
    RARCH_LOG("RETROK_DOWN is set!!!");
    ret = MENU_ACTION_DOWN;
    menu_event_kb_set_internal(RETROK_DOWN, 0); 
}
else if (menu_event_kb_is_set(RETROK_UP))
{
    RARCH_LOG("RETROK_UP is set!!!");
    ret = MENU_ACTION_UP;
    menu_event_kb_set_internal(RETROK_UP, 0); 
}
else if (menu_event_kb_is_set(RETROK_LEFT))
{
    RARCH_LOG("RETROK_LEFT is set!!!");
    ret = MENU_ACTION_LEFT;
    menu_event_kb_set_internal(RETROK_LEFT, 0); 
} 
else if (menu_event_kb_is_set(RETROK_RIGHT))
{
    RARCH_LOG("RETROK_RIGHT is set!!!");
    ret = MENU_ACTION_RIGHT;
    menu_event_kb_set_internal(RETROK_RIGHT, 0); 
}
else if (menu_event_kb_is_set(RETROK_RETURN))
{
    RARCH_LOG("RETROK_RETURN is set!!!");
    ret = MENU_ACTION_OK;
    menu_event_kb_set_internal(RETROK_RETURN, 0); 
}

when i push the arrow keys, i can see the "is set!!" log and if the corresponding MENU_ACTION_X is returned there, the menu moves. I've also reset the key after this, to avoid processing it multiple times.

I suppose that the solution involves other things to handle repeated presses, when to handle the keypress (for a single keypress, i'm seeing the key down and key up events, i don't know which of them should be handled. Logs added at the end)...etc. I don't even know if that is the right place or way to handle and reset keyboard events, but I hope that this helps to get the keyboard working on the menu.

This are the logs for a single keystroke of the arrow down key (keycode 20).

01-18 21:10:26.740 15042 15062 I RetroArch: android_input_poll_input EVENT_TYPE_KEY keycode 20 01-18 21:10:26.740 15042 15062 I RetroArch: is_keyboard_id 134 return true 01-18 21:10:26.740 15042 15062 I RetroArch: android_input_poll_input predispatched 01-18 21:10:26.740 15042 15062 I RetroArch: is_keyboard_id 134 return true 01-18 21:10:26.740 15042 15062 I RetroArch: android_input_poll_input type_event 1 01-18 21:10:26.740 15042 15062 I RetroArch: android_input_poll_input EVENT_TYPE_KEY keycode 20 01-18 21:10:26.740 15042 15062 I RetroArch: is_keyboard_id 134 return true 01-18 21:10:26.740 15042 15062 I RetroArch: android_input_poll_input not predispatched 01-18 21:10:26.740 15042 15062 I RetroArch: input_keyboard_event down 1 code 274 character 274 mod 0 device 3 01-18 21:10:26.740 15042 15062 I RetroArch: else case 01-18 21:10:26.740 15042 15062 I RetroArch: menu down: 1, keycode: 274, mod: 0, character: 274 01-18 21:10:26.740 15042 15062 I RetroArch: menu_event_kb_set down 1 key 274 01-18 21:10:26.740 15042 15062 I RetroArch: menu_event_kb_set_internal idx 274 key 1 01-18 21:10:26.740 15042 15062 I RetroArch: called key_event 01-18 21:10:26.740 15042 15062 I RetroArch: android_input_poll_event_type_keyboard keycode 20 keydown 1 handled 1 01-18 21:10:26.741 15042 15062 I RetroArch: android_input_poll_event_type_key keycode 20 handled 1 01-18 21:10:26.741 15042 15062 I RetroArch: AInputQueue_finishEvent called handled 1 01-18 21:10:26.742 15042 15062 I RetroArch: menu_event input_bits 0x663157f8 01-18 21:10:26.742 15042 15062 I RetroArch: RETROK_DOWN is set!!! 01-18 21:10:26.742 15042 15062 I RetroArch: menu_event_kb_set_internal idx 274 key 0 01-18 21:10:26.746 15042 15062 I RetroArch: menu_event input_bits 0x663157f8 01-18 21:10:26.812 15042 15062 I chatty : uid=10109(u0_a109) Thread-2 identical 4 lines 01-18 21:10:26.829 15042 15062 I RetroArch: menu_event input_bits 0x663157f8 01-18 21:10:26.839 682 757 D WindowManager: handleComboKeys keyCode: 20, keyAction: 1 01-18 21:10:26.844 15042 15062 I RetroArch: is_keyboard_id 134 return true 01-18 21:10:26.844 15042 15062 I RetroArch: android_input_poll_input type_event 1 01-18 21:10:26.844 15042 15062 I RetroArch: android_input_poll_input EVENT_TYPE_KEY keycode 20 01-18 21:10:26.844 15042 15062 I RetroArch: is_keyboard_id 134 return true 01-18 21:10:26.844 15042 15062 I RetroArch: android_input_poll_input predispatched 01-18 21:10:26.845 15042 15062 I RetroArch: menu_event input_bits 0x663157f8 01-18 21:10:26.862 15042 15062 I RetroArch: is_keyboard_id 134 return true 01-18 21:10:26.862 15042 15062 I RetroArch: android_input_poll_input type_event 1 01-18 21:10:26.862 15042 15062 I RetroArch: android_input_poll_input EVENT_TYPE_KEY keycode 20 01-18 21:10:26.862 15042 15062 I RetroArch: is_keyboard_id 134 return true 01-18 21:10:26.862 15042 15062 I RetroArch: android_input_poll_input not predispatched 01-18 21:10:26.862 15042 15062 I RetroArch: input_keyboard_event down 0 code 274 character 274 mod 0 device 3 01-18 21:10:26.862 15042 15062 I RetroArch: else case 01-18 21:10:26.862 15042 15062 I RetroArch: menu down: 0, keycode: 274, mod: 0, character: 274 01-18 21:10:26.862 15042 15062 I RetroArch: menu_event_kb_set down 0 key 274 01-18 21:10:26.862 15042 15062 I RetroArch: menu_event_kb_set_internal idx 274 key 0 01-18 21:10:26.862 15042 15062 I RetroArch: called key_event 01-18 21:10:26.862 15042 15062 I RetroArch: android_input_poll_event_type_keyboard keycode 20 keydown 0 handled 1 01-18 21:10:26.862 15042 15062 I RetroArch: android_input_poll_event_type_key keycode 20 handled 1 01-18 21:10:26.862 15042 15062 I RetroArch: AInputQueue_finishEvent called handled 1 01-18 21:10:26.863 15042 15062 I RetroArch: menu_event input_bits 0x663157f8 01-18 21:10:34.512 15042 15062 I chatty : uid=10109(u0_a109) Thread-2 identical 459 lines 01-18 21:10:34.529 15042 15062 I RetroArch: menu_event input_bits 0x663157f8 01-18 21:10:34.534 682 682 I WifiLocationBasedCountryCode: getLocationUpdate: true, reason: Scheduled 01-18 21:10:34.535 682 682 D CountryDetector: The first listener is added 01-18 21:10:34.536 682 682 I WifiLocationBasedCountryCode: getCountryIso: Country {ISO=US, source=3, time=1206336631} 01-18 21:10:34.536 682 682 W AlarmManager: Unrecognized alarm listener vendor.nvidia.hardware.server.wifi.WifiLocationBasedCountryCode$3@8bda5b5 01-18 21:10:34.545 15042 15062 I RetroArch: menu_event input_bits 0x663157f8

filigran commented 5 years ago

I have this issue too. Trying to use a flirc as input for menus to save games, exit app etc. The remote works in other apps (Kodi for example), but not in retroarch.

This is also on a shield tv, running Android 8.1 oreo.

I tried disabling autoconfig, but that stopped the gamepad from responding...

I get this yellow text on first key press: "Android Gamepad (8352/1) not configured, using fallback" But no respons from key presses.

It is shown in system info with a device name "flirc.tv flirc (#0)", but device config name: N/A.

How would I go about getting it configured?

I can bind keys for user N, but not for hotkey binds. Doesn't matter if I bind it to a user first or not. I can however use it to move up/down. But cannot bind to save state for example.

unaiast commented 5 years ago

I've finally been able to use the USB keyboard in Retroarch in NVidia Shield TV (Android 8). The trick was to set menu_unified_controls="true" and everything started working as it should. I could use the arrow keys to move through the menu, ...etc.

I don't know why this is set to false as default, or why the menu doesn't respond to the keyboard if it's not set to true, but setting that option to true made all the problems dissapear. Maybe this should be included in the documentation, in the section Getting started -> Input & Controls

This is specially a problem in Android for controllers that work as a keyboard only (AINPUT_SOURCE_KEYBOARD), because using the "android" input driver, in case a controller is detected as AINPUT_SOURCE_KEYBOARD, the input driver does not load the joypad autoconfig profile, even if the product id, vendor id and name match, due to this code in the file "android_input.c", that returns without loading the joypad autoconfig profile

 /* If device is keyboard only and didn't match any of the devices above
  * then assume it is a keyboard, register the id, and return unless the
  * maximum number of keyboards are already registered. */
 else if(source == AINPUT_SOURCE_KEYBOARD && kbd_num < MAX_NUM_KEYBOARDS)
 {
    kbd_id[kbd_num] = id;
    kbd_num++;
    return;
 }
 /* if device was not keyboard only, yet did not match any of the devices
  * then try to autoconfigure as gamepad based on device_name. */
 else if (!string_is_empty(device_name))
 {
    strlcpy(name_buf, device_name, sizeof(name_buf));
 }

So, this renders that keyboards and keyboard-based gamepads unusable for the menu until the option menu_unified_controls is set to true. (or if the joypad autoconfig profile were loaded, they would work as they should)

This issue can be closed if you want, but I'd want to leave some final notes that should be considered, maybe openning a separate issue:

andres-asm commented 5 years ago

unified controls is legacy code, has a fair share of bugs and is undesirable. One of my keyboards works just fine with no tweaking. others don't.

We do-not-support-autoconf for keyboards. Autoconf is for gamepads.

unaiast commented 5 years ago

Ok, thank for the clarification, but this is a bit confusing...

(I'm referring all the time to "android" input driver) I started this issue because I own a X-Arcade Dual Joystick https://shop.xgaming.com/products/x-arcade-dual-joystick-usb-included that is detected as a AINPUT_SOURCE_KEYBOARD in Android (because it has a keyboard controller and acts as a keyboard, simulating a key press for each stick movement and button. There are also more arcade controllers that are detected as keyboards). I've not been able to use it unless I activated the legacy code, nor use an autoconfig profile because the android input driver skips that code, nor rebind controls (i could rebind them using Rebind All, the keypresses were detected during the rebind and assigned to the retropad buttons, but after that... it still doesn't work). I removed that code check, and made the android input driver load an autoconfig profile for it, it worked Ok (just to see that it could).

I've also tried with a Logitech K400+ keyboard, and just because it has a mouse pad, it's not detected as a keyboard-only, and it loads an autoconf profile (I think because it's detected as AINPUT_SOURCE_KEYBOARD|AINPUT_SOURCE_DPAD, even if it's not a gamepad but a keyboard + mouse). It even has an autoconfig profile included in the official autoconfig package. (¿Maybe this is the reason one of your keyboard works? )

I've also been using the X-Arcade in retropie without problems (maybe because it was an older version of retroarch, with the legacy code? or maybe because it was a different input driver (linux)?). It also can be used without problems in the Android OS and apps.

As you can see, for a normal user that knows nothing about retroarch's internals this could be a bit confusing.

For all this, i suggested to update the documentation or support autoconfig profiles for keyboard-only based joysticks (i've seen that they work, at least for the x-arcade, and it's not necessary to bundle them in the official package, but give the user the chance to use their own local autoconfig profile. It has to match all the identifiers, it's not like it would be loaded for another gamepad by mistake...)

If this is not going to be done, at least could you tell me how to make a keyboard/x-arcade work with the latest version of Retroarch (1.7.5) in android without the legacy code? . I've been nearly a week changing options and I've not been able, it's really frustrating.

And please..even if it continues deactivated as default, do not remove the option of unified controls in the future.

I really appreciate the work done in retroarch, it's an amazing app, and i'm trying to have it working instead of installing all the stand alone emulators, even if it takes more time.

hermanfenderson commented 5 years ago

I am experiencing exactly the same problem with the k400 keyboard detected as a pad only on a nvidia shield. Also here only android driver... A few more tests on this. Something weird is going on with keyboard support in android. I tried a different bluetooth keyboard with fuse core. Keyboard is working alright on MacOs (games get keypresses). It doesn't work in android....

unaiast commented 5 years ago

I'm seeing the same. The Logitech K400+ keyboard does not work as a keyboard for Retroarch, and it doesn't let me use the mapped keys inside Retroarch or the cores. Pressing F1 doesn't bring the core menu, for example, but using another USB keyboard-only, the F1 brings the core menu ok. The keyboard support in Retroarch with the "android" driver is not working as it should.

bademux commented 4 years ago

Any keyboard is detected as Android Gamepad with Retroach 1.8.1 on MiboxS. Tested with 2 wireless and one ps2/USB. It is blocker on Android TV as there is no possibility to click something, only screenshot and vol shortcuts work ) UPD: menu_unified_controls="true" didn't help Similar issue #8388