Fix hwengine crash when using >1 controllers
Reason: Data type mismatch for SDL_JoystickName, we wed in an index, but it expected a controller handle.
Solution: Switch to SDL_JoystickNameForIndex.
module Main( main ) whereimport System.Console.GetOptimport System.Environmentimport System.Exitimport System.IOimport Data.Maybe( fromMaybe, isJust, fromJust )import Data.List (find, intercalate)import Control.Monadimport Pas2Cmain = do args <- getArgs if length args == 0 then do name <- getProgName hPutStrLn stderr $ usageInfo header options exitFailure else do case getOpt RequireOrder options args of (flags, [], []) | enoughFlags flags -> do let m = flag flags isName let i = flag flags isInput let o = flag flags isOutput let a = fromMaybe o $ liftM extractString $ find isAlt flags let symbols = ["PAS2C", "FPC"] ++ (map extractString $ filter isSymbol flags) hPutStrLn stdout $ "--------Pas2C Config--------" hPutStrLn stdout $ "Main module: " ++ m hPutStrLn stdout $ "Input path : " ++ i hPutStrLn stdout $ "Output path: " ++ o hPutStrLn stdout $ "Altern path: " ++ a hPutStrLn stdout $ "Symbols defined: " ++ (intercalate ", " symbols) hPutStrLn stdout $ "----------------------------" pas2C m (i++"/") (o++"/") (a++"/") symbols hPutStrLn stdout $ "----------------------------" | otherwise -> error $ usageInfo header options (_, nonOpts, []) -> error $ "unrecognized arguments: " ++ unwords nonOpts (_, _, msgs) -> error $ usageInfo header options where header = "Freepascal to C conversion! Please specify -n -i -o options.\n" enoughFlags f = and $ map (isJust . flip find f) [isName, isInput, isOutput] flag f = extractString . fromJust . flip find fdata Flag = HelpMessage | Name String | Input String | Output String | Alternate String | Symbol StringextractString :: Flag -> StringextractString (Name s) = sextractString (Input s) = sextractString (Output s) = sextractString (Alternate s) = sextractString (Symbol s) = sextractString _ = undefinedisName, isInput, isOutput, isAlt, isSymbol :: Flag -> BoolisName (Name _) = TrueisName _ = FalseisInput (Input _) = TrueisInput _ = FalseisOutput (Output _) = TrueisOutput _ = FalseisAlt (Alternate _) = TrueisAlt _ = FalseisSymbol (Symbol _) = TrueisSymbol _ = Falseoptions :: [OptDescr Flag]options = [ Option ['h'] ["help"] (NoArg HelpMessage) "print this help message", Option ['n'] ["name"] (ReqArg Name "MAIN") "name of the main Pascal module", Option ['i'] ["input"] (ReqArg Input "DIR") "input directory, where .pas files will be read", Option ['o'] ["output"] (ReqArg Output "DIR") "output directory, where .c/.h files will be written", Option ['a'] ["alternate"] (ReqArg Alternate "DIR") "alternate input directory, for out of source builds", Option ['d'] ["define"] (ReqArg Symbol "SYMBOL") "define symbol" ]