robreuss / VirtualGameController

Software-based game controllers for iOS, tvOS, OS X and watchOS in Swift 4.2.
MIT License
462 stars 44 forks source link

Custom elements fix #5

Closed jakubknejzlik closed 8 years ago

jakubknejzlik commented 8 years ago

When trying running as .Central I've found that the CustomElements overridden init method wasn't public, making it impossible to initialize from another module.

robreuss commented 8 years ago

Thanks. I don't have much experience with pull requests. Should I use the Github feature to automatically merge, thereby bringing your podspec in, and then update that to point to my repository? Or should I just merge the CustomElements change via the command line?

jakubknejzlik commented 8 years ago

Didn't try it from the command line (also I'm not sure, if it's possible from command line to accept pull request)...github worked fine for me in all cases.

jakubknejzlik commented 8 years ago

Ouch, my bad! I've watched the commited changes again, and it contains edits from another commit (cocoapods pull request). I'll create new or, if you want to update it manualy. Just please don't accept this PR. I'm sorry for troubles.

jakubknejzlik commented 8 years ago

It's all just about this line

robreuss commented 8 years ago

Great, I'll just make that change. FYI, this a wiki page on using custom elements in case you didn't see it: https://github.com/robreuss/VirtualGameController/wiki/Custom-Elements

Let me know if you notice any errors. Can you tell me in general terms how you're using custom elements, just so I can get a feel for use cases?

jakubknejzlik commented 8 years ago

Well, I've copied it from example :). Also when I've specified nil value for customElements and customMappings, the app crashes right after peripheral (ios in my case) controller gets connected.

robreuss commented 8 years ago

Yeah, I tried setting things up to allow nil for those parameters but it was seeming like a pain, so I created an alternative startAs method in VgcManager that doesn't take those parameters, and initializes them using the superclass, which has the net effect of creating an empty set of elements/mappings:

    public class func startAs(appRole: AppRole, appIdentifier: String) {
        VgcManager.startAs(appRole, appIdentifier: appIdentifier, customElements: CustomElementsSuperclass(), customMappings: CustomMappingsSuperclass())
    }
jakubknejzlik commented 8 years ago

Ah, I see...ok then:) ... btw you can also create it this way:

public class func startAs(appRole: AppRole, appIdentifier: String, customElements: CustomElements = CustomElements(), customMappers: CustomMappers = CustomMappers()) {
...