mirror of
https://github.com/TomHarte/CLK.git
synced 2025-04-09 00:37:27 +00:00
By removing its status as a special case, eliminated the Atari 2600 document. It's fairly clear that my date with doing joysticks properly can be deferred only so much longer but this is no worse than previously things were.
This commit is contained in:
parent
bf468db73d
commit
cfdd5fb686
@ -37,7 +37,6 @@
|
||||
4B4DC8211D2C2425003C5BF8 /* Vic20.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B4DC81F1D2C2425003C5BF8 /* Vic20.cpp */; };
|
||||
4B4DC8281D2C2470003C5BF8 /* C1540.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B4DC8261D2C2470003C5BF8 /* C1540.cpp */; };
|
||||
4B4DC82B1D2C27A4003C5BF8 /* SerialBus.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B4DC8291D2C27A4003C5BF8 /* SerialBus.cpp */; };
|
||||
4B55CE581C3B7D360093A61B /* Atari2600Document.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B55CE561C3B7D360093A61B /* Atari2600Document.swift */; };
|
||||
4B55CE5D1C3B7D6F0093A61B /* CSOpenGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B55CE5C1C3B7D6F0093A61B /* CSOpenGLView.m */; };
|
||||
4B55CE5F1C3B7D960093A61B /* MachineDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B55CE5E1C3B7D960093A61B /* MachineDocument.swift */; };
|
||||
4B643F3A1D77AD1900D431D6 /* CSStaticAnalyser.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B643F391D77AD1900D431D6 /* CSStaticAnalyser.mm */; };
|
||||
@ -453,7 +452,6 @@
|
||||
4B4DC8271D2C2470003C5BF8 /* C1540.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = C1540.hpp; sourceTree = "<group>"; };
|
||||
4B4DC8291D2C27A4003C5BF8 /* SerialBus.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SerialBus.cpp; sourceTree = "<group>"; };
|
||||
4B4DC82A1D2C27A4003C5BF8 /* SerialBus.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SerialBus.hpp; sourceTree = "<group>"; };
|
||||
4B55CE561C3B7D360093A61B /* Atari2600Document.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Atari2600Document.swift; sourceTree = "<group>"; };
|
||||
4B55CE5B1C3B7D6F0093A61B /* CSOpenGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSOpenGLView.h; sourceTree = "<group>"; };
|
||||
4B55CE5C1C3B7D6F0093A61B /* CSOpenGLView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSOpenGLView.m; sourceTree = "<group>"; };
|
||||
4B55CE5E1C3B7D960093A61B /* MachineDocument.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MachineDocument.swift; sourceTree = "<group>"; };
|
||||
@ -481,6 +479,7 @@
|
||||
4B96F7201D75119A0058BB2D /* Tape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Tape.cpp; path = ../../StaticAnalyser/Acorn/Tape.cpp; sourceTree = "<group>"; };
|
||||
4B96F7211D75119A0058BB2D /* Tape.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Tape.hpp; path = ../../StaticAnalyser/Acorn/Tape.hpp; sourceTree = "<group>"; };
|
||||
4B9CCDA01DA279CA0098B625 /* Vic20OptionsPanel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Vic20OptionsPanel.swift; sourceTree = "<group>"; };
|
||||
4B9CCDA21DA27C3F0098B625 /* CSJoystickMachine.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSJoystickMachine.h; sourceTree = "<group>"; };
|
||||
4BA22B051D8817CE0008C640 /* Disk.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Disk.cpp; path = ../../StaticAnalyser/Commodore/Disk.cpp; sourceTree = "<group>"; };
|
||||
4BA22B061D8817CE0008C640 /* Disk.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Disk.hpp; path = ../../StaticAnalyser/Commodore/Disk.hpp; sourceTree = "<group>"; };
|
||||
4BA61EAE1D91515900B3C876 /* NSData+StdVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+StdVector.h"; sourceTree = "<group>"; };
|
||||
@ -938,18 +937,19 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4BBC34241D2208B100FFC9DF /* CSFastLoading.h */,
|
||||
4B9CCDA21DA27C3F0098B625 /* CSJoystickMachine.h */,
|
||||
4B2A53931D117D36003C6002 /* CSKeyboardMachine.h */,
|
||||
4B2A53951D117D36003C6002 /* CSMachine.h */,
|
||||
4B2A53941D117D36003C6002 /* CSMachine+Subclassing.h */,
|
||||
4B643F3C1D77AE5C00D431D6 /* CSMachine+Target.h */,
|
||||
4B2A53971D117D36003C6002 /* KeyCodes.h */,
|
||||
4B8FE2251DA1DE2D0090D3CE /* NSBundle+DataResource.h */,
|
||||
4BA61EAE1D91515900B3C876 /* NSData+StdVector.h */,
|
||||
4B8FE2261DA1DE2D0090D3CE /* NSBundle+DataResource.m */,
|
||||
4B2A53961D117D36003C6002 /* CSMachine.mm */,
|
||||
4BA61EAF1D91515900B3C876 /* NSData+StdVector.mm */,
|
||||
4B643F3B1D77AD6D00D431D6 /* StaticAnalyser */,
|
||||
4B2A53981D117D36003C6002 /* Wrappers */,
|
||||
4BA61EAE1D91515900B3C876 /* NSData+StdVector.h */,
|
||||
4BA61EAF1D91515900B3C876 /* NSData+StdVector.mm */,
|
||||
4B8FE2251DA1DE2D0090D3CE /* NSBundle+DataResource.h */,
|
||||
4B8FE2261DA1DE2D0090D3CE /* NSBundle+DataResource.m */,
|
||||
);
|
||||
path = Machine;
|
||||
sourceTree = "<group>";
|
||||
@ -1048,7 +1048,6 @@
|
||||
4B55CE551C3B7D360093A61B /* Documents */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4B55CE561C3B7D360093A61B /* Atari2600Document.swift */,
|
||||
4B8FE21F1DA19D7C0090D3CE /* Atari2600OptionsPanel.swift */,
|
||||
4B8FE2281DA1EDDF0090D3CE /* ElectronOptionsPanel.swift */,
|
||||
4B55CE5E1C3B7D960093A61B /* MachineDocument.swift */,
|
||||
@ -2151,7 +2150,6 @@
|
||||
4B4DC82B1D2C27A4003C5BF8 /* SerialBus.cpp in Sources */,
|
||||
4BC3B74F1CD194CC00F86E85 /* Shader.cpp in Sources */,
|
||||
4B8FE2221DA19FB20090D3CE /* MachinePanel.swift in Sources */,
|
||||
4B55CE581C3B7D360093A61B /* Atari2600Document.swift in Sources */,
|
||||
4BBB14311CD2CECE00BDB55C /* IntermediateShader.cpp in Sources */,
|
||||
4BD5F1951D13528900631CD1 /* CSBestEffortUpdater.m in Sources */,
|
||||
4B96F7221D75119A0058BB2D /* Tape.cpp in Sources */,
|
||||
|
@ -9,18 +9,4 @@
|
||||
import Cocoa
|
||||
|
||||
class DocumentController: NSDocumentController {
|
||||
/* override func makeDocument(withContentsOf url: URL, ofType typeName: String) throws -> NSDocument {
|
||||
if let analyser = CSStaticAnalyser(fileAt: url) {
|
||||
if let documentClass = analyser.documentClass as? NSDocument.Type {
|
||||
let document = documentClass.init()
|
||||
if let machineDocument = document as? MachineDocument {
|
||||
machineDocument.displayName = analyser.displayName
|
||||
machineDocument.configureAs(analyser)
|
||||
return machineDocument
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return try super.makeDocument(withContentsOf: url, ofType: typeName)
|
||||
}*/
|
||||
}
|
||||
|
@ -1,50 +0,0 @@
|
||||
//
|
||||
// Atari2600Document.swift
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 16/07/2015.
|
||||
// Copyright © 2015 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class Atari2600Document: MachineDocument {
|
||||
|
||||
// MARK: CSOpenGLViewResponderDelegate
|
||||
/* fileprivate func inputForKey(_ event: NSEvent) -> Atari2600DigitalInput? {
|
||||
switch event.keyCode {
|
||||
case 123: return Atari2600DigitalInputJoy1Left
|
||||
case 126: return Atari2600DigitalInputJoy1Up
|
||||
case 124: return Atari2600DigitalInputJoy1Right
|
||||
case 125: return Atari2600DigitalInputJoy1Down
|
||||
case 0: return Atari2600DigitalInputJoy1Fire
|
||||
default:
|
||||
Swift.print("\(event.keyCode)")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
override func keyDown(_ event: NSEvent) {
|
||||
super.keyDown(event)
|
||||
|
||||
if let input = inputForKey(event) {
|
||||
atari2600.setState(true, for: input)
|
||||
}
|
||||
|
||||
if event.keyCode == 36 {
|
||||
atari2600.setResetLineEnabled(true)
|
||||
}
|
||||
}
|
||||
|
||||
override func keyUp(_ event: NSEvent) {
|
||||
super.keyUp(event)
|
||||
|
||||
if let input = inputForKey(event) {
|
||||
atari2600.setState(false, for: input)
|
||||
}
|
||||
|
||||
if event.keyCode == 36 {
|
||||
atari2600.setResetLineEnabled(false)
|
||||
}
|
||||
}*/
|
||||
}
|
@ -163,23 +163,41 @@ class MachineDocument:
|
||||
throw NSError(domain: NSOSStatusErrorDomain, code: unimpErr, userInfo: nil)
|
||||
}
|
||||
|
||||
// MARK: Key forwarding
|
||||
// MARK: Input management
|
||||
fileprivate func withKeyboardMachine(_ action: (CSKeyboardMachine) -> ()) {
|
||||
if let keyboardMachine = self.machine as? CSKeyboardMachine {
|
||||
action(keyboardMachine)
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func withJoystickMachine(_ action: (CSJoystickMachine) -> ()) {
|
||||
if let joystickMachine = self.machine as? CSJoystickMachine {
|
||||
action(joystickMachine)
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func sendJoystickEvent(_ machine: CSJoystickMachine, keyCode: UInt16, isPressed: Bool) {
|
||||
switch keyCode {
|
||||
case 123: machine.setDirection(.left, onPad: 0, isPressed: isPressed)
|
||||
case 126: machine.setDirection(.up, onPad: 0, isPressed: isPressed)
|
||||
case 124: machine.setDirection(.right, onPad: 0, isPressed: isPressed)
|
||||
case 125: machine.setDirection(.down, onPad: 0, isPressed: isPressed)
|
||||
default: machine.setButtonAt(0, onPad: 0, isPressed: isPressed)
|
||||
}
|
||||
}
|
||||
|
||||
func windowDidResignKey(_ notification: Notification) {
|
||||
self.withKeyboardMachine { $0.clearAllKeys() }
|
||||
}
|
||||
|
||||
func keyDown(_ event: NSEvent) {
|
||||
self.withKeyboardMachine { $0.setKey(event.keyCode, isPressed: true) }
|
||||
self.withJoystickMachine { sendJoystickEvent($0, keyCode: event.keyCode, isPressed: false) }
|
||||
}
|
||||
|
||||
func keyUp(_ event: NSEvent) {
|
||||
self.withKeyboardMachine { $0.setKey(event.keyCode, isPressed: false) }
|
||||
self.withJoystickMachine { sendJoystickEvent($0, keyCode: event.keyCode, isPressed: true) }
|
||||
}
|
||||
|
||||
func flagsChanged(_ newModifiers: NSEvent) {
|
||||
|
22
OSBindings/Mac/Clock Signal/Machine/CSJoystickMachine.h
Normal file
22
OSBindings/Mac/Clock Signal/Machine/CSJoystickMachine.h
Normal file
@ -0,0 +1,22 @@
|
||||
//
|
||||
// CSJoystickMachine.h
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 03/10/2016.
|
||||
// Copyright © 2016 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
typedef NS_ENUM(NSInteger, CSJoystickDirection)
|
||||
{
|
||||
CSJoystickDirectionUp,
|
||||
CSJoystickDirectionDown,
|
||||
CSJoystickDirectionLeft,
|
||||
CSJoystickDirectionRight
|
||||
};
|
||||
|
||||
@protocol CSJoystickMachine <NSObject>
|
||||
|
||||
- (void)setButtonAtIndex:(NSUInteger)button onPad:(NSUInteger)pad isPressed:(BOOL)isPressed;
|
||||
- (void)setDirection:(CSJoystickDirection)direction onPad:(NSUInteger)pad isPressed:(BOOL)isPressed;
|
||||
|
||||
@end
|
@ -8,10 +8,10 @@
|
||||
|
||||
#include "CSMachine.h"
|
||||
#include "Atari2600Inputs.h"
|
||||
#import "CSJoystickMachine.h"
|
||||
|
||||
@interface CSAtari2600 : CSMachine
|
||||
@interface CSAtari2600 : CSMachine <CSJoystickMachine>
|
||||
|
||||
- (void)setState:(BOOL)state forDigitalInput:(Atari2600DigitalInput)digitalInput;
|
||||
- (void)setResetLineEnabled:(BOOL)enabled;
|
||||
|
||||
@property (nonatomic, assign) BOOL colourButton;
|
||||
|
@ -49,9 +49,23 @@ struct CRTDelegate: public Outputs::CRT::Delegate {
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setState:(BOOL)state forDigitalInput:(Atari2600DigitalInput)digitalInput {
|
||||
- (void)setDirection:(CSJoystickDirection)direction onPad:(NSUInteger)pad isPressed:(BOOL)isPressed {
|
||||
Atari2600DigitalInput input;
|
||||
switch(direction)
|
||||
{
|
||||
case CSJoystickDirectionUp: input = pad ? Atari2600DigitalInputJoy2Up : Atari2600DigitalInputJoy1Up; break;
|
||||
case CSJoystickDirectionDown: input = pad ? Atari2600DigitalInputJoy2Down : Atari2600DigitalInputJoy1Down; break;
|
||||
case CSJoystickDirectionLeft: input = pad ? Atari2600DigitalInputJoy2Left : Atari2600DigitalInputJoy1Left; break;
|
||||
case CSJoystickDirectionRight: input = pad ? Atari2600DigitalInputJoy2Right : Atari2600DigitalInputJoy1Right; break;
|
||||
}
|
||||
@synchronized(self) {
|
||||
_atari2600.set_digital_input(digitalInput, state ? true : false);
|
||||
_atari2600.set_digital_input(input, isPressed ? true : false);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setButtonAtIndex:(NSUInteger)button onPad:(NSUInteger)pad isPressed:(BOOL)isPressed {
|
||||
@synchronized(self) {
|
||||
_atari2600.set_digital_input(pad ? Atari2600DigitalInputJoy2Fire : Atari2600DigitalInputJoy1Fire, isPressed ? true : false);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user