Adding prototype custom keyboard
This commit is contained in:
parent
1df30ba7ac
commit
4f468b765a
|
@ -246,6 +246,7 @@
|
|||
9250DCB51CAEFD3B0093CE9A /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9250DCB41CAEFD3B0093CE9A /* GameController.framework */; };
|
||||
928410581CA8443A00DC5D93 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 928410571CA8443A00DC5D93 /* Images.xcassets */; };
|
||||
92B9EADF24D3369700E6CFB2 /* EmulatorKeyboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92B9EADE24D3369700E6CFB2 /* EmulatorKeyboard.swift */; };
|
||||
92E2063225AADFB000AE3F28 /* PreviewUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92E2063125AADF6E00AE3F28 /* PreviewUI.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXBuildRule section */
|
||||
|
@ -598,6 +599,7 @@
|
|||
928410571CA8443A00DC5D93 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = ActiveGS/Images.xcassets; sourceTree = "<group>"; };
|
||||
92B9EADD24D3369600E6CFB2 /* ActiveGS-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ActiveGS-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
92B9EADE24D3369700E6CFB2 /* EmulatorKeyboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmulatorKeyboard.swift; sourceTree = "<group>"; };
|
||||
92E2063125AADF6E00AE3F28 /* PreviewUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewUI.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
@ -1012,6 +1014,7 @@
|
|||
924A1BB31CBA049D00D69162 /* KeyMapper.h */,
|
||||
924A1BB41CBA049D00D69162 /* KeyMapper.m */,
|
||||
92B9EADE24D3369700E6CFB2 /* EmulatorKeyboard.swift */,
|
||||
92E2063125AADF6E00AE3F28 /* PreviewUI.swift */,
|
||||
92B9EADD24D3369600E6CFB2 /* ActiveGS-Bridging-Header.h */,
|
||||
);
|
||||
name = Common.iphone;
|
||||
|
@ -1365,6 +1368,7 @@
|
|||
09A5CE60125D41860018DC22 /* infoViewController.mm in Sources */,
|
||||
0972554713CF2232006194F9 /* activegsEmulatorController.mm in Sources */,
|
||||
924A1BB51CBA049D00D69162 /* KeyMapper.m in Sources */,
|
||||
92E2063225AADFB000AE3F28 /* PreviewUI.swift in Sources */,
|
||||
0907BCC9142F567A0051CA0A /* asynccommand.mm in Sources */,
|
||||
09052B7D19053C9F00853FAE /* pngread.cpp in Sources */,
|
||||
09C81A781657ACAE008539D5 /* adb.cpp in Sources */,
|
||||
|
|
|
@ -61,6 +61,7 @@ class KeyboardButton: UIButton {
|
|||
@objc protocol EmulatorKeyboardKeyPressedDelegate: class {
|
||||
func keyDown(_ key: KeyCoded)
|
||||
func keyUp(_ key: KeyCoded)
|
||||
func updateTransparency(toAlpha alpha: CGFloat)
|
||||
}
|
||||
|
||||
@objc protocol EmulatorKeyboardModifierPressedDelegate: class {
|
||||
|
@ -129,9 +130,9 @@ class EmulatorKeyboardView: UIView {
|
|||
|
||||
private func commonInit() {
|
||||
backgroundColor = .clear
|
||||
layer.borderColor = UIColor.white.cgColor
|
||||
layer.borderWidth = 1.0
|
||||
layer.cornerRadius = 15.0
|
||||
// layer.borderColor = UIColor.white.cgColor
|
||||
// layer.borderWidth = 1.0
|
||||
// layer.cornerRadius = 15.0
|
||||
layoutMargins = UIEdgeInsets(top: 16, left: 4, bottom: 16, right: 4)
|
||||
insetsLayoutMarginsFromSafeArea = false
|
||||
addSubview(keyRowsStackView)
|
||||
|
@ -230,7 +231,7 @@ class EmulatorKeyboardView: UIView {
|
|||
}
|
||||
key.translatesAutoresizingMaskIntoConstraints = false
|
||||
key.widthAnchor.constraint(equalToConstant: (25 * CGFloat(keyCoded.keySize.rawValue))).isActive = true
|
||||
key.heightAnchor.constraint(equalToConstant: 25).isActive = true
|
||||
key.heightAnchor.constraint(equalToConstant: 35).isActive = true
|
||||
key.layer.borderWidth = 1.0
|
||||
key.layer.borderColor = UIColor.white.cgColor
|
||||
key.layer.cornerRadius = 6.0
|
||||
|
@ -250,6 +251,9 @@ class EmulatorKeyboardView: UIView {
|
|||
spacer.widthAnchor.constraint(equalToConstant: 25.0 * CGFloat(keyCoded.keySize.rawValue)).isActive = true
|
||||
spacer.heightAnchor.constraint(equalToConstant: 25.0).isActive = true
|
||||
return spacer
|
||||
} else if let sliderKey = keyCoded as? SliderKey {
|
||||
sliderKey.keyboardViewModel = self.viewModel
|
||||
return sliderKey.createView()
|
||||
}
|
||||
return createKey(keyCoded)
|
||||
}
|
||||
|
@ -312,6 +316,30 @@ class SpacerKey: KeyCoded {
|
|||
}
|
||||
}
|
||||
|
||||
class SliderKey: KeyCoded {
|
||||
let keyLabel = ""
|
||||
let keyCode = 0
|
||||
let keySize: KeySize
|
||||
let isModifier = false
|
||||
let keyImageName: String? = nil
|
||||
let keyImageNameHighlighted: String? = nil
|
||||
weak var keyboardViewModel: EmulatorKeyboardViewModel?
|
||||
init(keySize: KeySize = .standard) {
|
||||
self.keySize = keySize
|
||||
}
|
||||
func createView() -> UIView {
|
||||
let slider = UISlider(frame: .zero)
|
||||
slider.minimumValue = 0.1
|
||||
slider.maximumValue = 1.0
|
||||
slider.addTarget(self, action: #selector(adjustKeyboardAlpha(_:)), for: .valueChanged)
|
||||
slider.value = 1.0
|
||||
return slider
|
||||
}
|
||||
@objc func adjustKeyboardAlpha(_ sender: UISlider) {
|
||||
keyboardViewModel?.delegate?.updateTransparency(toAlpha: CGFloat(sender.value))
|
||||
}
|
||||
}
|
||||
|
||||
struct KeyPosition {
|
||||
let row: Int
|
||||
let column: Int
|
||||
|
@ -422,18 +450,18 @@ struct KeyPosition {
|
|||
],
|
||||
[
|
||||
AppleIIKey(label: "SHIFT", code: AppleKeyboardKey.KEY_SHIFT.rawValue,
|
||||
keySize: .wide, isModifier: true, imageName: "shift", imageNameHighlighted: "shift.fill"),
|
||||
AppleIIKey(label: "123", code: AppleKeyboardKey.KEY_SPECIAL_TOGGLE.rawValue, keySize: .wide, imageName: "textformat.123"),
|
||||
keySize: .standard, isModifier: true, imageName: "shift", imageNameHighlighted: "shift.fill"),
|
||||
AppleIIKey(label: "123", code: AppleKeyboardKey.KEY_SPECIAL_TOGGLE.rawValue, keySize: .standard, imageName: "textformat.123"),
|
||||
AppleIIKey(label: "", code: AppleKeyboardKey.KEY_APPLE.rawValue,
|
||||
keySize: .standard, isModifier: true)
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "SPACE", code: AppleKeyboardKey.KEY_SPACE.rawValue)
|
||||
keySize: .standard, isModifier: true),
|
||||
AppleIIKey(label: "SPACE", code: AppleKeyboardKey.KEY_SPACE.rawValue, keySize: .wide)
|
||||
]
|
||||
],
|
||||
alternateKeys:
|
||||
[
|
||||
[],
|
||||
[
|
||||
SliderKey(keySize: .standard)
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "1", code: AppleKeyboardKey.KEY_1.rawValue),
|
||||
AppleIIKey(label: "2", code: AppleKeyboardKey.KEY_2.rawValue),
|
||||
|
@ -454,13 +482,11 @@ struct KeyPosition {
|
|||
],
|
||||
[
|
||||
AppleIIKey(label: "SHIFT", code: AppleKeyboardKey.KEY_SHIFT.rawValue,
|
||||
keySize: .wide, isModifier: true, imageName: "shift", imageNameHighlighted: "shift.fill"),
|
||||
AppleIIKey(label: "ABC", code: AppleKeyboardKey.KEY_SPECIAL_TOGGLE.rawValue, keySize: .wide, imageName: "textformat.abc"),
|
||||
keySize: .standard, isModifier: true, imageName: "shift", imageNameHighlighted: "shift.fill"),
|
||||
AppleIIKey(label: "ABC", code: AppleKeyboardKey.KEY_SPECIAL_TOGGLE.rawValue, keySize: .standard, imageName: "textformat.abc"),
|
||||
AppleIIKey(label: "OPT", code: AppleKeyboardKey.KEY_OPTION.rawValue,
|
||||
keySize: .standard, isModifier: true)
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "SPACE", code: AppleKeyboardKey.KEY_SPACE.rawValue)
|
||||
keySize: .standard, isModifier: true),
|
||||
AppleIIKey(label: "SPACE", code: AppleKeyboardKey.KEY_SPACE.rawValue, keySize: .wide)
|
||||
]
|
||||
]
|
||||
)
|
||||
|
@ -532,6 +558,183 @@ struct KeyPosition {
|
|||
]
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@objc let leftKeyboardModel2 = EmulatorKeyboardViewModel(
|
||||
keys:
|
||||
[
|
||||
[
|
||||
AppleIIKey(label: "esc", code: AppleKeyboardKey.KEY_ESC.rawValue),
|
||||
AppleIIKey(label: "tab", code: AppleKeyboardKey.KEY_TAB.rawValue),
|
||||
AppleIIKey(label: "CTRL", code: AppleKeyboardKey.KEY_CTRL.rawValue,
|
||||
keySize: .standard, isModifier: true, imageName: "control")
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "q", code: AppleKeyboardKey.KEY_Q.rawValue),
|
||||
AppleIIKey(label: "a", code: AppleKeyboardKey.KEY_A.rawValue),
|
||||
AppleIIKey(label: "z", code: AppleKeyboardKey.KEY_Z.rawValue),
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "w", code: AppleKeyboardKey.KEY_W.rawValue),
|
||||
AppleIIKey(label: "s", code: AppleKeyboardKey.KEY_S.rawValue),
|
||||
AppleIIKey(label: "x", code: AppleKeyboardKey.KEY_X.rawValue),
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "e", code: AppleKeyboardKey.KEY_E.rawValue),
|
||||
AppleIIKey(label: "d", code: AppleKeyboardKey.KEY_D.rawValue),
|
||||
AppleIIKey(label: "c", code: AppleKeyboardKey.KEY_C.rawValue)
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "r", code: AppleKeyboardKey.KEY_R.rawValue),
|
||||
AppleIIKey(label: "f", code: AppleKeyboardKey.KEY_F.rawValue),
|
||||
AppleIIKey(label: "v", code: AppleKeyboardKey.KEY_V.rawValue),
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "t", code: AppleKeyboardKey.KEY_T.rawValue),
|
||||
AppleIIKey(label: "g", code: AppleKeyboardKey.KEY_G.rawValue),
|
||||
AppleIIKey(label: "b", code: AppleKeyboardKey.KEY_B.rawValue)
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "SHIFT", code: AppleKeyboardKey.KEY_SHIFT.rawValue,
|
||||
keySize: .wide, isModifier: true, imageName: "shift", imageNameHighlighted: "shift.fill"),
|
||||
AppleIIKey(label: "123", code: AppleKeyboardKey.KEY_SPECIAL_TOGGLE.rawValue, keySize: .standard, imageName: "textformat.123")
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "SPACE", code: AppleKeyboardKey.KEY_SPACE.rawValue, keySize: .wide),
|
||||
AppleIIKey(label: "", code: AppleKeyboardKey.KEY_APPLE.rawValue,
|
||||
keySize: .standard, isModifier: true)
|
||||
]
|
||||
],
|
||||
alternateKeys:
|
||||
[
|
||||
[
|
||||
AppleIIKey(label: "esc", code: AppleKeyboardKey.KEY_ESC.rawValue),
|
||||
AppleIIKey(label: "tab", code: AppleKeyboardKey.KEY_TAB.rawValue),
|
||||
AppleIIKey(label: "CTRL", code: AppleKeyboardKey.KEY_CTRL.rawValue,
|
||||
keySize: .standard, isModifier: true, imageName: "control")
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "1", code: AppleKeyboardKey.KEY_1.rawValue),
|
||||
AppleIIKey(label: "-", code: AppleKeyboardKey.KEY_MINUS.rawValue),
|
||||
AppleIIKey(label: "]", code: AppleKeyboardKey.KEY_RIGHT_BRACKET.rawValue)
|
||||
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "2", code: AppleKeyboardKey.KEY_2.rawValue),
|
||||
AppleIIKey(label: "=", code: AppleKeyboardKey.KEY_EQUALS.rawValue),
|
||||
AppleIIKey(label: "~", code: AppleKeyboardKey.KEY_TILDE.rawValue)
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "3", code: AppleKeyboardKey.KEY_3.rawValue),
|
||||
AppleIIKey(label: ";", code: AppleKeyboardKey.KEY_SEMICOLON.rawValue),
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "4", code: AppleKeyboardKey.KEY_4.rawValue),
|
||||
AppleIIKey(label: "/", code: AppleKeyboardKey.KEY_FSLASH.rawValue)
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "5", code: AppleKeyboardKey.KEY_5.rawValue),
|
||||
AppleIIKey(label: "[", code: AppleKeyboardKey.KEY_LEFT_BRACKET.rawValue)
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "SHIFT", code: AppleKeyboardKey.KEY_SHIFT.rawValue,
|
||||
keySize: .wide, isModifier: true, imageName: "shift", imageNameHighlighted: "shift.fill"),
|
||||
AppleIIKey(label: "ABC", code: AppleKeyboardKey.KEY_SPECIAL_TOGGLE.rawValue, keySize: .wide, imageName: "textformat.abc"),
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "SPC", code: AppleKeyboardKey.KEY_SPACE.rawValue),
|
||||
AppleIIKey(label: "OPT", code: AppleKeyboardKey.KEY_OPTION.rawValue,
|
||||
keySize: .standard, isModifier: true)
|
||||
]
|
||||
]
|
||||
)
|
||||
|
||||
@objc let rightKeyboardModel2 = EmulatorKeyboardViewModel(
|
||||
keys:
|
||||
[
|
||||
[
|
||||
SpacerKey(),
|
||||
SpacerKey(),
|
||||
AppleIIKey(label: "RESET", code: AppleKeyboardKey.KEY_RESET.rawValue)
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "y", code: AppleKeyboardKey.KEY_Y.rawValue),
|
||||
AppleIIKey(label: "h", code: AppleKeyboardKey.KEY_H.rawValue),
|
||||
AppleIIKey(label: "n", code: AppleKeyboardKey.KEY_N.rawValue),
|
||||
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "u", code: AppleKeyboardKey.KEY_U.rawValue),
|
||||
AppleIIKey(label: "j", code: AppleKeyboardKey.KEY_J.rawValue),
|
||||
AppleIIKey(label: "m", code: AppleKeyboardKey.KEY_M.rawValue),
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "i", code: AppleKeyboardKey.KEY_I.rawValue),
|
||||
AppleIIKey(label: "k", code: AppleKeyboardKey.KEY_K.rawValue),
|
||||
AppleIIKey(label: ",", code: AppleKeyboardKey.KEY_COMMA.rawValue)
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "o", code: AppleKeyboardKey.KEY_O.rawValue),
|
||||
AppleIIKey(label: "l", code: AppleKeyboardKey.KEY_L.rawValue),
|
||||
AppleIIKey(label: ".", code: AppleKeyboardKey.KEY_PERIOD.rawValue),
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "p", code: AppleKeyboardKey.KEY_P.rawValue),
|
||||
AppleIIKey(label: ";", code: AppleKeyboardKey.KEY_SEMICOLON.rawValue),
|
||||
AppleIIKey(label: "/", code: AppleKeyboardKey.KEY_FSLASH.rawValue)
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "]", code: AppleKeyboardKey.KEY_RIGHT_BRACKET.rawValue),
|
||||
AppleIIKey(label: "'", code: AppleKeyboardKey.KEY_SQUOTE.rawValue),
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "RETURN", code: AppleKeyboardKey.KEY_RETURN.rawValue, keySize: .wide),
|
||||
AppleIIKey(label: "DELETE", code: AppleKeyboardKey.KEY_DELETE.rawValue, imageName: "delete.left", imageNameHighlighted: "delete.left.fill")
|
||||
]
|
||||
],
|
||||
alternateKeys:
|
||||
[
|
||||
[
|
||||
AppleIIKey(label: "6", code: AppleKeyboardKey.KEY_6.rawValue),
|
||||
SpacerKey(),
|
||||
SpacerKey()
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "7", code: AppleKeyboardKey.KEY_7.rawValue),
|
||||
SpacerKey(),
|
||||
SpacerKey()
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "8", code: AppleKeyboardKey.KEY_8.rawValue),
|
||||
SpacerKey(),
|
||||
SpacerKey()
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "9", code: AppleKeyboardKey.KEY_9.rawValue),
|
||||
SpacerKey(),
|
||||
SpacerKey()
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "0", code: AppleKeyboardKey.KEY_0.rawValue),
|
||||
AppleIIKey(label: "⬆", code: AppleKeyboardKey.KEY_UP_CURSOR.rawValue),
|
||||
SpacerKey()
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "⬅", code: AppleKeyboardKey.KEY_LEFT_CURSOR.rawValue),
|
||||
AppleIIKey(label: "⬇", code: AppleKeyboardKey.KEY_DOWN_CURSOR.rawValue),
|
||||
AppleIIKey(label: "➡", code: AppleKeyboardKey.KEY_RIGHT_CURSOR.rawValue)
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "SHIFT", code: AppleKeyboardKey.KEY_SHIFT.rawValue,
|
||||
keySize: .standard, isModifier: true, imageName: "shift", imageNameHighlighted: "shift.fill"),
|
||||
AppleIIKey(label: "DELETE", code: AppleKeyboardKey.KEY_DELETE.rawValue, imageName: "delete.left", imageNameHighlighted: "delete.left.fill")
|
||||
],
|
||||
[
|
||||
AppleIIKey(label: "RETURN", code: AppleKeyboardKey.KEY_RETURN.rawValue, keySize: .standard)
|
||||
]
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
init() {
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
|
@ -543,8 +746,8 @@ struct KeyPosition {
|
|||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
// setupView()
|
||||
setupViewFrames()
|
||||
setupView()
|
||||
// setupViewFrames()
|
||||
// setupKeyModels()
|
||||
|
||||
let panGesture = UIPanGestureRecognizer(target: self, action: #selector(draggedView(_:)))
|
||||
|
@ -560,20 +763,20 @@ struct KeyPosition {
|
|||
keyboardConstraints.removeAll()
|
||||
leftKeyboardView.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(leftKeyboardView)
|
||||
leftKeyboardView.heightAnchor.constraint(equalToConstant: 200).isActive = true
|
||||
leftKeyboardView.widthAnchor.constraint(equalToConstant: 180).isActive = true
|
||||
leftKeyboardView.heightAnchor.constraint(equalToConstant: 250).isActive = true
|
||||
leftKeyboardView.widthAnchor.constraint(equalToConstant: 175).isActive = true
|
||||
keyboardConstraints.append(contentsOf: [
|
||||
leftKeyboardView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
|
||||
leftKeyboardView.centerYAnchor.constraint(equalTo: view.centerYAnchor)
|
||||
leftKeyboardView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
|
||||
])
|
||||
rightKeyboardView.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(rightKeyboardView)
|
||||
keyboardConstraints.append(contentsOf: [
|
||||
rightKeyboardView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor),
|
||||
rightKeyboardView.centerYAnchor.constraint(equalTo: view.centerYAnchor),
|
||||
rightKeyboardView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)
|
||||
])
|
||||
rightKeyboardView.heightAnchor.constraint(equalToConstant: 200).isActive = true
|
||||
rightKeyboardView.widthAnchor.constraint(equalToConstant: 180).isActive = true
|
||||
rightKeyboardView.heightAnchor.constraint(equalToConstant: 250).isActive = true
|
||||
rightKeyboardView.widthAnchor.constraint(equalToConstant: 175).isActive = true
|
||||
NSLayoutConstraint.activate(keyboardConstraints)
|
||||
}
|
||||
|
||||
|
@ -582,10 +785,10 @@ struct KeyPosition {
|
|||
// since we don't know the frame of this view yet until layout time,
|
||||
// assume it's taking the full screen
|
||||
let screenFrame = UIScreen.main.bounds
|
||||
let keyboardHeight: CGFloat = 240.0
|
||||
let keyboardWidth: CGFloat = 173.0
|
||||
let keyboardHeight: CGFloat = 250.0
|
||||
let keyboardWidth: CGFloat = 180.0
|
||||
let bottomLeftFrame = CGRect(
|
||||
x: 20,
|
||||
x: 0,
|
||||
y: screenFrame.size.height - 40 - keyboardHeight - 20,
|
||||
width: keyboardWidth, height: keyboardHeight)
|
||||
let bottomRightFrame = CGRect(
|
||||
|
@ -601,23 +804,23 @@ struct KeyPosition {
|
|||
|
||||
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
||||
// get relative positions of frames to size
|
||||
for v in [leftKeyboardView, rightKeyboardView] {
|
||||
let xPercent = v.frame.origin.x / view.frame.size.width
|
||||
let yPercent = v.frame.origin.y / view.frame.size.height
|
||||
var newX = size.width * xPercent
|
||||
var newY = size.height * yPercent
|
||||
// mmm need to check if the views fit within the frame and adjust
|
||||
if newX + v.bounds.size.width > size.width {
|
||||
newX = size.width - v.bounds.size.width
|
||||
} else if newX < 0 {
|
||||
newX = 0
|
||||
}
|
||||
if newY + v.bounds.size.height > size.height {
|
||||
newY = size.height - v.bounds.size.height
|
||||
}
|
||||
let newFrame = CGRect(x: newX, y: newY, width: v.bounds.size.width, height: v.bounds.size.height)
|
||||
v.frame = newFrame
|
||||
}
|
||||
// for v in [leftKeyboardView, rightKeyboardView] {
|
||||
// let xPercent = v.frame.origin.x / view.frame.size.width
|
||||
// let yPercent = v.frame.origin.y / view.frame.size.height
|
||||
// var newX = size.width * xPercent
|
||||
// var newY = size.height * yPercent
|
||||
// // mmm need to check if the views fit within the frame and adjust
|
||||
// if newX + v.bounds.size.width > size.width {
|
||||
// newX = size.width - v.bounds.size.width
|
||||
// } else if newX < 0 {
|
||||
// newX = 0
|
||||
// }
|
||||
// if newY + v.bounds.size.height > size.height {
|
||||
// newY = size.height - v.bounds.size.height
|
||||
// }
|
||||
// let newFrame = CGRect(x: newX, y: newY, width: v.bounds.size.width, height: v.bounds.size.height)
|
||||
// v.frame = newFrame
|
||||
// }
|
||||
}
|
||||
|
||||
func setupKeyModels() {
|
||||
|
@ -648,4 +851,9 @@ extension EmulatorKeyboardController: EmulatorKeyboardViewDelegate {
|
|||
keyboard.refreshModifierStates()
|
||||
}
|
||||
}
|
||||
func updateTransparency(toAlpha alpha: Float) {
|
||||
for keyboard in [leftKeyboardView, rightKeyboardView] {
|
||||
keyboard.alpha = CGFloat(alpha)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
//
|
||||
// PreviewUI.swift
|
||||
// activegs
|
||||
//
|
||||
// Created by Yoshi Sugawara on 1/9/21.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct ContentView: View {
|
||||
var body: some View {
|
||||
//Text("Hello, World!")
|
||||
IntegratedController()
|
||||
}
|
||||
}
|
||||
|
||||
struct ContentView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
Group {
|
||||
ContentView().previewLayout(.fixed(width: 568, height: 320))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct IntegratedController: UIViewControllerRepresentable {
|
||||
|
||||
func makeUIViewController(context: UIViewControllerRepresentableContext<IntegratedController>) -> EmulatorKeyboardController {
|
||||
let controller = EmulatorKeyboardController()
|
||||
controller.view.backgroundColor = .black
|
||||
return controller
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: EmulatorKeyboardController, context: UIViewControllerRepresentableContext<IntegratedController>) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -731,6 +731,10 @@ int x_lock_zoom = 0;
|
|||
add_event_key((int)key.keyCode, 1);
|
||||
}
|
||||
|
||||
-(void)updateTransparencyToAlpha:(CGFloat)alpha {
|
||||
self.emuKeyboardController.view.alpha = alpha;
|
||||
}
|
||||
|
||||
#pragma mark - EmulatorKeyboardModifierPressedDelegate
|
||||
-(void)modifierPressedWithKey:(id<KeyCoded>)key enable:(BOOL)enable {
|
||||
int modifierKey;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
ActiveGS, Copyright 2004-2016 Olivier Goguel, https://github.com/ogoguel/ActiveGS
|
||||
Based on Kegs, Copyright 2004 Kent Dickey, https://kegs.sourceforge.net
|
||||
This code is covered by the GNU GPL licence
|
||||
*/
|
||||
|
||||
/*
|
||||
ActiveGS, Copyright 2004-2016 Olivier Goguel, https://github.com/ogoguel/ActiveGS
|
||||
Based on Kegs, Copyright 2004 Kent Dickey, https://kegs.sourceforge.net
|
||||
This code is covered by the GNU GPL licence
|
||||
*/
|
||||
|
||||
#include "adb.h"
|
||||
#include "moremem.h"
|
||||
#include "paddles.h"
|
||||
|
@ -1270,16 +1270,17 @@ update_mouse(int x, int y, int button_states, int buttons_valid)
|
|||
|
||||
mouse_compress_fifo(dcycs);
|
||||
|
||||
#if 0
|
||||
//#if 0
|
||||
printf("Update Mouse called with buttons:%d (state:%d) x,y:%d,%d, fifo:%d,%d, "
|
||||
" a2: %d,%d\n", buttons_valid,button_states, x, y,
|
||||
g_adb.g_mouse_fifo[0].x, g_mouse_fifo[0].y,
|
||||
g_adb.g_mouse_fifo[0].x, g_adb.g_mouse_fifo[0].y,
|
||||
g_adb.g_mouse_a2_x, g_adb.g_mouse_a2_y);
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
if((buttons_valid == -1) &&(g_adb.g_warp_pointer==WARP_POINTER)) {
|
||||
/* Warping the pointer causes it to jump here...this is not */
|
||||
/* real motion, just update info and get out */
|
||||
printf("yoshi debug doing warp pointer logic!\n");
|
||||
g_adb.g_mouse_a2_x += (x - g_adb.g_mouse_fifo[0].x);
|
||||
g_adb.g_mouse_a2_y += (y - g_adb.g_mouse_fifo[0].y);
|
||||
g_adb.g_mouse_fifo[0].x = x;
|
||||
|
@ -1287,11 +1288,11 @@ update_mouse(int x, int y, int button_states, int buttons_valid)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
//#if 0
|
||||
printf("...real move, warp: %d, %d, new x: %d, %d, a2:%d,%d\n",
|
||||
g_adb.g_mouse_warp_x, g_adb.g_mouse_warp_y, g_adb.g_mouse_fifo[0].x,
|
||||
g_adb.g_mouse_fifo[0].y, g_adb.g_mouse_a2_x, g_adb.g_mouse_a2_y);
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
mouse_moved = (g_adb.g_mouse_fifo[0].x != x) || (g_adb.g_mouse_fifo[0].y != y);
|
||||
|
||||
|
|
|
@ -627,7 +627,7 @@ float refScaleLandscape;
|
|||
self.useTouch = touch;
|
||||
|
||||
lastMousePos = [self rotateTouch:touch];
|
||||
|
||||
NSLog(@"last mouse pos = %f , %f",lastMousePos.x, lastMousePos.y);
|
||||
add_event_mouse(lastMousePos.x,lastMousePos.y,0,-1);
|
||||
|
||||
if (self.secondTouch)
|
||||
|
@ -802,6 +802,7 @@ float refScaleLandscape;
|
|||
{
|
||||
|
||||
lastMousePos = [self rotateTouch:self.useTouch];
|
||||
NSLog(@"touchesmoved: last mouse pos = %f , %f",lastMousePos.x, lastMousePos.y);
|
||||
add_event_mouse(lastMousePos.x,lastMousePos.y,mouseDown,1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue