From 1b591888c4aec568da64ea2897e9ad8bbf33cea1 Mon Sep 17 00:00:00 2001 From: notaz Date: Wed, 6 Sep 2023 23:47:23 +0300 Subject: [PATCH] some lightgun selection mechanism --- frontend/libretro.c | 4 ++++ frontend/plugin_lib.c | 4 ++++ include/psemu_plugin_defs.h | 4 +++- libpcsxcore/plugins.c | 8 ++++++++ plugins/dfinput/externals.h | 1 + 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 32d27f5d..b64c3cae 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -518,6 +518,10 @@ void pl_update_gun(int *xn, int *yn, int *xres, int *yres, int *in) { } +void pl_gun_byte2(int port, unsigned char byte) +{ +} + /* sound calls */ static void snd_feed(void *buf, int bytes) { diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c index bdf09c71..2a417a4d 100644 --- a/frontend/plugin_lib.c +++ b/frontend/plugin_lib.c @@ -634,6 +634,10 @@ void pl_update_gun(int *xn, int *yn, int *xres, int *yres, int *in) *yres = psx_h; } +void pl_gun_byte2(int port, unsigned char byte) +{ +} + #define MAX_LAG_FRAMES 3 #define tvdiff(tv, tv_old) \ diff --git a/include/psemu_plugin_defs.h b/include/psemu_plugin_defs.h index b855eacc..8645eab7 100644 --- a/include/psemu_plugin_defs.h +++ b/include/psemu_plugin_defs.h @@ -222,7 +222,9 @@ typedef struct //configuration mode Request 0x43 int configMode; - unsigned char reserved[87]; + + unsigned char txData[32]; + unsigned char reserved[56]; //Lightgun values int absoluteX,absoluteY; diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index 6886a6a0..4516b5ce 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -745,10 +745,18 @@ unsigned char _PADpoll(int port, unsigned char value) { } } + if (reqPos < sizeof(pad[port].txData)) + pad[port].txData[reqPos] = value; + //if no new request the pad return 0xff, for signaling connected if (reqPos >= respSize) return 0xff; + if (in_type[port] == PSE_PAD_TYPE_GUN) { + if (reqPos == 2) + pl_gun_byte2(port, value); + } + else switch(reqPos){ case 2: reqIndex2Treatment(port, value); diff --git a/plugins/dfinput/externals.h b/plugins/dfinput/externals.h index 2e216fdc..822fa2c5 100644 --- a/plugins/dfinput/externals.h +++ b/plugins/dfinput/externals.h @@ -10,6 +10,7 @@ void dfinput_activate(void); #define GUNIN_BTNB (1<<2) #define GUNIN_TRIGGER2 (1<<3) /* offscreen trigger */ extern void pl_update_gun(int *xn, int *yn, int *xres, int *yres, int *in); +extern void pl_gun_byte2(int port, unsigned char byte); /* vibration trigger to frontend */ extern int in_enable_vibration; -- 2.39.2