Analog sticks debug mode.

This commit is contained in:
Sorgelig
2026-04-29 16:40:01 +08:00
parent 798793acdc
commit adbec3e99d
3 changed files with 42 additions and 2 deletions

View File

@@ -4797,6 +4797,7 @@ int input_test(int getchar)
struct input_absinfo absinfo;
struct input_event ev;
static uint32_t timeout = 0;
static int stick_debug = 0;
if (touch_rel && CheckTimer(touch_rel))
{
@@ -5372,6 +5373,15 @@ int input_test(int getchar)
if (ioctl(pool[i].fd, EVIOCGABS(ev.code), &absinfo) < 0) memset(&absinfo, 0, sizeof(absinfo));
else
{
if (stick_debug & 4)
{
static int x = 0, y = 0;
if (ev.code == 0 || ev.code == 3 || ev.code == 2) x = (255 * (ev.value - absinfo.minimum)) / (absinfo.maximum - absinfo.minimum);
if (ev.code == 1 || ev.code == 4 || ev.code == 5) y = (255 * (ev.value - absinfo.minimum)) / (absinfo.maximum - absinfo.minimum);
dbg_draw_cursor(x, y);
if (ev.code <= 5) return 0;
}
//DS4 specific: touchpad as lightgun
if (input[i].quirk == QUIRK_DS4TOUCH && ev.code <= 1)
{
@@ -5546,6 +5556,13 @@ int input_test(int getchar)
//keyboard, buttons
case EV_KEY:
printf("%04x:%04x:%02d P%d Input event: type=EV_KEY, code=%d(0x%x), value=%d\n", input[dev].vid, input[dev].pid, i, input[dev].num, ev.code, ev.code, ev.value);
if (ev.code == 0x13d || ev.code == 0x13e || ev.code == 0x138 || ev.code == 0x139)
{
int mask = 1 << (ev.code & 1);
if (!ev.value) stick_debug &= ~mask;
else stick_debug |= mask;
if ((stick_debug & 3) == 3) stick_debug ^= 4;
}
break;
case EV_REL:

View File

@@ -3564,6 +3564,9 @@ static Imlib_Image load_bg()
return NULL;
}
static Imlib_Image *bg = 0;
static Imlib_Image menubg = 0;
static int bg_has_picture = 0;
extern uint8_t _binary_logo_png_start[], _binary_logo_png_end[];
void video_menu_bg(int n, int idle)
@@ -3613,14 +3616,13 @@ void video_menu_bg(int n, int idle)
menu_bgn = (menu_bgn == 1) ? 2 : 1;
static Imlib_Image menubg = 0;
static Imlib_Image bg1 = 0, bg2 = 0;
if (!bg1) bg1 = imlib_create_image_using_data(fb_width, fb_height, (uint32_t*)(fb_base + (FB_SIZE * 1)));
if (!bg1) printf("Warning: bg1 is 0\n");
if (!bg2) bg2 = imlib_create_image_using_data(fb_width, fb_height, (uint32_t*)(fb_base + (FB_SIZE * 2)));
if (!bg2) printf("Warning: bg2 is 0\n");
Imlib_Image *bg = (menu_bgn == 1) ? &bg1 : &bg2;
bg = (menu_bgn == 1) ? &bg1 : &bg2;
//printf("*bg = %p\n", *bg);
static Imlib_Image curtain = 0;
@@ -3774,6 +3776,25 @@ void video_menu_bg(int n, int idle)
video_fb_enable(0);
}
void dbg_draw_cursor(int x, int y)
{
static int c = 0;
if (menubg)
{
imlib_context_set_image(*bg);
int src_w = imlib_image_get_width();
int src_h = imlib_image_get_height();
x = (((src_w - 20)*x) / 255) + 10;
y = (((src_h - 20)*y) / 255) + 10;
c = (c + 1) % 3;
imlib_context_set_color(c == 0 ? 255 : 0, c == 1 ? 255 : 0, c == 2 ? 255 : 0, 255);
imlib_image_fill_ellipse(x, y, 10, 10);
}
}
int video_bg_has_picture()
{
return bg_has_picture;

View File

@@ -74,4 +74,6 @@ void video_core_description(char *str, size_t len);
void video_scaler_description(char *str, size_t len);
char* video_get_core_mode_name(int with_vrefresh = 1);
void dbg_draw_cursor(int x, int y);
#endif // VIDEO_H