core+platforms, revise pico pen handling

the MSB in the tablet position register denotes pen on surface.
add logic and a hotkey for handling pen not on surface. This allows
for repositioning of the pen without the storyware reacting to it.
This commit is contained in:
kub 2024-03-17 10:44:57 +01:00
parent 9f29605f55
commit c87e36d750
12 changed files with 127 additions and 70 deletions

View file

@ -1050,10 +1050,9 @@ void run_events_pico(unsigned int events)
switch (pico_inp_mode) {
case 2: emu_status_msg("Input: Pen on Pad"); break;
case 1: emu_status_msg("Input: Pen on Storyware"); break;
case 0: emu_status_msg("Input: Joystick");
PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;
break;
case 0: emu_status_msg("Input: Joystick"); break;
}
PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;
}
if (events & PEV_PICO_PPREV) {
PicoPicohw.page--;
@ -1067,10 +1066,15 @@ void run_events_pico(unsigned int events)
PicoPicohw.page = 6;
emu_status_msg("Page %i", PicoPicohw.page);
}
if (events & PEV_PICO_PEN) {
if (events & PEV_PICO_SHPEN) {
currentConfig.EmuOpt ^= EOPT_PICO_PEN;
emu_status_msg("%s Pen", currentConfig.EmuOpt & EOPT_PICO_PEN ? "Show" : "Hide");
}
if (events & PEV_PICO_PPOSV) {
PicoPicohw.pen_pos[0] ^= 0x8000;
PicoPicohw.pen_pos[1] ^= 0x8000;
emu_status_msg("Pen %s", PicoPicohw.pen_pos[0] & 0x8000 ? "Up" : "Down");
}
if (pico_inp_mode == 0)
return;
@ -1084,15 +1088,17 @@ void run_events_pico(unsigned int events)
if (pico_pen_y < PICO_PEN_ADJUST_Y)
pico_pen_y = PICO_PEN_ADJUST_Y;
if (pico_pen_y > 224 - PICO_PEN_ADJUST_Y)
pico_pen_y = 224 - PICO_PEN_ADJUST_Y;
if (pico_pen_y > 224-1 - PICO_PEN_ADJUST_Y)
pico_pen_y = 224-1 - PICO_PEN_ADJUST_Y;
if (pico_pen_x < PICO_PEN_ADJUST_X)
pico_pen_x = PICO_PEN_ADJUST_X;
if (pico_pen_x > 320 - PICO_PEN_ADJUST_X)
pico_pen_x = 320 - PICO_PEN_ADJUST_X;
if (pico_pen_x > 320-1 - PICO_PEN_ADJUST_X)
pico_pen_x = 320-1 - PICO_PEN_ADJUST_X;
PicoPicohw.pen_pos[0] = 0x03c + pico_pen_x;
PicoPicohw.pen_pos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y);
PicoPicohw.pen_pos[0] &= 0x8000;
PicoPicohw.pen_pos[1] &= 0x8000;
PicoPicohw.pen_pos[0] |= 0x03c + pico_pen_x;
PicoPicohw.pen_pos[1] |= (pico_inp_mode == 1 ? 0x2f8 : 0x1fc) + pico_pen_y;
}
static void do_turbo(unsigned short *pad, int acts)

View file

@ -107,8 +107,8 @@ extern unsigned char *movie_data;
extern int reset_timing;
extern int flip_after_sync;
#define PICO_PEN_ADJUST_X 2
#define PICO_PEN_ADJUST_Y 2
#define PICO_PEN_ADJUST_X 1
#define PICO_PEN_ADJUST_Y 1
extern int pico_pen_x, pico_pen_y;
extern int pico_inp_mode;

View file

@ -28,8 +28,9 @@
#define PEVB_PICO_PNEXT 21
#define PEVB_PICO_PPREV 20
#define PEVB_PICO_SWINP 19
#define PEVB_PICO_PEN 18
#define PEVB_RESET 17
#define PEVB_PICO_SHPEN 18
#define PEVB_PICO_PPOSV 17
#define PEVB_RESET 16
#define PEV_VOL_DOWN (1 << PEVB_VOL_DOWN)
#define PEV_VOL_UP (1 << PEVB_VOL_UP)
@ -43,9 +44,10 @@
#define PEV_PICO_PNEXT (1 << PEVB_PICO_PNEXT)
#define PEV_PICO_PPREV (1 << PEVB_PICO_PPREV)
#define PEV_PICO_SWINP (1 << PEVB_PICO_SWINP)
#define PEV_PICO_PEN (1 << PEVB_PICO_PEN)
#define PEV_PICO_SHPEN (1 << PEVB_PICO_SHPEN)
#define PEV_PICO_PPOSV (1 << PEVB_PICO_PPOSV)
#define PEV_RESET (1 << PEVB_RESET)
#define PEV_MASK 0x7ffe0000
#define PEV_MASK 0x7fff0000
#endif /* INCLUDE_c48097f3ff2a6a9af1cce8fd7a9b3f0c */

View file

@ -30,7 +30,8 @@ const struct in_default_bind in_sdl_defbinds[] = {
{ SDLK_F6, IN_BINDTYPE_EMU, PEVB_PICO_PPREV },
{ SDLK_F7, IN_BINDTYPE_EMU, PEVB_PICO_PNEXT },
{ SDLK_F8, IN_BINDTYPE_EMU, PEVB_PICO_SWINP },
{ SDLK_F9, IN_BINDTYPE_EMU, PEVB_PICO_PEN },
{ SDLK_F9, IN_BINDTYPE_EMU, PEVB_PICO_SHPEN },
{ SDLK_F10, IN_BINDTYPE_EMU, PEVB_PICO_PPOSV },
{ SDLK_BACKSPACE, IN_BINDTYPE_EMU, PEVB_FF },
{ 0, 0, 0 }
};

View file

@ -362,7 +362,8 @@ me_bind_action emuctrl_actions[] =
{ "Pico Next page ", PEV_PICO_PNEXT },
{ "Pico Prev page ", PEV_PICO_PPREV },
{ "Pico Switch input", PEV_PICO_SWINP },
{ "Pico Display pen ", PEV_PICO_PEN },
{ "Pico Pen sensor ", PEV_PICO_PPOSV },
{ "Pico Show pen ", PEV_PICO_SHPEN },
{ NULL, 0 }
};