git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

JoyKit/JOYMultiplayerController.m

      1 #import "JOYMultiplayerController.h"
      2 
      3 @interface JOYController ()
      4 - (instancetype)initWithDevice:(IOHIDDeviceRef)device reportIDFilter:(NSArray <NSNumber *> *) filter serialSuffix:(NSString *)suffix hacks:(NSDictionary *)hacks;
      5 - (void)elementChanged:(IOHIDElementRef) element toValue:(IOHIDValueRef) value;
      6 - (void)disconnected;
      7 - (void)sendReport:(NSData *)report;
      8 @end
      9 
     10 @implementation JOYMultiplayerController
     11 {
     12     NSMutableArray <JOYController *> *_children;
     13 }
     14 
     15 - (instancetype)initWithDevice:(IOHIDDeviceRef) device reportIDFilters:(NSArray <NSArray <NSNumber *> *>*) reportIDFilters hacks:(NSDictionary *)hacks;
     16 {
     17     self = [super init];
     18     if (!self) return self;
     19     
     20     _children = [NSMutableArray array];
     21     
     22     unsigned index = 1;
     23     for (NSArray *filter in reportIDFilters) {
     24         JOYController *controller = [[JOYController alloc] initWithDevice:device reportIDFilter:filter serialSuffix:[NSString stringWithFormat:@"%d", index] hacks:hacks];
     25         [_children addObject:controller];
     26         index++;
     27     }
     28     return self;
     29 }
     30 
     31 - (void)elementChanged:(IOHIDElementRef) element toValue:(IOHIDValueRef) value
     32 {
     33     for (JOYController *child in _children) {
     34         [child elementChanged:element toValue:value];
     35     }
     36 }
     37 
     38 - (void)disconnected
     39 {
     40     for (JOYController *child in _children) {
     41         [child disconnected];
     42     }
     43 }
     44 
     45 - (void)sendReport:(NSData *)report
     46 {
     47     [[_children firstObject] sendReport:report];
     48 }
     49 
     50 @end

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.