Re: Creating a wrapper for interception.dll (fixed and working!)
Posted: 25 Jun 2017, 15:12
Hi! I have been a little busy, and was testing this code and it works nice, it sleeps the mouse click, in a individual way to mantain the raw input sepparation.
This is used for crt lightguns connected to windows, as they work as absolute coord mice, but need a flashing just a moment before the click (15, 30 or 45ms depending on the game/ emulator), because they dont track on dark colors:
The next I wanted to do, is converting this to direct input. I mean, I have some games which work with direct input and the mice/guns aiming don't get sepparated.
I can set triggers to any key instead of mouse1button1, mouse2button1, and so each trigger shoots the correct player bullets, but the coordenates are shared, and when both guns are aiming to the screen, the shoots gets crossed.
So I thought this:
And, and it separate the shoots correctly, but as you said, when using MOUSE_MOVE, it may lag, although it isn't noticeable, the flashing and the click don't mach and don't work propperly on dark colors.
In this same code if I change
to
The flashing works propperly, but as I'm not blocking the sistem mouse coordinates, the shoots get crossed between p1 and p2.
Any idea about that? you said to sepparate in two scripts? I tried something but I don't understand how to do it...
do you think this is the problem? the lag caused when blocking MOUSE_MOVE?
This is used for crt lightguns connected to windows, as they work as absolute coord mice, but need a flashing just a moment before the click (15, 30 or 45ms depending on the game/ emulator), because they dont track on dark colors:
Code: Select all
load()
context:=create_context()
set_filter(context, "keyboard","KEY_ALL")
loop,5 ;everything but MOUSE_MOVE
set_filter(context, "mouse", mouse_filter "MOUSE_BUTTON_1_DOWN|MOUSE_BUTTON_1_UP")
while ( receive(context,device:=wait(context),key,mouse,1) >0 )
{
critical
if is_keyboard(device)
{
get_keyname(key,name,state)
if name=F12
break
send(context,device,key,1)
}
else if is_mouse(device)
{
get_keyname(mouse,name,state)
;ToolTip % "device: " device "`nname:" name "`nstate:" state "`nid:" hardware_id
if (device = gun1id || device = gun2id)
{
if name=LButton
{
if (state = 1)
{
if (device = gun1id)
flasher := gun1flasher
if (device = gun2id)
flasher := gun2flasher
send %flasher%
sleep, %triggerdelay%
send(context,device,mouse,1)
sleep, %triggerlength%
mouse.state := 2
send(context,device,mouse,1)
}
}
else
send(context,device,mouse,1)
}
else
send(context,device,mouse,1)
}
}
destroy_context(context)
return
The next I wanted to do, is converting this to direct input. I mean, I have some games which work with direct input and the mice/guns aiming don't get sepparated.
I can set triggers to any key instead of mouse1button1, mouse2button1, and so each trigger shoots the correct player bullets, but the coordenates are shared, and when both guns are aiming to the screen, the shoots gets crossed.
So I thought this:
Code: Select all
load()
context:=create_context()
set_filter(context, "keyboard","KEY_ALL")
set_filter(context, "mouse", "MOUSE_ALL")
while ( receive(context,device:=wait(context),key,mouse,1) >0 )
{
critical
if is_keyboard(device)
{
get_keyname(key,name,state)
if name=F12
break
send(context,device,key,1)
}
else if is_mouse(device)
{
get_keyname(mouse,name,state)
;ToolTip % "device: " device "`nname:" name "`nstate:" state "`nid:" hardware_id
if (device = gun1id || device = gun2id)
{
if name=LButton
{
if (state = 1)
{
if (device = gun1id)
trigger := gun1trigger
if (device = gun2id)
trigger := gun2trigger
;send(context,device,mouse,0)
mouse.state := 2
send(context,device,mouse,1)
sleep, %triggerdelay%
send {%trigger% down}
sleep, %triggerlength%
send {%trigger% up}
}
}
In this same code if I change
Code: Select all
set_filter(context, "mouse", "MOUSE_ALL")
Code: Select all
set_filter(context, "mouse", mouse_filter "MOUSE_BUTTON_1_DOWN|MOUSE_BUTTON_1_UP")
Any idea about that? you said to sepparate in two scripts? I tried something but I don't understand how to do it...
do you think this is the problem? the lag caused when blocking MOUSE_MOVE?