Page 4 of 6

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 10 Apr 2017, 10:28
by evilC
So the gun sends regular mouse buttons?
gun1Button0 == LMB?
gun1Button1 == RMB?

What is gun2Button0? LMB on a different mouse?

MouseDelta does not normally pay attention to button input, but I could give you code that does.
If the guns do just behave like a mouse though, unless gun0 and gun1 report as different mice, we would not need MouseDelta, we could just use a regular hotkey.

Try this script - does it show a tooltip when you press some of the gun buttons?

Code: Select all

~LButton::
~RButton::
~MButton::
~XButton1::
~XButton2::
	Tooltip % A_ThisHotkey
	return

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 10 Apr 2017, 10:54
by phasermaniac
Yes, gun buttons are regular mouse buttons. this is the driver I use:
http://www.arcadehits.net/pics/ups/Top-G_005.jpg

gun 0 and gun 1 reports as diferent mice, ID=65591 is gun1 ID=65592 is gun1 and 65593 is a regular mouse.

When i press mouse left button or some of the gun trigger I get "~LButton"message

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 10 Apr 2017, 11:00
by evilC
OK, so we need MouseDelta to be able to differentiate between the mice.

I can make you a modified version of MouseDelta that reports button numbers instead of axis position, so that is no problem.

Now that I know that the different guns report as different IDs though, that is a bit of a problem.
I do not know how to send fake mouse data as a *specific* mouse, only as ID 0.

Can you rig the emulator so that it responds to keys for the triggers?
ie we write code that listens for gun 1 trigger being pressed, and when it sees it pressed, flashes the screen, then sends F1.
The game is then told that the trigger is in fact F1, not mouse ID#65591 button 1

Is this possible?

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 10 Apr 2017, 11:20
by Helgef
phasermaniac wrote:gun 0 and gun 1 reports as diferent mice, ID=65591 is gun1 ID=65592 is gun1 and 65593 is a regular mouse.
My observations are that the ids change on reboot. You might need some id identification procedure rather than hardcoding it.

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 10 Apr 2017, 11:39
by phasermaniac
I use a program that makes some emus that supported only one gun playable with 2 guns, and it save the following ids for guns:
P1Device = \\?\HID#VID_0B9A&PID_016A&Col01#7&28d4c0d1&3&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}
P2Device = \\?\HID#VID_0B9A&PID_016A&Col01#7&3b8e7176&8&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}
they don't change.

emulators like mame, supermodel let you map the triggers as you want but others won't. Would be easy this way?

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 10 Apr 2017, 11:50
by phasermaniac
I asked the author of this program (Demulshooter) if he thinks would work:
"But as far as DemulShooter is concerned, it will not recognize these kind of script-sent inputs :
To be able to dissociate devices I have to ask windows to forward me all raw-input message so that I can identify them and treat them
Most of the time, ahk scripts and other program are sending direct input messages, and it totally different"

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 10 Apr 2017, 13:54
by evilC
Helgef wrote:
phasermaniac wrote:gun 0 and gun 1 reports as diferent mice, ID=65591 is gun1 ID=65592 is gun1 and 65593 is a regular mouse.
My observations are that the ids change on reboot. You might need some id identification procedure rather than hardcoding it.
This begs the question of how MAME knows which ID is for which gun.

I wonder if this value that we have been using as "MouseID" is actually a pointer to a GUID or something?

RAWINPUTHEADER

hDevice
Type: HANDLE
A handle to the device generating the raw input data.

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 10 Apr 2017, 14:53
by phasermaniac
Take care because

P1Device = \\?\HID#VID_0B9A&PID_016A&Col01#7&28d4c0d1&3&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}
P2Device = \\?\HID#VID_0B9A&PID_016A&Col01#7&3b8e7176&8&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}

And

ID=65591 is gun1 ID=65592 is gun1 and 65593

Are data taken from different computers so don't correspond

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 10 Apr 2017, 15:09
by Helgef

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 10 Apr 2017, 17:21
by evilC
Still not sure that's gonna help us achieve his ideal goal.
Current plan of remapping the trigger to something inactive is not gonna fly, because we can only send as ID 0 (ie AFAIK mouse_event always sends as ID 0), so the driver will not recognize button presses as coming from the guns, or at least not from player 2.

I think Interception could probably solve this, but I am not that down with C++ I am afraid, also potentially nefarius' ViGEm suite may be able to sort this (if he gets around to finishing it)

Unless we can find some way of faking the gun triggers, then basically the only option I see is to physically mod his guns to add a two-stage trigger, and have the first stage do the flash.

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 11 Apr 2017, 09:15
by phasermaniac
This was posted by nuvee plugins autor (dual lightguns suport for ps1 and ps2 emulators)
http://ngemu.com/threads/input-plugin-n ... er.143143/
Seems the way the plugin comunicates with emulator.
May it help in some way?

typedef void (CALLBACK* PADhandleHID)(LPARAM);


case WM_INPUT:
PAD1_handleHID( lParam );
PAD2_handleHID( lParam );
return TRUE;

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 11 Apr 2017, 10:19
by phasermaniac

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 11 Apr 2017, 10:21
by evilC
Arg, I wish I knew more about RawInput...

The way I send fake input is using the mouse_event API call, though it can also be done using SendInput.
Both of these calls have a dwExtraInfo parameter which I normally never use.

The docs say: An additional value associated with the mouse event. An application calls GetMessageExtraInfo to obtain this extra information
This is set using SetMessageExtraInfo

Code: Select all

LPARAM WINAPI SetMessageExtraInfo(
  _In_ LPARAM lParam
);
So this appears to allow you to set the LPARAM for the input?
Is the driver expecting something in LPARAM that identifies where the input came from?

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 11 Apr 2017, 10:23
by evilC
Most of this appears to be relevant to interpreting the data that comes in from the guns - this is not the major problem at the moment, the major problem is to work out if it is possible to send fake input data that appears to come from an attached device.

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 11 Apr 2017, 10:49
by Helgef
evilC wrote:the major problem is to work out if it is possible to send fake input data that appears to come from an attached device.
Maybe set up your own RAWINPUT structure, then pass its adress as the lParam of a WM_INPUT message. I guess you would try to send WM_INPUT to one of your own scripts with mouse delta active, and see if it responds. But then there is the problem of knowing where (which HWND) to send it to. Just a thought.

About GetRawInputDeviceList, that could be used to fetch all mouse devices and list them by name in the UCR mouse selection control. So the control could list all mice on creation, instead of being added when detected via movement.

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 11 Apr 2017, 11:19
by Helgef
I only found one mouse, I have two connected, and this is what I got, \\?\HID#VID_045E&PID_00CB#7&311ffe2c&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}, not very exciting. :thumbdown:

Code: Select all

Msgbox, % GetMiceList()
GetMiceList(){
	static cbSize:=A_PtrSize*2
	static RIDI_DEVICENAME:=0x20000007
	DllCall("GetRawInputDeviceList", "UptrP", 0, "UintP", puiNumDevices, "Uint", cbSize)
	VarSetCapacity(pRawInputDeviceList,puiNumDevices*cbSize,0)
	r:=DllCall("GetRawInputDeviceList", "Uptr", &pRawInputDeviceList, "UintP", puiNumDevices, "Uint", cbSize)
	Loop, % puiNumDevices {
		hDevice:=NumGet(&pRawInputDeviceList,cbSize*(A_Index-1),"Uptr")
		dwType:=NumGet(&pRawInputDeviceList, cbSize*(A_Index),"Uint")
		if (dwType) ; RIM_TYPEMOUSE=0
			continue
		uiCommand:=RIDI_DEVICENAME
		DllCall("GetRawInputDeviceInfo", "Uptr", hDevice, "Uint", uiCommand, "PtrP", 0, "UintP", pcbSize)
		VarSetCapacity(pData,pcbSize*(A_IsUnicode?2:1),0)
		DllCall("GetRawInputDeviceInfo", "Uptr", hDevice, "Uint", uiCommand, "Ptr", &pData, "UintP", pcbSize)
		str.=StrGet(&pData)  "`n" 
	}
	return str
}
/*
---------------------------
20170411174902.ahk
---------------------------
\\?\HID#VID_045E&PID_00CB#7&311ffe2c&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}
---------------------------
OK   
---------------------------
*/
Edit: This code has errors it seems.

Edit3:
It should be more like this,but this crashes :eh:

Code: Select all

Msgbox, % GetMiceList()
GetMiceList(){
	static cbSize:=A_PtrSize*2
	static RIDI_DEVICENAME:=0x20000007
	DllCall("GetRawInputDeviceList", "Uptr", 0, "UintP", puiNumDevices, "Uint", cbSize)
	VarSetCapacity(pRawInputDeviceList,puiNumDevices*cbSize,0)
	r:=DllCall("GetRawInputDeviceList", "Uptr", &pRawInputDeviceList, "UintP", puiNumDevices, "Uint", cbSize)
	Loop, % puiNumDevices {
		hDevice:=NumGet(&pRawInputDeviceList+0,cbSize*(A_Index-1),"Uptr")
		dwType:=NumGet(&pRawInputDeviceList+0, cbSize*(A_Index-1)+A_PtrSize,"Uint")
		if (dwType) ; RIM_TYPEMOUSE=0
			continue
		uiCommand:=RIDI_DEVICENAME
		DllCall("GetRawInputDeviceInfo", "Uptr", hDevice, "Uint", uiCommand, "Ptr", 0, "UintP", pcbSize)
		if !pcbSize
			continue
		VarSetCapacity(pData,pcbSize*(A_IsUnicode?2:1)+2,0)
		DllCall("GetRawInputDeviceInfo", "Uptr", hDevice, "Uint", uiCommand, "Ptr", &pData, "UintP", pcbSize)
		str.=StrGet(&pData)  "`n`n" 
	}
	return str
}
This seems better, but it gives me four results, as I said, I have only two mice. Sorry for derailing. :offtopic:

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 11 Apr 2017, 14:46
by phasermaniac
many thanks for your interest Helgef.
For me seems its working nice. Tried plugging and unplugging and reports the correct number of devices

So with theis method, can rawinput false pulsations be sent?

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 12 Apr 2017, 11:05
by phasermaniac
Sorry I'm a bit lost with this code, never played with dlls and so. Doesn't it resolves anything to you evilC? It seems to show the correct ID for mice for me

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 12 Apr 2017, 12:20
by Helgef
The code I provided doesn't really help you, it is just meant to get the names of the devices, I didn't test my earlier suggestion to send custom input messages. And even if it would work, we might not know where to send it in your case. In the end, there should be more sophisticated solutions, but that is beyond me.

Re: [Library] MouseDelta - See mouse input the way games see it. (Use for mouse axis->key or joystick)

Posted: 12 Apr 2017, 17:59
by phasermaniac
Thanks you two anyway, do you think its woth to talk with interception guys or do you think it can't be done? For me, so much difficult, and it's so specific... most people use ir guns and they don't have this problem