Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix keys not working, always allow dpad pointer, make gui usable #73

Merged
merged 1 commit into from
Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions libretro/libretro-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ int keyId(const char *val)
int i=0;
while (keyDesc[i]!=NULL)
{
if (!strcmp(keyDesc[i],val))
if (strstr(keyDesc[i],val))
return keyVal[i];
i++;
}
Expand Down Expand Up @@ -477,16 +477,16 @@ void retro_set_environment(retro_environment_t cb)
i++;
}

snprintf(buf[0],sizeof(buf[0]), "RetroPad Y; %s|%s","RETROK_F9", keys);
snprintf(buf[0],sizeof(buf[0]), "RetroPad Y; %s|%s","RETROK_F9 (Virtual Keyboard)", keys);
snprintf(buf[1],sizeof(buf[1]), "RetroPad X; %s|%s","RETROK_RETURN", keys);
snprintf(buf[2],sizeof(buf[2]), "RetroPad B; %s|%s","RETROK_ESCAPE", keys);
snprintf(buf[3],sizeof(buf[3]), "RetroPad L; %s|%s","RETROK_KP_PLUS", keys);
snprintf(buf[4],sizeof(buf[4]), "RetroPad R; %s|%s","RETROK_KP_MINUS", keys);
snprintf(buf[5],sizeof(buf[5]), "RetroPad L2; %s|%s","RETROK_KP_MULTIPLY", keys);
snprintf(buf[6],sizeof(buf[6]), "RetroPad R2; %s|%s","RETROK_ESCAPE", keys);
snprintf(buf[2],sizeof(buf[2]), "RetroPad B; %s|%s","RETROK_ESCAPE (Run/Stop)", keys);
snprintf(buf[3],sizeof(buf[3]), "RetroPad L; %s|%s","RETROK_KP_PLUS (Fliplist Next)", keys);
snprintf(buf[4],sizeof(buf[4]), "RetroPad R; %s|%s","RETROK_KP_MINUS (Fliplist Previous)", keys);
snprintf(buf[5],sizeof(buf[5]), "RetroPad L2; %s|%s","RETROK_KP_MULTIPLY (Swap Joyports)", keys);
snprintf(buf[6],sizeof(buf[6]), "RetroPad R2; %s|%s","RETROK_ESCAPE (Run/Stop)", keys);
snprintf(buf[7],sizeof(buf[7]), "RetroPad L3; %s|%s","RETROK_TAB", keys);
snprintf(buf[8],sizeof(buf[8]), "RetroPad R3; %s|%s","RETROK_F5", keys);
snprintf(buf[9],sizeof(buf[9]),"RetroPad START; %s|%s","RETROK_KP_DIVIDE", keys);
snprintf(buf[9],sizeof(buf[9]),"RetroPad START; %s|%s","RETROK_KP_DIVIDE (Vice Menu)", keys);

cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables);

Expand Down
8 changes: 4 additions & 4 deletions libretro/nukleargui/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ extern void Screen_SetFullUpdate(int scr);
extern void vkbd_key(int key,int pressed);
extern void app_vkb_handle();

extern char Core_Key_Sate[512];
extern char Core_old_Key_Sate[512];
extern char core_key_state[512];
extern char core_old_key_state[512];
extern char RPATH[512];
extern int SHOWKEY;
extern int want_quit;
Expand Down Expand Up @@ -95,8 +95,8 @@ int app_init()
filebrowser_init();
sprintf(LCONTENT,"%s",RPATH);

memset(Core_Key_Sate,0,512);
memset(Core_old_Key_Sate ,0, sizeof(Core_old_Key_Sate));
memset(core_key_state,0,512);
memset(core_old_key_state ,0, sizeof(core_old_key_state));

printf("Init nuklear %d\n",0);

Expand Down
4 changes: 2 additions & 2 deletions libretro/nukleargui/gui.i
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ gui(struct file_browser *browser,struct nk_context *ctx)

case GUI_VKBD:

if (nk_begin(ctx,"Vice keyboard", GUIRECT, window_flags)){
if (nk_begin(ctx,"Vice Keyboard", GUIRECT, window_flags)){
#include "vkboard.i"
nk_end(ctx);
}
Expand All @@ -141,7 +141,7 @@ gui(struct file_browser *browser,struct nk_context *ctx)

case GUI_MAIN:

if (nk_begin(ctx,"Vice GUI", GUIRECT, window_flags)){
if (nk_begin(ctx,"Vice Menu", GUIRECT, window_flags)){
#include "c64menu.i"
nk_end(ctx);
}
Expand Down
113 changes: 57 additions & 56 deletions libretro/nukleargui/retro/nuklear_retro_soft.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ NK_API struct nk_retro_event* nk_retro_event_ptr();

extern retro_input_poll_t input_poll_cb;
extern retro_input_state_t input_state_cb;
extern int mapper_keys[16];
static int joy_button_latch[16] = { 0 };

struct nk_retro_event {

Expand Down Expand Up @@ -627,81 +629,81 @@ NK_API void
nk_retro_handle_event(int *evt,int poll)
{
struct nk_context *ctx = &retro.ctx;

if(poll)input_poll_cb();

static int lmx=0,lmy=0;
static int mmbL=0,mmbR=0,mmbM=0;
static int mbt[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

int mouse_l,mouse_m,mouse_r;

int mouse_l=0;
int mouse_m=0;
int mouse_r=0;
int16_t mouse_x=0,mouse_y=0;
int i;

if(poll)input_poll_cb();

Process_key();

int i=2;//TOGGLE: real mouse/ joypad emulate mouse
if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) && mbt[i]==0 )
mbt[i]=1;
else if ( mbt[i]==1 && ! input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) ){
mbt[i]=0;
revent.MOUSE_EMULATED=-revent.MOUSE_EMULATED;
if (pauseg == 1)
// allow the menu button to toggle the gui off as well as on
{
for(i=0; i<16; i++)
{
if( (i<4 || i>8) && i!=2)
{
if (!input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) && !joy_button_latch[i])
{
if (mapper_keys[i] == RETROK_F10 || mapper_keys[i] == RETROK_KP_DIVIDE)
joy_button_latch[i] = 1;
}
else if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) && joy_button_latch[i])
{
if (mapper_keys[i] == RETROK_F10 || mapper_keys[i] == RETROK_KP_DIVIDE)
{
joy_button_latch[i] = 0;
pauseg = 0;
}
}
}
}
}

revent.mouse_wu = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_WHEELUP);
revent.mouse_wd = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_WHEELDOWN);
if(revent.mouse_wu || revent.mouse_wd)mousebut(4,revent.mouse_wd?-1:1,0,0);

if(revent.MOUSE_EMULATED==1){

if(revent.slowdown>0)return;

mouse_l=input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A);
mouse_r=input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B);
mouse_m=input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y);

if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A) || input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT))
mouse_l = 1;
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B) || input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT))
mouse_r = 1;
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y) || input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_MIDDLE))
mouse_m = 1;

//relative
if(revent.MOUSE_RELATIVE)
{
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT))mouse_x += revent.MOUSE_PAS;
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT))mouse_x -= revent.MOUSE_PAS;
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN))mouse_y += revent.MOUSE_PAS;
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP))mouse_y -= revent.MOUSE_PAS;

mouse_x += input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
mouse_y += input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y);
revent.gmx+=mouse_x;
revent.gmy+=mouse_y;
if(revent.gmx<0)revent.gmx=0;
if(revent.gmx>retro.width-1)revent.gmx=retro.width-1;
if(revent.gmy<0)revent.gmy=0;
if(revent.gmy>retro.height-1)revent.gmy=retro.height-1;

}
else {
mouse_l = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT);
mouse_r = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT);
mouse_m = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_MIDDLE);
}

//relative
if(revent.MOUSE_RELATIVE){

if(revent.MOUSE_EMULATED==1){

if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT))mouse_x += revent.MOUSE_PAS;
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT))mouse_x -= revent.MOUSE_PAS;
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN))mouse_y += revent.MOUSE_PAS;
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP))mouse_y -= revent.MOUSE_PAS;

}
else {

mouse_x = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
mouse_y = input_state_cb(0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y);

}

revent.gmx+=mouse_x;
revent.gmy+=mouse_y;
if(revent.gmx<0)revent.gmx=0;
if(revent.gmx>retro.width-1)revent.gmx=retro.width-1;
if(revent.gmy<0)revent.gmy=0;
if(revent.gmy>retro.height-1)revent.gmy=retro.height-1;

}
else{

else
{
//absolute
//FIXME FULLSCREEN no pointer
int p_x = input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X);
int p_y = input_state_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y);

if(p_x!=0 && p_y!=0){
if(p_x!=0 && p_y!=0)
{
int px=(int)((p_x+0x7fff)*retro.width/0xffff);
int py=(int)((p_y+0x7fff)*retro.height/0xffff);
//printf("px:%d py:%d (%d,%d)\n",p_x,p_y,px,py);
Expand Down Expand Up @@ -733,7 +735,6 @@ nk_retro_handle_event(int *evt,int poll)
//FIXME: mouse left button in scale widget.
#endif
#endif

}

}
Expand Down
16 changes: 8 additions & 8 deletions libretro/vkbd.i
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const char* keyDesc[] = {
"RETROK_CLEAR",//12,
"RETROK_RETURN",//13,
"RETROK_PAUSE",//19,
"RETROK_ESCAPE",//27,
"RETROK_ESCAPE (Run/Stop)",//27,
"RETROK_SPACE",//32,
"RETROK_EXCLAIM",//33,
"RETROK_QUOTEDBL",//34,
Expand Down Expand Up @@ -198,10 +198,10 @@ const char* keyDesc[] = {
"RETROK_KP8",//264,
"RETROK_KP9",//265,
"RETROK_KP_PERIOD",//266,
"RETROK_KP_DIVIDE",//267,
"RETROK_KP_MULTIPLY",//268,
"RETROK_KP_MINUS",//269,
"RETROK_KP_PLUS",//270,
"RETROK_KP_DIVIDE (Vice Menu)",//267,
"RETROK_KP_MULTIPLY (Swap Joyports)",//268,
"RETROK_KP_MINUS (Fliplist Previous)",//269,
"RETROK_KP_PLUS (Fliplist Next)",//270,
"RETROK_KP_ENTER",//271,
"RETROK_KP_EQUALS",//272,
"RETROK_UP",//273,
Expand All @@ -221,10 +221,10 @@ const char* keyDesc[] = {
"RETROK_F6",//287,
"RETROK_F7",//288,
"RETROK_F8",//289,
"RETROK_F9",//290,
"RETROK_F10",//291,
"RETROK_F9 (Virtual Keyboard)",//290,
"RETROK_F10 (Vice Menu)",//291,
"RETROK_F11",//292,
"RETROK_F12",//293,
"RETROK_F12 (Reset)",//293,
"RETROK_F13",//294,
"RETROK_F14",//295,
"RETROK_F15",//296,
Expand Down
5 changes: 0 additions & 5 deletions vice/src/arch/libretro/defaultkey.inc
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,12 @@ static void retro_defaultkeyboard(){

keyboard_keyword_clear();

joystick_joypad_clear();
kbd_lshiftrow = 1;
kbd_lshiftcol = 7;
joystick_joypad_clear();
kbd_rshiftrow = 6;
kbd_rshiftcol = 4;
joystick_joypad_clear();
vshift=KEY_RSHIFT;
joystick_joypad_clear();
shiftl=KEY_LSHIFT;
joystick_joypad_clear();

#if defined(__VIC20__)
keyboard_parse_set_pos_row(27, 0, 3,8); /* ESC -> Run/Stop */
Expand Down
2 changes: 1 addition & 1 deletion vice/src/arch/libretro/joy.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ static int set_retrojoy(int val, void *param)
}

static const resource_int_t retrojoy_resources_int[] = {
{ "RetroJoy", 0, RES_EVENT_NO, NULL,
{ "RetroJoy", 1, RES_EVENT_NO, NULL,
&retrojoy_enabled, set_retrojoy, NULL },
RESOURCE_INT_LIST_END
};
Expand Down