From 1609a6d1150217fccb166d7757745c7dd97e394a Mon Sep 17 00:00:00 2001 From: Not6 Date: Sun, 15 Oct 2017 19:20:18 +0200 Subject: [PATCH] add keyboard typecore option (input poll or input callback) --- libretro/core-mapper.c | 4 ++++ libretro/libretro-core.c | 25 +++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/libretro/core-mapper.c b/libretro/core-mapper.c index d0bf8d9..9a6f002 100644 --- a/libretro/core-mapper.c +++ b/libretro/core-mapper.c @@ -72,6 +72,8 @@ unsigned char MXjoy[2]; // joy extern int a5200_joyhack; +extern int keyboard_type; + //MOUSE extern int pushi; // gui mouse btn int gmx,gmy; //gui mouse @@ -372,6 +374,8 @@ void Process_key() { int i; + if(keyboard_type==1)return; + for(i=0;i<320;i++) Key_Sate[i]=input_state_cb(0, RETRO_DEVICE_KEYBOARD, 0,i) ? 0x80: 0; diff --git a/libretro/libretro-core.c b/libretro/libretro-core.c index f5dfe45..96d9aa3 100644 --- a/libretro/libretro-core.c +++ b/libretro/libretro-core.c @@ -22,6 +22,7 @@ int retroh=300; unsigned atari_devices[ 2 ]; +int keyboard_type=0; int autorun5200=0; int a5200_joyhack=0; @@ -118,7 +119,10 @@ void retro_set_environment(retro_environment_t cb) "atari800_resolution", "Internal resolution; 336x240|320x240|384x240|384x272|384x288|400x300", }, - + { + "atari800_keyboard", + "Retroarch Keyboard type; poll|callback", + }, { NULL, NULL }, }; @@ -328,6 +332,20 @@ static void update_variables(void) } } + var.key = "atari800_keyboard"; + var.value = NULL; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (strcmp(var.value, "poll") == 0) + { + keyboard_type=0; + } + else if (strcmp(var.value, "callback") == 0) + { + keyboard_type=1; + } + } } static void retro_wrap_emulator() @@ -622,11 +640,14 @@ void retro_run(void) co_switch(emuThread); } - +extern char Key_Sate[512]; unsigned int lastdown,lastup,lastchar; static void keyboard_cb(bool down, unsigned keycode, uint32_t character, uint16_t mod) { + if(keyboard_type==0)return; + Key_Sate[keycode]= down ? 1 : 0; + /* printf( "Down: %s, Code: %d, Char: %u, Mod: %u.\n", down ? "yes" : "no", keycode, character, mod);