spokes2112 Posted October 24, 2013 Report Posted October 24, 2013 Hi Pete, I started making a "mouselook" type Lua file for FS9 and it works quite well except 2 more functions I have trouble with. I am making this so my joystick will perform the same between FSX and FS9, in FSX my primary hat is trim along with 2 alternate look functions, In FS9 the primary hat is pan with the same 2 alternate look functions. While in FS9 I keep tagging the spacebar for mouselook and just go "UGGH!" :mad: The part I will have trouble with is (assuming) getting the mouse middle button & mouse wheel ( Reset and Zoom) through the Com library since it is not available through the Event library.. I am afraid using the Com library may be a step too far for me. I have tried the .ini settings Debug=Please and LogExtras=512 and using FSX for the development because of the console debug window but I cannot seem to get any data from the mouse. When using a logging file all I get is Vendor/Product data etc.. with none of the actual passing hardware data being shown. MMM??? You can get a list of all HID devices connected to your PC, as well as their comings and goings So I guess a few questions - Is this even possible? If so, can you give me nudge in the right direction? I have a feeling it has to do with com.openhid initreport ?? Below is the Lua I have so far. Thanks in advanced, Having fun w/ Lua! Roman -- FS9 Mouselook.Lua -- Use HidScanner.exe to get Vendor, Product and Unit for mouse wheel and middle button Vendor = 0x045E Product = 0x075C Unit = 0 initial = 0 delta_move = 200 --[[ PAN_DOWN 65735 PAN_LEFT 65671 PAN_LEFT_DOWN 65855 PAN_LEFT_UP 65854 PAN_RESET 65875 PAN_RESET_COCKPIT 66415 PAN_RIGHT 65672 PAN_RIGHT_DOWN 65857 PAN_RIGHT_UP 65856 PAN_TILT_LEFT 65873 PAN_TILT_RIGHT 65874 PAN_UP 65734 ]] function activated() -- middle mouse button = reset view / reset initial -- mousewheel = zoom in/out -- L/R = pan L/R -- F/B = pan up/down newx, newy, xr, yr, xp, yp = mouse.getpos() -- PAN RIGHT / UP if newx > (initialx + delta_move) and newy < (initialy - delta_move) then ipc.control(65856) end -- PAN RIGHT if newx > (initialx + delta_move) and (math.abs(initialy - newy) < delta_move) then ipc.control(65672) end -- PAN RIGHT / DOWN if newx > (initialx + delta_move) and newy > (initialy + delta_move) then ipc.control(65857) end --PAN LEFT / UP if newx < (initialx - delta_move) and newy < (initialy - delta_move) then ipc.control(65854) end --PAN LEFT if newx < (initialx - delta_move) and (math.abs(initialy - newy) < delta_move) then ipc.control(65671) end --PAN LEFT / DOWN if newx < (initialx - delta_move) and newy > (initialy + delta_move) then ipc.control(65855) end --PAN DOWN if newy > (initialy + delta_move) and (math.abs(initialx - newx) < delta_move) then ipc.control(65735) end --PAN UP if newy < (initialy - delta_move) and (math.abs(initialx - newx) < delta_move) then ipc.control(65734) end end function activate() if initial == 0 then -- GET MOUSE CURRENT POSITION initialx, initialy, xr, yr, xp, yp = mouse.getpos() -- GET HID INFO FOR MID BUTTON / WHEEL handle, rd, rdf, wr, initreport = com.openhid(Vendor, Product, Unit, 0) initial = 1 end ipc.writeSTR(0x3380, handle .. rd .. rdf .. wr .. initreport) ipc.writeSW(0x32FA, 10) activated() end function reset() initial = 0 end -- spacebar = 32,8 down | downarrow = 40,8 | leftarrow = start lua | rightarrow = kill lua -- event.key(40, 8, 5, "activate") event.key(40, 8, 5, "activate") event.key(40, 8, 2, "reset")
Pete Dowson Posted October 24, 2013 Report Posted October 24, 2013 The part I will have trouble with is (assuming) getting the mouse middle button & mouse wheel ( Reset and Zoom) through the Com library since it is not available through the Event library Mouse events are available in FSUIPC4. I'm afraid I have frozen FSUIPC3 development, some time ago in fact. Recent changes have been just corrections and minor improvements. Adding complete new facilities is a definite no-no. It's such old code now, I have to move on. I am afraid using the Com library may be a step too far for me. I have tried the .ini settings Debug=Please and LogExtras=512 and using FSX for the development because of the Com debug window but I cannot seem to get any data from the mouse. When using a logging file all I get is Vendor/Product data etc.. with none of the actual passing hardware data being shown. MMM??? I'm afraid only joystick type HID devices are fully handled by the HID functions in the COM library. Mouse and keyboard devices use completely different protocols which FSUIPC will not recognise (in the same way as HidScanner doesn't, in fact). You can certainly try reading data from them and working out what it might mean, but for that you'd be on your own. The gethidvalue, gethidbuttons, gethidcount and testhidbutton functions provided by FSUIPC only interpret joystick type data. Maybe you can get reference information for Mouse USB data on the Microsoft support websites. Or else, trial and error -- with logging, as you say, but you'll not LogExtras=512 because that logs results of the HID-specific functions which only work on those joystick devices. You'd need to read the data and format and write it to the log yourself, with your own Lua code. (the Lua trace/debug option might help, but decoding the data from that would be difficult). Note that in your code all you have done with the mouse is open it to get a handle. You need to do that just once at the beginning. You need the handle in a "com.read" function in order to actually read data. The length is given by the 'rd' parameter you got in the open response too (or maybe the 'rdf' value if the data is supplied as a 'feature' block) but I think these lengths might only apply to the input report types supported by joysticks. For mouse and keyboard the input report numbers may be different and openhid won't know their lengths. You are going to need a lot of experimentation, including possibly selecting which reports you receive give you the information you need. Regards Pete
spokes2112 Posted October 24, 2013 Author Report Posted October 24, 2013 Pete,Thank you for the nudge! :razz: I am getting length data from 'rd and 'rdf' returns from com.openhid unit 0 & 1 so things 'may' (ha) be looking good. Just have to read it to see what's there. (Thanks) Never dealt with Com before ( communications ? ) so its a learning experience.. This will be a fun afternoon LOL! Below is just the relevant part of the HidScanner.log with some comments that I assume.. It seems to fit the functions of the mouse. Thanks again - For everything! Roman Device at "\\?\hid#vid_045e&pid_075c&col01#6&38988418&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}" Vendor=045E, Product=075C (Version 4.48) Manufacturer= Microsoft Product= Microsoft® SideWindersion 4.48) Serial Number= Device is a mouse Usage Page: 1 Input Report Byte Length: 10 Output Report Byte Length: 0 Feature Report Byte Length: 0 Number of Link Collection Nodes: 4 Number of Input Button Caps: 1 Number of InputValue Caps: 4 Number of InputData Indices: 9 Number of Output Button Caps: 0 Number of Output Value Caps: 0 Number of Output Data Indices: 0 Number of Feature Button Caps: 0 Number of Feature Value Caps: 0 Number of Feature Data Indices: 0 Buttons range 1 -> 5 at indices 0 -> 4 Value Y at index 5, range -32767 -> 32767, using 16 bits <!-- Laser X/Y??? --> Value X at index 6, range -32767 -> 32767, using 16 bits <!-- Laser X/Y??? --> Value Wh at index 7, range -32767 -> 32767, using 16 bits <!-- Laser X/Y??? --> Value Wh at index 8, range -32767 -> 32767, using 16 bits <!-- Laser X/Y??? --> ************************************************************************** Device at "\\?\hid#vid_045e&pid_075c&col02#6&38988418&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}" Vendor=045E, Product=075C (Version 4.48) Manufacturer= Microsoft Product= Microsoft® SideWindersion 4.48) Serial Number= Usage Page: C Input Report Byte Length: 5 Output Report Byte Length: 0 Feature Report Byte Length: 13 Number of Link Collection Nodes: 4 Number of Input Button Caps: 3 Number of InputValue Caps: 6 Number of InputData Indices: 1286 Number of Output Button Caps: 0 Number of Output Value Caps: 0 Number of Output Data Indices: 0 Number of Feature Button Caps: 1 Number of Feature Value Caps: 13 Number of Feature Data Indices: 14 Value 0x25 at index 1280, range 0 -> 4, using 8 bits <!-- Button --> Value 0x26 at index 1281, range 0 -> 65535, using 16 bits <!-- Button? --> Value 0x28 at index 1282, range 0 -> 255, using 8 bits <!-- Button --> Value 0x27 at index 1283, range 0 -> 255, using 8 bits <!-- Button --> Value 0x29 at index 1284, range 0 -> 7, using 3 bits <!-- Button? --> Value U/RX at index 1285, range 0 -> 255, using 8 bits <!-- Mousewheel -->
Pete Dowson Posted October 24, 2013 Report Posted October 24, 2013 Thank you for the nudge! :razz: I am getting length data from 'rd and 'rdf' returns from com.openhid unit 0 & 1 so things 'may' (ha) be looking good. Just have to read it to see what's there. (Thanks) Never dealt with Com before ( communications ? ) so its a learning experience.. This will be a fun afternoon LOL! Below is just the relevant part of the HidScanner.log with some comments that I assume.. It seems to fit the functions of the mouse. Actually, I'm a bit puzzled. Without delving into the code I don't really know what is going on. The data returned by HidScanner does lead me to believe that the HID facilities could actually decode the Mouse style data. The button positions are identified, as are the "axes" positions, albeit with different names. However, I plugged the Vendor and Product IDs into HidDemo.lua (one from the collection installed with FSUIPC), and get no data from com.read or com.readlast. Note that I had to increase the "Device" number to 1 in any case. With my logitech wireless mouse and keyboard system all three parts (the wireless module, keyboard, mouse) have the same Vendor and Product, so you need to count down in HidScanner to see which Device number to use (counting from 0). I'm a bit intrigued. There's nothing obvious staring at me for the difference, apart from the blatant "Device is a mouse" message in HidScanner. Maybe my code for HID devices simply eliminates non-joysticks. I'll have to delve into it. But not now -- maybe tomorrow. I'll see. Meanwhile, I suspect you won't get anywhere at present. Pete
spokes2112 Posted October 24, 2013 Author Report Posted October 24, 2013 Pete, No need to delve into it, unless it intrigues you :mrgreen: . Afterall this is for FS9. Roman
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