maple: refactor usage of rt/lt. zero out joystick values if ggpo active
Fix mouse cursor being invisible when emu throws an exception
This commit is contained in:
parent
a4c14ebef7
commit
8594d11693
|
@ -6,6 +6,8 @@
|
|||
#include "cfg/option.h"
|
||||
|
||||
u32 maple_kcode[4];
|
||||
u8 maple_rt[4];
|
||||
u8 maple_lt[4];
|
||||
|
||||
static u8 GetBtFromSgn(s8 val)
|
||||
{
|
||||
|
@ -71,8 +73,8 @@ void MapleConfigMap::GetInput(PlainJoystickState* pjs)
|
|||
pjs->kcode = maple_kcode[player_num];
|
||||
pjs->joy[PJAI_X1] = GetBtFromSgn(joyx[player_num]);
|
||||
pjs->joy[PJAI_Y1] = GetBtFromSgn(joyy[player_num]);
|
||||
pjs->trigger[PJTI_R] = rt[player_num];
|
||||
pjs->trigger[PJTI_L] = lt[player_num];
|
||||
pjs->trigger[PJTI_R] = maple_rt[player_num];
|
||||
pjs->trigger[PJTI_L] = maple_lt[player_num];
|
||||
}
|
||||
else if (settings.platform.system == DC_PLATFORM_ATOMISWAVE)
|
||||
{
|
||||
|
@ -119,10 +121,10 @@ void MapleConfigMap::GetInput(PlainJoystickState* pjs)
|
|||
switch (NaomiGameInputs->axes[axis].axis)
|
||||
{
|
||||
case 4:
|
||||
pjs->joy[axis] = rt[player_num];
|
||||
pjs->joy[axis] = maple_rt[player_num];
|
||||
break;
|
||||
case 5:
|
||||
pjs->joy[axis] = lt[player_num];
|
||||
pjs->joy[axis] = maple_lt[player_num];
|
||||
break;
|
||||
default:
|
||||
pjs->joy[axis] = 0x80;
|
||||
|
@ -142,8 +144,8 @@ void MapleConfigMap::GetInput(PlainJoystickState* pjs)
|
|||
{
|
||||
pjs->joy[PJAI_X1] = GetBtFromSgn(joyx[player_num]);
|
||||
pjs->joy[PJAI_Y1] = GetBtFromSgn(joyy[player_num]);
|
||||
pjs->joy[PJAI_X2] = rt[player_num];
|
||||
pjs->joy[PJAI_Y2] = lt[player_num];
|
||||
pjs->joy[PJAI_X2] = maple_rt[player_num];
|
||||
pjs->joy[PJAI_Y2] = maple_lt[player_num];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,8 @@ private:
|
|||
};
|
||||
|
||||
extern u32 maple_kcode[4];
|
||||
extern u8 maple_rt[4];
|
||||
extern u8 maple_lt[4];
|
||||
|
||||
void mcfg_CreateDevices();
|
||||
void mcfg_CreateNAOMIJamma();
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "hw/sh4/sh4_mem.h"
|
||||
#include "hw/sh4/sh4_sched.h"
|
||||
#include "network/ggpo.h"
|
||||
#include "input/gamepad_device.h"
|
||||
|
||||
enum MaplePattern
|
||||
{
|
||||
|
@ -147,7 +148,14 @@ static void maple_DoDma()
|
|||
}
|
||||
#endif
|
||||
|
||||
ggpo::getInput(maple_kcode);
|
||||
ggpo::getInput(maple_kcode, maple_lt, maple_rt);
|
||||
if (ggpo::active())
|
||||
{
|
||||
memset(&joyx[0], 0, sizeof(joyx));
|
||||
memset(&joyy[0], 0, sizeof(joyy));
|
||||
memset(&joyrx[0], 0, sizeof(joyrx));
|
||||
memset(&joyry[0], 0, sizeof(joyry));
|
||||
}
|
||||
|
||||
const bool swap_msb = (SB_MMSEL == 0);
|
||||
u32 xfer_count=0;
|
||||
|
|
|
@ -561,13 +561,13 @@ protected:
|
|||
case 7:
|
||||
return read_joystick_y(3);
|
||||
case 8:
|
||||
return rt[0] << 8;
|
||||
return maple_rt[0] << 8;
|
||||
case 9:
|
||||
return rt[1] << 8;
|
||||
return maple_rt[1] << 8;
|
||||
case 10:
|
||||
return rt[2] << 8;
|
||||
return maple_rt[2] << 8;
|
||||
case 11:
|
||||
return rt[3] << 8;
|
||||
return maple_rt[3] << 8;
|
||||
default:
|
||||
return 0x8000;
|
||||
}
|
||||
|
@ -598,7 +598,7 @@ protected:
|
|||
jvs_io_board::read_digital_in(buttons, v);
|
||||
for (u32 player = 0; player < player_count; player++)
|
||||
{
|
||||
u8 trigger = rt[player] >> 2;
|
||||
u8 trigger = maple_rt[player] >> 2;
|
||||
// Ball button
|
||||
v[player] = ((trigger & 0x20) << 3) | ((trigger & 0x10) << 5) | ((trigger & 0x08) << 7)
|
||||
| ((trigger & 0x04) << 9) | ((trigger & 0x02) << 11) | ((trigger & 0x01) << 13)
|
||||
|
@ -1537,9 +1537,9 @@ u32 jvs_io_board::handle_jvs_message(u8 *buffer_in, u32 length_in, u8 *buffer_ou
|
|||
if (axisDesc.type == Half)
|
||||
{
|
||||
if (axisDesc.axis == 4)
|
||||
axis_value = rt[player_num] << 8;
|
||||
axis_value = maple_rt[player_num] << 8;
|
||||
else if (axisDesc.axis == 5)
|
||||
axis_value = lt[player_num] << 8;
|
||||
axis_value = maple_lt[player_num] << 8;
|
||||
else
|
||||
axis_value = 0;
|
||||
if (axisDesc.inverted)
|
||||
|
|
|
@ -411,25 +411,31 @@ void stopSession()
|
|||
ggpoSession = nullptr;
|
||||
}
|
||||
|
||||
void getInput(u32 out_kcode[4])
|
||||
void getInput(u32 out_kcode[4], u8 out_lt[4], u8 out_rt[4])
|
||||
{
|
||||
// TODO need a std::recursive_mutex to use a lock here
|
||||
memcpy(out_kcode, kcode, sizeof(kcode));
|
||||
if (ggpoSession == nullptr)
|
||||
{
|
||||
memcpy(out_kcode, kcode, sizeof(kcode));
|
||||
memcpy(out_lt, lt, sizeof(lt));
|
||||
memcpy(out_rt, rt, sizeof(rt));
|
||||
return;
|
||||
}
|
||||
memset(out_lt, 0, sizeof(out_lt));
|
||||
memset(out_rt, 0, sizeof(out_rt));
|
||||
// should not call any callback
|
||||
u32 inputs[4];
|
||||
ggpo_synchronize_input(ggpoSession, (void *)&inputs[0], sizeof(inputs[0]) * 2, nullptr); // FIXME numPlayers
|
||||
out_kcode[0] = ~inputs[0];
|
||||
out_kcode[1] = ~inputs[1];
|
||||
//out_kcode[2] = ~inputs[2];
|
||||
//out_kcode[3] = ~inputs[3];
|
||||
out_kcode[2] = ~0;
|
||||
out_kcode[3] = ~0;
|
||||
if (settings.platform.system != DC_PLATFORM_NAOMI)
|
||||
{
|
||||
rt[0] = (inputs[0] & EMU_BTN_TRIGGER_RIGHT) != 0 ? 255 : 0;
|
||||
lt[0] = (inputs[0] & EMU_BTN_TRIGGER_LEFT) != 0 ? 255 : 0;
|
||||
rt[1] = (inputs[1] & EMU_BTN_TRIGGER_RIGHT) != 0 ? 255 : 0;
|
||||
lt[1] = (inputs[1] & EMU_BTN_TRIGGER_LEFT) != 0 ? 255 : 0;
|
||||
out_lt[0] = (inputs[0] & EMU_BTN_TRIGGER_RIGHT) != 0 ? 255 : 0;
|
||||
out_lt[0] = (inputs[0] & EMU_BTN_TRIGGER_LEFT) != 0 ? 255 : 0;
|
||||
out_lt[1] = (inputs[1] & EMU_BTN_TRIGGER_RIGHT) != 0 ? 255 : 0;
|
||||
out_lt[1] = (inputs[1] & EMU_BTN_TRIGGER_LEFT) != 0 ? 255 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace ggpo
|
|||
std::future<bool> startNetwork();
|
||||
void startSession(int localPort, int localPlayerNum);
|
||||
void stopSession();
|
||||
void getInput(u32 out_kcode[4]);
|
||||
void getInput(u32 out_kcode[4], u8 out_lt[4], u8 out_rt[4]);
|
||||
void nextFrame();
|
||||
bool active();
|
||||
void displayStats();
|
||||
|
|
|
@ -55,6 +55,7 @@ bool mainui_rend_frame()
|
|||
if (!error.empty())
|
||||
{
|
||||
dc_stop();
|
||||
EventManager::event(Event::Pause);
|
||||
gui_stop_game(error);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue