Skip to content

Commit 2db412a

Browse files
committed
switch over to libretro input code
too much trouble with 2 separate codebases
1 parent 1351a8f commit 2db412a

18 files changed

+1343
-1436
lines changed

Makefile

-3
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,6 @@ libchdr/src/%.o: CFLAGS += -Wno-unused -Ilibchdr/deps/lzma-19.00/include
174174
libchdr/deps/lzma-19.00/src/%.o: CFLAGS += -Wno-unused -D_7ZIP_ST -Ilibchdr/deps/lzma-19.00/include
175175
#endif
176176

177-
# dfinput
178-
OBJS += plugins/dfinput/main.o plugins/dfinput/pad.o plugins/dfinput/guncon.o
179-
180177
# frontend/gui
181178
OBJS += frontend/cspace.o
182179
ifeq "$(HAVE_NEON_ASM)" "1"

frontend/libretro.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "../libpcsxcore/r3000a.h"
3030
#include "../plugins/dfsound/out.h"
3131
#include "../plugins/dfsound/spu_config.h"
32-
#include "../plugins/dfinput/externals.h"
3332
#include "cspace.h"
3433
#include "main.h"
3534
#include "menu.h"
@@ -514,7 +513,7 @@ void plat_trigger_vibrate(int pad, int low, int high)
514513
}
515514
}
516515

517-
void pl_update_gun(int *xn, int *yn, int *xres, int *yres, int *in)
516+
void pl_gun_byte2(int port, unsigned char byte)
518517
{
519518
}
520519

@@ -2468,17 +2467,19 @@ static void update_input_guncon(int port, int ret)
24682467
//Mouse range is -32767 -> 32767
24692468
//1% is about 655
24702469
//Use the left analog stick field to store the absolute coordinates
2471-
//Fix cursor to top-left when gun is detected as "offscreen"
2470+
2471+
int gunx = input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X);
2472+
int guny = input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y);
2473+
2474+
//Have the Libretro API let /libpcsxcore/plugins.c know when the lightgun is pointed offscreen
2475+
//Offscreen value is chosen to be well out of range of any possible scaling done via core options
24722476
if (input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN) || input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD))
24732477
{
2474-
in_analog_left[port][0] = -32767;
2475-
in_analog_left[port][1] = -32767;
2478+
in_analog_left[port][0] = (65536 - 512) * 64;
2479+
in_analog_left[port][1] = (65536 - 512) * 64;
24762480
}
24772481
else
24782482
{
2479-
int gunx = input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X);
2480-
int guny = input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y);
2481-
24822483
in_analog_left[port][0] = (gunx * GunconAdjustRatioX) + (GunconAdjustX * 655);
24832484
in_analog_left[port][1] = (guny * GunconAdjustRatioY) + (GunconAdjustY * 655);
24842485
}

frontend/menu.c

-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include "../libpcsxcore/cdriso.h"
3737
#include "../libpcsxcore/cheat.h"
3838
#include "../libpcsxcore/new_dynarec/new_dynarec.h"
39-
#include "../plugins/dfinput/externals.h"
4039
#include "../plugins/dfsound/spu_config.h"
4140
#include "psemu_plugin_defs.h"
4241
#include "arm_features.h"
@@ -2696,8 +2695,6 @@ void menu_prepare_emu(void)
26962695
if (ret)
26972696
fprintf(stderr, "Warning: GPU_open returned %d\n", ret);
26982697
}
2699-
2700-
dfinput_activate();
27012698
}
27022699

27032700
void menu_update_msg(const char *msg)

frontend/pl_gun_ts.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
#include "plugin_lib.h"
1616
#include "pl_gun_ts.h"
1717
#include "menu.h"
18-
#include "../plugins/dfinput/externals.h"
19-
#include "../plugins/dfinput/main.h"
2018

2119
#ifdef MAEMO
2220
#define N900_TSMAX_X 4096
@@ -57,9 +55,9 @@ int pl_gun_ts_update_raw(struct tsdev *ts, int *x, int *y, int *p)
5755
limit(gun_x, 0, 1023);
5856
limit(gun_y, 0, 1023);
5957
if (sp && !(g_opts & OPT_TSGUN_NOTRIGGER))
60-
gun_in |= GUNIN_TRIGGER;
58+
gun_in |= 1;
6159
else
62-
gun_in &= ~GUNIN_TRIGGER;
60+
gun_in &= ~1;
6361
}
6462
}
6563

frontend/plugin.c

+55-13
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,65 @@ static long CALLBACK PADshutdown(void) { return 0; }
6868
static long CALLBACK PADclose(void) { return 0; }
6969
static void CALLBACK PADsetSensitive(int _) { return; }
7070

71-
static long CALLBACK PADreadPort1(PadDataS *pad)
72-
{
73-
pad->controllerType = in_type[0];
74-
pad->buttonStatus = ~in_keystate[0];
75-
if (in_type[0] == PSE_PAD_TYPE_ANALOGPAD) {
76-
pad->leftJoyX = in_analog_left[0][0];
77-
pad->leftJoyY = in_analog_left[0][1];
78-
pad->rightJoyX = in_analog_right[0][0];
79-
pad->rightJoyY = in_analog_right[0][1];
71+
static long CALLBACK PADreadPort1(PadDataS *pad) {
72+
int pad_index = pad->requestPadIndex;
73+
74+
pad->controllerType = in_type[pad_index];
75+
pad->buttonStatus = ~in_keystate[pad_index];
76+
77+
if (multitap1 == 1)
78+
pad->portMultitap = 1;
79+
else
80+
pad->portMultitap = 0;
81+
82+
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)
83+
{
84+
pad->leftJoyX = in_analog_left[pad_index][0];
85+
pad->leftJoyY = in_analog_left[pad_index][1];
86+
pad->rightJoyX = in_analog_right[pad_index][0];
87+
pad->rightJoyY = in_analog_right[pad_index][1];
88+
89+
pad->absoluteX = in_analog_left[pad_index][0];
90+
pad->absoluteY = in_analog_left[pad_index][1];
91+
}
92+
93+
if (in_type[pad_index] == PSE_PAD_TYPE_MOUSE)
94+
{
95+
pad->moveX = in_mouse[pad_index][0];
96+
pad->moveY = in_mouse[pad_index][1];
8097
}
98+
8199
return 0;
82100
}
83101

84-
static long CALLBACK PADreadPort2(PadDataS *pad)
85-
{
86-
pad->controllerType = in_type[1];
87-
pad->buttonStatus = ~in_keystate[0] >> 16;
102+
static long CALLBACK PADreadPort2(PadDataS *pad) {
103+
int pad_index = pad->requestPadIndex;
104+
105+
pad->controllerType = in_type[pad_index];
106+
pad->buttonStatus = ~in_keystate[pad_index];
107+
108+
if (multitap2 == 1)
109+
pad->portMultitap = 2;
110+
else
111+
pad->portMultitap = 0;
112+
113+
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)
114+
{
115+
pad->leftJoyX = in_analog_left[pad_index][0];
116+
pad->leftJoyY = in_analog_left[pad_index][1];
117+
pad->rightJoyX = in_analog_right[pad_index][0];
118+
pad->rightJoyY = in_analog_right[pad_index][1];
119+
120+
pad->absoluteX = in_analog_left[pad_index][0];
121+
pad->absoluteY = in_analog_left[pad_index][1];
122+
}
123+
124+
if (in_type[pad_index] == PSE_PAD_TYPE_MOUSE)
125+
{
126+
pad->moveX = in_mouse[pad_index][0];
127+
pad->moveY = in_mouse[pad_index][1];
128+
}
129+
88130
return 0;
89131
}
90132

frontend/plugin_lib.c

+6-7
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "psemu_plugin_defs.h"
3434
#include "../libpcsxcore/new_dynarec/new_dynarec.h"
3535
#include "../libpcsxcore/psxmem_map.h"
36-
#include "../plugins/dfinput/externals.h"
3736

3837
#define HUD_HEIGHT 10
3938

@@ -620,18 +619,18 @@ static void update_input(void)
620619
emu_set_action(emu_act);
621620

622621
in_keystate[0] = actions[IN_BINDTYPE_PLAYER12];
622+
623+
// fixme
624+
//if (in_type[0] == PSE_PAD_TYPE_GUNCON && tsdev)
625+
// pl_gun_ts_update(tsdev, xn, yn, in);
626+
// in_analog_left[0][0] = xn
623627
}
624628
#else /* MAEMO */
625629
extern void update_input(void);
626630
#endif
627631

628-
void pl_update_gun(int *xn, int *yn, int *xres, int *yres, int *in)
632+
void pl_gun_byte2(int port, unsigned char byte)
629633
{
630-
if (tsdev)
631-
pl_gun_ts_update(tsdev, xn, yn, in);
632-
633-
*xres = psx_w;
634-
*yres = psx_h;
635634
}
636635

637636
#define MAX_LAG_FRAMES 3

include/psemu_plugin_defs.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ typedef struct
141141
long PADquery(void);
142142
143143
unsigned char PADstartPoll(int);
144-
unsigned char PADpoll(unsigned char);
144+
unsigned char PADpoll(unsigned char, int *);
145145
146146
*/
147147

@@ -222,7 +222,9 @@ typedef struct
222222

223223
//configuration mode Request 0x43
224224
int configMode;
225-
unsigned char reserved[87];
225+
226+
unsigned char txData[32];
227+
unsigned char reserved[56];
226228

227229
//Lightgun values
228230
int absoluteX,absoluteY;

0 commit comments

Comments
 (0)