mirror of https://github.com/snes9xgit/snes9x.git
Merge pull request #428 from CapnCrinklepants/master
Swap joypads over Netplay
This commit is contained in:
commit
b5270db944
|
@ -2442,6 +2442,15 @@ void S9xApplyCommand (s9xcommand_t cmd, int16 data1, int16 data2)
|
|||
S9xSetInfoString("Cannot swap pads: port 2 is not a joypad");
|
||||
break;
|
||||
}
|
||||
|
||||
if (Settings.NetPlay && data2 != 1) { //data2 == 1 means it's sent by the netplay code
|
||||
if (Settings.NetPlayServer) {
|
||||
S9xNPSendJoypadSwap();
|
||||
} else {
|
||||
S9xSetInfoString("Netplay Client cannot swap pads.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
newcontrollers[1] = curcontrollers[0];
|
||||
newcontrollers[0] = curcontrollers[1];
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <sys/types.h>
|
||||
|
||||
#include "snes9x.h"
|
||||
#include "controls.h"
|
||||
|
||||
#ifdef __WIN32__
|
||||
#include <winsock.h>
|
||||
|
@ -493,7 +494,13 @@ bool8 S9xNPWaitForHeartBeat ()
|
|||
else
|
||||
S9xNPSetWarning("CLIENT: Server has resumed.");
|
||||
break;
|
||||
case NP_SERV_LOAD_ROM:
|
||||
case NP_SERV_JOYPAD_SWAP:
|
||||
#ifdef NP_DEBUG
|
||||
printf("CLIENT: Joypad Swap received @%ld\n", S9xGetMilliTime() - START);
|
||||
#endif
|
||||
S9xApplyCommand(S9xGetCommandT("SwapJoypads"), 1, 1);
|
||||
break;
|
||||
case NP_SERV_LOAD_ROM:
|
||||
#ifdef NP_DEBUG
|
||||
printf ("CLIENT: LOAD_ROM received @%ld\n", S9xGetMilliTime () - START);
|
||||
#endif
|
||||
|
|
|
@ -57,6 +57,8 @@
|
|||
#define NP_SERV_FREEZE_FILE 6
|
||||
#define NP_SERV_SRAM_DATA 7
|
||||
#define NP_SERV_READY 8
|
||||
// ...
|
||||
#define NP_SERV_JOYPAD_SWAP 12
|
||||
|
||||
struct SNPClient
|
||||
{
|
||||
|
@ -198,6 +200,7 @@ void S9xNPServerAddTask (uint32 task, void *data);
|
|||
|
||||
bool8 S9xNPStartServer (int port);
|
||||
void S9xNPStopServer ();
|
||||
void S9xNPSendJoypadSwap ();
|
||||
#ifdef __WIN32__
|
||||
#define S9xGetMilliTime timeGetTime
|
||||
#else
|
||||
|
|
14
server.cpp
14
server.cpp
|
@ -680,6 +680,20 @@ void S9xNPSendServerPause (bool8 paused)
|
|||
S9xNPSendToAllClients (pause, 7);
|
||||
}
|
||||
|
||||
void S9xNPSendJoypadSwap()
|
||||
{
|
||||
#ifdef NP_DEBUG
|
||||
printf("SERVER: Swap Joypads - @%ld\n", S9xGetMilliTime() - START);
|
||||
#endif
|
||||
uint8 swap[7];
|
||||
uint8 *ptr = swap;
|
||||
*ptr++ = NP_SERV_MAGIC;
|
||||
*ptr++ = 0;
|
||||
*ptr++ = NP_SERV_JOYPAD_SWAP;
|
||||
WRITE_LONG(ptr, 7);
|
||||
S9xNPSendToAllClients(swap, 7);
|
||||
}
|
||||
|
||||
void S9xNPServerLoop (void *)
|
||||
{
|
||||
#ifdef __WIN32__
|
||||
|
|
|
@ -96,6 +96,7 @@
|
|||
<IntDir>$(SolutionDir)_Intermediate\$(ProjectName)\$(Configuration)\$(PlatformTarget)\</IntDir>
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
<IncludePath>$(DXSDK_DIR)include;$(CG_INC_PATH);$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(DXSDK_DIR)include;$(CG_INC_PATH);$(IncludePath);$(DXSDK_DIR)\include</IncludePath>
|
||||
<LibraryPath>$(DXSDK_DIR)Lib\$(PlatformTarget);$(CG_LIB_PATH);$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Unicode|x64'">
|
||||
|
|
Loading…
Reference in New Issue