Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Pointer confinement support (opt-in)" #17173

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions cores/libretro-net-retropad/net_retropad_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,6 @@ void NETRETROPAD_CORE_PREFIX(retro_set_environment)(retro_environment_t cb)
{ "net_retropad_screen", "Start screen; Retropad|Keyboard tester|Sensor tester" },
{ "net_retropad_hide_analog_mismatch", "Hide mismatching analog button inputs; True|False" },
{ "net_retropad_pointer_test", "Pointer test; Off|Mouse|Pointer|Lightgun|Old lightgun" },
{ "net_retropad_pointer_confine", "Pointer confinement; Off|Edge" },
{ NULL, NULL },
};
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565;
Expand All @@ -807,17 +806,15 @@ void NETRETROPAD_CORE_PREFIX(retro_set_environment)(retro_environment_t cb)

static void netretropad_check_variables(void)
{
unsigned pointer_confinement = RETRO_POINTER_CONFINEMENT_LEGACY;
struct retro_variable var, var2, var3, var4, port_var, screen_var, hide_a_var, mouse_var, confine_var;
var.key = "net_retropad_ip_octet1";
var2.key = "net_retropad_ip_octet2";
var3.key = "net_retropad_ip_octet3";
var4.key = "net_retropad_ip_octet4";
port_var.key = "net_retropad_port";
screen_var.key = "net_retropad_screen";
hide_a_var.key = "net_retropad_hide_analog_mismatch";
mouse_var.key = "net_retropad_pointer_test";
confine_var.key = "net_retropad_pointer_confine";
struct retro_variable var, var2, var3, var4, port_var, screen_var, hide_a_var, mouse_var;
var.key = "net_retropad_ip_octet1";
var2.key = "net_retropad_ip_octet2";
var3.key = "net_retropad_ip_octet3";
var4.key = "net_retropad_ip_octet4";
port_var.key = "net_retropad_port";
screen_var.key = "net_retropad_screen";
hide_a_var.key = "net_retropad_hide_analog_mismatch";
mouse_var.key = "net_retropad_pointer_test";

NETRETROPAD_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
NETRETROPAD_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &var2);
Expand All @@ -827,7 +824,6 @@ static void netretropad_check_variables(void)
NETRETROPAD_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &screen_var);
NETRETROPAD_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &hide_a_var);
NETRETROPAD_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &mouse_var);
NETRETROPAD_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_GET_VARIABLE, &confine_var);

snprintf(server, sizeof(server), "%s.%s.%s.%s", var.value, var2.value, var3.value, var4.value);
port = atoi(port_var.value);
Expand All @@ -853,9 +849,6 @@ static void netretropad_check_variables(void)
else
mouse_type = 0;

if (confine_var.value && strstr(confine_var.value,"Edge"))
pointer_confinement = RETRO_POINTER_CONFINEMENT_EDGE;
NETRETROPAD_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_SET_POINTER_CONFINEMENT, &pointer_confinement);
}

void NETRETROPAD_CORE_PREFIX(retro_set_audio_sample)(retro_audio_sample_t cb)
Expand Down
33 changes: 10 additions & 23 deletions gfx/video_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,15 +694,14 @@ bool video_driver_translate_coord_viewport(
int16_t *res_x, int16_t *res_y,
int16_t *res_screen_x, int16_t *res_screen_y)
{
runloop_state_t *runloop_st = runloop_state_get_ptr();
int norm_vp_width = (int)vp->width;
int norm_vp_height = (int)vp->height;
int norm_full_vp_width = (int)vp->full_width;
int norm_full_vp_height = (int)vp->full_height;
int scaled_screen_x = -0x8000; /* Legacy OOB */
int scaled_screen_y = -0x8000; /* Legacy OOB */
int scaled_x = -0x8000; /* Legacy OOB */
int scaled_y = -0x8000; /* Legacy OOB */
int norm_vp_width = (int)vp->width;
int norm_vp_height = (int)vp->height;
int norm_full_vp_width = (int)vp->full_width;
int norm_full_vp_height = (int)vp->full_height;
int scaled_screen_x = -0x8000; /* OOB */
int scaled_screen_y = -0x8000; /* OOB */
int scaled_x = -0x8000; /* OOB */
int scaled_y = -0x8000; /* OOB */
if ( (norm_vp_width <= 0)
|| (norm_vp_height <= 0)
|| (norm_full_vp_width <= 0)
Expand All @@ -723,24 +722,12 @@ bool video_driver_translate_coord_viewport(
if (mouse_x >= 0 && mouse_x <= norm_vp_width)
scaled_x = ((2 * mouse_x * 0x7fff)
/ norm_vp_width) - 0x7fff;
else if (runloop_st->pointer_confinement == RETRO_POINTER_CONFINEMENT_EDGE)
{
if (mouse_x < 0)
scaled_x = -0x7fff;
else
scaled_x = 0x7fff;
}
else
scaled_x = -0x8000; /* OOB */

if (mouse_y >= 0 && mouse_y <= norm_vp_height)
scaled_y = ((2 * mouse_y * 0x7fff)
/ norm_vp_height) - 0x7fff;
else if (runloop_st->pointer_confinement == RETRO_POINTER_CONFINEMENT_EDGE)
{
if (mouse_y < 0)
scaled_y = -0x7fff;
else
scaled_y = 0x7fff;
}

*res_x = scaled_x;
*res_y = scaled_y;
Expand Down
28 changes: 0 additions & 28 deletions libretro-common/include/libretro.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,6 @@ extern "C" {
#define RETRO_DEVICE_ID_POINTER_PRESSED 2
#define RETRO_DEVICE_ID_POINTER_COUNT 3

/* Values for pointer confinement */
#define RETRO_POINTER_CONFINEMENT_LEGACY 0
#define RETRO_POINTER_CONFINEMENT_EDGE 1
/** @} */

/* Returned from retro_get_region(). */
Expand Down Expand Up @@ -2572,31 +2569,6 @@ enum retro_mod
*/
#define RETRO_ENVIRONMENT_GET_FILE_BROWSER_START_DIRECTORY 80

/**
* Controls how the frontend should handle screen edges and off-screen for
* inputs returning screen coordinates (pointer and lightgun).
*
* Default behavior is that (0,0) coordinates are returned if cursor leaves
* the actual viewport, and resides on either the black padding area or
* outside the window (if there is one), but it is somewhat input driver
* dependent.
*
* Modified behavior is that coordinates will always be in the range of
* [-0x7fff,0x7fff], with the edge values meaning that cursor has left the
* viewport in that direction.
*
* @param[in] data <tt>const unsigned *</tt>.
* Pointer to a single \c unsigned that indicates the confinement method.
* Can point to a value of \c RETRO_POINTER_CONFINEMENT_LEGACY but this
* isn't necessary, pointer confinement support is opt-in.
* The behavior is not changed compared to the previous state if \c data
* is <tt>NULL</tt>.
* @returns \c true if the environment call is available.
* @see RETRO_DEVICE_POINTER
* @see RETRO_DEVICE_LIGHTGUN
*/
#define RETRO_ENVIRONMENT_SET_POINTER_CONFINEMENT 81

/**@}*/

/**
Expand Down
7 changes: 0 additions & 7 deletions runloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -3586,13 +3586,6 @@ bool runloop_environment_cb(unsigned cmd, void *data)
}
}
break;

case RETRO_ENVIRONMENT_SET_POINTER_CONFINEMENT:
if (data)
runloop_st->pointer_confinement = *(unsigned*)data;
RARCH_LOG("[Environ]: RETRO_ENVIRONMENT_SET_POINTER_CONFINEMENT: %d\n", runloop_st->pointer_confinement);
break;

default:
RARCH_LOG("[Environ]: UNSUPPORTED (#%u).\n", cmd);
return false;
Expand Down
1 change: 0 additions & 1 deletion runloop.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ struct runloop
unsigned subsystem_current_count;
unsigned entry_state_slot;
unsigned video_swap_interval_auto;
unsigned pointer_confinement;

fastmotion_overrides_t fastmotion_override; /* float alignment */

Expand Down
Loading