Adds a joystick calibration routine to preferences window

- TODO : use common code paths for key handling
This commit is contained in:
Aaron Culliney 2014-12-01 22:42:38 -08:00
parent 5c6c66f243
commit e61ff8e660
7 changed files with 274 additions and 70 deletions

View File

@ -182,6 +182,7 @@
77E1C0C619D7298F004344E0 /* EmulatorFullscreenWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 77E1C0C219D7298F004344E0 /* EmulatorFullscreenWindow.m */; };
77EB316C1A27A9AF00DC5A8A /* blank.dsk.gz in Resources */ = {isa = PBXBuildFile; fileRef = 4ADC523019E8D3F600186B36 /* blank.dsk.gz */; };
77EB316D1A27A9AF00DC5A8A /* blank.nib.gz in Resources */ = {isa = PBXBuildFile; fileRef = 4ADC523119E8D3F600186B36 /* blank.nib.gz */; };
77F80B441A2D95E300D45030 /* EmulatorJoystickCalibrationView.m in Sources */ = {isa = PBXBuildFile; fileRef = 77F80B421A2D95E300D45030 /* EmulatorJoystickCalibrationView.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -345,6 +346,8 @@
77E1C0C219D7298F004344E0 /* EmulatorFullscreenWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = EmulatorFullscreenWindow.m; path = Classes/OSX/EmulatorFullscreenWindow.m; sourceTree = "<group>"; };
77E1C0C319D7298F004344E0 /* EmulatorFullscreenWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EmulatorFullscreenWindow.h; path = Classes/OSX/EmulatorFullscreenWindow.h; sourceTree = "<group>"; };
77E1C0C719D736EB004344E0 /* glvideo.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = glvideo.c; sourceTree = "<group>"; };
77F80B421A2D95E300D45030 /* EmulatorJoystickCalibrationView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = EmulatorJoystickCalibrationView.m; path = Classes/OSX/EmulatorJoystickCalibrationView.m; sourceTree = "<group>"; };
77F80B431A2D95E300D45030 /* EmulatorJoystickCalibrationView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EmulatorJoystickCalibrationView.h; path = Classes/OSX/EmulatorJoystickCalibrationView.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -506,6 +509,8 @@
77E1C0C319D7298F004344E0 /* EmulatorFullscreenWindow.h */,
77E1C0C019D7298F004344E0 /* EmulatorGLView.m */,
77E1C0C119D7298F004344E0 /* EmulatorGLView.h */,
77F80B421A2D95E300D45030 /* EmulatorJoystickCalibrationView.m */,
77F80B431A2D95E300D45030 /* EmulatorJoystickCalibrationView.h */,
77C279731A1048B4000FE33F /* EmulatorJoystickController.h */,
77C279741A1048B4000FE33F /* EmulatorJoystickController.m */,
773BC91719F2FD4500996893 /* EmulatorPrefsController.h */,
@ -1060,6 +1065,7 @@
773B3DAD19568A570085CE5F /* debugger.c in Sources */,
77E1C0B319D72700004344E0 /* vectorUtil.c in Sources */,
4AC7A76D19ECC3FB00BCD457 /* EmulatorWindow.m in Sources */,
77F80B441A2D95E300D45030 /* EmulatorJoystickCalibrationView.m in Sources */,
773B3DAB19568A570085CE5F /* keys.c in Sources */,
773B3DBC19568A570085CE5F /* timing.c in Sources */,
773B3DAF19568A570085CE5F /* misc.c in Sources */,

View File

@ -365,27 +365,27 @@ DQ
<outlet property="startupLoadDiskB" destination="Ceo-uO-cRu" id="V0B-0f-YZu"/>
</connections>
</customObject>
<window title="Apple2Mac Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="Mzv-VG-jce" userLabel="Window - Prefs">
<window title="Apple2Mac Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="Mzv-VG-jce" userLabel="Window - Prefs" customClass="EmulatorWindow">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="109" y="132" width="522" height="302"/>
<rect key="contentRect" x="109" y="132" width="580" height="360"/>
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="778"/>
<view key="contentView" id="bfK-7M-z1X">
<rect key="frame" x="0.0" y="0.0" width="522" height="302"/>
<rect key="frame" x="0.0" y="1" width="580" height="360"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<tabView id="xvZ-VK-VbM">
<rect key="frame" x="13" y="10" width="496" height="286"/>
<rect key="frame" x="13" y="10" width="554" height="344"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<font key="font" metaFont="system"/>
<tabViewItems>
<tabViewItem label="General" identifier="1" id="9QL-dh-vnO">
<view key="view" id="NHh-74-iPh">
<rect key="frame" x="10" y="33" width="476" height="240"/>
<rect key="frame" x="10" y="33" width="534" height="298"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" setsMaxLayoutWidthAtFirstLayout="YES" id="RMd-Jf-hgi">
<rect key="frame" x="196" y="220" width="84" height="17"/>
<rect key="frame" x="225" y="278" width="84" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="center" title="CPU Speed" id="cbb-4q-VuM">
<font key="font" metaFont="system"/>
@ -393,17 +393,8 @@ DQ
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" setsMaxLayoutWidthAtFirstLayout="YES" id="hHW-BV-aWU">
<rect key="frame" x="196" y="102" width="84" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="center" title="Alt Speed" id="aPu-QU-jtF">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="BIH-lT-BN3">
<rect key="frame" x="365" y="180" width="44" height="17"/>
<rect key="frame" x="423" y="238" width="44" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="100%" id="mKS-Ef-da9">
<font key="font" metaFont="system"/>
@ -412,7 +403,7 @@ DQ
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="v8u-UP-OWx">
<rect key="frame" x="365" y="62" width="44" height="17"/>
<rect key="frame" x="423" y="121" width="44" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="400%" id="LVf-iB-pGv">
<font key="font" metaFont="system"/>
@ -421,7 +412,7 @@ DQ
</textFieldCell>
</textField>
<slider verticalHuggingPriority="750" id="HBI-oW-CEl">
<rect key="frame" x="15" y="175" width="346" height="27"/>
<rect key="frame" x="15" y="233" width="404" height="27"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<sliderCell key="cell" continuous="YES" alignment="left" minValue="0.25" maxValue="4" doubleValue="1" tickMarkPosition="below" numberOfTickMarks="16" sliderType="linear" id="FcD-OP-Q8S"/>
<connections>
@ -429,7 +420,7 @@ DQ
</connections>
</slider>
<button id="cZP-xV-zs3">
<rect key="frame" x="413" y="179" width="48" height="18"/>
<rect key="frame" x="471" y="237" width="48" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Max" bezelStyle="regularSquare" imagePosition="left" inset="2" id="YOA-Uz-RHo">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@ -440,7 +431,7 @@ DQ
</connections>
</button>
<button id="Sjk-sn-E28">
<rect key="frame" x="413" y="61" width="48" height="18"/>
<rect key="frame" x="471" y="119" width="48" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Max" bezelStyle="regularSquare" imagePosition="left" inset="2" id="JEt-BY-gNF">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@ -451,33 +442,42 @@ DQ
</connections>
</button>
<box autoresizesSubviews="NO" verticalHuggingPriority="750" title="Box" boxType="separator" titlePosition="noTitle" id="9U0-v9-wTm">
<rect key="frame" x="17" y="125" width="450" height="5"/>
<rect key="frame" x="17" y="183" width="508" height="5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<color key="borderColor" white="0.0" alpha="0.41999999999999998" colorSpace="calibratedWhite"/>
<color key="fillColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<font key="titleFont" metaFont="system"/>
</box>
<slider verticalHuggingPriority="750" id="y10-Rm-oDB">
<rect key="frame" x="15" y="57" width="346" height="27"/>
<rect key="frame" x="15" y="115" width="404" height="27"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<sliderCell key="cell" continuous="YES" state="on" alignment="left" minValue="0.25" maxValue="4" doubleValue="4" tickMarkPosition="below" numberOfTickMarks="16" sliderType="linear" id="Moc-Ll-CEH"/>
<connections>
<action selector="sliderDidMove:" target="mUW-Rh-bL1" id="JWb-jF-Yi8"/>
</connections>
</slider>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" setsMaxLayoutWidthAtFirstLayout="YES" id="hHW-BV-aWU">
<rect key="frame" x="225" y="160" width="84" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="center" title="Alt Speed" id="aPu-QU-jtF">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</view>
</tabViewItem>
<tabViewItem label="Audio" identifier="1" id="sJk-7J-qt2" userLabel="Audio">
<view key="view" id="ct0-V1-eFp">
<rect key="frame" x="10" y="33" width="476" height="240"/>
<rect key="frame" x="10" y="33" width="534" height="298"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<matrix verticalHuggingPriority="750" allowsEmptySelection="NO" autorecalculatesCellSize="YES" id="3d5-Z5-xDN">
<rect key="frame" x="17" y="179" width="442" height="58"/>
<rect key="frame" x="17" y="237" width="442" height="58"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
<size key="cellSize" width="442" height="18"/>
<size key="cellSize" width="353" height="18"/>
<size key="intercellSpacing" width="4" height="2"/>
<buttonCell key="prototype" type="radio" title="Radio" imagePosition="left" alignment="left" enabled="NO" state="on" inset="2" id="fXT-Uh-8o7">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@ -485,7 +485,7 @@ DQ
</buttonCell>
<cells>
<column>
<buttonCell type="radio" title="No soundcard" imagePosition="left" alignment="left" enabled="NO" tag="1" inset="2" id="QsT-B1-n2t">
<buttonCell type="radio" title="No soundcard" imagePosition="left" alignment="left" enabled="NO" state="on" tag="1" inset="2" id="QsT-B1-n2t">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
@ -508,11 +508,11 @@ DQ
</tabViewItem>
<tabViewItem label="Video" identifier="1" id="Hoz-MQ-lVE">
<view key="view" id="gXd-lK-Huk">
<rect key="frame" x="10" y="33" width="476" height="240"/>
<rect key="frame" x="10" y="33" width="534" height="298"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="dak-eg-hHn">
<rect key="frame" x="15" y="220" width="96" height="17"/>
<rect key="frame" x="15" y="278" width="96" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Color :" id="eHo-1T-edz">
<font key="font" metaFont="system"/>
@ -521,7 +521,7 @@ DQ
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" id="1sF-py-jCs">
<rect key="frame" x="115" y="213" width="158" height="26"/>
<rect key="frame" x="115" y="271" width="158" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Black/white" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="PX0-X3-MxY" id="eVj-ax-48A">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
@ -545,12 +545,12 @@ DQ
</connections>
</popUpButton>
<slider verticalHuggingPriority="750" id="9FG-IJ-hYc">
<rect key="frame" x="115" y="171" width="346" height="27"/>
<rect key="frame" x="115" y="229" width="404" height="27"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<sliderCell key="cell" enabled="NO" state="on" alignment="left" maxValue="100" doubleValue="50" tickMarkPosition="below" numberOfTickMarks="5" sliderType="linear" id="Cma-o2-8gh"/>
</slider>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="RsU-77-Dkx">
<rect key="frame" x="15" y="183" width="96" height="17"/>
<rect key="frame" x="15" y="241" width="96" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Graphic Effects :" id="foK-d1-Lrb">
<font key="font" metaFont="system"/>
@ -563,22 +563,22 @@ DQ
</tabViewItem>
<tabViewItem label="Joystick" identifier="2" id="Zc6-NX-eT8">
<view key="view" id="g6Z-G2-RwC">
<rect key="frame" x="10" y="33" width="476" height="240"/>
<rect key="frame" x="10" y="33" width="534" height="298"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<box autoresizesSubviews="NO" horizontalHuggingPriority="750" title="Box" boxType="separator" titlePosition="noTitle" id="Fkg-X3-0XG">
<rect key="frame" x="236" y="9" width="5" height="236"/>
<rect key="frame" x="265" y="9" width="5" height="286"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<color key="borderColor" white="0.0" alpha="0.41999999999999998" colorSpace="calibratedWhite"/>
<color key="fillColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<font key="titleFont" metaFont="system"/>
</box>
<customView id="OWJ-x7-P0q">
<rect key="frame" x="259" y="37" width="200" height="200"/>
<customView id="OWJ-x7-P0q" customClass="EmulatorJoystickCalibrationView">
<rect key="frame" x="276" y="39" width="256" height="256"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</customView>
<popUpButton verticalHuggingPriority="750" id="gBd-cR-p7O">
<rect key="frame" x="15" y="213" width="218" height="26"/>
<rect key="frame" x="15" y="271" width="218" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="tK3-cL-Zwi">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
@ -599,7 +599,7 @@ DQ
</connections>
</popUpButton>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="Zt8-bA-2cM">
<rect key="frame" x="245" y="12" width="75" height="17"/>
<rect key="frame" x="262" y="9" width="75" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Button 1 :" id="5aE-WW-hxS">
<font key="font" metaFont="system"/>
@ -608,7 +608,7 @@ DQ
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="ea3-X4-r6a">
<rect key="frame" x="15" y="162" width="29" height="17"/>
<rect key="frame" x="15" y="220" width="29" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" enabled="NO" sendsActionOnEndEditing="YES" alignment="left" title="100" id="XJf-vx-Msv">
<font key="font" metaFont="system"/>
@ -617,7 +617,7 @@ DQ
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="pGe-nD-Lac">
<rect key="frame" x="324" y="12" width="18" height="17"/>
<rect key="frame" x="341" y="9" width="18" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="✓" id="ubH-gJ-97X">
<font key="font" metaFont="system"/>
@ -626,7 +626,7 @@ DQ
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="XFG-kU-Ioe">
<rect key="frame" x="443" y="12" width="18" height="17"/>
<rect key="frame" x="516" y="9" width="18" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="✓" id="heq-gj-6Z1">
<font key="font" metaFont="system"/>
@ -635,7 +635,7 @@ DQ
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="gWY-LF-DGr">
<rect key="frame" x="364" y="12" width="75" height="17"/>
<rect key="frame" x="444" y="9" width="75" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Button 2 :" id="t0J-m7-pfW">
<font key="font" metaFont="system"/>
@ -644,7 +644,7 @@ DQ
</textFieldCell>
</textField>
<button id="MbK-fn-sy2">
<rect key="frame" x="15" y="187" width="217" height="18"/>
<rect key="frame" x="15" y="245" width="217" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Keypad Auto-Recenter" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="swI-VW-5rZ">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@ -654,8 +654,19 @@ DQ
<action selector="autoRecenterChoiceChanged:" target="mUW-Rh-bL1" id="Ehf-jm-Exs"/>
</connections>
</button>
<button id="wu9-dx-Rxy" userLabel="Clip to Radius">
<rect key="frame" x="15" y="245" width="217" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Clip to Radius" bezelStyle="regularSquare" imagePosition="left" alignment="left" state="on" inset="2" id="AMY-tC-0Yf">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="clipToRadiusChoiceChanged:" target="mUW-Rh-bL1" id="CWO-Ct-YTC"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="e2h-SS-aex">
<rect key="frame" x="69" y="162" width="163" height="17"/>
<rect key="frame" x="69" y="220" width="163" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" enabled="NO" sendsActionOnEndEditing="YES" alignment="left" title="Keypad Sensitivity" id="Gx0-zf-TeB">
<font key="font" metaFont="system"/>
@ -664,7 +675,7 @@ DQ
</textFieldCell>
</textField>
<stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" id="BrH-bm-tx3">
<rect key="frame" x="47" y="156" width="19" height="27"/>
<rect key="frame" x="47" y="214" width="19" height="27"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<stepperCell key="cell" continuous="YES" alignment="left" minValue="1" maxValue="255" doubleValue="4" id="Qxz-h1-hQt"/>
<connections>
@ -672,25 +683,24 @@ DQ
</connections>
</stepper>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" id="PLJ-iK-Nsf">
<rect key="frame" x="15" y="17" width="217" height="34"/>
<rect key="frame" x="15" y="9" width="243" height="34"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Left Alt and right Alt keys are Joystick buttons 1 and 2" id="Kgw-5H-ygQ">
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Left Alt and right Alt keys are joystick buttons 1 and 2" id="Kgw-5H-ygQ">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" id="qrP-3M-EgH">
<rect key="frame" x="69" y="110" width="109" height="32"/>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" id="LUN-A2-S1l">
<rect key="frame" x="15" y="9" width="246" height="34"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Calibrate..." bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Zhp-bX-Quw">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" id="TEm-S7-9qg">
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="calibrateJoystick:" target="mUW-Rh-bL1" id="zBh-I8-o6E"/>
</connections>
</button>
<string key="title">We recommend the Clip to Radius setting for gamepad devices (not traditional joysticks) which cannot generate values in the extreme corners.</string>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</view>
</tabViewItem>
@ -698,7 +708,7 @@ DQ
</tabView>
</subviews>
</view>
<point key="canvasLocation" x="-328" y="-1027"/>
<point key="canvasLocation" x="-286" y="-1308"/>
</window>
<customObject id="mUW-Rh-bL1" customClass="EmulatorPrefsController">
<connections>
@ -711,13 +721,17 @@ DQ
<outlet property="cpuMaxChoice" destination="cZP-xV-zs3" id="FQf-hE-FC6"/>
<outlet property="cpuSlider" destination="HBI-oW-CEl" id="xW6-qf-8dt"/>
<outlet property="cpuSliderLabel" destination="BIH-lT-BN3" id="DQN-Z9-0pa"/>
<outlet property="joystickCalibrationView" destination="OWJ-x7-P0q" id="g08-0g-YOg"/>
<outlet property="joystickCalibrationView" destination="OWJ-x7-P0q" id="R9D-0T-Ar5"/>
<outlet property="joystickChoice" destination="gBd-cR-p7O" id="3os-mX-1E4"/>
<outlet property="joystickClipToRadius" destination="wu9-dx-Rxy" id="MqM-BI-mzv"/>
<outlet property="joystickDeviceNotes" destination="LUN-A2-S1l" id="UTM-zV-dSn"/>
<outlet property="joystickKPadNotes" destination="PLJ-iK-Nsf" id="Hdw-rG-TuN"/>
<outlet property="joystickRecenter" destination="MbK-fn-sy2" id="nEJ-ZU-arF"/>
<outlet property="joystickStepLabel" destination="ea3-X4-r6a" id="JKX-kB-tcM"/>
<outlet property="joystickStepper" destination="BrH-bm-tx3" id="PmM-yE-XNH"/>
<outlet property="prefsWindow" destination="Mzv-VG-jce" id="4MA-Wb-bdU"/>
<outlet property="joystickStepperLabel" destination="e2h-SS-aex" id="I6X-YN-AmA"/>
<outlet property="soundCardChoice" destination="3d5-Z5-xDN" id="uHI-Ip-s2E"/>
<outlet property="window" destination="Mzv-VG-jce" id="86q-Ys-9Mt"/>
</connections>
</customObject>
</objects>

View File

@ -0,0 +1,13 @@
//
// EmulatorJoystickCalibrationView.h
// Apple2Mac
//
// Created by Aaron Culliney on 11/30/14.
// Copyright (c) 2014 deadc0de.org. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface EmulatorJoystickCalibrationView : NSView
@end

View File

@ -0,0 +1,61 @@
//
// EmulatorJoystickCalibrationView.m
// Apple2Mac
//
// Created by Aaron Culliney on 11/30/14.
// Copyright (c) 2014 deadc0de.org. All rights reserved.
//
#import "EmulatorJoystickCalibrationView.h"
#import "common.h"
#import <QuartzCore/QuartzCore.h>
@implementation EmulatorJoystickCalibrationView
- (void)drawRect:(NSRect)dirtyRect
{
[super drawRect:dirtyRect];
[self drawView];
}
- (void)drawView
{
static int pulseSize = 1;
CGRect bounds = [self bounds];
NSAssert(bounds.size.height == 256.f, @"view should be 256pts high");
NSAssert(bounds.size.width == 256.f, @"view should be 256pts wide");
CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
CGContextSaveGState(context);
CGContextSetLineWidth(context, 1);
CGContextSetRGBStrokeColor(context, 0, 0, 0, 1);
CGContextAddEllipseInRect(context, bounds);
CGContextStrokePath(context);
CGFloat x_val = joy_x;
CGFloat y_val = 256-joy_y;
CGContextSetRGBStrokeColor(context, 1, 0, 0, 1);
CGRect cursor = CGRectMake(x_val-(pulseSize/2.f), y_val-(pulseSize/2.f), pulseSize, pulseSize);
CGContextAddEllipseInRect(context, cursor);
CGContextStrokePath(context);
CGContextRestoreGState(context);
pulseSize = ((pulseSize+1) & 0x7) +1;
}
- (void)keyUp:(NSEvent *)event
{
[[self nextResponder] keyUp:event];
}
- (void)keyDown:(NSEvent *)event
{
[[self nextResponder] keyDown:event];
}
@end

View File

@ -8,6 +8,8 @@
#import "EmulatorPrefsController.h"
#import "EmulatorDiskController.h"
#import "EmulatorJoystickCalibrationView.h"
#import "EmulatorWindowController.h"
#import "common.h"
#define kApple2SavedPrefs @"kApple2SavedPrefs"
@ -23,8 +25,6 @@
@interface EmulatorPrefsController ()
@property (assign) IBOutlet NSWindow *prefsWindow;
@property (assign) IBOutlet NSSlider *cpuSlider;
@property (assign) IBOutlet NSSlider *altSlider;
@property (assign) IBOutlet NSTextField *cpuSliderLabel;
@ -38,12 +38,16 @@
@property (assign) IBOutlet NSPopUpButton *joystickChoice;
@property (assign) IBOutlet NSButton *joystickRecenter;
@property (assign) IBOutlet NSButton *joystickClipToRadius;
@property (assign) IBOutlet NSTextField *joystickStepLabel;
@property (assign) IBOutlet NSStepper *joystickStepper;
@property (assign) IBOutlet NSTextField *joystickStepperLabel;
@property (assign) IBOutlet NSTextField *joystickKPadNotes;
@property (assign) IBOutlet NSTextField *joystickDeviceNotes;
@property (assign) IBOutlet NSTextField *button0Pressed;
@property (assign) IBOutlet NSTextField *button1Pressed;
@property (assign) IBOutlet NSView *joystickCalibrationView;
@property (assign) IBOutlet EmulatorJoystickCalibrationView *joystickCalibrationView;
@end
@ -122,6 +126,15 @@
joy_step = [defaults integerForKey:kApple2JoystickStep];
[self.joystickStepLabel setIntegerValue:joy_step];
[self.joystickStepper setIntegerValue:joy_step];
[self _setupJoystickUI];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(drawJoystickCalibration:) name:(NSString *)kDrawTimerNotification object:nil];
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
- (void)_savePrefs
@ -134,6 +147,7 @@
[defaults setBool:([self.altMaxChoice state] == NSOnState) forKey:kApple2AltSpeedIsMax];
[defaults setInteger:color_mode forKey:kApple2ColorConfig];
[defaults setInteger:joy_mode forKey:kApple2JoystickConfig];
[defaults setInteger:joy_step forKey:kApple2JoystickStep];
[defaults setBool:joy_auto_recenter forKey:kApple2JoystickAutoRecenter];
}
@ -201,6 +215,20 @@
#warning TODO : make soundcard configurable at runtime
}
#pragma mark -
#pragma mark Joystick preferences
- (void)_setupJoystickUI
{
[self.joystickRecenter setHidden:(joy_mode == JOY_PCJOY)];
[self.joystickClipToRadius setHidden:(joy_mode != JOY_PCJOY)];
[self.joystickStepLabel setHidden:(joy_mode == JOY_PCJOY)];
[self.joystickStepper setHidden:(joy_mode == JOY_PCJOY)];
[self.joystickStepperLabel setHidden:(joy_mode == JOY_PCJOY)];
[self.joystickKPadNotes setHidden:(joy_mode == JOY_PCJOY)];
[self.joystickDeviceNotes setHidden:(joy_mode != JOY_PCJOY)];
}
- (IBAction)joystickChoiceChanged:(id)sender
{
NSInteger mode = [self.joystickChoice indexOfSelectedItem];
@ -209,6 +237,7 @@
mode = JOY_PCJOY;
}
joy_mode = (joystick_mode_t)mode;
[self _setupJoystickUI];
[self _savePrefs];
}
@ -218,6 +247,11 @@
[self _savePrefs];
}
- (IBAction)clipToRadiusChoiceChanged:(id)sender
{
// TBD : handle joysticks with radius (most gamepads)
}
- (IBAction)stepValueChanged:(id)sender
{
joy_step = [self.joystickStepper intValue];
@ -225,8 +259,84 @@
[self _savePrefs];
}
- (IBAction)calibrateJoystick:(id)sender
#pragma mark -
#pragma Joystick calibration
- (void)drawJoystickCalibration:(NSNotification *)notification
{
if (![self.joystickCalibrationView isHidden])
{
[self.joystickCalibrationView setNeedsDisplay:YES];
[self.button0Pressed setHidden:!(joy_button0)];
[self.button1Pressed setHidden:!(joy_button1)];
}
}
- (void)flagsChanged:(NSEvent*)event
{
// NOTE : yay, awesome! checking for ([event modifierFlags] & NSAlternateKeyMask) does not work properly if both were pressed and then one ALT key is unpressed ... kudoes to Apple for an excellent key-handling API /sarc
static BOOL leftAltEngaged = NO;
static BOOL rightAltEngaged = NO;
switch ([event keyCode])
{
case ALT_LT:
leftAltEngaged = !leftAltEngaged;
c_keys_handle_input(SCODE_L_ALT, /*pressed:*/leftAltEngaged, /*cooked:*/0);
break;
case ALT_RT:
rightAltEngaged = !rightAltEngaged;
c_keys_handle_input(SCODE_R_ALT, /*pressed:*/rightAltEngaged, /*cooked:*/0);
break;
default:
break;
}
if (!([event modifierFlags] & NSAlternateKeyMask))
{
// But we can trust the system state if no alt modifier exists ... this resets b0rken edge cases
leftAltEngaged = NO;
rightAltEngaged = NO;
}
[self.button0Pressed setHidden:!(joy_button0)];
[self.button1Pressed setHidden:!(joy_button1)];
}
- (void)_handleKeyEvent:(NSEvent *)event pressed:(BOOL)pressed
{
unichar c = [[event charactersIgnoringModifiers] characterAtIndex:0];
int scode = (int)c;
switch (scode)
{
case NSUpArrowFunctionKey:
c_keys_handle_input(SCODE_U, pressed, /*cooked:*/0);
break;
case NSDownArrowFunctionKey:
c_keys_handle_input(SCODE_D, pressed, /*cooked:*/0);
break;
case NSLeftArrowFunctionKey:
c_keys_handle_input(SCODE_L, pressed, /*cooked:*/0);
break;
case NSRightArrowFunctionKey:
c_keys_handle_input(SCODE_R, pressed, /*cooked:*/0);
break;
default:
break;
}
}
- (void)keyUp:(NSEvent *)event
{
[self _handleKeyEvent:event pressed:NO];
// Allow other character to be handled (or not and beep)
//[super keyDown:event];
}
- (void)keyDown:(NSEvent *)event
{
[self _handleKeyEvent:event pressed:YES];
// Allow other character to be handled (or not and beep)
//[super keyDown:event];
}
@end

View File

@ -11,6 +11,14 @@
#import <Cocoa/Cocoa.h>
#import "EmulatorGLView.h"
#define CAPS_LOCK 0x39
#define SHIFT_LT 0x38
#define SHIFT_RT 0x3c
#define CTRL_LT 0x3b
#define CTRL_RT 0x3e
#define ALT_LT 0x3a
#define ALT_RT 0x3d
extern const NSString *kDrawTimerNotification;
@interface EmulatorWindowController : NSWindowController

View File

@ -12,14 +12,6 @@
#import "EmulatorFullscreenWindow.h"
#import "common.h"
#define CAPS_LOCK 0x39
#define SHIFT_LT 0x38
#define SHIFT_RT 0x3c
#define CTRL_LT 0x3b
#define CTRL_RT 0x3e
#define ALT_LT 0x3a
#define ALT_RT 0x3d
@interface EmulatorWindowController ()
@property (nonatomic, assign) BOOL paused;