mirror of https://github.com/LIJI32/SameBoy.git
Adjust Joy-Con terminology
This commit is contained in:
parent
052e2429e0
commit
e1fa28bd54
|
@ -7,7 +7,7 @@
|
|||
GBTintedImageCell *_tintedImageCell;
|
||||
NSImageCell *_imageCell;
|
||||
NSMutableDictionary<NSString *, NSString *> *_pairings;
|
||||
NSMutableDictionary<NSString *, NSNumber *> *_orientationSettings;
|
||||
NSMutableDictionary<NSString *, NSNumber *> *_gripSettings;
|
||||
NSButton *_autoPairCheckbox;
|
||||
bool _unpairing;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@
|
|||
_tintedImageCell.tint = [NSColor selectedMenuItemColor];
|
||||
}
|
||||
_pairings = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"GBJoyConPairings"] ?: @{} mutableCopy];
|
||||
_orientationSettings = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"GBJoyConOrientations"] ?: @{} mutableCopy];
|
||||
_gripSettings = [[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"GBJoyConGrips"] ?: @{} mutableCopy];
|
||||
|
||||
// Sanity check the pairings
|
||||
for (NSString *key in _pairings) {
|
||||
|
@ -85,11 +85,11 @@
|
|||
case JOYJoyConTypeNone:
|
||||
return nil;
|
||||
case JOYJoyConTypeLeft:
|
||||
return [NSImage imageNamed:[NSString stringWithFormat:@"%sJoyConLeftTemplate", controller.usesHorizontalJoyConMode? "Horizontal" :""]];
|
||||
return [NSImage imageNamed:[NSString stringWithFormat:@"%sJoyConLeftTemplate", controller.usesHorizontalJoyConGrip? "Horizontal" :""]];
|
||||
case JOYJoyConTypeRight:
|
||||
return [NSImage imageNamed:[NSString stringWithFormat:@"%sJoyConRightTemplate", controller.usesHorizontalJoyConMode? "Horizontal" :""]];
|
||||
case JOYJoyConTypeCombined:
|
||||
return [NSImage imageNamed:@"JoyConCombinedTemplate"];
|
||||
return [NSImage imageNamed:[NSString stringWithFormat:@"%sJoyConRightTemplate", controller.usesHorizontalJoyConGrip? "Horizontal" :""]];
|
||||
case JOYJoyConTypeDual:
|
||||
return [NSImage imageNamed:@"JoyConDualTemplate"];
|
||||
}
|
||||
}
|
||||
case 1: {
|
||||
|
@ -104,19 +104,19 @@
|
|||
return ret;
|
||||
}
|
||||
case 2:
|
||||
return @([(_orientationSettings[controller.uniqueID] ?: @(-1)) unsignedIntValue] + 1);
|
||||
return @([(_gripSettings[controller.uniqueID] ?: @(-1)) unsignedIntValue] + 1);
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)updateOrientationForController:(JOYController *)controller
|
||||
- (void)updateGripForController:(JOYController *)controller
|
||||
{
|
||||
NSNumber *orientation = _orientationSettings[controller.uniqueID];
|
||||
if (!orientation) {
|
||||
controller.usesHorizontalJoyConMode = [[NSUserDefaults standardUserDefaults] boolForKey:@"GBJoyConsDefaultsToHorizontal"];
|
||||
NSNumber *grip = _gripSettings[controller.uniqueID];
|
||||
if (!grip) {
|
||||
controller.usesHorizontalJoyConGrip = [[NSUserDefaults standardUserDefaults] boolForKey:@"GBJoyConsDefaultsToHorizontal"];
|
||||
return;
|
||||
}
|
||||
controller.usesHorizontalJoyConMode = [orientation unsignedIntValue] == 1;
|
||||
controller.usesHorizontalJoyConGrip = [grip unsignedIntValue] == 1;
|
||||
}
|
||||
|
||||
- (void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
|
||||
|
@ -125,22 +125,22 @@
|
|||
if (columnIndex != 2) return;
|
||||
if (row >= [self numberOfRowsInTableView:tableView]) return;
|
||||
JOYController *controller = self.joycons[row];
|
||||
if (controller.joyconType == JOYJoyConTypeCombined) {
|
||||
if (controller.joyconType == JOYJoyConTypeDual) {
|
||||
return;
|
||||
}
|
||||
switch ([object unsignedIntValue]) {
|
||||
case 0:
|
||||
[_orientationSettings removeObjectForKey:controller.uniqueID];
|
||||
[_gripSettings removeObjectForKey:controller.uniqueID];
|
||||
break;
|
||||
case 1:
|
||||
_orientationSettings[controller.uniqueID] = @(0);
|
||||
_gripSettings[controller.uniqueID] = @(0);
|
||||
break;
|
||||
case 2:
|
||||
_orientationSettings[controller.uniqueID] = @(1);
|
||||
_gripSettings[controller.uniqueID] = @(1);
|
||||
break;
|
||||
}
|
||||
[[NSUserDefaults standardUserDefaults] setObject:_orientationSettings forKey:@"GBJoyConOrientations"];
|
||||
[self updateOrientationForController:controller];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:_gripSettings forKey:@"GBJoyConGrips"];
|
||||
[self updateGripForController:controller];
|
||||
}
|
||||
|
||||
- (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
|
||||
|
@ -150,7 +150,7 @@
|
|||
unsigned columnIndex = [[tableView tableColumns] indexOfObject:tableColumn];
|
||||
if (columnIndex == 2) {
|
||||
JOYCombinedController *controller = (JOYCombinedController *)self.joycons[row];
|
||||
if (controller.joyconType == JOYJoyConTypeCombined) {
|
||||
if (controller.joyconType == JOYJoyConTypeDual) {
|
||||
NSButtonCell *cell = [[NSButtonCell alloc] initTextCell:@"Separate Joy-Cons"];
|
||||
cell.bezelStyle = NSBezelStyleRounded;
|
||||
cell.action = @selector(invoke);
|
||||
|
@ -185,7 +185,7 @@
|
|||
|
||||
- (void)controllerConnected:(JOYController *)controller
|
||||
{
|
||||
[self updateOrientationForController:controller];
|
||||
[self updateGripForController:controller];
|
||||
for (JOYController *partner in [JOYController allControllers]) {
|
||||
if ([partner.uniqueID isEqualToString:_pairings[controller.uniqueID]]) {
|
||||
[self pairJoyCon:controller withJoyCon:partner];
|
||||
|
@ -241,8 +241,8 @@
|
|||
|
||||
_pairings[first.uniqueID] = second.uniqueID;
|
||||
_pairings[second.uniqueID] = first.uniqueID;
|
||||
first.usesHorizontalJoyConMode = false;
|
||||
second.usesHorizontalJoyConMode = false;
|
||||
first.usesHorizontalJoyConGrip = false;
|
||||
second.usesHorizontalJoyConGrip = false;
|
||||
[[NSUserDefaults standardUserDefaults] setObject:_pairings forKey:@"GBJoyConPairings"];
|
||||
return [[JOYCombinedController alloc] initWithChildren:@[first, second]];
|
||||
}
|
||||
|
@ -305,7 +305,7 @@
|
|||
{
|
||||
[[NSUserDefaults standardUserDefaults] setBool:sender.state forKey:@"GBJoyConsDefaultsToHorizontal"];
|
||||
for (JOYController *controller in self.joycons) {
|
||||
[self updateOrientationForController:controller];
|
||||
[self updateGripForController:controller];
|
||||
}
|
||||
if (_arrangementMode) {
|
||||
[self.tableView reloadData];
|
||||
|
|
|
@ -524,8 +524,8 @@ static const uint8_t workboy_vk_to_key[] = {
|
|||
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"GBMBC7JoystickOverride"]) return;
|
||||
if (self.mouseControlsActive) return;
|
||||
if (controller != lastController) return;
|
||||
// When using a combined two Joy-Cons, ignore motion data from the left Joy-Con
|
||||
if (controller.joyconType == JOYJoyConTypeCombined) {
|
||||
// When using Joy-Cons in dual-controller grip, ignore motion data from the left Joy-Con
|
||||
if (controller.joyconType == JOYJoyConTypeDual) {
|
||||
for (JOYController *child in [(JOYCombinedController *)controller children]) {
|
||||
if (child.joyconType != JOYJoyConTypeRight && [child.axes3D containsObject:axes]) {
|
||||
return;
|
||||
|
|
Before Width: | Height: | Size: 315 B After Width: | Height: | Size: 315 B |
Before Width: | Height: | Size: 483 B After Width: | Height: | Size: 483 B |
|
@ -1322,7 +1322,7 @@
|
|||
<button focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xhI-kr-h3J">
|
||||
<rect key="frame" x="18" y="287" width="485" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="check" title="Automatically pair together left and right Joy-Cons when they're connected" bezelStyle="regularSquare" imagePosition="left" state="on" focusRingType="none" inset="2" id="dPv-XO-6Fp">
|
||||
<buttonCell key="cell" type="check" title="Automatically pair together Joy-Cons to a dual-controller grip" bezelStyle="regularSquare" imagePosition="left" state="on" focusRingType="none" inset="2" id="dPv-XO-6Fp">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
|
@ -1333,7 +1333,7 @@
|
|||
<button focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="DaV-H7-VVr">
|
||||
<rect key="frame" x="18" y="266" width="485" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="check" title="Single Joy-Cons default to horizontal orientation" bezelStyle="regularSquare" imagePosition="left" state="on" focusRingType="none" inset="2" id="18L-S2-0wg">
|
||||
<buttonCell key="cell" type="check" title="Single Joy-Cons default to horizontal group" bezelStyle="regularSquare" imagePosition="left" state="on" focusRingType="none" inset="2" id="18L-S2-0wg">
|
||||
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
|
@ -1341,10 +1341,21 @@
|
|||
<action selector="toggleHorizontalDefault:" target="fMo-Ht-Dis" id="yhh-pY-XOq"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6Tm-Sf-8w1">
|
||||
<rect key="frame" x="432" y="13" width="75" height="32"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
|
||||
<buttonCell key="cell" type="push" title="Close" bezelStyle="rounded" alignment="center" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" id="leb-Jp-RfR">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="closeJoyConsSheet:" target="QvC-M9-y7g" id="K2P-xu-B1o"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gmw-t5-3nG">
|
||||
<rect key="frame" x="18" y="20" width="411" height="14"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
|
||||
<textFieldCell key="cell" controlSize="small" lineBreakMode="clipping" focusRingType="none" title="Hold L and R on two Joy-Cons to pair them together" id="kRC-pE-5Pd">
|
||||
<textFieldCell key="cell" controlSize="small" lineBreakMode="clipping" focusRingType="none" title="Hold L and R on two Joy-Cons to pair them to a dual-controller grip" id="kRC-pE-5Pd">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
|
@ -1394,14 +1405,14 @@ Test</string>
|
|||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</tableHeaderCell>
|
||||
<popUpButtonCell key="dataCell" type="bevel" title="Horizontal Orientation" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="bezel" imageScaling="proportionallyDown" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" selectedItem="IJX-Qq-TaU" id="rif-6W-xsN">
|
||||
<popUpButtonCell key="dataCell" type="bevel" title="Horizontal Grip" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="bezel" imageScaling="proportionallyDown" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" selectedItem="IJX-Qq-TaU" id="rif-6W-xsN">
|
||||
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
<menu key="menu" id="36b-lh-dDy">
|
||||
<items>
|
||||
<menuItem title="Default Orientation" id="8im-vm-Bj9"/>
|
||||
<menuItem title="Vertical Orientation" id="bU8-po-vzF"/>
|
||||
<menuItem title="Horizontal Orientation" state="on" id="IJX-Qq-TaU"/>
|
||||
<menuItem title="Default Grip" id="8im-vm-Bj9"/>
|
||||
<menuItem title="Vertical Grip" id="bU8-po-vzF"/>
|
||||
<menuItem title="Horizontal Grip" state="on" id="IJX-Qq-TaU"/>
|
||||
</items>
|
||||
</menu>
|
||||
</popUpButtonCell>
|
||||
|
@ -1424,17 +1435,6 @@ Test</string>
|
|||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
</scrollView>
|
||||
<button focusRingType="none" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6Tm-Sf-8w1">
|
||||
<rect key="frame" x="432" y="13" width="75" height="32"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
|
||||
<buttonCell key="cell" type="push" title="Close" bezelStyle="rounded" alignment="center" borderStyle="border" focusRingType="none" imageScaling="proportionallyDown" inset="2" id="leb-Jp-RfR">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" metaFont="system"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="closeJoyConsSheet:" target="QvC-M9-y7g" id="K2P-xu-B1o"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
</view>
|
||||
<point key="canvasLocation" x="-1062.5" y="-96"/>
|
||||
|
|
|
@ -33,7 +33,7 @@ typedef enum {
|
|||
JOYJoyConTypeNone,
|
||||
JOYJoyConTypeLeft,
|
||||
JOYJoyConTypeRight,
|
||||
JOYJoyConTypeCombined,
|
||||
JOYJoyConTypeDual,
|
||||
} JOYJoyConType;
|
||||
|
||||
@interface JOYController : NSObject
|
||||
|
@ -55,7 +55,7 @@ typedef enum {
|
|||
@property (readonly) JOYJoyConType joyconType;
|
||||
@property (readonly) NSString *deviceName;
|
||||
@property (readonly) NSString *uniqueID;
|
||||
@property (nonatomic) bool usesHorizontalJoyConMode;
|
||||
@property (nonatomic) bool usesHorizontalJoyConGrip;
|
||||
@end
|
||||
|
||||
@interface JOYCombinedController : JOYController
|
||||
|
|
|
@ -1111,15 +1111,15 @@ typedef union {
|
|||
return ret;
|
||||
}
|
||||
|
||||
- (void)setUsesHorizontalJoyConMode:(bool)usesHorizontalJoyConMode
|
||||
- (void)setusesHorizontalJoyConGrip:(bool)usesHorizontalJoyConGrip
|
||||
{
|
||||
if (usesHorizontalJoyConMode == _usesHorizontalJoyConMode) return; // Nothing to do
|
||||
_usesHorizontalJoyConMode = usesHorizontalJoyConMode;
|
||||
if (usesHorizontalJoyConGrip == _usesHorizontalJoyConGrip) return; // Nothing to do
|
||||
_usesHorizontalJoyConGrip = usesHorizontalJoyConGrip;
|
||||
switch (self.joyconType) {
|
||||
case JOYJoyConTypeLeft:
|
||||
case JOYJoyConTypeRight: {
|
||||
NSArray <JOYButton *> *buttons = _buttons.allValues; // not self.buttons to skip emulated buttons
|
||||
if (!usesHorizontalJoyConMode) {
|
||||
if (!usesHorizontalJoyConGrip) {
|
||||
for (JOYAxes2D *axes in self.axes2D) {
|
||||
axes.rotation = 0;
|
||||
}
|
||||
|
@ -1476,12 +1476,12 @@ typedef union {
|
|||
if (_children.count != 2) return JOYJoyConTypeNone;
|
||||
if (_children[0].joyconType == JOYJoyConTypeLeft &&
|
||||
_children[1].joyconType == JOYJoyConTypeRight) {
|
||||
return JOYJoyConTypeCombined;
|
||||
return JOYJoyConTypeDual;
|
||||
}
|
||||
|
||||
if (_children[1].joyconType == JOYJoyConTypeLeft &&
|
||||
_children[0].joyconType == JOYJoyConTypeRight) {
|
||||
return JOYJoyConTypeCombined;
|
||||
return JOYJoyConTypeDual;
|
||||
}
|
||||
return JOYJoyConTypeNone;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue