mirror of
https://github.com/libretro/opera-libretro.git
synced 2026-11-07 04:25:58 -10:00
input: clamp active devices and crosshair input
This commit is contained in:
1 parent
d0a3b910f8
commit
d31cff928e
4 files changed
+50
-5
No files matched your search
@@ -260,7 +260,7 @@ static struct retro_core_option_v2_definition option_defs_us_v2[] =
|
||||
"opera_active_devices",
|
||||
"Active Input Devices",
|
||||
NULL,
|
||||
"There exists a bug (perhaps in Opera itself, but possibly in certain games) where having more than 1 emulated controller causes content to ignore gamepad input. Setting 'Active Input Devices' to 1 provides a workaround for this issue.",
|
||||
"Sets the maximum number of emulated input devices. Certain games, particularly when using >16x CDROM speed and have more than 1 emulated controller, causes content to ignore gamepad input or crash. Setting 'Active Input Devices' to 1 can be workaround for this issue on some titles.",
|
||||
NULL,
|
||||
"input",
|
||||
{
|
||||
@@ -568,7 +568,7 @@ static struct retro_core_option_definition option_defs_us[] =
|
||||
{
|
||||
"opera_active_devices",
|
||||
"Active Input Devices",
|
||||
"There exists a bug (perhaps in Opera itself, but possibly in certain games) where having more than 1 emulated controller causes content to ignore gamepad input. Setting 'Active Input Devices' to 1 provides a workaround for this issue.",
|
||||
"Sets the maximum number of emulated input devices. There exists a bug (perhaps in Opera itself, but possibly in certain games) where having more than 1 emulated controller causes content to ignore gamepad input. Setting 'Active Input Devices' to 1 provides a workaround for this issue.",
|
||||
{
|
||||
{ "0", NULL },
|
||||
{ "1", NULL },
|
||||
|
||||
+30
-1
@@ -249,16 +249,42 @@ lr_input_poll(const int port_)
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
uint32_t
|
||||
lr_input_get_active_devices(const uint32_t active_devices_)
|
||||
{
|
||||
unsigned frontend_devices;
|
||||
uint32_t active_devices;
|
||||
|
||||
active_devices = active_devices_;
|
||||
if(active_devices > LR_INPUT_MAX_DEVICES)
|
||||
active_devices = LR_INPUT_MAX_DEVICES;
|
||||
|
||||
frontend_devices = 0;
|
||||
if(retro_environment_cb(RETRO_ENVIRONMENT_GET_INPUT_MAX_USERS,&frontend_devices) &&
|
||||
(frontend_devices > 0) &&
|
||||
(frontend_devices < active_devices))
|
||||
active_devices = frontend_devices;
|
||||
|
||||
return active_devices;
|
||||
}
|
||||
|
||||
void
|
||||
lr_input_device_set(const uint32_t port_,
|
||||
const uint32_t device_)
|
||||
{
|
||||
if(port_ >= LR_INPUT_MAX_DEVICES)
|
||||
return;
|
||||
|
||||
PBUS_DEVICES[port_] = device_;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
lr_input_device_get(const uint32_t port_)
|
||||
{
|
||||
if(port_ >= LR_INPUT_MAX_DEVICES)
|
||||
return RETRO_DEVICE_NONE;
|
||||
|
||||
return PBUS_DEVICES[port_];
|
||||
}
|
||||
|
||||
@@ -266,10 +292,13 @@ void
|
||||
lr_input_update(const uint32_t active_devices_)
|
||||
{
|
||||
int i;
|
||||
uint32_t active_devices;
|
||||
|
||||
opera_pbus_reset();
|
||||
retro_input_poll_cb();
|
||||
for(i = 0; i < active_devices_; i++)
|
||||
active_devices = lr_input_get_active_devices(active_devices_);
|
||||
|
||||
for(i = 0; i < active_devices; i++)
|
||||
{
|
||||
if(PBUS_DEVICES[i] == RETRO_DEVICE_NONE)
|
||||
continue;
|
||||
|
||||
+15
-2
@@ -36,8 +36,21 @@ lr_input_crosshair_draw(const lr_crosshair_t *crosshair_,
|
||||
int32_t y;
|
||||
uint32_t *p;
|
||||
|
||||
x = ((crosshair_->x + 32768) / (65535 / width_));
|
||||
y = ((crosshair_->y + 32768) / (65535 / height_));
|
||||
if((width_ <= 0) || (height_ <= 0))
|
||||
return;
|
||||
|
||||
x = (((crosshair_->x + 32768) * width_) / 65536);
|
||||
y = (((crosshair_->y + 32768) * height_) / 65536);
|
||||
|
||||
if(x < 0)
|
||||
x = 0;
|
||||
else if(x >= width_)
|
||||
x = (width_ - 1);
|
||||
|
||||
if(y < 0)
|
||||
y = 0;
|
||||
else if(y >= height_)
|
||||
y = (height_ - 1);
|
||||
|
||||
p = &buf_[x + (y * width_)];
|
||||
|
||||
|
||||
@@ -218,6 +218,9 @@ lr_input_device_set_with_descs(const uint32_t port_,
|
||||
uint32_t rv;
|
||||
struct retro_input_descriptor desc[256];
|
||||
|
||||
if(port_ >= LR_INPUT_MAX_DEVICES)
|
||||
return;
|
||||
|
||||
lr_input_device_set(port_,device_);
|
||||
|
||||
rv = 0;
|
||||
|
||||
Reference in new issue
Block a user