From: <sv...@ww...> - 2006-04-15 17:42:06
|
Author: mkrose Date: 2006-04-15 10:41:57 -0700 (Sat, 15 Apr 2006) New Revision: 1898 Modified: trunk/csp/tools/hid/README trunk/csp/tools/map2hid Log: Update the hid readme and add a default include path to map2hid to make it easier to use. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1898 Modified: trunk/csp/tools/hid/README =================================================================== --- trunk/csp/tools/hid/README 2006-04-15 06:50:52 UTC (rev 1897) +++ trunk/csp/tools/hid/README 2006-04-15 17:41:57 UTC (rev 1898) @@ -1,63 +1,41 @@ Input maps for CSPSim -======================================================================== +============================================================================== -Currently there are two important input maps that you must have for -CSPSim to function properly. One is called the "gamescreen" map, -which handles commands like Exit, Pause, Change views, etc. The -other is the "vehicle" map which is used to control the current -vehicle. As the only vehicle right now is the Mirage 2000, the -vehicle map you need is 'aircraft.map'. The input mapping system -is designed to be highly sophisticated and flexible, but here we -just present some of the basics for getting started. If you want -to learn more about programming map files, see README.map. +Currently there are two important input maps that you must have for CSPSim to +function properly. One is called the "gamescreen" map, which handles commands +like Exit, Pause, Change views, etc. The other is the "vehicle" map which is +used to control the current vehicle. As the only vehicle right now is the +Mirage 2000, the vehicle map you need is 'aircraft.map'. The input mapping +system is designed to be highly sophisticated and flexible, but here we just +present some of the basics for getting started. If you want to learn more +about programming map files, see README.map. -The first this you must do is create "customized" maps. The maps -available in CVS are often updated with new functionality, so it -is best to create your own maps that extend these basic maps. This -way whenever the CVS maps are updated you will then gain the new -functionality without losing any of your customizations. +The first this you must do is create "customized" maps. The maps available in +CVS are often updated with new functionality, so it is best to create your own +maps that extend these basic maps. This way whenever the CVS maps are updated +you will then gain the new functionality without losing any of your +customizations. -To start, copy aircraft.map and gamescreen.map from the Examples -directory to the current directory. These will be your custom -maps. They automatically include the appropriate maps in the Maps -directory, and these key bindings which should be fine to start -with. You should however modify the joystick axis binding to suit -your particular stick and throttle. There are some stick bindings -in Examples/aircraft.map that may or may not work for you since -the axis number vary from stick to stick. +To start, copy aircraft.map and gamescreen.map from the Examples directory to +the current directory. These will be your custom maps. They automatically +include the appropriate maps in the Maps directory, and these key bindings +which should be fine to start with. You should however modify the joystick +axis binding to suit your particular stick and throttle. There are some stick +bindings in Examples/aircraft.map that may or may not work for you since the +axis number vary from stick to stick. -Under Linux you can run the jstest utility (which is included in -most distributions) to see which axis numbers your stick, throttle, -and rudders map to. I'm not sure of a simple way to determine this -under Windows, but if all else fails you can resort to trial and -error. /* can one of the windows developers please comment on -this? */ +Under Linux you can run the jstest utility (which is included in most +distributions) to see which axis numbers your stick, throttle, and rudders map +to. I'm not sure of a simple way to determine this under Windows, but if all +else fails you can resort to trial and error. /* can one of the windows +developers please comment on this? */ -After you modify a map file, you must create a corresponding "hid" -(human interface device) file for use in the simulation. To do so, -use the cspinput tool in this directory. The resulting hid files -must be placed in the CSPSim Data/Input directory before they can -be used. +After you modify a map file, you must create a corresponding "hid" (human +interface device) file for use in the simulation. To do so, use the cspinput +tool in this directory. The resulting hid files must be placed in the CSPSim +Data/Input directory before they can be used. -Here are some examples for converting from map to hid under Linux: +Here is an example for converting from map to hid: - $ ./compile.py aircraft.map - $ cp aircraft.hid ../../data/input +$ python tools/map2hid tools/hid/examples/aircraft.map data/input/aircraft.hid -or - - $ ./compile aircraft.map - >../../data/input - -and under Windows: - - > python compile.py aircraft.map - > copy aircraft.hid ..\..\data\input - -or - - > python compile.py aircraft.map - >..\..\data\input - -Also under Windows you can usually just drag and drop your map -file onto the cspinput icon, then drag the resulting hid file to -the data\input directory. - Modified: trunk/csp/tools/map2hid =================================================================== --- trunk/csp/tools/map2hid 2006-04-15 06:50:52 UTC (rev 1897) +++ trunk/csp/tools/map2hid 2006-04-15 17:41:57 UTC (rev 1898) @@ -22,9 +22,10 @@ Converts interface definitions (.map) to a condensed format used by the simulation (.hid). -Usage: %(prog)s [options] [infile|-] [outfile|-] +Usage: %(prog)s [options] infile [outfile|-] """ +import os import sys from csp.base import app @@ -36,6 +37,14 @@ app.usage() return 1 + include_path = app.options.include_path + + # for convenience, add the default include path if the program appears + # to have been run from the tools directory. + program_path = os.path.dirname(app.programPath()) + if program_path.lower().endswith('tools'): + include_path.append(os.path.join(program_path, 'hid')) + outfile = sys.stdout if len(args) == 2 and args[1] != '-': outfile = args[1] @@ -43,10 +52,11 @@ if args: infile = args[0] else: - infile = '-' + app.usage() + return 1 try: - compiler.MapCompiler.compile(infile, outfile, include_path=app.options.include_path) + compiler.MapCompiler.compile(infile, outfile, include_path=include_path) except compiler.Error, e: print str(e) return 1 |