Jump to content

dmonds

Members
  • Posts

    41
  • Joined

  • Last visited

Everything posted by dmonds

  1. I have also found it necessary, when faffing about in the plugins folder, to restart the FAST service. Much faster than having to reboot the PC. Here's a batch file I created previously which I run as admin... @echo off net stop TmWinService net start TmWinService timeout /t 5 /nobreak exit
  2. I just tested this using a slightly modified .tmc include "target.tmh" int TestFunction(){} //program startup int main() { if(Init(&EventHandle)) return 1; // declare the event handler, return on error printf( "Hello world!\xa"); int lib = LoadLibrary("TestFunction.dll"); printf( "Library address: %d\xa", lib ); int funk = GetProcAddress(lib, "TestFunction"); printf( "Library function address: %d\xa", funk ); int mapped = Map(&TestFunction, funk, MAP_IPTR_VPN); // returns object. mode:MAP_NORMAL=1, MAP_IPTR=2, MAP_IPTR_VPN=3, MAP_THISCALL=4 printf( "Mapped function address: %d\xa", mapped ); printf( "%d", TestFunction(), "\xa"); //add initialization code here } //event handler int EventHandle(int type, alias o, int x) { DefaultMapping(&o, x); //add event handling code here } Here's the cut/paste of the console output; Open TARGET Script Editor: Loaded plugin module "C:\Program Files (x86)\Thrustmaster\TARGET\Plugins\sys.dll"(*) Loaded plugin module "C:\Program Files (x86)\Thrustmaster\TARGET\Plugins\TestFunction.dll"(*) Compile; Loaded plugin module "C:\Program Files (x86)\Thrustmaster\TARGET\Plugins\sys.dll"(*) Loaded plugin module "C:\Program Files (x86)\Thrustmaster\TARGET\Plugins\TestFunction.dll"(*) Compiling script: TestFunction.tmc Mapped plugin module "C:\Program Files (x86)\Thrustmaster\TARGET\Plugins\sys.dll" Compile Succeeded. Failed to map plugin module "C:\Program Files (x86)\Thrustmaster\TARGET\Plugins\TestFunction.dll" ! Now run (!!!!) Running script: D:\Users\Den\OneDrive\Personal\Thrustmaster\TARGET\Clicker\Development\Sandpit\TestFunction.tmc Mapped plugin module "C:\Program Files (x86)\Thrustmaster\TARGET\Plugins\sys.dll" Failed to map plugin module "C:\Program Files (x86)\Thrustmaster\TARGET\Plugins\TestFunction.dll" ! Compile Succeeded. Physical USB HID devices managed by script! Currently plugged USB HID devices[3]: 1: "T-Rudder" - "USB\VID_044F&PID_B679&REV_0110" 2: "Throttle - HOTAS Warthog" - "USB\VID_044F&PID_0404&REV_0100" 3: "Joystick - HOTAS Warthog" - "USB\VID_044F&PID_0402&REV_0100" USB HID device "Throttle - HOTAS Warthog"(USB\VID_044F&PID_0404\7&338B91D0&0&4) selected USB HID device "Joystick - HOTAS Warthog"(USB\VID_044F&PID_0402\6&19FF8499&0&1) selected USB HID device with hardware id "VID_044F&PID_0403" cannot be found USB HID device with hardware id "VID_044F&PID_b351" cannot be found USB HID device with hardware id "VID_044F&PID_b352" cannot be found USB HID device with hardware id "VID_044F&PID_0400" cannot be found USB HID device with hardware id "VID_044F&PID_B10A" cannot be found USB HID device with hardware id "VID_044F&PID_B10B" cannot be found USB HID device with hardware id "VID_044F&PID_B687" cannot be found USB HID device "T-Rudder"(USB\VID_044F&PID_B679\7&338B91D0&0&1) selected USB HID device with hardware id "VID_044F&PID_B68F" cannot be found USB HID device with hardware id "VID_044F&PID_0405" cannot be found USB HID device with hardware id "VID_044F&PID_0406" cannot be found USB HID device with hardware id "VID_044F&PID_0407" cannot be found USB HID device with hardware id "VID_044F&PID_0408" cannot be found USB HID device with hardware id "VID_044F&PID_040A" cannot be found USB HID device with hardware id "VID_044F&PID_040B" cannot be found USB HID device with hardware id "VID_044F&PID_0409" cannot be found USB HID device with hardware id "VID_044F&PID_0412" cannot be found USB HID device with hardware id "VID_044F&PID_0413" cannot be found USB HID device with hardware id "VID_044F&PID_040E" cannot be found USB HID device with hardware id "VID_044F&PID_040F" cannot be found USB HID device with hardware id "VID_044F&PID_0416" cannot be found USB HID device with hardware id "VID_044F&PID_0417" cannot be found USB HID device with hardware id "VID_044F&PID_0430" cannot be found USB HID device with hardware id "VID_044F&PID_0438" cannot be found USB HID device with hardware id "VID_044F&PID_0431" cannot be found USB HID device with hardware id "VID_044F&PID_0439" cannot be found USB HID device with hardware id "VID_044F&PID_0432" cannot be found USB HID device with hardware id "VID_044F&PID_043A" cannot be found USB HID device with hardware id "VID_044F&PID_0420" cannot be found USB HID device with hardware id "VID_044F&PID_0428" cannot be found USB HID device with hardware id "VID_044F&PID_0421" cannot be found USB HID device with hardware id "VID_044F&PID_0429" cannot be found USB HID device with hardware id "VID_044F&PID_0422" cannot be found USB HID device with hardware id "VID_044F&PID_042A" cannot be found USB HID device with hardware id "VID_044F&PID_041B" cannot be found USB HID device with hardware id "VID_044F&PID_041C" cannot be found Virtual HID devices managed by script! Connecting virtual joystick...Done Device name set to Thrustmaster Combined Connecting virtual keyboard...Done Connecting virtual mouse (absolute axes)...Done Hello world! Library address: 1917059072 Library function address: 1917063168 Mapped function address: 63452096 42 main returned 0 So despite not being mapped as a plugin .dll the dll is still loaded by TARGET and mapped via your .tmc file This simply means you can drop .dll files into the plugin folder and TARGET will look there at compile/run time.
  3. One other thing, whist it's top of mind... It seems to be implied that sys.dll (in the plugins folder) contains the functions which are defined within sys.tmh. In @ivanwfr posts he mentions dropping a second sys.dll file which contains a fixed version of strstr(){} and which gets mapped ahead of the latest one (which has a broke strstr(){} ) function. I would assume that the working .dll was either built by ivanwfr, provided by Thrustmaster or came from a previous working version of sys.dll. Either way, sys.dll does not publicly export the functions listed via sys.tmh and rather, exports only 'systemMap' which presumably is a gateway into the mapped functions. I suspect there's more under the hood but I'm only a beginner when it comes to C coding.
  4. Hi @JasonMel, Using x86 Native Tools Command Prompt for VS run the command: cl /nologo /W3 /EHsc /MD /LD TestFunction.cpp /link /EXPORT:TestFunction /OUT:TestFunction.dll This produces TestFunction.dll which exports "TestFunction". ...and here's the modified .tmc file using 'TestFunction.dll' and 'TestFunction' exported function include "target.tmh" int fonctionne(){} //program startup int main() { if(Init(&EventHandle)) return 1; // declare the event handler, return on error printf( "Hello world!\xa"); int lib = LoadLibrary("TestFunction.dll"); printf( "Library address: %d\xa", lib ); int funk = GetProcAddress(lib, "TestFunction"); printf( "Library function address: %d\xa", funk ); int mapped = Map(&fonctionne, funk, MAP_IPTR_VPN); // returns object. mode:MAP_NORMAL=1, MAP_IPTR=2, MAP_IPTR_VPN=3, MAP_THISCALL=4 printf( "Mapped function address: %d\xa", mapped ); printf( "%d\xa", fonctionne()); //add initialization code here } //event handler int EventHandle(int type, alias o, int x) { DefaultMapping(&o, x); //add event handling code here } I think you are correct about TARGET being finicky about compiler options when building a .dll to drop into the Plugins folder. That option would be much more elegant to be able to drop the .dll in and do no other TARGET coding. I have reached out to Thrustmaster and asked some questions, inlcuding if I might get access to the TARGET SDK which some people believe exists. I'll wait for an answer and post back if/when they reply. This method that you've outlined does work and will allow me to do what I need in the meantime. Many thanks dmonds
  5. Hi Ivan, Not sure if you are still around and if so, hope you are keeping well. I'm keen to understand where you got those 2x sys.dll files and managed to get strstr() working. Second, like JasonMel, I'd be keen to work out how to successfully create a dll to drop into the plugins folder. I've tried to create my own dll using C++ to test and use a strcpy() function as TARGET does not have one. At present, TARGET Script Editor will load the dll but when you compile, I get the dreaded ; Failed to map plugin module "C:\Program Files (x86)\Thrustmaster\TARGET\Plugins\clicker.dll" ! I can do this using target script, but was keen to learn how I might move basic reusable functions into a plugin dll. My C++ source is attached. I'm hoping it's something obvious and you could assist. Regards, dmonds clicker.cpp
  6. Couple of things to be mindful of, especially if you've reset your PC. 1) Make sure you reinstall the latest drivers and TARGET software. 2) If you are using TARGET scripts or the TARGET GUI to load a profile, they can take some time to load the first time. 3) Try to avoid having the Profiles or scripts load from the cloud or an external device. Once you think things are loaded up ok and before starting the game, run joy.cpl. If using a script or profile and depending on what you've included in your script or Profile, you may see the controller "Thrustmaster Combined" instead of the individual controllers. Of course any non-included controller within the script or profile will still appear in joy.cpl. Hope this helps.
  7. Hi @Drakoz, So are you saying that if I replace all instances of &Joystick with &joy2 and all instances of Joystick[button name] with joy2[button name] in my scripts then it would not matter if I had a WARTHOG, F18 Flight stick, AVA F16 or AVAF18 connected since they all have the exact same button mappings? ...and therefore, the script should just work? Regards dmonds
  8. Replace &Joystick (or &JoystickF18) with &AVA_F16 (or &AVA_F18) in your TARGET scripts. If you use "if" statements to interrogate buttons (eg if(Jostick[S3]...) then also replace "Joystick[" (or "JoystickF18[") with "AVA_F16[" (or "AVA_F18[") ... depending on which flight stick you use. Hope this helps, dmonds
  9. As the good SGT has suggested...there are some excellent ideas and suggestions within this thread...it is WELL WORTH reading every page! In the meantime, the short answer is no...you can print any variable! printf("My int variable = %d", <int variable>); printf("My String variable = %s", <string variable>); printf("My float variable = %f", <float value>); And it gets better! Hope this helps. dmonds
  10. T-Rudder is normal for TFRPRudder as far as I know. I have one of these and its always been reported that way. dmonds
  11. Too sensible. I'll keep playing with this over time and see what I can learn. Thanks for all your patience in explaining stuff. Cheers dmonds
  12. Hi again...thanks for all that. It makes sense and aligns with how I "thought" it should work. When testing...I wrote a string, using combinations of putc and fwrite. In both cases I wrote a NUL at the end. When reading back...at first I thought I'd nailed it as the printf was printing the string correctly. Then, subsequent, stop/start of the script, and...garbage again at the end of the string. As the strdel seemed to work , I kind of went "too hard, I'll come back to it later". TLDR...I have not seen adding a NUL to a string I am writing in target as doing what it should. Perhaps I did it wrong? I tried fwrite with a string "abcdef\x0" (where string was 7 chars). I tried fwrite with a string "abcdef"...(6 chars) then a putc 0. Both seemed to work at first...then, subsequent runs later....boom....garbage after the string when printf the string...very frustrating. Mind you...only printf exhibited the issue. Things like strcmp etc all worked fine, 100% of the time. Very strange....probably a bug in printf. dmonds
  13. Yeah, sorry...another global which should be local but I've been moving a lot of stuff into and out of my functions. What are the contents of your json file? Maybe it is something in the file you are reading. File I'm reading is a simple, one line json. I have several copies of this which I test my code via a simple copy file on a command line to simulate the program. There is nothing in it which would trip up this function. It is funny my own function to read a configuration file is very similar to yours. Right down to the part where we both figured out we have to add a NULL to the char[0] element of our alias (buf[0]=0 in my version). I take that as a compliment. But I ended up using fgetc(fp) instead of fread() - mostly because I wanted to try character IO on a file instead of taking the easy way out of using fread(). :D You calling me lazy? ;-) But I notice you don't add a NULL to the end of &myJson after you read the line from your file. I assume this somehow doesn't matter for your script? If I remember correctly, I had to add a NULL to the end of &buf because the string functions wouldn't work with it otherwise. See the buf[i+1] = 0 line. Hmmm...the function works but if I printf &myJson ... often get garbage displayed at the end of the string. Hence, the 'strdel' statement. I'm not a programmer, this works, but if there is a 'proper' way to seal my string after the fread, then I'm all ears....are you saying I add a null via a 'strcat' rather than the 'strdel' is better/preferred/more-proper-ish? Anyhoo, regardless of why I needed to run 'fnsReadStatusJson();' before the REXEC ... it now works and I can move onto what I was trying to achieve in the first place. For that, I thank you for your very valuable assistance. Cheers dmonds p.s. no doubt I'll be back with more newbie questions very soon!
  14. /snap...both posted at same time! original post (prior to yours) My eyes are giving up on me...so I'll call it a night and take another look tomorrow. Thanks heaps for helping out...really appreciate it. dmonds
  15. Bizarre!!! If I call fnsReadStatusJson(); before using the REXEC...it works. I do not understand why though. dmonds p.s. using ... ActKey(KEYON+REXEC(3, 5000, "fnsReadStatusJson();", RNOSTOP));
  16. HI @Drakoz (again)... 1) Speak() ... I'm going to have a go at this and see if it works for me in Win10. Voice.exe, I believe, uses the same mshta if I recall, so... 2) REXEC ... still can't get this working. It just hangs the TARGET Script application. Here are the statements I tried... ActKey(KEYON+REXEC(3, 5000, "fnsReadStatusJson();", RNOSTOP)); ...which hangs TARGET script...and... ActKey(KEYON+REXEC(3, 5000, fnsReadStatusJson(), RNOSTOP)); ...which returns "Bad alias in REXEC ( line 415 in target.tmh )" Here's fnsReadStatus() ... int fnsReadStatusJson() { int buf = 512; int myResult; Dim(&myJson, buf); myJson[0] = 0; fp = fopen(&StatusFile, "r"); if (fp) { myResult = fread(&myJson, 1, buf, fp); fclose(fp); if (myResult == 0) { printf("File Read Error: %s\x0a", &StatusFile); } else { strdel(&myJson, myResult-1, buf); // <<< having to do this this is annoying } } else { printf("Status.json file not found.\x0a"); } } Obviously, I have an 'alias Statusfile = "c:\\....file path" ' set correctly and 'char myJson;' declared as global variables ... when I call the function normally, it works perfectly. Any help greatly appreciated. dmonds
  17. Hi @Drakoz, Just read the stuff in the link you included. Interesting stuff, I'll look forward to absorbing properly when I get home tonight. In particular interest was the "Speak()" stuff. I recall that I had trouble getting "spawn" to work in Win 10, so I'm making an assumption that you are using Win7? Anyhoo and just an FYI...I solved my Text-To-Speech requirements by using a free Win32 program called "voice.exe" and using a function with a text string argument parsed to it to dynamically build a "syscmd" to call it. cheers dmonds
  18. Thanks again @Drakoz. My code snippet in my last post is how I was trying to run it. Funnily enough, I use REXEC in my code to in a couple MapKey statements already, and didn't realise REXEC specifically needed a MapKey/ActKey/KeyAxis wrapper. I'll give your suggestion a go this evening when I'm at home again and will let you know. Cheers dmonds
  19. Ok, well thanks @drakoz for proving I'm not a total numpty. My next challenge is REXEC. 1) I have written a function that reads a short, one line json file. 2) I have also written a function to find and read various key values within this file. They work well. 3) I have also found and played with an external C++ program which can also read same file and send me the contents of a specific key whenever it changes (via RegisterGameCallback()). This also works well (but requires the external program to be running whilst the game is running). I was thinking...why not just use REXEC to run the function described in '1)' above every 1-2 seconds and do away with the external C++ program. Except...I can't get this to work. My function name (in a seperate '.tmh' file) is called 'fnReadJson();' My statement is; REXEC(1, 2000, "fnReadJson();", RNOSTOP); This just hangs the Target Script Editor. I've looked for examples and they all deal with a switch/button press and simple ActKey(PULSE+KEYON+'a') type code. Does anyone here know how I can call my function using REXEC (or any other method) and have it loop indefinitely in the background? Thanks dmonds
  20. Help to get position of substring in TARGET SCRIPT Hiya, I'm working my way through the string manipulation functions available (listed in sys.tmh). I am stumbling on the following function. int strstr(alias string, alias substring){} // returns substring position, or -1 of not found I cannot seem to get this to work. It always returns a '0'. sample code... alias string1 = "This is a test"; alias string2 = "is"; int pos; pos = strstr(&string1, &string2); printf("pos = %d\x0a", pos); Can anyone here advise what I'm doing wrong and how to get this working? Or, heaven forbid, I found a bug in this function! dmonds
  21. All those things...but do-able!
  22. Not too sure what you are trying to achieve here. But, you can simply include “file.tmc” in your main script file. Otherwise, if what you are looking to do is remap one or more keys, you can do this from within a function/routine, then when you want to switch , just call the function. Dmonds
  23. Hi guys, Has anyone had experience with the TARGET system() function on Windows 10? I've used this method to grab the Time of Day and add to console or log file messages as follows... int TOD; system("time /T > c:\\tod.txt"); fp = fopen("c:\\tod.txt", "r"); if (fp) { fread(TOD, 1, 5, fp); fclose(fp); } I'm really just interested in any examples of working script code which uses system() under Win10. Cheers dmonds
  24. Hi, FWIW I had issues with Device Analyzer with just my Warthog. It was when I was using Windows 10 1803 and 1809. Since upgrading to 1903 it's working again. The Game Controller control panel applet did show the combination working fine and , of course, everything worked fine in game. I know not everyone had the same issue, so, YMMV if you happen to be on Win10 and using v 180x. On another topic, I'd be keen to know how you got the Virpil stick working as a combined Thrustmaster device in the first place. Hope this helps dmonds
  25. Hi @speedbird5, Check the syntax...I think you have too many zeros...plus... You cannot declare IO button twice using your method as the second call overrides the first. Hope this helps. Dmonds
×
×
  • Create New...