Jump to content

Inputlock question- target switching.


Recommended Posts

 Using KRPC I was running into problems setting a target programmatically - which used to work fine, but now was throwing up a  'Target switching locked' message in KSP.   I removed all other mods and it was still happening.  

I tossed       InputLockManager.ClearControlLocks();  into a service I'd been adding onto KRPC and that fixed it...  I could call that and then set the targets however I wanted to...  but...  that seems a rather poor solution since it screws up whatever locks others have set for good reasons?

Is there a way to figure out the id of the lock that's causing the problem and fix it?  Or a way to set the locks equal to the locks minus the target switching one?  And what IS the bitflag for target switching?    Or has the preferred method for setting a target changed?   

Edited by artwhaley
Link to comment
Share on other sites

6 hours ago, artwhaley said:

I tossed       InputLockManager.ClearControlLocks();  into a service I'd been adding onto KRPC and that fixed it...  I could call that and then set the targets however I wanted to...  but...  that seems a rather poor solution since it screws up whatever locks others have set for good reasons?

I concur, you should probably avoid stomping on locks that have been set by stock KSP and/or other mods.

 

6 hours ago, artwhaley said:

Is there a way to figure out the id of the lock that's causing the problem and fix it?

InputLockManager.PrintLockStack(); might give you something to work with in terms of manual inspection.
If you want to do it programatically, InputLockManager.lockStack is Dictionary< string, ulong > which is probably has lockID string as key and the bitmask ulong so you could iterate over and determine the lockID(s) that have a lock on the controls you want.

 

6 hours ago, artwhaley said:

And what IS the bitflag for target switching?

The complete enum of ControlTypes is here.
For targeting, ControlTypes.TARGETING = 1ul << 55 should be what you're looking for.

 

hth

Link to comment
Share on other sites

I figured out what my problem was but I'm waiting on smarter people in the project to fix it.  Target setting is one of the control locks that gets set by KSP when the application window loses focus!   So switching out to my python interpreter to issue KRPC commands was locking me out of being able to run them.   As a test case adding THIS to my mod code fixed it - 

 

InputLockManager.lockMask &= (ulong) ~ ControlTypes.TARGETING;

That's a bitwise and with the compliment of the Targeting control type added to the bitmask.  If the smarter people come up with a smarter way around this, I'll post that here too so time travelers from the future can see that. 

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...