aboutsummaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authorAutechre2020-06-07 14:23:46 +0200
committerGitHub2020-06-07 14:23:46 +0200
commitba5205015c1db5866b6979537c594d8e81f90500 (patch)
treefbf1653225e1f0427a60e74c6c29927623289ee6 /frontend
parent7eafdc948efb45d0d2b8a03bdbf560786669b1c4 (diff)
parent7dea987c9689c441d8148b9523871f3fbbca2804 (diff)
downloadpcsx_rearmed-ba5205015c1db5866b6979537c594d8e81f90500.tar.gz
pcsx_rearmed-ba5205015c1db5866b6979537c594d8e81f90500.tar.bz2
pcsx_rearmed-ba5205015c1db5866b6979537c594d8e81f90500.zip
Merge pull request #428 from negativeExponent/libretro
Add Sony Mouse Controller support
Diffstat (limited to 'frontend')
-rw-r--r--frontend/libretro.c36
-rw-r--r--frontend/libretro_core_options.h8
-rw-r--r--frontend/libretro_core_options_intl.h16
-rw-r--r--frontend/plugin.c91
-rw-r--r--frontend/plugin_lib.h1
5 files changed, 115 insertions, 37 deletions
diff --git a/frontend/libretro.c b/frontend/libretro.c
index d489ce5..a91c5c1 100644
--- a/frontend/libretro.c
+++ b/frontend/libretro.c
@@ -112,6 +112,7 @@ int in_type[8] = {
int in_analog_left[8][2] = { { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 } };
int in_analog_right[8][2] = { { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 }, { 127, 127 } };
unsigned short in_keystate[PORTS_NUMBER];
+int in_mouse[8][2];
int multitap1 = 0;
int multitap2 = 0;
int in_enable_vibration = 1;
@@ -595,6 +596,8 @@ static void update_controller_port_variable(unsigned port)
in_type[port] = PSE_PAD_TYPE_NEGCON;
else if (strcmp(var.value, "guncon") == 0)
in_type[port] = PSE_PAD_TYPE_GUNCON;
+ else if (strcmp(var.value, "mouse") == 0)
+ in_type[port] = PSE_PAD_TYPE_MOUSE;
else if (strcmp(var.value, "none") == 0)
in_type[port] = PSE_PAD_TYPE_NONE;
// else 'default' case, do nothing
@@ -2428,6 +2431,39 @@ static void update_input(void)
case PSE_PAD_TYPE_NEGCON:
update_input_negcon(i, ret);
break;
+ case PSE_PAD_TYPE_MOUSE:
+ {
+ /* mouse x/y movement, range -128 to +127 */
+ float accum_x = 0, accum_y = 0;
+
+ float x = input_state_cb(i, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
+ float y = input_state_cb(i, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y);
+
+ accum_x += x;
+ accum_y += y;
+
+ if (accum_x > 127)
+ accum_x = 127;
+ else if (accum_x < -128)
+ accum_x = -128;
+
+ if (accum_y > 127)
+ accum_y = 127;
+ else if (accum_y < -128)
+ accum_y = -128;
+
+ in_mouse[i][0] = (int)accum_x;
+ in_mouse[i][1] = (int)accum_y;
+
+ /* mouse button state */
+ if (input_state_cb(i, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT))
+ in_keystate[i] |= 1 << 11;
+
+ if (input_state_cb(i, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT))
+ in_keystate[i] |= 1 << 10;
+
+ break;
+ }
default:
// Query digital inputs
for (j = 0; j < RETRO_PSX_MAP_LEN; j++)
diff --git a/frontend/libretro_core_options.h b/frontend/libretro_core_options.h
index cab6a9a..46670ba 100644
--- a/frontend/libretro_core_options.h
+++ b/frontend/libretro_core_options.h
@@ -118,6 +118,7 @@ struct retro_core_option_definition option_defs_us[] = {
{ "dualshock", NULL },
{ "negcon", NULL },
{ "guncon", NULL },
+ { "mouse", NULL },
{ "none", NULL },
{ NULL, NULL },
},
@@ -133,6 +134,7 @@ struct retro_core_option_definition option_defs_us[] = {
{ "dualshock", NULL },
{ "negcon", NULL },
{ "guncon", NULL },
+ { "mouse", NULL },
{ "none", NULL },
{ NULL, NULL },
},
@@ -148,6 +150,7 @@ struct retro_core_option_definition option_defs_us[] = {
{ "dualshock", NULL },
{ "negcon", NULL },
{ "guncon", NULL },
+ { "mouse", NULL },
{ "none", NULL },
{ NULL, NULL },
},
@@ -163,6 +166,7 @@ struct retro_core_option_definition option_defs_us[] = {
{ "dualshock", NULL },
{ "negcon", NULL },
{ "guncon", NULL },
+ { "mouse", NULL },
{ "none", NULL },
{ NULL, NULL },
},
@@ -178,6 +182,7 @@ struct retro_core_option_definition option_defs_us[] = {
{ "dualshock", NULL },
{ "negcon", NULL },
{ "guncon", NULL },
+ { "mouse", NULL },
{ "none", NULL },
{ NULL, NULL },
},
@@ -192,6 +197,7 @@ struct retro_core_option_definition option_defs_us[] = {
{ "dualshock", NULL },
{ "negcon", NULL },
{ "guncon", NULL },
+ { "mouse", NULL },
{ "none", NULL },
{ NULL, NULL },
},
@@ -206,6 +212,7 @@ struct retro_core_option_definition option_defs_us[] = {
{ "dualshock", NULL },
{ "negcon", NULL },
{ "guncon", NULL },
+ { "mouse", NULL },
{ "none", NULL },
{ NULL, NULL },
},
@@ -220,6 +227,7 @@ struct retro_core_option_definition option_defs_us[] = {
{ "dualshock", NULL },
{ "negcon", NULL },
{ "guncon", NULL },
+ { "mouse", NULL },
{ "none", NULL },
{ NULL, NULL },
},
diff --git a/frontend/libretro_core_options_intl.h b/frontend/libretro_core_options_intl.h
index 107cd57..1e7fd79 100644
--- a/frontend/libretro_core_options_intl.h
+++ b/frontend/libretro_core_options_intl.h
@@ -124,6 +124,8 @@ struct retro_core_option_definition option_defs_tr[] = {
{ "analog", NULL },
{ "dualshock", NULL },
{ "negcon", NULL },
+ { "guncon", NULL },
+ { "mouse", NULL },
{ "none", "hiçbiri" },
{ NULL, NULL },
},
@@ -138,6 +140,8 @@ struct retro_core_option_definition option_defs_tr[] = {
{ "analog", NULL },
{ "dualshock", NULL },
{ "negcon", NULL },
+ { "guncon", NULL },
+ { "mouse", NULL },
{ "none", "hiçbiri" },
{ NULL, NULL },
},
@@ -152,6 +156,8 @@ struct retro_core_option_definition option_defs_tr[] = {
{ "analog", NULL },
{ "dualshock", NULL },
{ "negcon", NULL },
+ { "guncon", NULL },
+ { "mouse", NULL },
{ "none", "hiçbiri" },
{ NULL, NULL },
},
@@ -166,6 +172,8 @@ struct retro_core_option_definition option_defs_tr[] = {
{ "analog", NULL },
{ "dualshock", NULL },
{ "negcon", NULL },
+ { "guncon", NULL },
+ { "mouse", NULL },
{ "none", "hiçbiri" },
{ NULL, NULL },
},
@@ -180,6 +188,8 @@ struct retro_core_option_definition option_defs_tr[] = {
{ "analog", NULL },
{ "dualshock", NULL },
{ "negcon", NULL },
+ { "guncon", NULL },
+ { "mouse", NULL },
{ "none", "hiçbiri" },
{ NULL, NULL },
},
@@ -193,6 +203,8 @@ struct retro_core_option_definition option_defs_tr[] = {
{ "analog", NULL },
{ "dualshock", NULL },
{ "negcon", NULL },
+ { "guncon", NULL },
+ { "mouse", NULL },
{ "none", "hiçbiri" },
{ NULL, NULL },
},
@@ -206,6 +218,8 @@ struct retro_core_option_definition option_defs_tr[] = {
{ "analog", NULL },
{ "dualshock", NULL },
{ "negcon", NULL },
+ { "guncon", NULL },
+ { "mouse", NULL },
{ "none", "hiçbiri" },
{ NULL, NULL },
},
@@ -219,6 +233,8 @@ struct retro_core_option_definition option_defs_tr[] = {
{ "analog", NULL },
{ "dualshock", NULL },
{ "negcon", NULL },
+ { "guncon", NULL },
+ { "mouse", NULL },
{ "none", "hiçbiri" },
{ NULL, NULL },
},
diff --git a/frontend/plugin.c b/frontend/plugin.c
index 30b0e08..a617c24 100644
--- a/frontend/plugin.c
+++ b/frontend/plugin.c
@@ -51,47 +51,64 @@ extern int CALLBACK SPUplayCDDAchannel(short *, int);
/* PAD */
static long PADreadPort1(PadDataS *pad) {
int pad_index = pad->requestPadIndex;
- pad->controllerType = in_type[pad_index];
- pad->buttonStatus = ~in_keystate[pad_index];
- if (multitap1 == 1)
- pad->portMultitap = 1;
- else
- pad->portMultitap = 0;
-
- if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGJOY || in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON || in_type[pad_index] == PSE_PAD_TYPE_GUNCON)
- {
- pad->leftJoyX = in_analog_left[pad_index][0];
- pad->leftJoyY = in_analog_left[pad_index][1];
- pad->rightJoyX = in_analog_right[pad_index][0];
- pad->rightJoyY = in_analog_right[pad_index][1];
-
- pad->absoluteX = in_analog_left[pad_index][0];
- pad->absoluteY = in_analog_left[pad_index][1];
- }
- return 0;
+
+ pad->controllerType = in_type[pad_index];
+ pad->buttonStatus = ~in_keystate[pad_index];
+
+ if (multitap1 == 1)
+ pad->portMultitap = 1;
+ else
+ pad->portMultitap = 0;
+
+ if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGJOY || in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON || in_type[pad_index] == PSE_PAD_TYPE_GUNCON)
+ {
+ pad->leftJoyX = in_analog_left[pad_index][0];
+ pad->leftJoyY = in_analog_left[pad_index][1];
+ pad->rightJoyX = in_analog_right[pad_index][0];
+ pad->rightJoyY = in_analog_right[pad_index][1];
+
+ pad->absoluteX = in_analog_left[pad_index][0];
+ pad->absoluteY = in_analog_left[pad_index][1];
+ }
+
+ if (in_type[pad_index] == PSE_PAD_TYPE_MOUSE)
+ {
+ pad->moveX = in_mouse[pad_index][0];
+ pad->moveY = in_mouse[pad_index][1];
+ }
+
+ return 0;
}
static long PADreadPort2(PadDataS *pad) {
int pad_index = pad->requestPadIndex;
-
- pad->controllerType = in_type[pad_index];
- pad->buttonStatus = ~in_keystate[pad_index];
- if (multitap2 == 1)
- pad->portMultitap = 2;
- else
- pad->portMultitap = 0;
-
- if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGJOY || in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON || in_type[pad_index] == PSE_PAD_TYPE_GUNCON)
- {
- pad->leftJoyX = in_analog_left[pad_index][0];
- pad->leftJoyY = in_analog_left[pad_index][1];
- pad->rightJoyX = in_analog_right[pad_index][0];
- pad->rightJoyY = in_analog_right[pad_index][1];
-
- pad->absoluteX = in_analog_left[pad_index][0];
- pad->absoluteY = in_analog_left[pad_index][1];
- }
- return 0;
+
+ pad->controllerType = in_type[pad_index];
+ pad->buttonStatus = ~in_keystate[pad_index];
+
+ if (multitap2 == 1)
+ pad->portMultitap = 2;
+ else
+ pad->portMultitap = 0;
+
+ if (in_type[pad_index] == PSE_PAD_TYPE_ANALOGJOY || in_type[pad_index] == PSE_PAD_TYPE_ANALOGPAD || in_type[pad_index] == PSE_PAD_TYPE_NEGCON || in_type[pad_index] == PSE_PAD_TYPE_GUNCON)
+ {
+ pad->leftJoyX = in_analog_left[pad_index][0];
+ pad->leftJoyY = in_analog_left[pad_index][1];
+ pad->rightJoyX = in_analog_right[pad_index][0];
+ pad->rightJoyY = in_analog_right[pad_index][1];
+
+ pad->absoluteX = in_analog_left[pad_index][0];
+ pad->absoluteY = in_analog_left[pad_index][1];
+ }
+
+ if (in_type[pad_index] == PSE_PAD_TYPE_MOUSE)
+ {
+ pad->moveX = in_mouse[pad_index][0];
+ pad->moveY = in_mouse[pad_index][1];
+ }
+
+ return 0;
}
/* GPU */
diff --git a/frontend/plugin_lib.h b/frontend/plugin_lib.h
index d51c5e7..09cc4c5 100644
--- a/frontend/plugin_lib.h
+++ b/frontend/plugin_lib.h
@@ -24,6 +24,7 @@ extern int multitap2;
extern int in_analog_left[8][2];
extern int in_analog_right[8][2];
extern unsigned short in_keystate[8];
+extern int in_mouse[8][2];
extern int in_adev[2], in_adev_axis[2][2];
extern int in_adev_is_nublike[2];