Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
benbaker76 committed Mar 2, 2020
1 parent 53f22c2 commit c7c662b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 21 deletions.
Binary file not shown.
2 changes: 2 additions & 0 deletions PinConfigurator/AudioNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#define LONIBBLE(n) ((char)(n) & 0xF)
#define HINIBBLE(n) ((char)(((char)(n) >> 4) & 0xF))

#define HDA_EAPD_BTL_ENABLE_EAPD 0x00000002

enum
{
kHdaPinCapabilitiesImpendance = (1 << 0),
Expand Down
11 changes: 1 addition & 10 deletions PinConfigurator/AudioNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#import "AudioNode.h"
#import "NSString+Pin.h"
#import "NSColor+Pin.h"
#import "HdaVerbs.h"
#import "HdaCodec.h"
#import <AppKit/AppKit.h>

@implementation AudioNode
Expand Down Expand Up @@ -250,14 +248,7 @@ - (NSColor *)jackColor

- (NSString *)directionString
{
NSString *pinDirection = @"--";

if ([self isOut])
pinDirection = @"Out";
else if ([self isIn])
pinDirection = @"In";

return pinDirection;
return [NSString pinDirection:_device];
}

@end
1 change: 1 addition & 0 deletions PinConfigurator/NSString+Pin.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN

@interface NSString (Pin)

+ (NSString *)pinDirection:(uint8_t)value;
+ (NSString *)pinColor:(uint8_t)value;
+ (NSString *)pinMisc:(uint8_t)value;
+ (NSString *)pinDefaultDevice:(uint8_t)value;
Expand Down
38 changes: 27 additions & 11 deletions PinConfigurator/NSString+Pin.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
//

#import "NSString+Pin.h"
#import "AudioNode.h"

@implementation NSString (Pin)

#define GetLocalizedString(key) \
[[NSBundle mainBundle] localizedStringForKey:(key) value:@"" table:nil]

const char *gPinColorArray[] = { "Unknown", "Black", "Gray", "Blue", "Green", "Red", "Orange", "Yellow", "Purple", "Pink", "Reserved1", "Unknown", "Unknown", "Reserved2", "White", "Other" };
const char *gPinMisc[] = { "Jack Detect Override", "Reserved", "Reserved", "Reserved" };
const char *gPinDefaultDeviceArray[] = { "Line Out", "Speaker", "HP Out", "CD", "SPDIF Out", "Digital Other Out", "Modem Line Side", "Modem Handset Side", "Line In", "AUX", "Mic In", "Telephony", "SPDIF In", "Digital Other In", "Reserved", "Other" };
Expand All @@ -22,51 +26,63 @@ @implementation NSString (Pin)
const char *gPinGrossSpecial9[] = { "Special", "ATAPI", "Special", "Special" };
const char *gPinEAPD[] = { "BTL", "EAPD", "L/R Swap" };

+ (NSString *)pinDirection:(uint8_t)value;
{
NSString *pinDirection = @"--";

if (value <= kHdaConfigDefaultDeviceModemHandset)
pinDirection = GetLocalizedString(@"Out");
else if (value > kHdaConfigDefaultDeviceModemHandset && value <= kHdaConfigDefaultDeviceOtherDigitalIn)
pinDirection = GetLocalizedString(@"In");

return pinDirection;
}

+ (NSString *)pinColor:(uint8_t)value
{
return [NSString stringWithUTF8String:gPinColorArray[value & 0xF]];
return GetLocalizedString([NSString stringWithUTF8String:gPinColorArray[value & 0xF]]);
}

+ (NSString *)pinMisc:(uint8_t)value
{
return [NSString stringWithUTF8String:gPinMisc[value & 0x3]];
return GetLocalizedString([NSString stringWithUTF8String:gPinMisc[value & 0x3]]);
}

+ (NSString *)pinDefaultDevice:(uint8_t)value
{
return [NSString stringWithUTF8String:gPinDefaultDeviceArray[value & 0xF]];
return GetLocalizedString([NSString stringWithUTF8String:gPinDefaultDeviceArray[value & 0xF]]);
}

+ (NSString *)pinConnector:(uint8_t)value
{
return [NSString stringWithUTF8String:gPinConnector[value & 0xF]];
return GetLocalizedString([NSString stringWithUTF8String:gPinConnector[value & 0xF]]);
}

+ (NSString *)pinPort:(uint8_t)value
{
return [NSString stringWithUTF8String:gPinPort[value & 0x3]];
return GetLocalizedString([NSString stringWithUTF8String:gPinPort[value & 0x3]]);
}

+ (NSString *)pinGrossLocation:(uint8_t)value;
{
return [NSString stringWithUTF8String:gPinGrossLocation[value]];
return GetLocalizedString([NSString stringWithUTF8String:gPinGrossLocation[value]]);
}

+ (NSString *)pinLocation:(uint8_t)grossLocation geometricLocation:(uint8_t)geometricLocation;
{
if (geometricLocation == 0x7)
return [NSString stringWithUTF8String:gPinGrossSpecial7[grossLocation]];
return GetLocalizedString([NSString stringWithUTF8String:gPinGrossSpecial7[grossLocation]]);
else if (geometricLocation == 0x8)
return [NSString stringWithUTF8String:gPinGrossSpecial8[grossLocation]];
return GetLocalizedString([NSString stringWithUTF8String:gPinGrossSpecial8[grossLocation]]);
else if (geometricLocation == 0x9)
return [NSString stringWithUTF8String:gPinGrossSpecial9[grossLocation]];
return GetLocalizedString([NSString stringWithUTF8String:gPinGrossSpecial9[grossLocation]]);

return [NSString stringWithUTF8String:gPinGeometricLocation[geometricLocation]];
return GetLocalizedString([NSString stringWithUTF8String:gPinGeometricLocation[geometricLocation]]);
}

+ (NSString *)pinEAPD:(uint8_t)value;
{
return [NSString stringWithUTF8String:gPinEAPD[value & 0x7]];
return GetLocalizedString([NSString stringWithUTF8String:gPinEAPD[value & 0x7]]);
}

+ (NSString *)pinConfigDescription:(uint8_t *)value
Expand Down

0 comments on commit c7c662b

Please sign in to comment.