Skip to content

Commit fcded62

Browse files
committed
Remote RetroPad:
- Show pointer in all screens - Add pointer idle timer - Remove sleep from retro_run
1 parent d18adfd commit fcded62

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

cores/libretro-net-retropad/net_retropad_core.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#define NETRETROPAD_SCREEN_KEYBOARD 1
6262
#define NETRETROPAD_SCREEN_SENSORS 2
6363
#define EVENT_RATE 60
64+
#define POINTER_IDLE_MAX EVENT_RATE*2
6465
#define NETRETROPAD_MOUSE 3
6566
#define NETRETROPAD_POINTER 4
6667
#define NETRETROPAD_LIGHTGUN 5
@@ -101,6 +102,7 @@ static int pointer_y = 0;
101102
static unsigned pointer_prev_x = 0;
102103
static unsigned pointer_prev_y = 0;
103104
static unsigned pointer_prev_color = 0;
105+
static unsigned pointer_idle = 0;
104106

105107
static int s;
106108
static int port;
@@ -536,7 +538,6 @@ void NETRETROPAD_CORE_PREFIX(retro_init)(void)
536538

537539
NETRETROPAD_CORE_PREFIX(log_cb)(RETRO_LOG_INFO, "Initialising sockets...\n");
538540
network_init();
539-
540541
}
541542

542543
void NETRETROPAD_CORE_PREFIX(retro_deinit)(void)
@@ -833,6 +834,7 @@ static void netretropad_check_variables(void)
833834
|| (current_screen == NETRETROPAD_SCREEN_KEYBOARD && strstr(screen_var.value,"Keyboard"))
834835
|| (current_screen == NETRETROPAD_SCREEN_SENSORS && strstr(screen_var.value,"Sensor"))))
835836
flip_screen();
837+
836838
if (hide_a_var.value && strstr(hide_a_var.value,"True"))
837839
hide_analog_mismatch = true;
838840
else
@@ -1350,8 +1352,6 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)
13501352
}
13511353
else if (current_screen == NETRETROPAD_SCREEN_SENSORS)
13521354
{
1353-
unsigned pointer_x_coord = get_pixel_coordinate(pointer_x, 320);
1354-
unsigned pointer_y_coord = get_pixel_coordinate(pointer_y, 240);
13551355

13561356
for (rle = 0; rle < ARRAY_SIZE(sensor_buttons); )
13571357
{
@@ -1381,18 +1381,30 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)
13811381

13821382
pixel += 65;
13831383
}
1384+
}
1385+
1386+
if (mouse_type)
1387+
{
1388+
unsigned pointer_x_coord = get_pixel_coordinate(pointer_x, 320);
1389+
unsigned pointer_y_coord = get_pixel_coordinate(pointer_y, 240);
13841390

1385-
if(pointer_x_coord != pointer_prev_x || pointer_y_coord != pointer_prev_y)
1391+
set_pixel(pointer_prev_x, pointer_prev_y, pointer_prev_color);
1392+
1393+
if (pointer_x_coord != pointer_prev_x || pointer_y_coord != pointer_prev_y)
13861394
{
1387-
set_pixel(pointer_prev_x, pointer_prev_y, pointer_prev_color);
1388-
pointer_prev_color = set_pixel(pointer_x_coord, pointer_y_coord, 0xffff);
1395+
pointer_prev_color = set_pixel(pointer_x_coord, pointer_y_coord, 0xbff7);
13891396
pointer_prev_x = pointer_x_coord;
13901397
pointer_prev_y = pointer_y_coord;
1398+
pointer_idle = 0;
1399+
}
1400+
else if (pointer_idle <= POINTER_IDLE_MAX)
1401+
{
1402+
pointer_prev_color = set_pixel(pointer_x_coord, pointer_y_coord, (pointer_idle > POINTER_IDLE_MAX / 2) ? 0xA000 : 0xbff7);
1403+
pointer_idle++;
13911404
}
13921405
}
13931406

13941407
NETRETROPAD_CORE_PREFIX(video_cb)(frame_buf, 320, 240, 640);
1395-
retro_sleep(4);
13961408
}
13971409

13981410
bool NETRETROPAD_CORE_PREFIX(retro_load_game)(const struct retro_game_info *info)

0 commit comments

Comments
 (0)