From e8d96071f1a0b34b58647372b9d9976c5e397aba Mon Sep 17 00:00:00 2001 From: phaseIV Date: Mon, 16 Nov 2015 14:24:33 +0100 Subject: initial neGcon controller support --- frontend/libretro.c | 40 ++++++++++++++++++++++++++++++++++++++-- frontend/menu.c | 4 ++-- frontend/plugin.c | 14 +++++++------- plugins/dfinput/main.c | 11 +++++++++++ 4 files changed, 58 insertions(+), 11 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 2964587..9bada99 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -329,8 +329,8 @@ void retro_set_environment(retro_environment_t cb) static const struct retro_variable vars[] = { { "pcsx_rearmed_frameskip", "Frameskip; 0|1|2|3" }, { "pcsx_rearmed_region", "Region; Auto|NTSC|PAL" }, - { "pcsx_rearmed_pad1type", "Pad 1 Type; standard|analog" }, - { "pcsx_rearmed_pad2type", "Pad 2 Type; standard|analog" }, + { "pcsx_rearmed_pad1type", "Pad 1 Type; standard|analog|negcon" }, + { "pcsx_rearmed_pad2type", "Pad 2 Type; standard|analog|negcon" }, #ifndef DRC_DISABLE { "pcsx_rearmed_drc", "Dynamic recompiler; enabled|disabled" }, #endif @@ -1067,6 +1067,8 @@ static void update_variables(bool in_flight) in_type1 = PSE_PAD_TYPE_STANDARD; if (strcmp(var.value, "analog") == 0) in_type1 = PSE_PAD_TYPE_ANALOGPAD; + if (strcmp(var.value, "negcon") == 0) + in_type1 = PSE_PAD_TYPE_NEGCON; } var.value = NULL; @@ -1077,6 +1079,9 @@ static void update_variables(bool in_flight) in_type2 = PSE_PAD_TYPE_STANDARD; if (strcmp(var.value, "analog") == 0) in_type2 = PSE_PAD_TYPE_ANALOGPAD; + if (strcmp(var.value, "negcon") == 0) + in_type2 = PSE_PAD_TYPE_NEGCON; + } #ifdef __ARM_NEON__ @@ -1232,6 +1237,7 @@ void retro_run(void) if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i)) in_keystate |= retro_psx_map[i]; + if (in_type1 == PSE_PAD_TYPE_ANALOGPAD) { in_a1[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; @@ -1248,6 +1254,36 @@ void retro_run(void) in_a4[1] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128; } + + if (in_type1 == PSE_PAD_TYPE_NEGCON) + { + in_a1[0] = 0; + + if(input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, 12)) // left brake + in_a1[1] = 255; + else + in_a1[1] = 0; + + + in_a2[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; //steer + in_a2[1] = 255 - ((input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128); //thrust + } + + if (in_type2 == PSE_PAD_TYPE_NEGCON) + { + in_a3[0] = 0; + + if(input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, 12)) // left brake + in_a3[1] = 255; + else + in_a3[1] = 0; + + + in_a4[0] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; //steer + in_a4[1] = 255 - ((input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128); //thrust + } + + stop = 0; psxCpu->Execute(); diff --git a/frontend/menu.c b/frontend/menu.c index 0088a63..5737db4 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -308,12 +308,12 @@ static void menu_sync_config(void) switch (in_type_sel1) { case 1: in_type1 = PSE_PAD_TYPE_ANALOGPAD; break; - case 2: in_type1 = PSE_PAD_TYPE_GUNCON; break; + case 2: in_type1 = PSE_PAD_TYPE_NEGCON; break; default: in_type1 = PSE_PAD_TYPE_STANDARD; } switch (in_type_sel2) { case 1: in_type2 = PSE_PAD_TYPE_ANALOGPAD; break; - case 2: in_type2 = PSE_PAD_TYPE_GUNCON; break; + case 2: in_type2 = PSE_PAD_TYPE_NEGCON; break; default: in_type2 = PSE_PAD_TYPE_STANDARD; } if (in_evdev_allow_abs_only != allow_abs_only_old) { diff --git a/frontend/plugin.c b/frontend/plugin.c index 49ae1fe..03fd47b 100644 --- a/frontend/plugin.c +++ b/frontend/plugin.c @@ -53,12 +53,12 @@ static long PADreadPort1(PadDataS *pad) { pad->controllerType = in_type1; pad->buttonStatus = ~in_keystate; - if (in_type1 == PSE_PAD_TYPE_ANALOGPAD) { - pad->leftJoyX = in_a1[0]; - pad->leftJoyY = in_a1[1]; - pad->rightJoyX = in_a2[0]; - pad->rightJoyY = in_a2[1]; - } + if (in_type1 == PSE_PAD_TYPE_ANALOGPAD || in_type1 == PSE_PAD_TYPE_NEGCON) { + pad->leftJoyX = in_a1[0]; + pad->leftJoyY = in_a1[1]; + pad->rightJoyX = in_a2[0]; + pad->rightJoyY = in_a2[1]; + } return 0; } @@ -66,7 +66,7 @@ static long PADreadPort2(PadDataS *pad) { pad->controllerType = in_type2; pad->buttonStatus = ~in_keystate >> 16; - if (in_type2 == PSE_PAD_TYPE_ANALOGPAD) { + if (in_type2 == PSE_PAD_TYPE_ANALOGPAD || in_type2 == PSE_PAD_TYPE_NEGCON) { pad->leftJoyX = in_a3[0]; pad->leftJoyY = in_a3[1]; pad->rightJoyX = in_a4[0]; diff --git a/plugins/dfinput/main.c b/plugins/dfinput/main.c index 475ea07..f4a14fa 100644 --- a/plugins/dfinput/main.c +++ b/plugins/dfinput/main.c @@ -15,6 +15,9 @@ #include #endif +#include +#include + #include "main.h" unsigned char CurPad, CurByte, CurCmd, CmdLen; @@ -44,6 +47,7 @@ static int old_controller_type1 = -1, old_controller_type2 = -1; PAD##n##_poll = PADpoll_guncon; \ guncon_init(); \ break; \ + case PSE_PAD_TYPE_NEGCON: \ case PSE_PAD_TYPE_GUN: \ default: \ PAD##n##_startPoll = PAD##n##__startPoll; \ @@ -52,9 +56,16 @@ static int old_controller_type1 = -1, old_controller_type2 = -1; } \ } +// case PSE_PAD_TYPE_NEGCON: \ +// PAD##n##_startPoll = PADstartPoll_negcon; \ +// PAD##n##_poll = PADpoll_negcon; \ +// negcon_init(); \ +// break; \ + void dfinput_activate(void) { PadDataS pad; + int i; PAD1_readPort1(&pad); select_pad(1); -- cgit v1.2.3 From b1c2fa8ffcf66a37aa7e5bf2704689018c2fb533 Mon Sep 17 00:00:00 2001 From: phaseIV Date: Tue, 17 Nov 2015 10:27:27 +0100 Subject: fix for buttons I and II values --- frontend/libretro.c | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 9bada99..e73135b 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -1257,30 +1257,54 @@ void retro_run(void) if (in_type1 == PSE_PAD_TYPE_NEGCON) { - in_a1[0] = 0; - - if(input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, 12)) // left brake + /* left brake */ + if(input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, 12)) in_a1[1] = 255; else in_a1[1] = 0; - - in_a2[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; //steer - in_a2[1] = 255 - ((input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128); //thrust + /* steer */ + in_a2[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; + + /* thrust and fire */ + val = ((input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 127)); + if(val < -2) { + in_a1[0] = 256 - val; + } + if (val > 2) { + in_a2[1] = val; + } + if(val >= -2 && val <= 2) + { + in_a2[1] = 0; + in_a1[0] = 0; + } } if (in_type2 == PSE_PAD_TYPE_NEGCON) { - in_a3[0] = 0; - - if(input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, 12)) // left brake + /* left brake */ + if(input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, 12)) in_a3[1] = 255; else in_a3[1] = 0; - - in_a4[0] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; //steer - in_a4[1] = 255 - ((input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128); //thrust + /* steer */ + in_a4[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; + + /* thrust and fire */ + val = ((input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 127)); + if(val < -2) { + in_a3[0] = 256 - val; + } + if (val > 2) { + in_a4[1] = val; + } + if(val >= -2 && val <= 2) + { + in_a4[1] = 0; + in_a3[0] = 0; + } } -- cgit v1.2.3 From f730f194726374a7f9bccc030632635d5d4a8c83 Mon Sep 17 00:00:00 2001 From: phaseIV Date: Tue, 17 Nov 2015 10:46:43 +0100 Subject: fixed compile error and player2 support --- frontend/libretro.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index e73135b..aaeb624 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -1220,7 +1220,7 @@ static void update_variables(bool in_flight) void retro_run(void) { - int i; + int i, val; input_poll_cb(); @@ -1284,16 +1284,16 @@ void retro_run(void) if (in_type2 == PSE_PAD_TYPE_NEGCON) { /* left brake */ - if(input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, 12)) + if(input_state_cb(1, RETRO_DEVICE_JOYPAD, 0, 12)) in_a3[1] = 255; else in_a3[1] = 0; /* steer */ - in_a4[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; + in_a4[0] = (input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128; /* thrust and fire */ - val = ((input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 127)); + val = ((input_state_cb(1, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 127)); if(val < -2) { in_a3[0] = 256 - val; } -- cgit v1.2.3 From 2cab5787882abef4508e5b45d18dae79a041c298 Mon Sep 17 00:00:00 2001 From: phaseIV Date: Tue, 17 Nov 2015 11:10:18 +0100 Subject: cleanup --- plugins/dfinput/main.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/plugins/dfinput/main.c b/plugins/dfinput/main.c index f4a14fa..c3adedd 100644 --- a/plugins/dfinput/main.c +++ b/plugins/dfinput/main.c @@ -15,9 +15,6 @@ #include #endif -#include -#include - #include "main.h" unsigned char CurPad, CurByte, CurCmd, CmdLen; @@ -56,16 +53,10 @@ static int old_controller_type1 = -1, old_controller_type2 = -1; } \ } -// case PSE_PAD_TYPE_NEGCON: \ -// PAD##n##_startPoll = PADstartPoll_negcon; \ -// PAD##n##_poll = PADpoll_negcon; \ -// negcon_init(); \ -// break; \ void dfinput_activate(void) { PadDataS pad; - int i; PAD1_readPort1(&pad); select_pad(1); -- cgit v1.2.3