fernandojsg / aframe-input-mapping-component

https://fernandojsg.github.io/aframe-input-mapping-component
MIT License
24 stars 7 forks source link

Remove actions from the mapping #14

Closed fernandojsg closed 6 years ago

fernandojsg commented 6 years ago

Right now we have:

var mappings = {
    actions: {
      changeTask: { label: 'Change task' },
      testlog: { label: 'Test Log' },
      testlog_task1: { label: 'Test Log Task 1' }
    },
    mappings: {
      default: {
        common: {
          triggerdown: 'testlog'
        },
        'vive-controls': {
          gripdown: 'changeTask',
          trackpaddown: 'testlog'
        },
        'oculus-touch-controls': {
          abuttondown: 'changeTask'
        },
        'windows-motion-controls': {
          gripdown: 'changeTask'
        },
        keyboard: {
          't_up': 'testlog',
          'c_up': 'changeTask'
        }
      },
...

And we call:

AFRAME.registerInputMappings(mappings);

The proposed change will be to take actions out from these mappings and create another function to set them:

AFRAME.registerInputActions(actions);
dmarcos commented 6 years ago

This looks good to me.

netpro2k commented 6 years ago

Actions exist in specific states, so the actions should be in states. Also states might want to have metadata also (imagining what the config UI might look like) so we might want to put actions in an object:

AFRAME.registerInputActions({
  default: {
    label: "Default State",
    actions: {
      changeTask: { label: 'Change task' },
      testlog: { label: 'Test Log' },
    }
  },
  task1: {
    label: "Painting",
    actions: {
      testlog_task1: { label: 'Test Log Task 1' }
    }
  }
});

With a corresponding mapping:

AFRAME.registerInputMappings({
  default: {
    'vive-controls': {
      gripdown: 'changeTask',
      trackpaddown: 'testlog'
    },
    'oculus-touch-controls': {
      abuttondown: 'changeTask'
      triggerdown: 'testlog'
    },
    'windows-motion-controls': {
      gripdown: 'changeTask'
      triggerdown: 'testlog'
    },
    keyboard: {
      't_up': 'testlog',
      'c_up': 'changeTask'
    }
  },
  task1: {
    'vive-controls': {
      triggerdown: 'testlog_task1',
      gripdown: 'changeTask'
    },
    'oculus-touch-controls': {
      triggerdown: 'testlog_task1',
      abuttondown: 'changeTask'
    },
    'windows-motion-controls': {
      triggerdown: 'testlog_task1',
      gripdown: 'changeTask'
    },
    keyboard: {
      'y_up': 'testlog_task1',
      'c_up': 'changeTask'
    }
  }
})

fernandojsg commented 6 years ago

@netpro2k yep, I just forgot to include them on the example. I created a PR with the proposals https://github.com/fernandojsg/aframe-input-mapping-component/pull/17