MIKMIDIMappingGeneratorDelegate

Objective-C

@protocol MIKMIDIMappingGeneratorDelegate <NSObject>

Swift

protocol MIKMIDIMappingGeneratorDelegate : NSObjectProtocol

Defines methods to be implemented by the delegate of an MIKMIDIMappingGenerator in order to customize mapping generation behavior.

  • Used to determine behavior when attempting to map a physical control that has been previously mapped to a new responder.

    When MIKMIDIMappingGenerator receives mappable messages from a physical control and finds that that control has already been mapped to one or more other virtual controls (responder/command combinations), it will call this method to ask what to do. One of the options specified in MIKMIDIMappingGeneratorRemapBehavior should be returned.

    To use the default behavior, (currently MIKMIDIMappingGeneratorRemapDisallow) return MIKMIDIMappingGeneratorRemapDefault. If the delegate does not respond to this method, the default behavior is used.

    Declaration

    Objective-C

    - (MIKMIDIMappingGeneratorRemapBehavior)
                                  mappingGenerator:
                                      (nonnull MIKMIDIMappingGenerator *)generator
        behaviorForRemappingControlMappedWithItems:
            (nonnull NSSet<MIKMIDIMappingItem *> *)mappingItems
                                    toNewResponder:
                                        (nonnull id<MIKMIDIMappableResponder>)
                                            newResponder
                                 commandIdentifier:
                                     (nonnull NSString *)commandIdentifier;

    Parameters

    generator

    The mapping generator performing the mapping.

    mappingItems

    The mapping items for commands previously mapped to the physical control in question.

    newResponder

    The responder for which a mapping is currently being generated.

    commandIdentifier

    The command identifier of newResponder that is being mapped.

    Return Value

    The behavior to use when mapping the newResponder. See MIKMIDIMappingGeneratorRemapBehavior for a list of possible values.

  • Used to determine whether the existing mapping item for a responder should be superceded by a new mapping item.

    The default behavior is to remove existing mapping items (return value of YES). If the delegate does not respond to this method, the default behavior is used.

    Declaration

    Objective-C

    - (BOOL)mappingGenerator:(nonnull MIKMIDIMappingGenerator *)generator
        shouldRemoveExistingMappingItems:
            (nonnull NSSet<MIKMIDIMappingItem *> *)mappingItems
                 forResponderBeingMapped:
                     (nonnull id<MIKMIDIMappableResponder>)responder;

    Parameters

    generator

    The mapping generator performing the mapping.

    mappingItems

    The set of existing MIKMIDIMappingItems associated with responder.

    responder

    The reponsder for which a mapping is currently being generated.

    Return Value

    YES to remove the existing mapping items. NO to keep the existing mapping items in addition to the new mapping item being generated.

  • The delegate can implement this to do some transformation of incoming commands in order to customize mapping. For instance, controls can be dynamically remapped, or incoming commands can be selectively ignored. Most users of MIKMIDIMappingGenerator will not need to use this.

    Declaration

    Objective-C

    - (nonnull MIKMIDIChannelVoiceCommand *)mappingGenerator:
                                                (nonnull MIKMIDIMappingGenerator *)
                                                    generator
                          commandByProcessingIncomingCommand:
                              (nonnull MIKMIDIChannelVoiceCommand *)command;

    Swift

    optional func mappingGenerator(_ generator: MIKMIDIMappingGenerator, commandByProcessingIncomingCommand command: MIKMIDIChannelVoiceCommand) -> MIKMIDIChannelVoiceCommand

    Parameters

    command

    An incoming MIKMIDICommand.

    Return Value

    A processed/modified copy of the incoming command, or nil to ignore the command.