Author Topic: override input_map from script?  (Read 3488 times)

millercentral

  • Jr. Member
  • **
  • Posts: 13
    • View Profile
override input_map from script?
« on: December 27, 2016, 04:15:02 PM »
Hello. Does anyone know of a way to change the input_map during runtime? For example, a hypothetical function:

fe.set_input(input_name, input_id, replace_existing)  // replace_existing true=replace current map with new id, false=add id as additional map


eg. fe.set_input("up", "Joy0 Up", true)

But it doesn't look like this is possible (so perhaps this is a feature request then.. ;). I'm sure there are other options that would be great to be able to reach during runtime, such as volume, but input_map adjustments is most important for my needs.

Thanks!

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: override input_map from script?
« Reply #1 on: December 27, 2016, 05:52:45 PM »
Yeah I think that would have to be a feature request. I think the only way you might be able to do it now would be to overwrite the AM config, and reload your layout - even that might not be possible if it only reads mappings at start or when they change in the settings.

In what scenario would you need that, can you give an example? Reason being is the user should decide the mappings, not the layout. There is a generic "up, down, left, right, select and back" regardless of what controls they have been mapped to, so you should be able to handle things using those.

I have a ton of joysticks so I could see that being useful with id changes, but you can use an external program to keep those joysticks at a set id.

raygun

  • Administrator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
Re: override input_map from script?
« Reply #2 on: January 01, 2017, 03:39:25 PM »
I'm not sure what you are trying to do with overridng the input_map, but if you want to stop the frontend from handling a particular action, you can do that from a plugin or layout script by adding a signal handler that returns true whenever the signal corresponding to that action is received.  https://github.com/mickelson/attract/blob/master/Layouts.md#add_signal_handler

So for example:
Code: [Select]
fe.add_signal_handler("suppress_select");
function suppress_select( sig )
{
   if ( sig == "select" ) return true;

   return false;
}

will stop whatever is configured as the 'select' input from working

you could then trigger the "select" signal yourself from the script whenever you want it triggered, using
Code: [Select]
fe.signal("select");
If you just want a different key to be the "select" key, you could have a tick function that regularly checks if your select key is pressed using
Code: [Select]
fe.get_input_state()https://github.com/mickelson/attract/blob/master/Layouts.md#get_input_state

those are the basics anyways of how you could approach an input override using what is there now.

hope this helps