Wazoo-VR Posted May 9, 2020 Posted May 9, 2020 I decided to make the jump into multiplayer servers and, of course, most have the GPS map function disabled. Ok... so I figured this is a good excuse to work on my pilotage skills by pulling up the briefing map and using ground references to navigate. Problem is I don't have a mouse handy with a scroll wheel because I play in a 6DOF motion platform and the mouse would just get thrown around. So frustrating that there are no options in-game to change something as simple as map zoom. I'm running a Warthog HOTAS and am even open to T.A.R.G.E.T profiles and/or VoiceAttack. Any help greatly appreciated.
Sandy_M Posted May 9, 2020 Posted May 9, 2020 I used JoystickGremlin to map a hat on my stick as a mouse and another up/down hat to scrolling. It works really well!
mattswe Posted May 9, 2020 Posted May 9, 2020 Here comes code for a TARGET script. You can modify the numbers to the right in order to change sensitivity. // Mouse up-down MapKey(&Throttle, CSU, AXIS(MOUSE_Y_AXIS, -160, 20)); MapKey(&Throttle, CSD, AXIS(MOUSE_Y_AXIS, 160, 20)); // Mouse left-right MapKey(&Throttle, CSL, AXIS(MOUSE_X_AXIS, -80, 20)); MapKey(&Throttle, CSR, AXIS(MOUSE_X_AXIS, 80, 20)); // Mouse wheel MapKey(&Throttle, MSR, AXIS(MOUSE_Z_AXIS, -1, 50)); MapKey(&Throttle, MSL, AXIS(MOUSE_Z_AXIS, 1, 50)); //Mouse right button MapKey(&Throttle, CHF, EXEC("ActKey(PULSE+KEYON+MOUSE_RIGHT);")); //Mouse left button MapKey(&Throttle, CHB, EXEC("ActKey(PULSE+KEYON+MOUSE_LEFT);"));
Wazoo-VR Posted May 9, 2020 Author Posted May 9, 2020 (edited) Hey Matt, Thanks a ton for this. A few questions. The mouse button commands don't seem to be working. I assume that snippet of code is so if I am holding the rocker switch forward or aft, it is like holding down the mouse button so I can then move the map around. Unfortunately it does not have any effect. EDIT: One other question. When I try the mouse wheel button, it only scrolls in and out a tiny bit no matter what values I set. It only seems to work in combo with moving the CS button around but that makes the zoom go all over the place. Probably user error but figured I'd ask. Thoughts? Edited May 9, 2020 by wazooda
VR-DriftaholiC Posted May 9, 2020 Posted May 9, 2020 I wish we could get key binds for map zoom and pan. Not to mention being able to pan a little off the edge of the map is a constant frustration when trying to center the area I'm working in when the action is near the edge of the playable area.
mattswe Posted May 9, 2020 Posted May 9, 2020 The snipped was just a general example on how to program the mouse. Let me tinker with it tomorrow, and Ill be back with a fully functional and tested solution (I hope). 1
Wazoo-VR Posted May 10, 2020 Author Posted May 10, 2020 (edited) 4 hours ago, mattswe said: Here comes code for a TARGET script. You can modify the numbers to the right in order to change sensitivity. // Mouse up-down MapKey(&Throttle, CSU, AXIS(MOUSE_Y_AXIS, -160, 20)); MapKey(&Throttle, CSD, AXIS(MOUSE_Y_AXIS, 160, 20)); // Mouse left-right MapKey(&Throttle, CSL, AXIS(MOUSE_X_AXIS, -80, 20)); MapKey(&Throttle, CSR, AXIS(MOUSE_X_AXIS, 80, 20)); // Mouse wheel MapKey(&Throttle, MSR, AXIS(MOUSE_Z_AXIS, -1, 50)); MapKey(&Throttle, MSL, AXIS(MOUSE_Z_AXIS, 1, 50)); //Mouse right button MapKey(&Throttle, CHF, EXEC("ActKey(PULSE+KEYON+MOUSE_RIGHT);")); //Mouse left button MapKey(&Throttle, CHB, EXEC("ActKey(PULSE+KEYON+MOUSE_LEFT);")); Thanks a million Matt. Greatly appreciated. I've been trying to learn TARGET just to solve this problem. I even tried remapping the throttle slider to the Mouse Z axis but it didn't work: MapAxis(&Throttle, THR_FC, MOUSE_Z_AXIS, AXIS_NORMAL, MAP_ABSOLUTE); SetSCurve(&Throttle, THR_FC, 0, 0, 0, 0, 0); 2 hours ago, driftaholic said: I wish we could get key binds for map zoom and pan. Not to mention being able to pan a little off the edge of the map is a constant frustration when trying to center the area I'm working in when the action is near the edge of the playable area. Yeah. As much as I love this program, some of the stuff is a bit surprising; the keybinding section being one of my major complaints. It is one area that I find DCS far outpaces IL-2.... Edited May 10, 2020 by wazooda Fix 1
mattswe Posted May 10, 2020 Posted May 10, 2020 Wow, this was tricky. I can make it work moving the mouse pointer over the map with buttons, and I can make the zoom work. But not at the same time! The first demands absolute axes for the virtual mouse, the other relative axes. And further, coding a right-click hold in order to move the map, doesnt work either. It seems like a right-click hold from the virtual mouse doesnt register in Sturmovik, that it has to be from the physical mouse. This is strange because the code works in other applications. It lets me move, zoom and right-click in Chrome for example. This demands further investigation. Sorry for not being able to deliver any working code. 1
Wazoo-VR Posted May 10, 2020 Author Posted May 10, 2020 Thank you SO much for the effort. Yeah.... I burned my entire Saturday trying to come up with a solution which of course the devs could solve pretty quickly with a patch. Maybe we'll get lucky?? ? 1
mattswe Posted May 10, 2020 Posted May 10, 2020 (edited) I have found two ways to control the mouse wheel with the hotas, that seems to work everywhere except inte the Sturmovik map: Example 1: Manage mouse scroll wheel with Mic Switch (MSR, MSL): This works for scrolling in Chrome, but not for zooming the Sturmovik map. // Scroll wheel MapKey(&Throttle, MSR, AXIS(MOUSE_Z_AXIS, -2, 50)); MapKey(&Throttle, MSL, AXIS(MOUSE_Z_AXIS, 2, 50)); Example 2: Manage mouse scroll wheel with 3-way switch or with left throttle axis: This is a more complicated snippet. I found it on reddit, written by someone called darkcyde. I added a three-state button input (APPAT/APAH/APALT). This code works for scrolling in Chrome, but not for zooming the Sturmovik map. include "target.tmh" //program startup int main() { if(Init(&EventHandle)) return 1; // declare the event handler, return on error wheelfn(&wspd); // prime the mouse wheel polling //Scroll wheel controlled by the left throttle axis: //KeyAxis(&Throttle, THR_LEFT, 0, AXMAP1(10, EXEC("wspd=wspd+1;"), EXEC("wspd=wspd-1;"), EXEC("wspd=0;"))); // Scroll wheel controlled by a three-state button (scroll up / no scroll / scroll down) MapKey(&Throttle, APPAT, EXEC("wspd=wspd+1;")); MapKey(&Throttle, APAH, EXEC("wspd=0;")); MapKey(&Throttle, APALT, EXEC("wspd=wspd-1;")); } // ---------------- mouse wheel movement code ------------- int wspd; // mouse wheel speed parameter, modified by the left throttle through KeyAxis int wheelfn(alias speed) { if(speed) VirtualOutput(OUT_TYPE_MOUSE, OUT_ID_AXIS+2, sgn(speed)); DeferCall(250/(abs(speed)+1), &wheelfn, &speed); } // -------------------------------------------------------- //event handler int EventHandle(int type, alias o, int x) { DefaultMapping(&o, x); //add event handling code here } Example 3: Relative virtual mouse - This actually works in Sturmovik, but creates other problems This third example actually works, but navigating the mouse cursor stops working, so... The idea is to change the virtual mouse from measuring absolut values to relative. What you have to do is override the target.tmh file. Make a copy of it and put it in your own scripts folder. Then, at line 199, change the input from 1 to 0: if(cfg & CREATE_MOUSE) PlugMouse(0); Now example 1 should work, but like I said, the cursor movement break then. So, this is about as far as I have come. Cheers! Edited May 12, 2020 by mattswe
DarKcyde Posted May 11, 2020 Posted May 11, 2020 Hah, I wish I could take credit for that. The guy who wrote that code knows Target (and coding) far more deeply than I do. Its really strange that changing the mouse mode affects the scroll, the wheel should be relative in either mode. I think Target is a bad solution for mouse wheel stuff, it looks like it has some bugs and was never tested well. Gremlin apparently has mouse scroll ability. 1
Wazoo-VR Posted May 11, 2020 Author Posted May 11, 2020 22 hours ago, mattswe said: I have found two ways to control the mouse wheel with the hotas, that seems to work everywhere except inte the Sturmovik map: Example 1: Manage mouse scroll wheel with Mic Switch (MSR, MSL): This works for scrolling in Chrome, but not for zooming the Sturmovik map. // Scroll wheel MapKey(&Throttle, MSR, AXIS(MOUSE_Z_AXIS, -2, 50)); MapKey(&Throttle, MSL, AXIS(MOUSE_Z_AXIS, 2, 50)); Example 2: Manage mouse scroll wheel with 3-way switch or with left throttle axis: This is a more complicated snippet. I found it on reddit, written by someone called darkcyde. I added a three-state button input (APPAT/APAH/APALT). This code works for scrolling in Chrome, but not for zooming the Sturmovik map. include "target.tmh" //program startup int main() { if(Init(&EventHandle)) return 1; // declare the event handler, return on error wheelfn(&wspd); // prime the mouse wheel polling //Scroll wheel controlled by the left throttle axis: //KeyAxis(&Throttle, THR_LEFT, 0, AXMAP1(10, EXEC("wspd=wspd+1;"), EXEC("wspd=wspd-1;"), EXEC("wspd=0;"))); // Scroll wheel controlled by a three-state button (scroll up / no scroll / scroll down) MapKey(&Throttle, APPAT, REXEC(0, 100, "wspd=wspd+1;")); MapKey(&Throttle, APAH, EXEC("wspd=0;")); MapKey(&Throttle, APALT, EXEC("wspd=wspd-1;")); } // ---------------- mouse wheel movement code ------------- int wspd; // mouse wheel speed parameter, modified by the left throttle through KeyAxis int wheelfn(alias speed) { if(speed) VirtualOutput(OUT_TYPE_MOUSE, OUT_ID_AXIS+2, sgn(speed)); DeferCall(250/(abs(speed)+1), &wheelfn, &speed); } // -------------------------------------------------------- //event handler int EventHandle(int type, alias o, int x) { DefaultMapping(&o, x); //add event handling code here } Example 3: Relative virtual mouse - This actually works in Sturmovik, but creates other problems This third example actually works, but navigating the mouse cursor stops working, so... The idea is to change the virtual mouse from measuring absolut values to relative. What you have to do is override the target.tmh file. Make a copy of it and put it in your own scripts folder. Then, at line 199, change the input from 1 to 0: if(cfg & CREATE_MOUSE) PlugMouse(0); Now example 1 should work, but like I said, the cursor movement break then. So, this is about as far as I have come. Cheers! Thanks for all the effort on this Matt. REALLY appreciated! 1
mattswe Posted May 11, 2020 Posted May 11, 2020 10 hours ago, DarKcyde said: Its really strange that changing the mouse mode affects the scroll, the wheel should be relative in either mode. I think Target is a bad solution for mouse wheel stuff, it looks like it has some bugs and was never tested well. Yeah, you might be right.
Alonzo Posted May 11, 2020 Posted May 11, 2020 Different option -- consider a trackball instead. I bought a left-handed trackball and I have mounted it to the side of my throttle. To manipulate mouse controls I take my hand off the throttle, then use the trackball (thumb on ball). This works great, no mapping/software required. I did try AHK mapping to mouse but it didn't work very well for me in IL2, so I went for the hardware solution instead.
mattswe Posted May 12, 2020 Posted May 12, 2020 Now I have dug a little deeper into this, and I feel ready to wrap things up. When you run a TARGET script, the method PlugMouse() is called in the background. You can see the actual call on line 199 in the file target.tmh (..\Program (x86)\Thrustmaster\TARGET\scripts). This call generates some text in the lower output area of the TARGET window. It says "Connecting virtual mouse (absolute axes)...Done". More information about this method can be found in the file hid.tmh, line 226. It says: //plug a virtual mouse device in the system //absolute - 0 for relative mouse (mouse position is interpreted as displacement added to the pointer), // 1 for absolute mouse (mouse position is the mapped to the pointer position on the screen, the wheel is still relative) // 2 for absolute mouse with nullable X,Y axes (pressing a button sends a null value for the axes instead of the current positions, not compatible with some games) int PlugMouse(int absolute) {} So, default value for the inparameter is 1, meaning the mouse axes x and y will be set to absolute values, while the wheel axis y will be set to relative. At least this seems to be the intention, since it doesnt work correctly. If setting the input param to 0 all three axes (x, y and x) becomes relative, which means the wheel (z axis) works, but the x and y axes goes awry. Setting the input param to 2 makes not difference from 1 in this application. Now, I did write a TARGET script that controls the mouse (movement, scroll wheel and buttons) from the virtual controller, my Warthog hotas. Nothing fancy here: include "target.tmh" //program startup int main() { if(Init(&EventHandle)) return 1; // declare the event handler, return on error // Mouse movement (Coolie Switch - CSU, CSD, CDL, CDR) MapKey(&Throttle, CSU, AXIS(MOUSE_Y_AXIS, -40*2, 40)); // Mouse up MapKey(&Throttle, CSD, AXIS(MOUSE_Y_AXIS, 40*2, 40)); // Mouse down MapKey(&Throttle, CSL, AXIS(MOUSE_X_AXIS, -10*2, 20)); // Mouse left MapKey(&Throttle, CSR, AXIS(MOUSE_X_AXIS, 10*2, 20)); // Mouse right // Scroll wheel (Mic Switch - MSR, MSL) MapKey(&Throttle, MSR, AXIS(MOUSE_Z_AXIS, -2, 50)); MapKey(&Throttle, MSL, AXIS(MOUSE_Z_AXIS, 2, 50)); // Mouse right button (Slew Control press - SC) MapKey(&Throttle, SC, EXEC("ActKey(PULSE+KEYON+MOUSE_RIGHT);")); // Mouse right button (Left Throttle Button - LTB) MapKey(&Throttle, LTB, EXEC("ActKey(PULSE+KEYON+MOUSE_LEFT);")); } //event handler int EventHandle(int type, alias o, int x) { DefaultMapping(&o, x); //add event handling code here } Running this script I can control the mouse (movement, wheel and buttons) with my Warthog throttle in Google Chrome and in MS Words, no problems there. So I went to DCS. Going into key settings, it becomes obvious that the scroll wheel, the Z axis, is not fully relative. Each time I release the scroll and press it again, the position resets before starting to scroll. Now, running Sturmovik, the wheel behaviour on the map and in the key mapping settings is the same. Though, different from DCS. It's like if it generates one single mousescroll event. So my conclusion sadly has to be the same as others. It seems like the coding in the TARGET dlls regarding the mouse Z axis isnt solid. Somehow the relative setting on the Z axis seems to be faulty, since it resets the axis position each time you start to scroll. By now Im out of ideas and I think we will have to look somewhere else for mouse wheel functionality. By the way, the exampel 2 in my previous reply, the one I copied from reddit, is a quite clever piece of code. You can find more info about the VirtualOutput() method in hid.tmh on line 177, and there are calls to it in target.tmh. It's built around a recursive call. /Cheers
Wazoo-VR Posted May 13, 2020 Author Posted May 13, 2020 Thanks again for giving this a shot. It shows what a great community IL-2 has to support it. Cheers!
Guest deleted@134347 Posted May 14, 2020 Posted May 14, 2020 about 3 years ago I took the Rii mini keyboard (Rii i4 Mini Bluetooth Keyboard with Touchpad is the latest) and used velcro to attach it to a wrist strap from go-pro (but really any wrist strap will work) a la pip boy. Works very well, and since it has a keyboard on it as well it's pretty useful as you get a mouse and can type stupid stuff in to a chat window.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now