Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement support for loading/saving mappings in iOS (Issue 131) #244

Merged
merged 3 commits into from
Mar 17, 2018

Conversation

adamjansch
Copy link
Contributor

For iOS, implemented loading of bundled mappings, and loading/saving of user mappings. Original issue at #131.

This also fixes a crash that occurs when accessing MIKMIDIMappingManager.shared() when there is a .midimap file present in the bundle (aka: a bundled mapping).

Adam Jansch added 3 commits March 7, 2018 09:29
Removed TARGET_OS_IPHONE if statements in MIKMIDIMappingManager class to allow iOS to use those methods.
Fixed crash when accessing MIKMIDIMappingManager shared instance. Tracked it down to the XML conversion, where a string was being asked to return an NSUInteger (for control number) which it cannot handle.
Added additional comment.
@armadsen
Copy link
Member

armadsen commented Mar 7, 2018

Thanks so much for this! I will review it and merge it and/or give feedback as soon as I can.

@armadsen
Copy link
Member

armadsen commented Mar 7, 2018

@aj-bmdi: Do you mind sending a .midimap file that caused a crash before your fix was implemented?

@adamjansch
Copy link
Contributor Author

@armadsen Sure, this is what I tested with (and what was causing the crash):

<?xml version="1.0" encoding="UTF-8"?>
<Mapping ControllerName="Network" MappingName="Network">
    <MappingItems>
	    <MappingItem InteractionType="Tap" Flipped="false">
		    <ResponderIdentifier>button-0</ResponderIdentifier>
		    <CommandIdentifier>ButtonDown</CommandIdentifier>
		    <Channel>0</Channel>
		    <CommandType>191</CommandType>
		    <ControlNumber>19</ControlNumber>
	    </MappingItem>
	    <MappingItem InteractionType="Key" Flipped="false">
		    <ResponderIdentifier>button-6</ResponderIdentifier>
		    <CommandIdentifier>ButtonDown</CommandIdentifier>
		    <Channel>0</Channel>
		    <CommandType>191</CommandType>
		    <ControlNumber>22</ControlNumber>
	    </MappingItem>
	    <MappingItem InteractionType="KnobSlider" Flipped="true">
		    <ResponderIdentifier>slider-0</ResponderIdentifier>
		    <CommandIdentifier>ValueChanged</CommandIdentifier>
		    <Channel>0</Channel>
		    <CommandType>191</CommandType>
		    <ControlNumber>126</ControlNumber>
	    </MappingItem>
	    <MappingItem InteractionType="KnobSlider" Flipped="false">
		    <ResponderIdentifier>slider-6</ResponderIdentifier>
		    <CommandIdentifier>ValueChanged</CommandIdentifier>
		    <Channel>0</Channel>
		    <CommandType>191</CommandType>
		    <ControlNumber>6</ControlNumber>
	    </MappingItem>
    </MappingItems>
</Mapping>

The crash was occurring when assigning the control number to the new mapping item, as the latter requires an unsigned int but the former was a coming through as a string and NSString has no method to convert to that type directly.

@adamjansch adamjansch changed the title Issue131 Implement support for loading/saving mappings in iOS (Issue 131) Mar 9, 2018
@armadsen
Copy link
Member

Looks great, thanks!

@armadsen armadsen merged commit bdf66d7 into mixedinkey-opensource:master Mar 17, 2018
@armadsen armadsen added this to the 1.7 milestone Mar 17, 2018
@adamjansch adamjansch deleted the Issue131 branch April 19, 2018 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants