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 1, 2023
2 parents be97e6d + ee5659a commit 1a15e45
Show file tree
Hide file tree
Showing 41 changed files with 398 additions and 168 deletions.
3 changes: 3 additions & 0 deletions MiSTer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
<ClCompile Include="support\pcecd\pcecdd.cpp" />
<ClCompile Include="support\pcecd\seektime.cpp" />
<ClCompile Include="support\psx\psx.cpp" />
<ClCompile Include="support\saturn\saturn.cpp" />
<ClCompile Include="support\saturn\saturncdd.cpp" />
<ClCompile Include="support\sharpmz\sharpmz.cpp" />
<ClCompile Include="support\snes\snes.cpp" />
<ClCompile Include="support\st\st_tos.cpp" />
Expand Down Expand Up @@ -175,6 +177,7 @@
<ClInclude Include="support\pcecd\pcecd.h" />
<ClInclude Include="support\psx\mcdheader.h" />
<ClInclude Include="support\psx\psx.h" />
<ClInclude Include="support\saturn\saturn.h" />
<ClInclude Include="support\sharpmz\sharpmz.h" />
<ClInclude Include="support\snes\snes.h" />
<ClInclude Include="support\st\st_tos.h" />
Expand Down
9 changes: 9 additions & 0 deletions MiSTer.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@
<ClCompile Include="support\neogeo\neogeocd.cpp">
<Filter>Source Files\support</Filter>
</ClCompile>
<ClCompile Include="support\saturn\saturn.cpp">
<Filter>Source Files\support</Filter>
</ClCompile>
<ClCompile Include="support\saturn\saturncdd.cpp">
<Filter>Source Files\support</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="battery.h">
Expand Down Expand Up @@ -459,5 +465,8 @@
<ClInclude Include="support\neogeo\neogeocd.h">
<Filter>Header Files\support</Filter>
</ClInclude>
<ClInclude Include="support\saturn\saturn.h">
<Filter>Header Files\support</Filter>
</ClInclude>
</ItemGroup>
</Project>
49 changes: 32 additions & 17 deletions input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,7 @@ typedef struct
char id[80];
char name[128];
char sysfs[512];
int max_range;
} devInput;

static devInput input[NUMDEV] = {};
Expand Down Expand Up @@ -2074,16 +2075,30 @@ static void joy_digital(int jnum, uint32_t mask, uint32_t code, char press, int
}
}

static void joy_analog(int num, int axis, int offset, int stick = 0)
static void joy_analog(int dev, int axis, int offset, int stick = 0)
{
int num = input[dev].num;
static int pos[2][NUMPLAYERS][2] = {};

if (grabbed && num > 0 && num < NUMPLAYERS+1)
{
num--;
pos[stick][num][axis] = offset;
if(stick) user_io_r_analog_joystick(num, (char)(pos[1][num][0]), (char)(pos[1][num][1]));
else user_io_l_analog_joystick(num, (char)(pos[0][num][0]), (char)(pos[0][num][1]));
int x = pos[stick][num][0];
int y = pos[stick][num][1];
if (is_n64() && stick == 0)
{
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;

// emulate n64 joystick range and shape for regular -127-+127 controllers
n64_joy_emu(x, y, &x, &y, input[dev].max_range);
}
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 Expand Up @@ -3323,58 +3338,58 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
// steering wheel passes full range, pedals are standardised in +127 to 0 to -127 range
if (ev->code == input[dev].wh_steer)
{
joy_analog(input[dev].num, 0, value, 0);
joy_analog(dev, 0, value, 0);
}
else if (ev->code == input[dev].wh_accel)
{
joy_analog(input[dev].num, 1, wh_value, 0);
joy_analog(dev, 1, wh_value, 0);
}
else if (ev->code == input[dev].wh_brake)
{
joy_analog(input[dev].num, 1, wh_value, 1);
joy_analog(dev, 1, wh_value, 1);
}
else if (ev->code == input[dev].wh_clutch)
{
joy_analog(input[dev].num, 0, wh_value, 1);
joy_analog(dev, 0, wh_value, 1);
}
else if (ev->code == input[dev].wh_combo)
{
// if accel and brake pedal use a shared axis then map negative to accel and positive to brake
if (value < -1) joy_analog(input[dev].num, 1, value, 0);
else if (value > 1) joy_analog(input[dev].num, 1, -value, 1);
if (value < -1) joy_analog(dev, 1, value, 0);
else if (value > 1) joy_analog(dev, 1, -value, 1);
else
{
joy_analog(input[dev].num, 1, 0, 0);
joy_analog(input[dev].num, 1, 0, 0);
joy_analog(dev, 1, 0, 0);
joy_analog(dev, 1, 0, 0);
}
}
}
else if (ev->code == 0 && input[dev].lightgun)
{
joy_analog(input[dev].num, 0, value);
joy_analog(dev, 0, value);
}
else if (ev->code == 1 && input[dev].lightgun)
{
joy_analog(input[dev].num, 1, value);
joy_analog(dev, 1, value);
}
else
{
int offset = (value < -1 || value>1) ? value : 0;
if (input[dev].stick_l[0] && ev->code == (uint16_t)input[dev].mmap[input[dev].stick_l[0]])
{
joy_analog(input[dev].num, 0, offset, 0);
joy_analog(dev, 0, offset, 0);
}
else if (input[dev].stick_l[1] && ev->code == (uint16_t)input[dev].mmap[input[dev].stick_l[1]])
{
joy_analog(input[dev].num, 1, offset, 0);
joy_analog(dev, 1, offset, 0);
}
else if (input[dev].stick_r[0] && ev->code == (uint16_t)input[dev].mmap[input[dev].stick_r[0]])
{
joy_analog(input[dev].num, 0, offset, 1);
joy_analog(dev, 0, offset, 1);
}
else if (input[dev].stick_r[1] && ev->code == (uint16_t)input[dev].mmap[input[dev].stick_r[1]])
{
joy_analog(input[dev].num, 1, offset, 1);
joy_analog(dev, 1, offset, 1);
}
}
}
Expand Down
Binary file removed releases/MiSTer_20200517
Binary file not shown.
Binary file removed releases/MiSTer_20200526
Binary file not shown.
Binary file removed releases/MiSTer_20200601
Binary file not shown.
Binary file removed releases/MiSTer_20200602
Binary file not shown.
Binary file removed releases/MiSTer_20200606
Binary file not shown.
Binary file removed releases/MiSTer_20200622
Binary file not shown.
Binary file removed releases/MiSTer_20200701
Binary file not shown.
Binary file removed releases/MiSTer_20200703
Binary file not shown.
Binary file removed releases/MiSTer_20200917
Binary file not shown.
Binary file removed releases/MiSTer_20200922
Binary file not shown.
Binary file removed releases/MiSTer_20201101
Binary file not shown.
Binary file removed releases/MiSTer_20201106
Binary file not shown.
Binary file removed releases/MiSTer_20201114
Binary file not shown.
Binary file removed releases/MiSTer_20201116
Binary file not shown.
Binary file removed releases/MiSTer_20210103
Binary file not shown.
Binary file removed releases/MiSTer_20210224
Binary file not shown.
Binary file removed releases/MiSTer_20210225
Binary file not shown.
Binary file removed releases/MiSTer_20210302
Binary file not shown.
Binary file removed releases/MiSTer_20210403
Binary file not shown.
Binary file removed releases/MiSTer_20210604
Binary file not shown.
Binary file removed releases/MiSTer_20210605
Binary file not shown.
Binary file removed releases/MiSTer_20210705
Binary file not shown.
Binary file removed releases/MiSTer_20210707
Binary file not shown.
Binary file removed releases/MiSTer_20210719
Binary file not shown.
Binary file removed releases/MiSTer_20210825
Binary file not shown.
Binary file removed releases/MiSTer_20211004
Binary file not shown.
Binary file removed releases/MiSTer_20211010
Binary file not shown.
Binary file removed releases/MiSTer_20211126
Binary file not shown.
Binary file removed releases/MiSTer_20220105
Binary file not shown.
Binary file removed releases/MiSTer_20220206
Binary file not shown.
Binary file removed releases/MiSTer_20220511
Binary file not shown.
Binary file removed releases/MiSTer_20221007
Binary file not shown.
Binary file added releases/MiSTer_20230915
Binary file not shown.
1 change: 1 addition & 0 deletions support.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@

// N64 support
#include "support/n64/n64.h"
#include "support/n64/n64_joy_emu.h"
Loading

0 comments on commit 1a15e45

Please sign in to comment.