p1pkin / demul

Automatically exported from code.google.com/p/demul
97 stars 19 forks source link

Dualshock 4 and Demul: unable to configure buttons #456

Open SegaArcade opened 6 years ago

SegaArcade commented 6 years ago

Hello

There is an issue when using Dualshock 4 controller on Demul: it's impossible to configure buttons, the emulator recognize the "joy0_anl3_key" eternally pressed (it should be the "sixasis").

It there was a way to make demul ignore the joy0_anl3_key, we could configure Dualshock 4 controlelrs without issues.

Thanks

ulao commented 6 years ago

This is relatively easy to fix. You should never detect by vale, only change. If an analog moves more then say X points, an analog was moved, map it. Relying on the rest position will never be the same.

Guessing this is an old post but Demul is one of the best emulators for DC. So lets make it great.

ghost commented 6 years ago

Hi, just want to report same issue with Blissbox adapter and an original Dreamcast controller. Beyond controls mapping screen, where the trick is to get the button you want to map need to be pressed before starting the mapping process, this affects gameplay. My test is with Crazy Taxi on Dreamcast. With L and R triggers properly configured using this trick, you cannot properly play with the gear box to get the start boost (for the ones that know the game).

SegaArcade commented 6 years ago

I can confirm that I have the same problem but for the Naomi version of Crazy Taxi using Dualshock 4. The "start boost" doesn't work.

p1pkin commented 6 years ago

try this plugin https://yadi.sk/d/hJkqI0sy3VGDeV and let us know if it solves the problem.

ghost commented 6 years ago

Thank you. Same issue with this plugin. Analogic trigger always pressed in controls window. Messing it up in crazy taxi as reported before.

p1pkin commented 6 years ago

which one is reported pressed ? JOY0_ANL3_KEY or other one ?

p1pkin commented 6 years ago

PS: updated plugin is mainly addressed to fix Dualshock issues, it have been verified to solve DS3 troubles. will be good to know if it helps in case of DS4.

but that "Blissbox adapter" might have another kind of weirdness instead.

ghost commented 6 years ago

JOY0_ANL2_KEY in my case.

below, my ini file for 1st dreamcast controller.

[JOY0_0] UP = 16777226 DOWN = 16777227 LEFT = 16777228 RIGHT = 16777229 A = 16777217 B = 16777219 C = 0 D = 0 X = 16777216 Y = 16777218 Z = 0 LTRIG = 33554693 RTRIG = 33554690 START = 16777221 S1UP = 33554689 S1DOWN = 33554433 S1LEFT = 33554688 S1RIGHT = 33554432 S2UP = 0 S2DOWN = 0 S2LEFT = 0 S2RIGHT = 0 UP2 = 0 DOWN2 = 0 LEFT2 = 0 RIGHT2 = 0

@ulao : Maybe this is where you can step in.

p1pkin commented 6 years ago

can you please provide screenshot similar to attached ? calibrate

press Win+R - enter there "joy.cpl", select gamepad and press "calibrate", then take screenshot(s) of available analog axis(es) and data read from them.

ulao commented 6 years ago

Hi p1pkin, I'm the author to Bliss-Box. If you have any direct questions about the adapter I can answer on a technical level for you.

There are 8 analogs. (All have an 8 bit value and reset at 0 or 128 but DX adds a few bits, 8 I think, bring it to 16 total. )

Main stick X rests at 128 (DC main stick x) Main stick Y rests at 128 (DC main stick y) X rotation rests at 0 (DC pad right trigger) Y rotation rests at 128 (not used by DC pad) Z rotation rests at 128 (not used by DC pad) Z axis rests at 0 (DC pad Left trigger) Dial rests at 128 (not used by DC pad) Slider rests at 128 (not used by DC pad) This adapter has 3 rows of buttons (all normal not pressed) and one HAT(pov) that rests at -1 (no value)

dc dc2 dc4

Also FYI, not a sales pitch and I'm happy to send you a developers kit to test. This adapter supports LCD writes and soon memory pack writes and possible native communication. This is all done via usb Feature get/set reports.

p1pkin commented 6 years ago

thanks for reply, I suspect this might be incorrect:

Y rotation rests at 128 (not used by DC pad) Z rotation rests at 128 (not used by DC pad) Dial rests at 128 (not used by DC pad) Slider rests at 128 (not used by DC pad)

at least Direct Input docs said "If the joystick does not have this axis, the value is 0." https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.reference.dijoystate(v=vs.85).aspx

I'm far not a pro in Input devices, but afaik missing Axis-es also should not generate Enumeration callbacks (at software level, don't know how it will be in hardware). but your device somehow reports it have all that stuff, and we see at 1st screen bunch of redundant Axis-es displayed (Y rotation, Z rotation, etc)...

ulao commented 6 years ago

This is a multi controller adapter. All analogs report all the time. Otherwise a separate descriptor would be needed on the fly and the by USB definition, this is not possible. Most all software sees 0 as or 128 as a resting point in the way of controllers. I have not looked at other emulators out there to see how they do it but I suspect they do it the way I state on my first post. Myself, In game I just ignore all analogs I didn't map. For the ones I mapped, I record a resting position. Upon my mapping screen I capture all values and mark as their respective resting points.

"thanks for reply, I suspect this might be incorrect" These will always report 0 when a DC is plugged in. Other controller will use these values like psx controllers.

p1pkin commented 6 years ago

can you check with this one plugin ? https://yadi.sk/d/hJkqI0sy3VGDeV

ulao commented 6 years ago

Looks like "JOY1_ANL2_KEY-" is always pressed. I'm going out on a limb here but my guess is ANL2 is either X rotation rests at 0 (DC pad right trigger) or Z axis rests at 0 (DC pad Left trigger) and anything less then 128 is a negative in DX(-32768 to +32768)? If it helps Bliss-Box usb IDs are 16d0:0Dxx, helpfull if you want to know when a Bliss-Box is attached.

WindDemulTeam commented 6 years ago

https://yadi.sk/d/hJkqI0sy3VGDeV pls, get update, retest and return stdout.txt to me

ghost commented 6 years ago

Cant test again on my side before Monday. Will report back then.

ulao commented 6 years ago

Steps

1) downloaded file and overwrote old file. (confirmed the file size difference) 2) ran demul ->controlers->joy1->ltrig (clicked it once), shows "JOY1_ANL2_KEY-" 3) I ran a search for "stdout" no results.

WindDemulTeam commented 6 years ago

driver Bliss-Box not support with EnumObjects?

ulao commented 6 years ago

That's a bit vag?

1) Bliss-Box uses HID (no drivers are required) and the most common/reliable driver for everything controller related. 2) Enum's are part of C, what do you mean by that? This? https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.idirectinputdevice8.idirectinputdevice8.enumobjects(v=vs.85).aspx Yes HID gamepad drivers should support that. I didn't write the HID drivers m$ did, I would assume they made that work with DX as long as you build against dx 6-9. After that they dropped HID in favor of xinput (and support HID virtually (limited))

WindDemulTeam commented 6 years ago

EnumObjects from dinput api. Bliss-Box driver is very bad support with directx input or xinput?

ulao commented 6 years ago

See my edits. Happy to work with you on the plug-in source over email or discord. https://discord.gg/h5WWNC

p1pkin commented 6 years ago

its about https://msdn.microsoft.com/en-us/library/windows/desktop/microsoft.directx_sdk.idirectinputdevice8.idirectinputdevice8.enumobjects(v=vs.85).aspx it is the way software enumerate DInput device properties. i.e. retrieve information which axis-es, etc exists in some device

if there was no stdout.txt file created in emulator folder - there was no any enum callback calls, which quite odd and unexpected.

ulao commented 6 years ago

right but see

DIDFT_ALIAS Controls identified by a Human Interface Device (HID) usage alias. This flag applies only to HID-compliant USB devices.

This is exactly what the Bliss-Box is a HID. So if they mention it, yes it should be supported.

ulao commented 6 years ago

Honestly guys the HID driver is not related to Bliss-Box and Bliss-Box has no drivers that are required. Saying Bliss-Box has bad support for XYZ is like saying Microsoft has bad support for XYZ. In this case XYZ is directX and that's like saying Microsoft has bad support for Microsoft.

Maybe I'm miss reading what you mean?

The drivers that operate the Bliss-Box are done via the windows HID system like all of these gamepad adapters you see on the net including and not limited to .

Raphnet Mayflash Nintendont RetroUSb and so many more.

The HID system as been around since win95 and support a number of devices. AKA plug n play USB. Flash driver, Mice, Keyboards, etc... I'm positive they support the enum objects, and I'm not sure what leads you to believe they do not?

WindDemulTeam commented 6 years ago

pls, retest: https://yadi.sk/d/TunnVHkM3VPTha have stdout?

ulao commented 6 years ago

No, would windows be trying to put it in some dumb users folder or something? I checked the root and the plugin folder. Or do I need to use a debug version?

ulao commented 6 years ago

I did a drive search, and have that file for a few emulators stella, mupen64, snes89x, boycott but I see nothing for demul

WindDemulTeam commented 6 years ago

Not good. Dinput not support with Bliss-Box. Current version use EnumObjects DIDFT_ALL-mode Raw usb-hid not used in padPlugin.

ulao commented 6 years ago

What version of Dinput are you implementing?

WindDemulTeam commented 6 years ago

Used dinput8 (last version).

ulao commented 6 years ago

That's fine.

What does

"Dinput not support with Bliss-Box." mean?

and what does

"Current version use EnumObjects DIDFT_ALL-mode Raw usb-hid not used in padPlugin." - mean?

FYI:

All of these examples work with the Bliss-Box https://code.msdn.microsoft.com/windowsdesktop/DirectInput-Samples-8ac6f5e3

Also there is this handy tool. https://www.codeproject.com/KB/directx/HIDEasyClass/usbhidioc_demo.zip data

ulao commented 6 years ago

Ok here is an example of enum objects working. del // Enumerate the joystick objects. The callback function enabled user // interface elements for objects that are found, and sets the min/max // values property for discovered axes. if( FAILED( hr = g_pJoystick->EnumObjects( EnumObjectsCallback, ( VOID* )hDlg, DIDFT_ALL ) ) ) return hr;

Here is the code.

joystick.zip

AS you can see the problem is the -1000. I'm not sure why the stdout is not getting made but it is not because of support. HID is the most compatible driver in existence (next to xinput).

If you need me to add any debug code outputs in this examples just let me know. ill compile and try it for you.

p1pkin commented 6 years ago

thanks.

AS you can see the problem is the -1000.

it looks like the root of problems. https://msdn.microsoft.com/en-us/library/ee417014%28VS.85%29.aspx

The combination of the left and right triggers in DirectInput is by design. Games have always assumed that DirectInput device axes are centered when there is no user interaction with the device.

so, Z values must be centered, i.e. 0, not -1000

p1pkin commented 6 years ago

for the case if it was not clear:

X rotation rests at 0 (DC pad right trigger) Z axis rests at 0 (DC pad Left trigger)

is NOT correct. they must be centered instead, and/or both combined into single axis as per DInput standards. it is bug/mistake in your device, and there is great question - why me and Wind wasting our time on that ?

ulao commented 6 years ago

hmm, are you using xinput? Because in xinput they are combined yes. Can you do it like my example? In my example they are not combined as it uses dinput not xinput. You should be able to detect dinput vs xinput.

If they are centered you will not get the full range. This was the original issue. Also combining them is not a dinput standard. I'm not sure why you said that. Many programs use them without combining them. This combinding was implemented in xinput. they did that so xinput could support dinput. Nobody is wasting anyone time here. There really is no need to be angry?

INFO: - from https://msdn.microsoft.com/en-us/library/windows/desktop/ee417014(v=vs.85).aspx


Using the Xbox 360 Controller with DirectInput

The Xbox 360 Controller is properly enumerated on DirectInput, and can be used with the DirectInputAPIs. However, some functionality provided by XInput will be missing from the DirectInput implementation:

The left and right trigger buttons will act as a single button, not independently
The vibration effects will not be available
Querying for headset devices will not be available

The combination of the left and right triggers in DirectInput is by design. Games have always assumed that DirectInput device axes are centered when there is no user interaction with the device. However, the Xbox 360 controller was designed to register minimum value, not center, when the triggers are not being held. Older games would therefore assume user interaction.

The solution was to combine the triggers, setting one trigger to a positive direction and the other to a negative direction, so no user interaction is indicative to DirectInput of the "control" being at center.


So there you are. This is not a HID implementation this is xinput. Hundreds of HID devices on the market do not combined axes like that. You are going to want to add support for both HID and xinput.

p1pkin commented 6 years ago

Demul code works in almost same way as example code. as it turned out the problem is not in enumeration, but because your device reports not centered value, as it should be as per Dinput standards.

ulao commented 6 years ago

I can move to dial and slider instead. but there is no standard likes that, there is some kind of a misunderstanding or communication error here. Let me give that a try and see how it acts.

p1pkin commented 6 years ago

no standards ? MSDN is OK ? Games have always assumed that DirectInput device axes are centered when there is no user interaction with the device.

p1pkin commented 6 years ago

i.e. if some axis have full range 0 - 255, resting position must be 128, always.

ulao commented 6 years ago

Hmm, I guess your assumption was incorrect, I move the data to dial and slider and centered the Z stuff now the issues is on JOY0_ANL6_KEY-

ulao commented 6 years ago

Ok but the game needs 0-255 ? If I center it the game will only get 128-256?

We already tried that. I centered them for onthewaveagain and the game does not work right. You must give the game 0-256 or at least up scale it and loose precision.

"With L and R triggers properly configured using this trick, you cannot properly play with the gear box to get the start boost (for the ones that know the game)."

The DC pad has 8 bits, if you center it you will only get 7 bits. There is a way to do this in DX but if you don;t want to do that, then you must bit shift up one bit in the code.

p1pkin commented 6 years ago

have you seen example code ? especially that part: diprg.lMin = -1000; diprg.lMax = +1000; if( FAILED( g_pJoystick->SetProperty( DIPROP_RANGE, &diprg.diph ) ) ) it tells DInput to scale axis value to -1000 - +1000 range, not matter what original range was, Demul works in same way, but other values used. it doesn't have any matter what values was actually reported by device.

ulao commented 6 years ago

And that is fine. I dont mind centering it for anyone that wants to use demul. As he and I both already said we did that but you can not play the game with the original DC pad.

The DC pad has 8 bits, if you center it you will only get 7 bits. You must bit shift up one bit in the code. However you send the data to the game it must see 0 to 255. For some reason it is seeing 0-128 or 128-256. I'm not sure.

or maybe that fix you made does work and he just need to put it back in center mode.

p1pkin commented 6 years ago

why only 7 or 8 bits ? why not use larger range ? other input devices use 0 - 0xffff, which is more than enough.

in general, I'm not interested in adding quirks into this emulator for various devices which does not follow standards, or have bugs.

ulao commented 6 years ago

I never asked Sega why they decided to use 8 I just assumed they did that because everyone else did?

The game pad has 8 bits of data for all axies. Like every other game pad out there. DX always takes that range (or any range like you said) and blows it way up. The game will expect 8 bits, so at some point in your code you are down sampling DX's blown up size back down to 8 bits. I'm mean obviously as that is what the game expects.

I have the Sega spec manuals that explains all of that. All I saying here is that the game is going to expect what the original controller is sending it. You are faking this data because its an emulator. In the channels somehow the data is getting shortened.

This is not specific to my device. This is the way all adapters and controllers work. I'm not asking you to do anything out of the norm. We simple have a communication disconnect here.

You requested me to center my values and there is an option for that in my adapter. But that didn't seem to work for the users that reported the issue.

I'm just trying to help but apparently its causing you trouble. This is not a special request. We are just not understating each other.

If you want to be friendly and work on this together I will of course work with you. I can help, that is a guarantee. This help is not just for my adapter its for all adapters out there that use HID. I welcome you to communicate over the discord so that we do not clutter up your forums here. We can share and talk code in a more private and communicative way. I'm not your enemy please stop reading it that way.

I'm not sure if the code to Chankast is open or not but they are doing it in a way that it works correctly. They detect the trigger after its pressed and games see the full range. But its chrakcast... comm'on. That's an old emulator.

I think most everyone would agree that demul is the best most advance emulator for DC. So hey, naturally we want to help you.

The way the issues appears to me...

your mapping code is having a hard time with detecting a press because of the 0 reset. If I change the adapter to reset at 128 you have to understand that you just cut off half the precision (8 bits to 7). If that does not makes sense ill put it another way. Resting at 0 gives you {0#########255] Resting at 128 gives you. (--------128#####255] So you just lost half the precision the Dream Cast pad is giving you.. No matter what way you want to look at it, the precision is lost.

Using that example I sent you you could do this.

//place up top. int Z_axis_old=0; int Z_rotate_old=0;

//place in the UpdateInputState function. (and add the label with pressed ID) _stprintf_s( strText, 512, TEXT( "Nothing pressed" ) ); int Z_axis = js.lZ; if (Z_axis_old != Z_axis) _stprintf_s( strText, 512, TEXT( "Z_axis pressed" ) ); int Z_rotate = js.lRz; if (Z_rotate_old != Z_rotate) _stprintf_s( strText, 512, TEXT( "Z_Rotate pressed" ) ); Z_axis_old = Z_axis; Z_rotate_old = Z_rotate;

This will only detect a movement and allows you to rest at any point you want to.

OR

You can do what you are thinking. My adapter has a mode that rests at center. And understand you are loosing the precision. then once you get the data from DX and are ready to send it to the game, multiple it by 2 (or bitshift) So you get the data back. This way the game will see a range of x*2.

Also: I have been getting asked what you mean by bugs/errors? Instead of just pointing a finger to a term, why not define it? What do you think is wrong with this adapter? Everything above you claimed I proved is incorrect in the example code.

WindDemulTeam commented 6 years ago

We will not support errors in the operation of your device. You need to fix the error in your device and the problem will be solved.

ghost commented 6 years ago

Why not just make the controller plug-in source code public or at least plugin documentation so that one can be developed to support this adapter and all others that have been reporting the same issue.

I think Blissbox deserves some dedications as it is a very good piece of hardware and serve videogames preservation interest as a whole. Playing Dreamcast over Demul with a 360 controller is just not right. Blissbox is the only one with potential real VMU support.

Your joined Collaboration guys would make Demul experience more accurate.

SegaArcade commented 6 years ago

I tried the new paddemul.dll file https://yadi.sk/d/hJkqI0sy3VGDeV

Unfortunately with Sony PS4 Dualshock 4 the issue remain, Demul always detect the JOY0_ANL3_KEY before any other inputs. Also testing again Crazy Taxi (Naomi version) same issue as before, no way to perfom the boost start (pedal + gearbox, in my case on DS4, R2 trigger + square button).

p1pkin commented 6 years ago

@SegaArcade thanks for testing. can you provide stdout.txt log file which should be created in emulator folder ?

WindDemulTeam commented 6 years ago

https://yadi.sk/d/hJkqI0sy3VGDeV pls, retest and return stdout.txt to me