Undid damage to shipdata.plist from last revision. Extended dummy joystick handler for OS X to reduce the number of #ifs in PlayerEntityControls.m.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1012 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Jens Ayton 2007-06-08 14:54:21 +00:00
parent 9137ef4581
commit 741f48d34a
7 changed files with 273 additions and 146 deletions

View File

@ -387,6 +387,7 @@
1ADBA5510BD0F173008FC99C /* OOBasicMaterial.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ADBA54F0BD0F173008FC99C /* OOBasicMaterial.m */; };
1ADF5CEC0B9DF59A00FDB2A3 /* OOCacheManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A231A170B9D8B1B00EF0852 /* OOCacheManager.m */; };
1ADF5F130B9E374B00FDB2A3 /* JoystickHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ADF5F110B9E374B00FDB2A3 /* JoystickHandler.h */; };
1AE546310C19A2E2005B89F3 /* JoystickHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 1AE546300C19A2E2005B89F3 /* JoystickHandler.m */; };
1AEAAB8F0BA45248000705D0 /* libjs.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AEAAB8E0BA45248000705D0 /* libjs.a */; };
1AEAAC9E0BA457E7000705D0 /* jsarena.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC6F0BA457E6000705D0 /* jsarena.h */; };
1AEAAC9F0BA457E7000705D0 /* jsarray.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEAAC700BA457E6000705D0 /* jsarray.h */; };
@ -1228,6 +1229,7 @@
1ADBA54E0BD0F173008FC99C /* OOBasicMaterial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOBasicMaterial.h; sourceTree = "<group>"; };
1ADBA54F0BD0F173008FC99C /* OOBasicMaterial.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOBasicMaterial.m; sourceTree = "<group>"; };
1ADF5F110B9E374B00FDB2A3 /* JoystickHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JoystickHandler.h; sourceTree = "<group>"; };
1AE546300C19A2E2005B89F3 /* JoystickHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JoystickHandler.m; sourceTree = "<group>"; };
1AEAAB8E0BA45248000705D0 /* libjs.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjs.a; path = "deps/Cocoa-deps/js/libjs.a"; sourceTree = "<group>"; };
1AEAAC6F0BA457E6000705D0 /* jsarena.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsarena.h; sourceTree = "<group>"; };
1AEAAC700BA457E6000705D0 /* jsarray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsarray.h; sourceTree = "<group>"; };
@ -1937,6 +1939,7 @@
1A8A3D8F0B9B058500AB7625 /* Audio */,
1A8A3D9E0B9B05C400AB7625 /* Groolite */,
1ADF5F110B9E374B00FDB2A3 /* JoystickHandler.h */,
1AE546300C19A2E2005B89F3 /* JoystickHandler.m */,
1A8071D70C0480AC00BA1935 /* Debug */,
);
name = "Mac-specific";
@ -2632,6 +2635,7 @@
1AED2DE80C046BA2004A1118 /* OODebugController.m in Sources */,
1A15044C0C12C50D0032F3E8 /* OOSkyDrawable.m in Sources */,
1A15049F0C12CA070032F3E8 /* OOProbabilisticTextureManager.m in Sources */,
1AE546310C19A2E2005B89F3 /* JoystickHandler.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -37,7 +37,7 @@
<real>2</real>
<key>max_flight_roll</key>
<real>2.7999999999999998</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>240</real>
<key>max_missiles</key>
<integer>1</integer>
@ -93,7 +93,7 @@
<real>2</real>
<key>max_flight_roll</key>
<real>2.7999999999999998</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>240</real>
<key>max_missiles</key>
<integer>1</integer>
@ -231,7 +231,7 @@
<real>0.5</real>
<key>max_flight_roll</key>
<real>0.5</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>50</real>
<key>missiles</key>
<integer>0</integer>
@ -287,7 +287,7 @@
<real>0.40000000000000002</real>
<key>max_flight_roll</key>
<real>0.75</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>140</real>
<key>max_missiles</key>
<integer>7</integer>
@ -335,7 +335,7 @@
<real>0.40000000000000002</real>
<key>max_flight_roll</key>
<real>0.75</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>140</real>
<key>max_missiles</key>
<integer>7</integer>
@ -500,7 +500,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>400</real>
<key>max_missiles</key>
<integer>1</integer>
@ -572,7 +572,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>400</real>
<key>max_missiles</key>
<integer>1</integer>
@ -623,7 +623,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>400</real>
<key>max_missiles</key>
<integer>1</integer>
@ -765,7 +765,7 @@
<real>0.10000000000000001</real>
<key>max_flight_roll</key>
<real>0.10000000000000001</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>0.0</real>
<key>missiles</key>
<integer>0</integer>
@ -815,7 +815,7 @@
<real>0.5</real>
<key>max_flight_roll</key>
<real>0.5</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>50</real>
<key>missiles</key>
<integer>0</integer>
@ -872,7 +872,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>2.7999999999999998</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>240</real>
<key>max_missiles</key>
<integer>4</integer>
@ -946,7 +946,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>2.5</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>312</real>
<key>max_missiles</key>
<integer>5</integer>
@ -1006,7 +1006,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>2.5</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>312</real>
<key>max_missiles</key>
<integer>5</integer>
@ -1144,7 +1144,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>2.7999999999999998</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>240</real>
<key>max_missiles</key>
<integer>4</integer>
@ -1288,7 +1288,7 @@
<real>0.5</real>
<key>max_flight_roll</key>
<real>0.5</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>5</real>
<key>missiles</key>
<integer>0</integer>
@ -1340,7 +1340,7 @@
<real>2</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>0.0</real>
<key>missiles</key>
<integer>0</integer>
@ -1381,7 +1381,7 @@
<real>2</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>0.0</real>
<key>missiles</key>
<integer>0</integer>
@ -1427,7 +1427,7 @@
<real>0.5</real>
<key>max_flight_roll</key>
<real>0.5</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>50</real>
<key>model</key>
<string>barrel.dat</string>
@ -1503,7 +1503,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>320</real>
<key>missile_launch_position</key>
<string>0.0 -4.5 16.5</string>
@ -1567,7 +1567,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>300</real>
<key>missile_launch_position</key>
<string>0.0 -4.5 16.5</string>
@ -1615,7 +1615,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>350</real>
<key>max_missiles</key>
<integer>4</integer>
@ -1768,7 +1768,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>300</real>
<key>missile_launch_position</key>
<string>0.0 -4.5 16.5</string>
@ -1824,7 +1824,7 @@
<real>1.2</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>260</real>
<key>missile_launch_position</key>
<string>0.0 -2.0 14.0</string>
@ -1884,7 +1884,7 @@
<real>1.2</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>260</real>
<key>max_missiles</key>
<integer>1</integer>
@ -1944,7 +1944,7 @@
<real>1.2</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>260</real>
<key>missile_launch_position</key>
<string>0.0 -2.0 14.0</string>
@ -1990,7 +1990,7 @@
<real>1.2</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>260</real>
<key>max_missiles</key>
<integer>1</integer>
@ -2150,7 +2150,7 @@
<real>1.75</real>
<key>max_flight_roll</key>
<real>2.5</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>600</real>
<key>max_missiles</key>
<integer>3</integer>
@ -2213,7 +2213,7 @@
<real>8</real>
<key>max_flight_roll</key>
<real>8</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>0.0</real>
<key>max_missiles</key>
<integer>0</integer>
@ -2308,7 +2308,7 @@
<real>8</real>
<key>max_flight_roll</key>
<real>8</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>0.0</real>
<key>max_missiles</key>
<integer>0</integer>
@ -2377,7 +2377,7 @@
<real>0.5</real>
<key>max_flight_roll</key>
<real>0.5</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>50</real>
<key>max_missiles</key>
<integer>0</integer>
@ -2458,7 +2458,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>3.6000000000000001</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>300</real>
<key>max_missiles</key>
<integer>2</integer>
@ -2507,7 +2507,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>3.6000000000000001</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>300</real>
<key>max_missiles</key>
<integer>2</integer>
@ -2655,7 +2655,7 @@
<real>1.5</real>
<key>max_flight_roll</key>
<real>3</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>300</real>
<key>max_missiles</key>
<integer>1</integer>
@ -2740,7 +2740,7 @@
<real>8</real>
<key>max_flight_roll</key>
<real>8</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>0.0</real>
<key>max_missiles</key>
<integer>0</integer>
@ -2818,7 +2818,7 @@
<real>1.5</real>
<key>max_flight_roll</key>
<real>2.75</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>300</real>
<key>max_missiles</key>
<integer>0</integer>
@ -2883,7 +2883,7 @@
<real>1.4</real>
<key>max_flight_roll</key>
<real>2.1</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>320</real>
<key>max_missiles</key>
<integer>0</integer>
@ -2944,7 +2944,7 @@
<real>1.4</real>
<key>max_flight_roll</key>
<real>2.1</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>320</real>
<key>max_missiles</key>
<integer>0</integer>
@ -3003,7 +3003,7 @@
<real>8</real>
<key>max_flight_roll</key>
<real>10</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>750</real>
<key>max_missiles</key>
<integer>0</integer>
@ -3058,7 +3058,7 @@
<real>1.5</real>
<key>max_flight_roll</key>
<real>2.5</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>300</real>
<key>max_missiles</key>
<integer>2</integer>
@ -3105,7 +3105,7 @@
<real>1.5</real>
<key>max_flight_roll</key>
<real>2.5</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>300</real>
<key>max_missiles</key>
<integer>2</integer>
@ -3253,7 +3253,7 @@
<real>1.5</real>
<key>max_flight_roll</key>
<real>2.5</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>300</real>
<key>max_missiles</key>
<integer>2</integer>
@ -3300,7 +3300,7 @@
<real>1.5</real>
<key>max_flight_roll</key>
<real>2.5</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>300</real>
<key>max_missiles</key>
<integer>2</integer>
@ -3452,7 +3452,7 @@
<real>0.80000000000000004</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>200</real>
<key>max_missiles</key>
<integer>2</integer>
@ -3517,7 +3517,7 @@
<real>0.80000000000000004</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>200</real>
<key>max_missiles</key>
<integer>2</integer>
@ -3564,7 +3564,7 @@
<real>0.80000000000000004</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>200</real>
<key>max_missiles</key>
<integer>2</integer>
@ -3716,7 +3716,7 @@
<real>0.80000000000000004</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>200</real>
<key>max_missiles</key>
<integer>2</integer>
@ -3753,7 +3753,7 @@
<real>2</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>1000</real>
<key>model</key>
<string>qbomb.dat</string>
@ -3800,7 +3800,7 @@
<real>8</real>
<key>max_flight_roll</key>
<real>8</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>0.0</real>
<key>max_missiles</key>
<integer>0</integer>
@ -3856,7 +3856,7 @@
<real>0.5</real>
<key>max_flight_roll</key>
<real>0.5</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>50</real>
<key>missiles</key>
<integer>0</integer>
@ -3900,7 +3900,7 @@
<real>0.90000000000000002</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>80</real>
<key>max_missiles</key>
<integer>0</integer>
@ -3961,7 +3961,7 @@
<real>1.6000000000000001</real>
<key>max_flight_roll</key>
<real>2.7999999999999998</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>370</real>
<key>max_missiles</key>
<integer>0</integer>
@ -4022,7 +4022,7 @@
<real>1.8</real>
<key>max_flight_roll</key>
<real>2.7999999999999998</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>370</real>
<key>max_missiles</key>
<integer>0</integer>
@ -4083,7 +4083,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>1</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>10</real>
<key>missiles</key>
<integer>0</integer>
@ -4146,7 +4146,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>450</real>
<key>missiles</key>
<integer>0</integer>
@ -4209,7 +4209,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>500</real>
<key>max_missiles</key>
<integer>5</integer>
@ -4261,7 +4261,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>100</real>
<key>max_missiles</key>
<integer>0</integer>
@ -4327,7 +4327,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>100</real>
<key>max_missiles</key>
<integer>0</integer>
@ -4393,7 +4393,7 @@
<real>1.8</real>
<key>max_flight_roll</key>
<real>2.7999999999999998</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>320</real>
<key>max_missiles</key>
<integer>1</integer>
@ -4481,7 +4481,7 @@
<real>2</real>
<key>max_flight_roll</key>
<real>4.2000000000000002</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>520</real>
<key>max_missiles</key>
<integer>3</integer>
@ -4564,7 +4564,7 @@
<real>1.8</real>
<key>max_flight_roll</key>
<real>2.7999999999999998</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>360</real>
<key>max_missiles</key>
<integer>1</integer>
@ -4625,7 +4625,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>110</real>
<key>max_missiles</key>
<integer>0</integer>
@ -4688,7 +4688,7 @@
<real>1</real>
<key>max_flight_roll</key>
<real>2</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>100</real>
<key>max_missiles</key>
<integer>0</integer>
@ -4748,7 +4748,7 @@
<real>8</real>
<key>max_flight_roll</key>
<real>10</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>750</real>
<key>max_missiles</key>
<integer>0</integer>
@ -4788,7 +4788,7 @@
<real>2.0</real>
<key>max_flight_roll</key>
<real>2.0</real>
<key>maxFlightSpeed</key>
<key>max_flight_speed</key>
<real>500</real>
<key>model</key>
<string>wreck1.dat</string>

View File

@ -5,6 +5,7 @@ JoystickHandler.h
Non-functional JoystickHandler.
This exists to reduce the amount of #ifdefs and duplicated code.
Oolite
Copyright (C) 2004-2007 Giles C Williams and contributors
@ -23,16 +24,117 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
This file may also be distributed under the MIT/X11 license:
Copyright (C) 2006 Jens Ayton
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#import <Foundation/Foundation.h>
#define STICK_AXISUNASSIGNED -10.0
// Enums are used here rather than a more complex ObjC object because
// these are required very frequently (once per frame) so must be light
// on CPU cycles (try and avoid too many objc sendmsgs).
// Controls that can be an axis
enum {
AXIS_ROLL,
AXIS_PITCH,
AXIS_PRECISION,
AXIS_THRUST,
AXIS_VIEW,
AXIS_end
} axfn;
// Controls that can be a button
enum {
BUTTON_INCTHRUST,
BUTTON_DECTHRUST,
BUTTON_SCANNERZOOM,
BUTTON_JETTISON,
BUTTON_COMPASSMODE,
BUTTON_COMMSLOG,
BUTTON_DOCKCPU,
BUTTON_DOCKCPUFAST,
BUTTON_DOCKCPUTARGET,
BUTTON_FUELINJECT,
BUTTON_HYPERSPEED,
BUTTON_HYPERDRIVE,
BUTTON_GALACTICDRIVE,
BUTTON_FIRE,
BUTTON_ARMMISSILE,
BUTTON_LAUNCHMISSILE,
BUTTON_UNARM,
BUTTON_CYCLEMISSILE,
BUTTON_ENERGYBOMB,
BUTTON_ID,
BUTTON_ECM,
BUTTON_ESCAPE,
BUTTON_CLOAK,
BUTTON_PRECISION,
BUTTON_end
} butfn;
// Stick constants
#define MAX_STICKS 2
#define MAX_AXES 10
#define MAX_BUTTONS 20
#define STICK_NOFUNCTION -1
#define STICK_AXISUNASSIGNED -10.0
#define STICK_PRECISIONDIV 98304 // 3 times more precise
#define STICK_NORMALDIV 32768
#define STICK_PRECISIONFAC (STICK_PRECISIONDIV/STICK_NORMALDIV)
// Kind of stick device (these are bits - if any more are added,
// the next one is 4 and so on).
#define HW_AXIS 1
#define HW_BUTTON 2
// The threshold at which an axis can trigger a call back.
// The max of abs(axis) is 32767.
#define AXCBTHRESH 20000
// Dictionary keys - used in the defaults file
#define AXIS_SETTINGS @"JoystickAxes" // NSUserDefaults
#define BUTTON_SETTINGS @"JoystickButs" // NSUserDefaults
#define STICK_ISAXIS @"isAxis" // YES=axis NO=button
#define STICK_NUMBER @"stickNum" // Stick number 0 to 4
#define STICK_AXBUT @"stickAxBt" // Axis or button number
#define STICK_FUNCTION @"stickFunc" // Function of axis/button
// shortcut to make code more readable when using enum as key for
// an NSDictionary
#define ENUMKEY(x) [NSString stringWithFormat: @"%d", x]
@interface JoystickHandler: NSObject
{
BOOL butstate[BUTTON_end];
}
+ (id)sharedStickHandler;
- (int) getNumSticks;
- (NSPoint) getRollPitchAxis;
- (const BOOL *)getAllButtonStates;
@end

View File

@ -0,0 +1,80 @@
/*
JoystickHandler.m
Oolite
Copyright (C) 2004-2007 Giles C Williams and contributors
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
This file may also be distributed under the MIT/X11 license:
Copyright (C) 2006 Jens Ayton
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#import "JoystickHandler.h"
JoystickHandler *sSharedStickHandler = nil;
@implementation JoystickHandler
+ (id)sharedStickHandler
{
if (sSharedStickHandler == nil) sSharedStickHandler = [[JoystickHandler alloc] init];
return sSharedStickHandler;
}
- (int)getNumSticks
{
return 0;
}
- (NSPoint)getRollPitchAxis
{
return NSMakePoint(0.0f, 0.0f);
}
- (const BOOL *)getAllButtonStates
{
return butstate;
}
@end

View File

@ -32,6 +32,7 @@ MA 02110-1301, USA.
#import "GuiDisplayGen.h"
#import "OODebugController.h"
#import <Carbon/Carbon.h>
#import "JoystickHandler.h"
static NSString * kOOLogKeyCodeOutOfRange = @"input.keyMapping.codeOutOfRange";
@ -109,7 +110,7 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
- (void)awakeFromNib
{
#ifndef NDEBUG
#if OO_INCLUDE_DEBUG_CONTROLLER
(void)[OODebugController sharedDebugController];
#endif
}
@ -590,7 +591,7 @@ static NSString * kOOLogKeyDown = @"input.keyMapping.keyPress.keyDown";
- (JoystickHandler *)getStickHandler
{
return nil;
return [JoystickHandler sharedStickHandler];
}

View File

@ -244,14 +244,12 @@ static NSTimeInterval time_last_frame;
{
MyOpenGLView *gameView = (MyOpenGLView *)[UNIVERSE gameView];
#if OOLITE_HAVE_JOYSTICK
// DJS: TODO: Sort where SDL keeps its stuff.
if(!stickHandler)
{
stickHandler=[gameView getStickHandler];
}
const BOOL *joyButtonState=[stickHandler getAllButtonStates];
#endif
// DJS: TODO: Sort where SDL keeps its stuff.
if(!stickHandler)
{
stickHandler=[gameView getStickHandler];
}
const BOOL *joyButtonState=[stickHandler getAllButtonStates];
BOOL paused = [[gameView gameController] game_is_paused];
double speed_delta = 5.0 * thrust;
@ -273,12 +271,7 @@ static NSTimeInterval time_last_frame;
//if (![gameView allowingStringInput])
if (![UNIVERSE displayCursor])
{
//
#if OOLITE_HAVE_JOYSTICK
if ((joyButtonState[BUTTON_FUELINJECT] || [gameView isDown:key_inject_fuel])&&(has_fuel_injection)&&(!hyperspeed_engaged))
#else
if (([gameView isDown:key_inject_fuel])&&(has_fuel_injection)&&(!hyperspeed_engaged))
#endif
{
if ((fuel > 0)&&(!afterburner_engaged))
{
@ -361,11 +354,7 @@ static NSTimeInterval time_last_frame;
// hyperspeed controls
//
#if OOLITE_HAVE_JOYSTICK
if ([gameView isDown:key_jumpdrive] || joyButtonState[BUTTON_HYPERSPEED]) // 'j'
#else
if ([gameView isDown:key_jumpdrive]) // 'j'
#endif
{
if (!jump_pressed)
{
@ -394,11 +383,7 @@ static NSTimeInterval time_last_frame;
//
// shoot 'a'
//
#if OOLITE_HAVE_JOYSTICK
if ((([gameView isDown:key_fire_lasers])||((mouse_control_on)&&([gameView isDown:gvMouseLeftButton]))||joyButtonState[BUTTON_FIRE])&&(shot_time > weapon_reload_time))
#else
if ((([gameView isDown:key_fire_lasers])||((mouse_control_on)&&([gameView isDown:gvMouseLeftButton])))&&(shot_time > weapon_reload_time))
#endif
{
if ([self fireMainWeapon])
@ -425,11 +410,7 @@ static NSTimeInterval time_last_frame;
//
// shoot 'm' // launch missile
//
#if OOLITE_HAVE_JOYSTICK
if ([gameView isDown:key_launch_missile] || joyButtonState[BUTTON_LAUNCHMISSILE])
#else
if ([gameView isDown:key_launch_missile])
#endif
{
// launch here
if (!fire_missile_pressed)
@ -447,11 +428,7 @@ static NSTimeInterval time_last_frame;
//
// shoot 'y' // next missile
//
#if OOLITE_HAVE_JOYSTICK
if ([gameView isDown:key_next_missile] || joyButtonState[BUTTON_CYCLEMISSILE])
#else
if ([gameView isDown:key_next_missile])
#endif
{
if ((!ident_engaged)&&(!next_missile_pressed)&&([self has_extra_equipment:@"EQ_MULTI_TARGET"]))
{
@ -503,11 +480,7 @@ static NSTimeInterval time_last_frame;
//
// shoot 'r' // switch on ident system
//
#if OOLITE_HAVE_JOYSTICK
if ([gameView isDown:key_ident_system] || joyButtonState[BUTTON_ID])
#else
if ([gameView isDown:key_ident_system])
#endif
{
// ident 'on' here
if (!ident_pressed)
@ -526,11 +499,7 @@ static NSTimeInterval time_last_frame;
//
// shoot 't' // switch on missile targetting
//
#if OOLITE_HAVE_JOYSTICK
if (([gameView isDown:key_target_missile] || joyButtonState[BUTTON_ARMMISSILE])&&(missile_entity[activeMissile]))
#else
if ([gameView isDown:key_target_missile] && missile_entity[activeMissile])
#endif
{
// targetting 'on' here
if (!target_missile_pressed)
@ -574,11 +543,7 @@ static NSTimeInterval time_last_frame;
//
// shoot 'u' // disarm missile targetting
//
#if OOLITE_HAVE_JOYSTICK
if ([gameView isDown:key_untarget_missile] || joyButtonState[BUTTON_UNARM])
#else
if ([gameView isDown:key_untarget_missile])
#endif
{
if (!safety_pressed)
{
@ -610,11 +575,7 @@ static NSTimeInterval time_last_frame;
//
// shoot 'e' // ECM
//
#if OOLITE_HAVE_JOYSTICK
if (([gameView isDown:key_ecm] || joyButtonState[BUTTON_ECM])&&(has_ecm))
#else
if ([gameView isDown:key_ecm] && has_ecm)
#endif
{
if (!ecm_in_operation)
{
@ -628,11 +589,7 @@ static NSTimeInterval time_last_frame;
//
// shoot 'tab' // Energy bomb
//
#if OOLITE_HAVE_JOYSTICK
if (([gameView isDown:key_energy_bomb] || joyButtonState[BUTTON_ENERGYBOMB])&&(has_energy_bomb))
#else
if ([gameView isDown:key_energy_bomb] && has_energy_bomb)
#endif
{
// original energy bomb routine
[self fireEnergyBomb];
@ -641,11 +598,7 @@ static NSTimeInterval time_last_frame;
//
// shoot 'escape' // Escape pod launch
//
#if OOLITE_HAVE_JOYSTICK
if (([gameView isDown:key_launch_escapepod] || joyButtonState[BUTTON_ESCAPE])&&(has_escape_pod)&&([UNIVERSE station]))
#else
if ([gameView isDown:key_launch_escapepod] && has_escape_pod && [UNIVERSE station])
#endif
{
found_target = [self launchEscapeCapsule];
@ -653,11 +606,7 @@ static NSTimeInterval time_last_frame;
//
// shoot 'd' // Dump Cargo
//
#if OOLITE_HAVE_JOYSTICK
if (([gameView isDown:key_dump_cargo] || joyButtonState[BUTTON_JETTISON])&&([cargo count] > 0))
#else
if ([gameView isDown:key_dump_cargo] && ([cargo count] > 0))
#endif
{
if ([self dumpCargo] != CARGO_NOT_CARGO)
{
@ -679,11 +628,7 @@ static NSTimeInterval time_last_frame;
//
// autopilot 'c'
//
#if OOLITE_HAVE_JOYSTICK
if ([gameView isDown:key_autopilot] || joyButtonState[BUTTON_DOCKCPU]) // look for the 'c' key
#else
if ([gameView isDown:key_autopilot]) // look for the 'c' key
#endif
{
if (has_docking_computer && (!autopilot_key_pressed)) // look for the 'c' key
{
@ -787,11 +732,7 @@ static NSTimeInterval time_last_frame;
//
// autopilot 'D'
//
#if OOLITE_HAVE_JOYSTICK
if ([gameView isDown:key_autodock] || joyButtonState[BUTTON_DOCKCPUFAST]) // look for the 'D' key
#else
if ([gameView isDown:key_autodock]) // look for the 'D' key
#endif
{
if (has_docking_computer && (!fast_autopilot_key_pressed)) // look for the 'D' key
{
@ -839,11 +780,7 @@ static NSTimeInterval time_last_frame;
//
// hyperspace 'h'
//
#if OOLITE_HAVE_JOYSTICK
if ([gameView isDown:key_hyperspace] || joyButtonState[BUTTON_HYPERDRIVE]) // look for the 'h' key
#else
if ([gameView isDown:key_hyperspace]) // look for the 'h' key
#endif
{
if (!hyperspace_pressed)
{
@ -910,11 +847,7 @@ static NSTimeInterval time_last_frame;
//
// Galactic hyperspace 'g'
//
#if OOLITE_HAVE_JOYSTICK
if (([gameView isDown:key_galactic_hyperspace] || joyButtonState[BUTTON_GALACTICDRIVE])&&(has_galactic_hyperdrive))// look for the 'g' key
#else
if ([gameView isDown:key_galactic_hyperspace] &&(has_galactic_hyperdrive))// look for the 'g' key
#endif
{
if (!galhyperspace_pressed)
{
@ -960,11 +893,7 @@ static NSTimeInterval time_last_frame;
//
// shoot '0' // Cloaking Device
//
#if OOLITE_HAVE_JOYSTICK
if (([gameView isDown:key_cloaking_device] || joyButtonState[BUTTON_CLOAK]) && has_cloaking_device)
#else
if ([gameView isDown:key_cloaking_device] && has_cloaking_device)
#endif
{
if (!cloak_pressed)
{

View File

@ -310,5 +310,16 @@ void quaternion_rotate_about_axis(Quaternion *quat, Vector axis, GLfloat angle)
NSString *QuaternionDescription(Quaternion quaternion)
{
return [NSString stringWithFormat:@"(%g + %gi + %gj + %gk)", quaternion.w, quaternion.x, quaternion.y, quaternion.z];
float x, y, z;
char xs, ys, zs;
x = fabsf(quaternion.x);
y = fabsf(quaternion.y);
z = fabsf(quaternion.z);
xs = (x == quaternion.x) ? '+' : '-';
ys = (y == quaternion.y) ? '+' : '-';
zs = (z == quaternion.z) ? '+' : '-';
return [NSString stringWithFormat:@"(%g %c %gi %c %gj %c %gk)", quaternion.w, xs, x, ys, y, zs, z];
}