mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-19 23:29:05 +00:00
Exposes persistent LED flag to Swift.
This commit is contained in:
parent
52ea3b741c
commit
ea63415d0e
@ -674,8 +674,8 @@ class MachineDocument:
|
|||||||
|
|
||||||
// Apply labels and create leds entries.
|
// Apply labels and create leds entries.
|
||||||
for c in 0 ..< leds.count {
|
for c in 0 ..< leds.count {
|
||||||
textFields[c].stringValue = leds[c]
|
textFields[c].stringValue = leds[c].name
|
||||||
self.leds[leds[c]] = LED(levelIndicator: activityIndicators[c])
|
self.leds[leds[c].name] = LED(levelIndicator: activityIndicators[c])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a fader.
|
// Create a fader.
|
||||||
|
@ -33,6 +33,11 @@ typedef NS_ENUM(NSInteger, CSMachineKeyboardInputMode) {
|
|||||||
CSMachineKeyboardInputModeJoystick,
|
CSMachineKeyboardInputModeJoystick,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@interface CSMachineLED: NSObject
|
||||||
|
@property(nonatomic, nonnull, readonly) NSString *name;
|
||||||
|
@property(nonatomic, readonly) BOOL isPersisent;
|
||||||
|
@end
|
||||||
|
|
||||||
// Deliberately low; to ensure CSMachine has been declared as an @class already.
|
// Deliberately low; to ensure CSMachine has been declared as an @class already.
|
||||||
#import "CSAtari2600.h"
|
#import "CSAtari2600.h"
|
||||||
#import "CSZX8081.h"
|
#import "CSZX8081.h"
|
||||||
@ -99,7 +104,7 @@ typedef NS_ENUM(NSInteger, CSMachineKeyboardInputMode) {
|
|||||||
@property (nonatomic, nullable) CSJoystickManager *joystickManager;
|
@property (nonatomic, nullable) CSJoystickManager *joystickManager;
|
||||||
|
|
||||||
// LED list.
|
// LED list.
|
||||||
@property (nonatomic, readonly, nonnull) NSArray<NSString *> *leds;
|
@property (nonatomic, readonly, nonnull) NSArray<CSMachineLED *> *leds;
|
||||||
|
|
||||||
// Special-case accessors; undefined behaviour if accessed for a machine not of the corresponding type.
|
// Special-case accessors; undefined behaviour if accessed for a machine not of the corresponding type.
|
||||||
@property (nonatomic, readonly, nullable) CSAtari2600 *atari2600;
|
@property (nonatomic, readonly, nullable) CSAtari2600 *atari2600;
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
@interface CSMachine() <CSScanTargetViewDisplayLinkDelegate>
|
@interface CSMachine() <CSScanTargetViewDisplayLinkDelegate>
|
||||||
- (void)speaker:(Outputs::Speaker::Speaker *)speaker didCompleteSamples:(const int16_t *)samples length:(int)length;
|
- (void)speaker:(Outputs::Speaker::Speaker *)speaker didCompleteSamples:(const int16_t *)samples length:(int)length;
|
||||||
- (void)speakerDidChangeInputClock:(Outputs::Speaker::Speaker *)speaker;
|
- (void)speakerDidChangeInputClock:(Outputs::Speaker::Speaker *)speaker;
|
||||||
- (void)addLED:(NSString *)led;
|
- (void)addLED:(NSString *)led isPersistent:(BOOL)isPersistent;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
struct LockProtectedDelegate {
|
struct LockProtectedDelegate {
|
||||||
@ -61,8 +61,8 @@ struct SpeakerDelegate: public Outputs::Speaker::Speaker::Delegate, public LockP
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct ActivityObserver: public Activity::Observer {
|
struct ActivityObserver: public Activity::Observer {
|
||||||
void register_led(const std::string &name, uint8_t) final {
|
void register_led(const std::string &name, uint8_t flags) final {
|
||||||
[machine addLED:[NSString stringWithUTF8String:name.c_str()]];
|
[machine addLED:[NSString stringWithUTF8String:name.c_str()] isPersistent:flags & Activity::Observer::LEDPresentation::Persistent];
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_led_status(const std::string &name, bool lit) final {
|
void set_led_status(const std::string &name, bool lit) final {
|
||||||
@ -76,6 +76,19 @@ struct ActivityObserver: public Activity::Observer {
|
|||||||
__unsafe_unretained CSMachine *machine;
|
__unsafe_unretained CSMachine *machine;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@implementation CSMachineLED
|
||||||
|
|
||||||
|
- (instancetype)initWithName:(NSString *)name isPersistent:(BOOL)isPersistent {
|
||||||
|
self = [super init];
|
||||||
|
if(self) {
|
||||||
|
_name = name;
|
||||||
|
_isPersisent = isPersistent;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation CSMachine {
|
@implementation CSMachine {
|
||||||
SpeakerDelegate _speakerDelegate;
|
SpeakerDelegate _speakerDelegate;
|
||||||
ActivityObserver _activityObserver;
|
ActivityObserver _activityObserver;
|
||||||
@ -86,7 +99,7 @@ struct ActivityObserver: public Activity::Observer {
|
|||||||
MachineTypes::JoystickMachine *_joystickMachine;
|
MachineTypes::JoystickMachine *_joystickMachine;
|
||||||
|
|
||||||
CSJoystickManager *_joystickManager;
|
CSJoystickManager *_joystickManager;
|
||||||
NSMutableArray<NSString *> *_leds;
|
NSMutableArray<CSMachineLED *> *_leds;
|
||||||
|
|
||||||
CSHighPrecisionTimer *_timer;
|
CSHighPrecisionTimer *_timer;
|
||||||
std::atomic_flag _isUpdating;
|
std::atomic_flag _isUpdating;
|
||||||
@ -623,11 +636,11 @@ struct ActivityObserver: public Activity::Observer {
|
|||||||
|
|
||||||
#pragma mark - Activity observation
|
#pragma mark - Activity observation
|
||||||
|
|
||||||
- (void)addLED:(NSString *)led {
|
- (void)addLED:(NSString *)led isPersistent:(BOOL)isPersistent {
|
||||||
[_leds addObject:led];
|
[_leds addObject:[[CSMachineLED alloc] initWithName:led isPersistent:isPersistent]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray<NSString *> *)leds {
|
- (NSArray<CSMachineLED *> *)leds {
|
||||||
return _leds;
|
return _leds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user