-
Notifications
You must be signed in to change notification settings - Fork 43
Add network output, based on MAME's network output system #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good feature but substantial rework needed. I don't like the Windows-specific nature of this. I think it's unnecessary: UDP should be done via SDL2_net, not Winsock, and threading should be done with std::thread, not the Windows API.
Also, make sure to add the Supermodel file header to each source file.
struct Packet | ||
{ | ||
|
||
static const UINT32 BUFFER_SIZE_UDP = 1460; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we convert tabs to spaces everywhere? I think we are using a 4-character tab stop.
#include <vector> | ||
#include <thread> | ||
|
||
namespace SMUDP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this namespace at all?
|
||
#pragma comment(lib, "ws2_32.lib") | ||
|
||
WinSockWrap::WinSockWrap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is Winsock needed? SDL2_net has UDP, to my knowledge. This should be platform-agnostic, similar to the netplay TCP code, no?
@@ -1582,6 +1583,9 @@ static Util::Config::Node DefaultConfig() | |||
#endif | |||
config.Set("Outputs", "none"); | |||
config.Set("DumpTextures", false); | |||
config.Set("NetOutputsWithLF", "1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can probably drop the Net prefix here and just group these below "Outputs".
@@ -1582,6 +1583,9 @@ static Util::Config::Node DefaultConfig() | |||
#endif | |||
config.Set("Outputs", "none"); | |||
config.Set("DumpTextures", false); | |||
config.Set("NetOutputsWithLF", "1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OutputsWithLF should probably be a bool rather than int?
// Will do SendUdpBroadcastWithId(); | ||
} | ||
|
||
LRESULT CNetOutputs::CreateServerThread() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refactor to eliminate all Windows dependencies here. std::thread can be used. No need for any Windows functions or types like LRESULT, DWORD, etc.
@@ -359,6 +359,10 @@ xcopy /D /Y "$(ProjectDir)..\Assets\*" "$(TargetDir)Assets"</Command> | |||
<ClCompile Include="..\Src\Network\SimNetBoard.cpp" /> | |||
<ClCompile Include="..\Src\Network\TCPReceive.cpp" /> | |||
<ClCompile Include="..\Src\Network\TCPSend.cpp" /> | |||
<ClCompile Include="..\Src\Network\TCPSendAsync.cpp" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to update Rules.inc in Makefiles.
All the network stuff is copy/paste from much earlier versions of supermodel before the networking code really worked. They shouldn't be needed I don't think for the mame outptut stuff. Tbh not even sure what it is / for. |
I've never used this feature but Nik hooked up the original output system to work with something called MameHooker (heh). It's for the various lights on the cabinets, for those who want to emulate those or implement them on custom cabs. |
The main thing is that the current outputs system is constrained to Windows but this one could actually be platform-independent. Better to do that. |
All the network code is what I wrote for spindizzi when we trying to get networking working. It wasn't required for the mame output stuff. In the end i rewrote the network code for SDL. |
@dukeeeey That's something I have done a long time ago for my own usage (forcefeedback software), maybe a few years ago, and forgot about it until somebody ask me an update today. When I will have spare time I will check your code review. Thank for spending time reviewing it. |
The only files you need are netoutputs.cpp / h. I am pretty sure the rest isn't needed. |
Add TCP server socket 8000 and UDP (broadcast) 8001 for network outputs.