Skip to content

Commit

Permalink
Merge branch 'MiSTer-devel:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
sithtoast authored Oct 16, 2023
2 parents 1a15e45 + 78edf5f commit aacee71
Show file tree
Hide file tree
Showing 8 changed files with 253 additions and 116 deletions.
25 changes: 20 additions & 5 deletions input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <sys/time.h>
#include <sys/types.h>
#include <stdarg.h>
#include <math.h>

#include "input.h"
#include "user_io.h"
Expand Down Expand Up @@ -1198,7 +1199,9 @@ typedef struct
char id[80];
char name[128];
char sysfs[512];
int max_range;
int ss_range[2];
int max_cardinal[2];
float max_range[2];
} devInput;

static devInput input[NUMDEV] = {};
Expand Down Expand Up @@ -2086,16 +2089,28 @@ static void joy_analog(int dev, int axis, int offset, int stick = 0)
pos[stick][num][axis] = offset;
int x = pos[stick][num][0];
int y = pos[stick][num][1];
if (is_n64() && stick == 0)
if (is_n64())
{
// Update maximum observed cardinal distance
const int abs_x = abs(x);
const int abs_y = abs(y);

if (abs_x > input[dev].max_range) input[dev].max_range = abs_x;
if (abs_y > input[dev].max_range) input[dev].max_range = abs_y;
if (abs_x > input[dev].max_cardinal[stick]) input[dev].max_cardinal[stick] = abs_x;
if (abs_y > input[dev].max_cardinal[stick]) input[dev].max_cardinal[stick] = abs_y;

// Update maximum observed diag
// Use sum of squares and only calc sqrt() when necessary
const int ss_range_curr = x*x + y*y;
// compare to max ss_range and update if larger
if ((ss_range_curr > input[dev].ss_range[stick]) & (abs(abs_x - abs_y) <= 3))
{
input[dev].ss_range[stick] = ss_range_curr;
input[dev].max_range[stick] = sqrt(ss_range_curr);
}

// emulate n64 joystick range and shape for regular -127-+127 controllers
n64_joy_emu(x, y, &x, &y, input[dev].max_range);
n64_joy_emu(x, y, &x, &y, input[dev].max_cardinal[stick], input[dev].max_range[stick]);
stick_swap(num,stick,&num,&stick);
}
if(stick) user_io_r_analog_joystick(num, (char)x, (char)y);
else user_io_l_analog_joystick(num, (char)x, (char)y);
Expand Down
2 changes: 1 addition & 1 deletion menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2241,7 +2241,7 @@ void HandleUI(void)
if (is_x86() || is_pcxt()) strcpy(Selected_tmp, x86_get_image_path(ioctl_index));
if (is_psx() && (ioctl_index == 2 || ioctl_index == 3)) fs_Options |= SCANO_SAVES;

if (is_pce() || is_megacd() || is_x86() || (is_psx() && !(fs_Options & SCANO_SAVES)) || is_neogeo())
if (is_saturn() || is_pce() || is_megacd() || is_x86() || (is_psx() && !(fs_Options & SCANO_SAVES)) || is_neogeo())
{
//look for CHD too
if (!strcasestr(ext, "CHD"))
Expand Down
Loading

0 comments on commit aacee71

Please sign in to comment.