KrossX / Pokopom

Input Plugin for Emulators
MIT License
42 stars 7 forks source link

Make Pokopom Cross-Platform #20

Open Algebro7 opened 7 years ago

Algebro7 commented 7 years ago

I started this process with #19 and #18 but figured it made sense to open an enhancement request ticket to discuss this development. As I mentioned in the PR, I'm pretty much a C++/cmake newb, but I've managed to get the plugin to build on Windows/Visual Studio using cmake, and PCSX2 seems to be able to load and configure it.

Unfortunately, on Linux, the plugin builds successfully with cmake but is not able to be loaded by PCSX2. It throws the following error when attempting to load it:

[wx] /usr/lib/games/PCSX2/libpadPokopom.so: undefined symbol: multitap
Path: /usr/lib/games/PCSX2/libpadPokopom.so
File is not a valid dynamic library.
Some kinda plugin failure: /usr/lib/games/PCSX2/libpadPokopom.so

When looking through the source code of other plugins in https://github.com/PCSX2/pcsx2/tree/master/plugins, I'm noticing a lot of code like this before function definitions: EXPORT_C_(const char *). I noticed you have a similar macro defined in https://github.com/KrossX/Pokopom/blob/master/Pokopom/General.h with #define DllExport extern "C". Do you think this macro needs to be added to various type definitions and functions through the project? Or do you think it might be an issue with my build configuration?

KrossX commented 7 years ago

I'm building it the "usual" way for me on linux and I got the same error. I didn't debug it much but got it to compile and show up on PCSX2. However, it segfaults and I have no clue why (the backtrace didn't help). I'll be making some tests to try and isolate the problematic part,

As for the defines, I would leave them as they are until it's proven to be the actual problem.

Algebro7 commented 7 years ago

Good to know, and thanks for helping me look into this. Is there any chance you would mind sending me your makefile for linux?

KrossX commented 7 years ago

Makefile? Pfff, that would be too fancy. I just use a terminal with something like this:

g++ --std=c++11 --shared -o libPokopom.so ./Pokopom/*.cpp

That should give a file ready to be used. Add extra arguments as needed for debug and stuff.

Algebro7 commented 7 years ago

Thanks for the information! Here's the behavior when I try on my machine:

g++ --std=c++11 --shared -m32 -o libPokopom.so ./Pokopomclion/Pokopom/*.cpp

(Compiles without any warnings or errors)

image

Are you seeing different behavior?

KrossX commented 7 years ago

I removed non-playstation systems. Those files should have some define guards to make it easier.

Algebro7 commented 7 years ago

Got it. I did the same and now it's just the multitap symbol as before. I removed Chankast, demul, and Zilmar* from the sources directory, were there any others I needed to get rid of?

KrossX commented 7 years ago

I think that's it. I'll add some define guards. As for the segfault, the following change seems to fix it for now. HEADER

#define DllExport extern "C" to #define DllExport extern "C" __attribute__((stdcall))

Though since this makes even the most basic stub fail without it, I guess this change is rather recent. I don't know if it will have an effect against ps1 emulators for example. Bummer.

#EDIT: Try again with latest changes.

Algebro7 commented 7 years ago

Awesome, thanks! PCSX2 will load the plugin now, but there is no option to configure it. Are you seeing the same behavior?

KrossX commented 7 years ago

It has always been that way, linux settings can only be changed from the ini file directly.

Algebro7 commented 7 years ago

Awesome, I really appreciate you looking into this.

Just so I understand, you're saying the change to the Export syntax fixes the problem for PCSX2, but may break compatibility with other emulators?

KrossX commented 7 years ago

It changes the way functions are called under linux. It seems to solve problems for PCSX2 (see change here) but pokopom works for multiple emulators even on linux. Though limited to only some ps1 emulators and PCSX2 in that os, I don't know if the ps1 emulators are still compatible.

Anyhow, if it becomes an issue at least I know where to start looking at.

Algebro7 commented 7 years ago

Do you know if there is any special trick to using this plugin on Linux? I tried plugging in both a steam controller and a DS3 controller and neither was detected by PCSX2. I'm sure it's just user error but if you have any ideas or could help me test that the plugin works that'd be awesome.

KrossX commented 7 years ago

Pokopom was an X360 controller plugin mostly. Under windows that means just using XInput, though other controllers may support that. On linux however, the plugin only accepts X360 controllers.

The rewrite that I started years ago was supposed to support multiple API and possibly any input device supported. But that rewrite never went anywhere.

Algebro7 commented 7 years ago

Ahh, ok, I appreciate the information. I just tested it with an X360 controller on Linux and it appears to work flawlessly. I will work on updating the wiki with build instructions and a getting started section that discusses some of these points.

Also, should we update the releases section to include the working Linux binary? The one hosted on your Google drive is the old, broken one. We could also update the Windows binary but I'd like to do some testing to make sure I didn't break anything before we do that.

KrossX commented 7 years ago

I used to make builds from the ubuntu build I would be using at the time. Though now perhaps it would be better for people to build their own? Pokopom on linux has always been a very "try at your own risk" operation after all.

As for windows, I don't see any new changes that would require a new build. Unless I'm missing something that is.

Algebro7 commented 7 years ago

Yeah, that makes sense. And with cmake support it will be easier to build on Linux, since all they need to do is cmake ../and it's ready to go.

Algebro7 commented 7 years ago

FYI, I updated the Pokopom wiki with detailed build instructions and a discussion about the current known limitations on Linux. I figured I'd let you know since I'm not sure if it notifies you when someone edits the wiki.

KrossX commented 7 years ago

Thanks and no, I don't get notifications about the wiki. That reminds me, I never updated the security setting on the wiki section (it's been public all along).

halian commented 3 years ago

g++ --std=c++11 --shared -o libPokopom.so ./Pokopom/*.cpp

On a point of information: This now requires -fPIC, but after that addition compiles without issue under Arch Linux.

Unfortunately, I have no clue how to configure Pokopom by hacking on the .ini file directly, as is required here….

KrossX commented 3 years ago

Checking the FileIO.cpp file should give you an idea about what settings do, there's not much to customize though. Any reason to be using Pokopom nowadays, specially on linux? Seems like an odd choice.

halian commented 3 years ago

As far as I can tell, it’s still required to get Steam Controller support in PCSX2 under Linux; neither of the included pad plugins recognize it.