• Login
  • Register
  • Dolphin Forums
  • Home
  • FAQ
  • Download
  • Wiki
  • Code


Dolphin, the GameCube and Wii emulator - Forums › Dolphin Emulator Discussion and Support › Development Discussion v
« Previous 1 ... 23 24 25 26 27 ... 114 Next »

Help porting GC Adapter implementation to a Node.js addon
View New Posts | View Today's Posts

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Modes
Help porting GC Adapter implementation to a Node.js addon
01-27-2017, 08:25 AM
#1
yonic
Unregistered
 
Question 
I'm currently developing a game with a Node.js engine, and I'd love to add support to the Wii U GameCube Adapter. At first I thought of using the HTML5 Gamepad API, but the support on Chromium is bugged and it won't detect the analog stick and the C-sticks (axes are null for some reason). I made a bug report about this issue on Chromium's issue tracker, but it seems like it's going to slip through the cracks...

So I decided to make a Node.js addon with C++ using Dolphin's source as a code base to start. But I've come by a bunch of problems.
  • Firstly, let me clarify that my knowledge of C++ is quite low and a bit rusty, but I know at least most of the basics (classes and inheritance, basic usage of pointers, structs and a bit of method hiding/overloading)
  • Because of that, I'm having trouble understanding some of the code (particularly threads), and how Dolphin actually reads the input and outputs it, once the adapter has been added.
  • I'm not sure how exactly will I make the connection between the C++ code and the creation of the Node.js addon, since in order for it to cause an effect in Node.js, it must output object types that the V8 JavaScript engine understands (say, v8::Number for double values), apart from other quirks. Also, Node.js uses libuv for threading, which makes me wonder if I should use Dolphin's implementation of threads or libuv's.
EDIT: Probably the best approach I thought for the port is to get GCPadStatus for each GameCube port as a v8::Object and do the rest of the code under the hood of the addon with C++, but I'm not sure when are these GCPadStatus objects returned to be obtained later on.

This article and this one from the Node.js docs should be more than enough to explain the process and the quirks of writting Node.js native addons with C++.

I'd really appreciate some guidance on understanding the code for the adapter's implementation.
Reply
01-27-2017, 04:57 PM
#2
degasus Offline
Developer
**********
Developers (Some Administrators and Super Moderators)
Posts: 1,827
Threads: 10
Joined: May 2012
I can't give any advice on the GC protocol, but you can't just copy it from dolphin. We don't parse it at all, just pass the binary stream of the WiiU adapter to the game. But we also have the reverse part, called emulated gamepad.
Find
Reply
01-28-2017, 12:48 PM
#3
yonic
Unregistered
 
So I started digging on how to get the binary stream from the adapter, when I came to a strange issue.

Starting the built program with the adapter just connected on Windows (the driver had already been replaced to WinUSB on Zadig), prompts a LIBUSB_ERROR_TIMEOUT while trying to do a bulk transfer.

However, if I start Elmassivo's Wii U GCN USB Driver, and after the input loop begins stop it, then start the program again, the error is gone and seems to get the requested data.
This also happens with interrupt transfers, used in Dolphin.

Here's my repo if you need to check the code. I must admit, it ended up being a lot like the Dolphin's GCAdapter.cpp Read() and AddGCNAdapter() methods despite not having the intention of copying it, I guess it's most likely because the procedures of getting to actually communicate with USB devices are mostly the same for each device and program.
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
  • Subscribe to this thread
Forum Jump:


Users browsing this thread: 1 Guest(s)



Powered By MyBB | Theme by Fragma

Linear Mode
Threaded Mode