#3504737 - 01/27/12 03:30 PM
Re: Conditional mapping of mouse to Warthog HAT1
[Re: dcs]
|
Joined: Jul 2005
Posts: 1,508
Teej
Member
|
Member
Joined: Jul 2005
Posts: 1,508
|
As it says in the book, 'AXIS' inside EXEC is forbidden.
What you'll need to do is a little more complex.
Immediately above "int main", add a line:
int MouseU, MouseD, MouseL, MouseR;
Then inside main, add 4 lines:
MouseU = AXIS(MOUSE_Y_AXIS, -80, 20); MouseD = AXIS(MOUSE_Y_AXIS, 80, 20); (add appropriate for L & R on MOUSE_X_AXIS as well)
Then for your mapping,
MapKey(&Joystick, H1U, EXEC("ActKey(KEYON+MouseU);")); // starts it moving MapKeyR(&Joystick,H1U, EXEC("ActKey(MouseU);")); // stops moving
And that should get you in business.
Last edited by Teej; 01/27/12 03:31 PM.
|
|
#3505829 - 01/28/12 07:13 PM
Re: Conditional mapping of mouse to Warthog HAT1
[Re: dcs]
|
Joined: Apr 2000
Posts: 46
dcs
Junior Member
|
Junior Member
Joined: Apr 2000
Posts: 46
|
I apologize for taking so long to get back to you with my thanks for your assistance.
“As it says in the book, 'AXIS' inside EXEC is forbidden.”
Yes it does. Argh! I even remember skimming through that paragraph when I was looking for something else, (although I wouldn’t have known how to work around it, without you help.) I’d love to find a programming reference with a table for all the functions, so I wouldn’t have to jump back and forth looking for syntax, usage, etc.
The code you provided works great, (in Windows), exactly what I was trying to accomplish. I do, however, have a problem with the mouse feature in the game itself.
I’m trying to use it in SteelBeasts PE for the unbuttoned driver’s position. The simulation doesn’t support anything except the mouse for panning the driver’s view. It doesn’t require fine control or range of motion, but it’s nice to be able to turn your head a little when dashing between cover.
In game, when I enable the mouse, the view is uncontrollable. I've played with the AXIS parameters to try to reduce sensitivity, but it doesn’t work as expected.
It doesn’t seem to be just the game, the CH handles this function without issue. The WARTHOG mouse works in game in the map view as you would expect; there is something about the external views that different.
When using the mouse function on the WARTHOG, the view will swerve rapidly in one direction. Sometime, even after changing direction on the HAT, the view will persist in the old direction every time the HAT is pressed, (regardless of direction.) There seems to be a buffer that it getting overloaded with inputs even when large delays are added to the axis definitions.
I tried to include the PULSE modifier to the ActKey(KEYON+Mouse?) command to try and restrict the amount of input sent to the game. I'm not sure that it’s supported or if it has any effect. Since the amount of view movement required by the drivers position, even if I have to repeating press the HAT, it would still be usefully.
Is there a way to “clear” the mouse status to remove any pending movement commands?
Is there a way to force individual mouse movement commands?
Thanks for any assistance you provide. Below is some of the sample code I’ve been trying for your reference: The S3 button simulates the crew position button to toggle the HAT state.
include "target.tmh"
int MouseU, MouseD, MouseL, MouseR, flag1; //program startup int main() { if(Init(&EventHandle)) return 1; // declare the event handler, return on error
flag1=1;
MouseU = AXIS(MOUSE_Y_AXIS, -20, 50); MouseD = AXIS(MOUSE_Y_AXIS, 20, 50);
MouseL = AXIS(MOUSE_X_AXIS, -20, 50); MouseR = AXIS(MOUSE_X_AXIS, 20, 50);
MapKey(&Joystick, H1U, EXEC("if(flag1) ActKey(PULSE+KEYON+MouseU); else ActKey(KEYON+DXHATUP);")); // starts it moving MapKeyR(&Joystick,H1U, EXEC("if(flag1) ActKey(MouseU); else ActKey(DXHATUP);")); // stops moving
MapKey(&Joystick, H1D, EXEC("if(flag1) ActKey(PULSE+KEYON+MouseD); else ActKey(KEYON+DXHATDOWN);")); // starts it moving MapKeyR(&Joystick,H1D, EXEC("if(flag1) ActKey(MouseD); else ActKey(DXHATDOWN);")); // stops moving
MapKey(&Joystick, H1L, EXEC("if(flag1) ActKey(PULSE+KEYON+MouseL); else ActKey(KEYON+DXHATLEFT);")); // starts it moving MapKeyR(&Joystick,H1L, EXEC("if(flag1) ActKey(MouseL);else ActKey(DXHATLEFT);")); // stops moving
MapKey(&Joystick, H1R, EXEC("if(flag1) ActKey(PULSE+KEYON+MouseR); else ActKey(KEYON+DXHATRIGHT);")); // starts it moving MapKeyR(&Joystick,H1R, EXEC("if(flag1) ActKey(MouseR); else ActKey(DXHATRIGHT);")); // stops moving
MapKey(&Joystick, S3, EXEC("flag1=!flag1;"));
}
//event handler int EventHandle(int type, alias o, int x) { DefaultMapping(&o, x); //add event handling code here }
|
|
#3506559 - 01/29/12 08:32 PM
Re: Conditional mapping of mouse to Warthog HAT1
[Re: dcs]
|
Joined: Jul 2005
Posts: 1,508
Teej
Member
|
Member
Joined: Jul 2005
Posts: 1,508
|
Give this a try. It has logic that should guarantee there's no "buildup" of mouse axis commands, and the panning in A10C is almost identical using the hat-as-mouse-axis and the normal view panning with A10C parsing the DXHAT as a pan.
include "target.tmh"
int MouseU, MouseD, MouseL, MouseR, MouseUoff, MouseDoff, MouseLoff, MouseRoff, flag1, flag2, flag3, flag4, flag5; //program startup int main() { if(Init(&EventHandle)) return 1; // declare the event handler, return on error
flag1=1; flag2=0; flag3=0; flag4=0; flag5=0;
MouseU = CHAIN(EXEC("flag2=1;"),AXIS(MOUSE_Y_AXIS, -5, 5)); MouseD = CHAIN(EXEC("flag3=1;"),AXIS(MOUSE_Y_AXIS, 5, 5)); MouseL = CHAIN(EXEC("flag4=1;"),AXIS(MOUSE_X_AXIS, -5, 5)); MouseR = CHAIN(EXEC("flag5=1;"),AXIS(MOUSE_X_AXIS, 5, 5));
MouseUoff = EXEC("flag2=0; ActKey(MouseU); ActKey(MouseUoff);"); MouseDoff = EXEC("flag3=0; ActKey(MouseD); ActKey(MouseDoff);"); MouseLoff = EXEC("flag4=0; ActKey(MouseL); ActKey(MouseLoff);"); MouseRoff = EXEC("flag5=0; ActKey(MouseR); ActKey(MouseRoff);");
MapKey(&Joystick, H1U, EXEC("if((1==flag1) & (0==flag2)) ActKey(KEYON+MouseU); else ActKey(KEYON+DXHATUP);")); // starts it moving MapKeyR(&Joystick,H1U, EXEC("if(flag1) ActKey(KEYON+MouseUoff); else ActKey(DXHATUP);")); // stops moving
MapKey(&Joystick, H1D, EXEC("if((1==flag1) & (0==flag3)) ActKey(KEYON+MouseD); else ActKey(KEYON+DXHATDOWN);")); // starts it moving MapKeyR(&Joystick,H1D, EXEC("if(flag1) ActKey(KEYON+MouseDoff); else ActKey(DXHATDOWN);")); // stops moving
MapKey(&Joystick, H1L, EXEC("if((1==flag1) & (0==flag4)) ActKey(KEYON+MouseL); else ActKey(KEYON+DXHATLEFT);")); // starts it moving MapKeyR(&Joystick,H1L, EXEC("if(flag1) ActKey(KEYON+MouseLoff); else ActKey(DXHATLEFT);")); // stops moving
MapKey(&Joystick, H1R, EXEC("if((1==flag1) & (0==flag5)) ActKey(KEYON+MouseR); else ActKey(KEYON+DXHATRIGHT);")); // starts it moving MapKeyR(&Joystick,H1R, EXEC("if(flag1) ActKey(KEYON+MouseRoff); else ActKey(DXHATRIGHT);")); // stops moving
MapKey(&Joystick, S3, EXEC("flag1=!flag1;"));
}
//event handler int EventHandle(int type, alias o, int x) { DefaultMapping(&o, x);
//add event handling code here }
|
|
#3506628 - 01/29/12 09:59 PM
Re: Conditional mapping of mouse to Warthog HAT1
[Re: dcs]
|
Joined: Apr 2000
Posts: 46
dcs
Junior Member
|
Junior Member
Joined: Apr 2000
Posts: 46
|
Teej, I was working on this when I noticed your update. I created these to videos to illustrate the difference between the two joysticks The first one is the CH stick. The video starts in the map view to show the sensitivity and control of the mouse. The movement is fairly choppy, but that’s mostly because of laziness. Since a great of fidelity isn’t need in the driver’s view, I never changed the resolution from my initial settings. I have no problem drawing a box. In the driver's unbuttoned position I am able to control the view. After panning back and forth, I draw a square and then follow the barrel. http://youtu.be/KJCUoi09eKEWith the WARTHOG, I set the sensitivity down to 5,5 so I would have some control of the mouse in the external view. It can draw a rectangle in the map view easily, although more slowly. In the external view, it’s a different story. All I’m trying to do is move the view slightly off-center. The view skews right to the limits of travel immediately. When I try to return to the center, it resists and then move in a completely different direction, left. Finally after forcing it away from the corner, it finally moves back to the center and beyond. Even if I stop pressing it one direction and try to change direction, when I enter input, it continues moving in the old direction. http://youtu.be/NDNwLEb7J4c The third video shows the new code. It seems to be identical to the first at 5,5. I change it to 5,50 to illustrate what seems to be the cause. I tried to move 10 increments at a time. Once I change direction with the HAT, the view continues to move ~10 more times in the same direction. Eventually, the buffer of wrong directional data is exhausted, and the mouse will start moving in the correct direction. After I change direction, it continued moving an equal number of times. Where is the other movement data coming from? http://youtu.be/85DZMhPl3-EI really appreciate all the effort you put into this. I’m going to try posting in the Esim forum to see if someone can identify the cause, (I wouldn’t expect a resolution.) But it would be nice to know why this happens. Thanks,
|
|
#3508172 - 01/31/12 08:03 PM
Re: Conditional mapping of mouse to Warthog HAT1
[Re: dcs]
|
Joined: Jul 2005
Posts: 1,508
Teej
Member
|
Member
Joined: Jul 2005
Posts: 1,508
|
The following is not known fact, just a hypothesis I figure is at least 95% likely to be accurate...
They're not seeing erroneous commands, it's the way the different titles are tracking. You can refer to axes in either "relative" or "absolute" mode. TARGET is functioning in "absolute" mode. You'll notice in windows when you launch the TARGET script and then bump your hat-mouse, the mouse "jumps" to the center of the screen. Then as you move it around, TARGET is keeping track of where the mouse should be based on your commands and positioning it accordingly.
This is fine for some titles...and even rfactor when you're not actually in the driving interface.
When you play SBPE, or drive in rfactor, it's accessing the mouse in "relative" mode. It's watching the _changes_ in the mouse location rather than the actual current position...and only updates its view while the mouse position is changing. The game will always be "chasing" the mouse.
That's why I was suggesting the slew control. It's easy to put that in relative mode, but I'm not sure if/how to do it using the method we're describing here.
Last edited by Teej; 01/31/12 08:04 PM.
|
|
#3508209 - 01/31/12 08:51 PM
Re: Conditional mapping of mouse to Warthog HAT1
[Re: dcs]
|
Joined: Jul 2005
Posts: 1,508
Teej
Member
|
Member
Joined: Jul 2005
Posts: 1,508
|
This might be close...might be perfect...if there's a problem let me know. There's a few things that could be tweaked yet.
include "target.tmh"
int MouseU, MouseD, MouseL, MouseR, MouseUO, MouseDO, MouseLO, MouseRO, flag1; //program startup int main() { if(Init(&EventHandle)) return 1; // declare the event handler, return on error
flag1=1;
MouseU = REXEC(0,10,"TrimDXAxis(MOUSE_Y_AXIS, -2);"); MouseD = REXEC(0,10,"TrimDXAxis(MOUSE_Y_AXIS, 2);"); MouseL = REXEC(1,10,"TrimDXAxis(MOUSE_X_AXIS, -2);"); MouseR = REXEC(1,10,"TrimDXAxis(MOUSE_X_AXIS, 2);");
MouseUO = CHAIN(EXEC("ActKey(MouseU);"),EXEC("TrimDXAxis(MOUSE_Y_AXIS,SET(0));")); MouseDO = CHAIN(EXEC("ActKey(MouseD);"),EXEC("TrimDXAxis(MOUSE_Y_AXIS,SET(0));")); MouseLO = CHAIN(EXEC("ActKey(MouseL);"),EXEC("TrimDXAxis(MOUSE_X_AXIS,SET(0));")); MouseRO = CHAIN(EXEC("ActKey(MouseR);"),EXEC("TrimDXAxis(MOUSE_X_AXIS,SET(0));"));
MapKey(&Joystick, H1U, EXEC("if(flag1) ActKey(KEYON+MouseU); else ActKey(KEYON+DXHATUP);")); // starts it moving MapKeyR(&Joystick,H1U, EXEC("if(flag1) ActKey(PULSE+KEYON+MouseUO); else ActKey(DXHATUP);")); // stops moving
MapKey(&Joystick, H1D, EXEC("if(flag1) ActKey(KEYON+MouseD); else ActKey(KEYON+DXHATDOWN);")); // starts it moving MapKeyR(&Joystick,H1D, EXEC("if(flag1) ActKey(PULSE+KEYON+MouseDO); else ActKey(DXHATDOWN);")); // stops moving
MapKey(&Joystick, H1L, EXEC("if(flag1) ActKey(KEYON+MouseL); else ActKey(KEYON+DXHATLEFT);")); // starts it moving MapKeyR(&Joystick,H1L, EXEC("if(flag1) ActKey(PULSE+KEYON+MouseLO);else ActKey(DXHATLEFT);")); // stops moving
MapKey(&Joystick, H1R, EXEC("if(flag1) ActKey(KEYON+MouseR); else ActKey(KEYON+DXHATRIGHT);")); // starts it moving MapKeyR(&Joystick,H1R, EXEC("if(flag1) ActKey(PULSE+KEYON+MouseRO); else ActKey(DXHATRIGHT);")); // stops moving
MapKey(&Joystick, S3, EXEC("flag1=!flag1;"));
}
//event handler int EventHandle(int type, alias o, int x) { DefaultMapping(&o, x);
//add event handling code here }
|
|
#4088857 - 03/07/15 04:24 AM
Re: Conditional mapping of mouse to Warthog HAT1
[Re: dcs]
|
Joined: Dec 2013
Posts: 46
Space the Blaze
Blazer of Space
|
Blazer of Space
Junior Member
Joined: Dec 2013
Posts: 46
|
Hello. It seems we got a common enemy ivanwfr at http://forums.eagle.ru/showthread.php?s=c5c410edaa38ba7c7d38fbafb870c622&t=73271&page=7found a way to make the 2 mouse cursors one. (you need to alter target.tmh file at line 193 (or 192). Set PlugMouse(0) I found some code that resets the adding up of coordinates to zero (so it starts again without the big hops) We are currently handling it here: http://forums.eagle.ru/showthread.php?s=c5c410edaa38ba7c7d38fbafb870c622&t=73271&page=7I know the code for stopping the adding. But I lack the skills to CHAIN DELAY both the code that stops calculating and the continuing of the mouse cursor in the same action. (as you can see if you follow the link) My idea is to cycle both stop adding/subtracting code, with the continuing of the mouse cursor. I will take bets it can be done. But for now my code stops movement period. Maybe we all hold pieces of the same puzzle, but we don't know it
|
|
#4238067 - 03/09/16 04:03 AM
Re: Conditional mapping of mouse to Warthog HAT1
[Re: dcs]
|
Joined: Dec 2013
Posts: 46
Space the Blaze
Blazer of Space
|
Blazer of Space
Junior Member
Joined: Dec 2013
Posts: 46
|
Update: Synkc gave me great code that works. https://forums.robertsspaceindustries.com/discussion/315586/t-a-r-g-e-t-working-mouse-code#latestSynkc: Replacing: MapKey(&T16000, H1L, REXEC(0, 88, "TrimDXAxis(MOUSE_X_AXIS, SET(-1));"));
MapKey(&T16000, H1R, REXEC(0, 88, "TrimDXAxis(MOUSE_X_AXIS, SET(1));"));
MapKey(&T16000, H1U, REXEC(0, 88, "TrimDXAxis(MOUSE_Y_AXIS, SET(-1));"));
MapKey(&T16000, H1D, REXEC(0, 88, "TrimDXAxis(MOUSE_Y_AXIS, SET(1));")); With:
MapKey(&T16000, H1U, REXEC(0, 2, "DXAxis(MOUSE_Y_AXIS, -1);"));
MapKey(&T16000, H1R, REXEC(1, 2, "DXAxis(MOUSE_X_AXIS, 1);"));
MapKey(&T16000, H1D, REXEC(0, 2, "DXAxis(MOUSE_Y_AXIS, 1);"));
MapKey(&T16000, H1L, REXEC(1, 2, "DXAxis(MOUSE_X_AXIS, -1);")); Should solve the mousehops problem when the virtual mouse is set to relative mode. To alter the speed, change the delay in REXEC().
Last edited by SpaceBlaze; 03/09/16 04:04 AM. Reason: code not coding
|
|
|
|
|
|
Exodus
by RedOneAlpha. 04/18/24 05:46 PM
|
|
|
|
|
|
|
|