|
|
|||||||
| Home | Register | Downloads | FAQ | Members List | Calendar | Arcade | Mark Forums Read |
» Less advertising throughout
» Post and participate in discussions
» Network with other forum members
» Free private messaging
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Registered User
Join Date: Aug 2012
Location: USA, CA
Posts: 15
|
Writing an input plugin
I see that ePSXe supports plugins, but I can't find any information regarding to whether or not it's possible to write an input plugin to support alternative controller types (such as the Wiimote, which I have written several libraries for in the past). I also can't find any source for ePSXe itself, which leads me to believe it is closed-source, meaning that the standard gamepad input may not be changable. So I was just wondering if anybody knew if ePSXe supported input plugins, and if there are any open source ones available? |
|
|
|
| Advertisement | [Remove Advertisement] | ||
|
|
|
#2 |
|
クロッスエクス
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Mar 2006
Location: Argentina
Posts: 3,636
|
ePSXe does not support input plugins under Windows but I think it does support them on linux. However, Shalma's Shark lets you use input plugins with ePSXe. As for creating the plugin itself, I suggest you check open source plugins to know the plugin specs and stuff. Then you would need to emulate the desired device, and then you would need to acquire the data from the wiimote to use on the emulated device. That last part you have it covered I think. |
|
|
|
|
|
#3 |
|
Registered User
Join Date: Aug 2012
Location: USA, CA
Posts: 15
|
I'm relieved to see that there is a standard for the way which emulator plugins are written (PSEmu). I've built a test library and got it to communicate with PCSX. It successfully discovers and connects to your wiimote, and the test operation works. I'm excited to see how far I can take this... Are other open-source libraries the only decent point of reference? For example, are there any development forums for this sort of thing? I just want to be sure I'm doing everything completely legit, so that I can eventually release this to the general public. Thanks for your help! |
|
|
|
|
|
#4 |
|
Registered User
Join Date: Feb 2010
Location: ugyuyh
Posts: 23
|
If it works, it's legit :-) Anyway, for develpment there's "psdev" , "psx-scene", not sure what's the situation there though. |
|
|
|
|
|
#5 |
|
クロッスエクス
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Mar 2006
Location: Argentina
Posts: 3,636
|
When I started to make my plugin, the open source plugins were the most useful information for the interface. Specially LillyPad for PCSX2 support. From those dev forums, the most useful thing I found was a padtest.elf to use with PCSX2. Mostly to check if you've done things nicely, or to see numbers for pressure. About emulating a DualShock, what I've found most useful has been Harakiri, Curious Inventors and H. Kashima's info. Other than that, I dunno. In my plugin, the basic PSX/2 interface is on main.cpp and the related devices on Controller/2.cpp but I dunno if it's readable. The main part with acquiring data is on the Xinput_Backend files. So maybe replacing that with Wiimote things might be a quick way to test? |
|
|
|
|
|
#6 | ||
|
Registered User
Join Date: Aug 2012
Location: USA, CA
Posts: 15
|
Quote:
Quote:
|
||
|
|
|
|
|
#7 |
|
クロッスエクス
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Mar 2006
Location: Argentina
Posts: 3,636
|
Yes, the emulator sends the command and you must return the proper data. From the datasheet, the Wireless column is the best one to use. That data was of utmost importance for me to get the ID sequence right (the 0x46 0x46 0x47 0x4C 0x4C one). I have a bunch of IDs and stuff in HERE which might be of help. |
|
|
|
|
|
#8 |
|
Registered User
Join Date: Aug 2012
Location: USA, CA
Posts: 15
|
You know what's funny? I've already been using your source as a point of reference for the past day or so, and somehow missed that little gem of information. You, good sir, have the first slot in my credits section. |
|
|
|
|
|
#9 |
|
クロッスエクス
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Mar 2006
Location: Argentina
Posts: 3,636
|
|
|
|
|
|
|
#10 |
|
Registered User
Join Date: Aug 2012
Location: USA, CA
Posts: 15
|
Hello again! So I've been messing around with PADstartPoll and PADpoll a lot lately, and I just don't understand what they are expecting. For example, which is responsible for issuing commands and which is for receiving data and when, etc... From what I can understand, the console is supposed to receive a poll (0x42) command from the device, but in which callback function and when? And is this supposed to be an unsigned char, short, int... ? Am I supposed to send a full command sequence such as {01, 42, 00, FF, FF} over some unspecified amount of time? I've tried a setup like the following: Code:
enum DualShockCommands
{
POLL_INFO = 0x41,
POLL_DEVICE = 0x42,
CONFIG_SWITCH = 0x43,
ANALOG_SWITCH = 0x44,
STATUS_INFO = 0x45,
READ_CONSTANT1 = 0x46,
READ_CONSTANT2 = 0x47,
READ_CONSTANT3 = 0x4C,
MAP_VIBRATION = 0x4D,
ANALOG_RESPONSE = 0x4F
};
unsigned char cmdFullConfigSequence[] = { 7, POLL_DEVICE, CONFIG_SWITCH, ANALOG_SWITCH, MAP_VIBRATION, ANALOG_RESPONSE, CONFIG_SWITCH, POLL_DEVICE };
int bufferIndex = 1;
unsigned char Command(unsigned char *cmd, int &index)
{
if(cmd == NULL)
return 0x00;
if(index > cmd[0])
index = 1;
return cmd[index++];
}
unsigned char CALLBACK PADstartPoll(signed int port)
{
return DualShockCommands::POLL_DEVICE;
}
unsigned char CALLBACK PADpoll(unsigned char data)
{
return Command(cmdBuffer, bufferIndex);
}
I also tried replacing your XInput backend with a Wiimote implementation and successfully got a button presses to work, but the analog modes make pSX crash (maybe because it's a PS1 emulator?)... The reference pages you gave me, as well as many others I've found, are either too vague in description or lean more toward hardware implementations rather than software emulation. So even if I understand the protocols, I still don't understand how to properly implement their design into a plugin, because I have no idea what the emulator itself is expecting from me. Since I want this to work on a PS1 emulator before moving on to PS2, I'll first need to emulate the SCPH-1200 DualShock controller (not the SCPH-10010... See HERE for a list of Sony devices). I can't find any specifications on this, but I could imagine very little difference. Would the PS2 controller protocols (like the one described on Curious Inventor) work in a PSX emulator? Last edited by Rectangle; August 18th, 2012 at 09:36.. |
|
|
|
|
|
#11 |
|
Registered User
Join Date: Aug 2012
Location: USA, CA
Posts: 15
|
Ok, so after further evaluation I've realized that the command bits are actually what the console sends to the controller, and the data bits are what the controller sends back to the console. Is this right? If this is the case, then those references are even more difficult to put into code. I would need to scan for specific byte sequences, and return data bits based on specific information. And to my current understanding, there are different 'modes' at which this data is collected, and some command headers appear to be identical making this specification even more insane. I decided to take a step back and just use keyboard presses to emulate button presses in digital mode. But I'm still not sure where to start with all of this, and I don't want to recycle your code because I wouldn't be learning anything that way. So my real questions are:
Any info here would be much appreciated. If I'm far away from the right direction, I'd really like to know. |
|
|
|
|
|
#12 |
|
クロッスエクス
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Mar 2006
Location: Argentina
Posts: 3,636
|
Subscribed now, so I can get notifications on posts here. Alright, so it doesn't really matter if you want to start with the digital PS1 controller or the DualShock 2 since all are basically the same but the latter a superset of the previous one. StartPoll and Poll are the main functions to use, the other readport# ones seem for old psx emus. Anyhow.. here's a basic "workflow" from this two functions with the common poll command for a digital controller: Code:
In: 0x01 0x42 0x00 0x00 0x00 Out: 0xFF 0x41 0x5A 0xFF 0xFF In functions as in (in)(func)(out) 0: 0x01 StartPoll -> 0xFF 1: 0x42 Poll -> 0x41 2: 0x00 Poll -> 0x5A 3: 0x00 Poll -> 0xFF 4: 0x00 Poll -> 0xFF Then for the next request... again it goes 0: 0x01 StartPoll -> 0xFF 1: 0x42 Poll -> 0x41 2: 0x00 Poll -> 0x5A 3: 0x00 Poll -> 0xFF 4: 0x00 Poll -> 0xFF #EDIT: PS: Yes, since Poll and StartPoll are unsigned char functions, you must return an unsigned char. |
|
|
|
|
|
#13 |
|
Registered User
Join Date: Aug 2012
Location: USA, CA
Posts: 15
|
Thanks! That clears a lot up! I've been experimenting with this and it seems the very first command sent out is always a poll command (which makes sense), skipping the first byte (where cmd = 0x01 and data = 0xFF). I have successfully told the emulator that I am polling for 21 bytes, making it red analog with pressure sensitive support. I have been testing in the SCPH-1001 bios (no roms/CD loaded) using the pSX emulator. I haven't got a button press to properly register like this yet (by setting byte #16 to 0xFF), but I'll keep experimenting and I'll post my updates here. As for the GUI for this monstrosity, I'm super stoked! It can already auto-discover any nearby Wiimotes and connect to them without too much trouble. I eventually plan to implement a "calibration window" (using OpenGL) which visually displays the orientation and button presses of the device, allowing the user to adjust these settings with a single button press, if need be. How cool would that be? This won't be until a much later release, though. For now, I'm simply focusing on getting the actual emulation part down. Last edited by Rectangle; August 20th, 2012 at 08:24.. |
|
|
|
|
|
#14 |
|
クロッスエクス
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Mar 2006
Location: Argentina
Posts: 3,636
|
Analog red is just the normal analog mode, so there should be no pressure involved there. Pressure must first be requested by cmd 0x4F. This enables pressure and updates the pressure mask. Note that the pressure mask must be full by default (0xFF 0xFF 0x03) since it might be requested without pressure enabled by cmd 0x41. Note that pressure has nothing to do with the digital states of the buttons. Pressure is a superset of the DualShock2 (from the DualShock1 I assume) that gives analog data for the buttons. The digital states are bytes 3 and 4 (from the previous post) which has the state of all the controller's buttons. #EDIT: PS: I guess I could make a wiki page with all the controller info. Last edited by KrossX; August 20th, 2012 at 08:19.. |
|
|
|
|
|
#15 | |
|
Registered User
Join Date: Aug 2012
Location: USA, CA
Posts: 15
|
Quote:
EDIT: I just noticed that 1=OFF, 0=ON. I'm sure many future emu devs would appreciate that! |
|
|
|
|
|
|
#16 |
|
クロッスエクス
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Mar 2006
Location: Argentina
Posts: 3,636
|
Yup yup, all 0xFF 0xFF means everything is off. Check the "Digital Button State Mapping" on the CuriousInventor page to know what is what. I didn't know it had one, but I just compared it and it's fine.
|
|
|
|
|
|
#17 |
|
Registered User
Join Date: Aug 2012
Location: USA, CA
Posts: 15
|
I've done it!! All digital controls are emulated flawlessly. =D Not only that, but I've somehow managed to boost the actual performance of the game itself. Runs smoother than most other input plugins, so far. I feel the need to credit you for this though, since I modified several chunks of your code to get the right order of things. Analog controls don't seem to work with the game I'm testing though (Silent Hill NTSC). I'll have to conduct a few more tests to see why that is, because I've read that it does support DualShock controls. Last edited by Rectangle; August 20th, 2012 at 16:05.. |
|
|
|
|
|
#18 |
|
クロッスエクス
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Mar 2006
Location: Argentina
Posts: 3,636
|
Since it's a PS1 game it may not detect the Dualshock unless you toggle the analog on the controller. So you gotta emulate the analog button. If it's automatic, like with FF8, just make sure to have commands 0x43 and 0x44 correct. 0x43 is the config mode, and 0x44 is for mode toggle/lock. |
|
|
|
|
|
#19 |
|
Registered User
Join Date: Aug 2012
Location: USA, CA
Posts: 15
|
Still fiddling with it, but I now have full Wiimote functionality over digital PSX controls. If you have a Wiimote and either a bluetooth adapter or internal bluetooth, and you'd like to test it out, let me know |
|
|
|
|
|
#20 |
|
Registered User
Join Date: Aug 2012
Location: USA, CA
Posts: 15
|
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|