Jump to content
The simFlight Network Forums

GoFlight RP48, rotaries.lua.. how to?


MatzeH84

Recommended Posts

Hi there!

 

I got myself a used GoFlight RP48. Goal is to be able to assign functions to the rotary knobs via the button/switches function in FSUIPC. Example: Turn knob 1, turn dial (altimeter, heading, whatever) in the sim via the heading bug inc/Dec command.

I'm not someone with huge programming skills. I spend about one day researching here and elsewhere for a "simple" solution, thinking I can't be the only one using this unit and FSUIPC.

Currently when I turn the knob, up to 3 buttons are recognized by FSUIPC per direction, however they are mixing up so the dial is not dialing up, but jumping back and forth.

I used the rotaries.lua file, made it automatically load and recognize the unit (I guess). But FSUIPC is still recognizing the "real" buttons instead of virtual ones I aim for.

 

HID scanner log:

  Device at "\\?\hid#vid_09f3&pid_0028#9&34a1e11e&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}"
  Vendor=09F3, Product=0028 (Version 1.1)
  Manufacturer= GoFlight
  Product= GoFlight GF-RP48
  Serial Number= GoFlight GF-RP48
  Usage Page: 2
  Input Report Byte Length: 6
  Output Report Byte Length: 0
  Feature Report Byte Length: 2
  Number of Link Collection Nodes: 4
  Number of Input Button Caps: 1
  Number of InputValue Caps: 1
  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: 1
  Number of Feature Value Caps: 2
  Number of Feature Data Indices: 3
  Buttons range 1 -> 8 at indices 1 -> 8
  Value Dial at index 0, range -128 -> 127, using 8 bits

 

********* FSUIPC7, Version 7.0.5a (12th January 2021) by John Dowson *********
Checking for FS path in 'C:\Users\(deleted)\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\UserCfg.opt'
FS path found = D:\MSFS\
WebSocket server found: D:\FSUIPC7\\Utils\FSUIPCWebSocketServer.exe
Windows 10 Pro 64 Bit reported as Build 19042, Release ID: 2009 (OS 10.0)
Reading options from "D:\FSUIPC7\FSUIPC7.ini"
Checking the Registrations now ...
User Name="(deleted)"
User Addr="(deleted)"
FSUIPC7 Key is provided
WIDEFS7 not user registered, or expired
      109 System time = 19/01/2021 22:44:32
      109 FLT path = "C:\Users\\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalState\"
      125 -------------------------------------------------------------------
      203 Registered HotKey 'InvokeFSUIPCOptionsKey' (key=0x46, modifier=0x1)
      219 FS path = "D:\MSFS\"
      219 ---------------------- Joystick Device Scan -----------------------
      234 Product= Saitek Pro Flight Yoke
      250    Manufacturer= Saitek
      250    Vendor=06A3, Product=0BAC (Version 3.1)
      265    GUIDs returned for product: VID_06A3&PID_0BAC:
      265       GUID= {5F23DDB0-62FF-11EA-8002-444553540000}
      265       Details: Btns=23, POVs=(0, 0, 0, 0), Cal=x00000000, Max=R0,U255,V255,X1023,Y1023,Z255
      265 Product= Alpha Flight Controls
      265    Manufacturer= Honeycomb Aeronautical
      265    Serial Number= 6D323C0C192C3B00
      265    Vendor=294B, Product=1900 (Version 2.32)
      265    GUIDs returned for product: VID_294B&PID_1900:
      265       GUID= {E9B5DA70-0348-11EB-8001-444553540000}
      265       Details: Btns=35, POVs=(0, 0, 0, 0), Cal=x00000000, Max=R0,U0,V0,X255,Y255,Z0
      265 Product= T.A320 Pilot
      281    Manufacturer= Thrustmaster
      281    Serial Number= 1
      281    Vendor=044F, Product=0405 (Version 2.0)
      281    GUIDs returned for product: VID_044F&PID_0405:
      281       GUID= {904D9F70-F2B5-11EA-8001-444553540000}
      281       Details: Btns=17, POVs=(0, 0, 0, 0), Cal=x00000000, Max=R255,U0,V0,X16383,Y16383,Z255
      281 Product= Saitek Pro Flight Rudder Pedals
      281    Manufacturer= Saitek
      281    Vendor=06A3, Product=0763 (Version 1.0)
      281    GUIDs returned for product: VID_06A3&PID_0763:
      281       GUID= {E53EFA00-6373-11EA-8002-444553540000}
      281       Details: Btns=0, POVs=(0, 0, 0, 0), Cal=x00000000, Max=R511,U0,V0,X127,Y127,Z0
      297 Product= Saitek Pro Flight Quadrant
      297    Manufacturer= Saitek
      297    Vendor=06A3, Product=0C2D (Version 2.0)
      297    GUIDs returned for product: VID_06A3&PID_0C2D:
      297       GUID= {E53EFA00-6373-11EA-8003-444553540000}
      297       Details: Btns=9, POVs=(0, 0, 0, 0), Cal=x00000000, Max=R0,U0,V0,X255,Y255,Z255
      312 Product= GF-TPM Throttle/Prop/Mixture Control
      312    Manufacturer= GoFlight
      328    Vendor=09F3, Product=0210 (Version 1.1)
      328    GUIDs returned for product: VID_09F3&PID_0210:
      328       GUID= {E53D4C50-6373-11EA-8001-444553540000}
      328       Details: Btns=0, POVs=(0, 0, 0, 0), Cal=x00000000, Max=R0,U0,V0,X255,Y255,Z255
      328 -------------------------------------------------------------------
      328 Device acquired for use:
      328    Joystick ID = 0 (Registry okay)
      328    0=Saitek Pro Flight Yoke
      328    0.GUID={5F23DDB0-62FF-11EA-8002-444553540000}
      328 Device acquired for use:
      328    Joystick ID = 5 (Registry okay)
      328    5=Alpha Flight Controls
      328    5.GUID={E9B5DA70-0348-11EB-8001-444553540000}
      328 Device acquired for use:
      328    Joystick ID = 4 (Registry okay)
      328    4=T.A320 Pilot
      328    4.GUID={904D9F70-F2B5-11EA-8001-444553540000}
      328 Device acquired for use:
      328    Joystick ID = 2 (Registry okay)
      328    2=Saitek Pro Flight Rudder Pedals
      328    2.GUID={E53EFA00-6373-11EA-8002-444553540000}
      328 Device acquired for use:
      328    Joystick ID = 3 (Registry okay)
      328    3=Saitek Pro Flight Quadrant
      328    3.GUID={E53EFA00-6373-11EA-8003-444553540000}
      328 Device acquired for use:
      328    Joystick ID = 1 (Registry okay)
      328    1=GoFlight GF-TPM Throttle/Pitch/Mixture control
      344    1.GUID={E53D4C50-6373-11EA-8001-444553540000}
      344 -------------------------------------------------------------------
      359 LogOptions=00000000 00000005
      375 Using "D:\FSUIPC7\GFDEV64.DLL", version 2.2.8.0
      375 GoFlight GFRP48 detected: 1 device
      375 GoFlight GFSECM detected: 1 device
     3203 Simulator detected
     8297 SimConnect_Open succeeded
     8297 Running in "KittyHawk", Version: 11.0.282174.999 (SimConnect: 11.0.62651.3)
     8297 MSFS version = 11.0.282174.999
     8297 Initialising SimConnect data requests now
     8359 C:\Users\MHane\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalState\MISSIONS\Custom\CustomFlight\CustomFlight.FLT
     8359 SimObjects\Airplanes\Asobo_DA40_NG\aircraft.CFG
     8359 User Aircraft ID 1 supplied, now being used
     8422 Aircraft loaded: running normally now ...
     8906 Aircraft="DA40-NG Asobo"
     8937 System time = 19/01/2021 22:44:41, Simulator time = 22:44:36 (21:44Z)
    14859 -------------------- Starting everything now ----------------------
    14937 LUA.1: beginning "D:\FSUIPC7\rotaries.lua"
    14937 LUA.1: D:\FSUIPC7\rotaries.lua:1
    14953 LUA.1: Global: ipcPARAM = 0
    14969 LUA.1: D:\FSUIPC7\rotaries.lua:2
    14984 LUA.1: Global: Vendor = GoFlight
    15000 LUA.1: D:\FSUIPC7\rotaries.lua:3
    15015 LUA.1: Global: Product = GF-RP48
    15031 LUA.1: D:\FSUIPC7\rotaries.lua:10
    15047 LUA.1: Global: Device = 0
    15062 LUA.1: D:\FSUIPC7\rotaries.lua:16
    15078 LUA.1: Global: Rotaries = table: 0000022D3416FC50
    15219 LUA.1: D:\FSUIPC7\rotaries.lua:18
    15234 LUA.1: Global: wr = 0
    15250 LUA.1: Global: wrf = 2
    15265 LUA.1: Global: dev = 1
    15281 LUA.1: Global: rd = 6
    15297 LUA.1: D:\FSUIPC7\rotaries.lua:26
    15312 LUA.1: D:\FSUIPC7\rotaries.lua:31
    15328 LUA.1: Global: FastTimeLimit = 60
    15344 LUA.1: D:\FSUIPC7\rotaries.lua:34
    15359 LUA.1: Global: Pollrate = 20
    15375 LUA.1: D:\FSUIPC7\rotaries.lua:35
    15390 LUA.1: Global: LastTimes = table: 0000022D34170A10
    15406 LUA.1: D:\FSUIPC7\rotaries.lua:36
    15422 LUA.1: Global: Buttons = 0
    15437 LUA.1: D:\FSUIPC7\rotaries.lua:37
    15453 LUA.1: Global: PrevButtons = 0
    15469 LUA.1: D:\FSUIPC7\rotaries.lua:81
    15484 LUA.1: Global: Diff = 0
    15500 LUA.1: D:\FSUIPC7\rotaries.lua:40
    15515 LUA.1: D:\FSUIPC7\rotaries.lua:83
    15547 LUA.1: Waiting for an event in "D:\FSUIPC7\rotaries.lua"
    15578 LUA.1: Timer event: calling "poll" in "D:\FSUIPC7\rotaries.lua"
    15578 LUA.1: D:\FSUIPC7\rotaries.lua:42
    15594 LUA.1: Local: Time = 281927484
    15609 LUA.1: D:\FSUIPC7\rotaries.lua:44
    15625 LUA.1: Global: data =
    15640 LUA.1: Global: n = 0
    15656 LUA.1: D:\FSUIPC7\rotaries.lua:81
    15687 LUA.1: Waiting for an event in "D:\FSUIPC7\rotaries.lua"
    15687 LUA.1: Timer event: calling "poll" in "D:\FSUIPC7\rotaries.lua"
    15687 LUA.1: D:\FSUIPC7\rotaries.lua:42
    15703 LUA.1: Local: Time = 281927593
    15719 LUA.1: D:\FSUIPC7\rotaries.lua:44
    15734 LUA.1: D:\FSUIPC7\rotaries.lua:81
    15765 LUA.1: Waiting for an event in "D:\FSUIPC7\rotaries.lua"
    15765 LUA.1: Timer event: calling "poll" in "D:\FSUIPC7\rotaries.lua"
    15765 LUA.1: D:\FSUIPC7\rotaries.lua:42
    15765 LUA.1: Local: Time = 281927671
    15797 LUA.1: D:\FSUIPC7\rotaries.lua:44
    15812 LUA.1: D:\FSUIPC7\rotaries.lua:81
    15828 LUA.1: Waiting for an event in "D:\FSUIPC7\rotaries.lua"
    15828 LUA.1: Timer event: calling "poll" in "D:\FSUIPC7\rotaries.lua"

(it keeps on going like that)

 

The LUA file:

 

Vendor = "GoFlight"
Product = "GF-RP48"
Device = 0  -- Multiple devices of the same name need increasing Device numbers

-- Use separate Lua plug-ins for separate cards!

-- NOTE: this can handle up to 16 rotaries only, using the first 64 "virtual buttons"
-- List the pairs here:

Rotaries = { 1,2,3,4,5,6,7,8}

-- Example { 31, 30, 25, 22 } would be 31+30 for one, 25+22 for the next, and so on
-- Which is clockwise and which counterclockwise doesn't matter -- you'll get
-- fast and slow of each in any case

dev, rd, wrf, wr, init = com.openhid(Vendor, Product, Device, Report)

if dev == 0 then
   ipc.log("Could not open HID")
   ipc.exit()
end

-- Set the boundary time in milliseconds between
-- "fast" (shorter) and "slow" (longer) signalling

FastTimeLimit = 60 -- Adjust to taste

-- Polling time in milliseconds: should be much shorter than
-- the boundary time

Pollrate = 20  -- same as 50 times per second

-- Initialise variables used to keep track of things
LastTimes = {}
Buttons = 0
PrevButtons = 0
Diff = 0

-- This function will be called by a time event, set at the end of the program before exit.
function poll(Time)
    -- read any data available from the device (only need most recent report)
  data, n = com.readlast(dev, rd)

    if n ~= 0 then
         -- Data was returned, so get the status of all the possible "buttons" we are using
      -- one value of 32 bits
        Buttons = com.gethidbuttons(dev, data)            

      -- See if any changes occurred:
      Diff = logic.Xor(Buttons, PrevButtons)
      PrevButtons = Buttons
             
    if Diff ~= 0 then
        offset = 0x3340
        buttonbit = 1
          j = 1
           while Rotaries[j] ~= nil do
                mask = logic.Shl(1, Rotaries[j]-1)               
                if logic.And(Diff,mask) ~= 0 then
                    -- This one changed
                   -- See if changed in less than the "boundary" time
                   thisbutton = buttonbit
                if (LastTimes[j] ~= nil) and ((Time - LastTimes[j]) < FastTimeLimit) then
              thisbutton = buttonbit + buttonbit  -- Use next higher button for fast
            end
               LastTimes[j] = Time
                        
              -- Toggle a virtual button accordingly
               ipc.togglebitsUD(offset, thisbutton)
                end
                
                j = j + 1
                buttonbit = 4 * buttonbit
                if logic.And(j,15) == 0 then
                   buttonbit = 1
                   offset = offset + 4
                end
          end
        end
    end
end

event.timer(Pollrate, "poll")

 

I don't know how to proceed from here.. some input-for-dummies would be well appreciated.

 

Best

Matthias

Link to comment
Share on other sites

12 hours ago, MatzeH84 said:

But FSUIPC is still recognizing the "real" buttons instead of virtual ones I aim for.

You can use the IgnoreThese ini parameter to ignore the physical button presses rather than the virtual ones. See the Advanced User Manual for details.

12 hours ago, MatzeH84 said:

I used the rotaries.lua file, made it automatically load and recognize the unit (I guess).

But why are you using this lua with the RP48? I have two of these devices and they work just fine using the GFDev64.dll and direct assignments. Each rotary has two buttons in each direction, one for a slow movement and one for a fast movement. You can just assign your small incr/decr to the slow movement buttons, and a larger inc/decr to the fast movement ones. 

 

Link to comment
Share on other sites

Thanks John for your quick reply. Sorry, work kept me from answering until now.

I already tried to use direct keybinds like to suggested, as it seemed the obvious and easiest option. However, this does not really work well.

Let's take the 4th dial for example.

I turn it clockwise slowly. FSUIPC registers buttons  22 and 23, but also 20 and 21 in between.
Counterclockwise it registers mainly 20 and 21, but also 22 and 23 in between.

Similar for every other dial. The faster I turn the knob, the more apparent becomes the error. This means, my values/ dials in the sim are jumping back and forth instead of counting straight up or down.

I hoped the LUA would help to rectify the issue, that's why I wanted to test it.

Link to comment
Share on other sites

Ok, strange though - I don't see this on my GF rotaries. And these would also trigger virtual button presses, no?
So you would have the same issue using the lua script.

But, as  I said, you can use the IgnoreThese ini parameter to ignore the physical button presses if you like.
 

However, the rotaries script was written to emulate slow/fast turning for rotary encoders with one button in each direction. Yours have two, so try programming just to the 'slow' button each direction. Also, check your button numbers in your script:

On 1/19/2021 at 11:00 PM, MatzeH84 said:

-- NOTE: this can handle up to 16 rotaries only, using the first 64 "virtual buttons"
-- List the pairs here:

Rotaries = { 1,2,3,4,5,6,7,8}

Are your rotary button numbers really like that? From your example description, this should really be something like
   Rotaries = {22, 20, .. }

(for rotary button 22 in one direction, 20 the other)

Link to comment
Share on other sites

Thank you, I will try that. As this is an older unit (black color, not the current Grey) it could also mean they were used so extensively that buttons are triggered that shouldn't.. I'll check that as well, maybe it's more a mechanical problem rather than a software issue.

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.