From 4f997b7dba92d4dfe89e9ce146e84272970a1a76 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 13 Dec 2009 21:42:55 +0000 Subject: [PATCH] linux: add --nojoy=1 to skip joystick initialization (for folks with laptops that have accelerometers for joysticks) --- desmume/src/addons.cpp | 6 +----- desmume/src/addons.h | 6 +----- desmume/src/commandline.cpp | 5 +++++ desmume/src/commandline.h | 3 +++ desmume/src/ctrlssdl.cpp | 7 +++++++ 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/desmume/src/addons.cpp b/desmume/src/addons.cpp index 0f427bca2..27fbbd61b 100644 --- a/desmume/src/addons.cpp +++ b/desmume/src/addons.cpp @@ -1,8 +1,4 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2009 CrazyMax +/* Copyright (C) 2009 CrazyMax Copyright (C) 2009 DeSmuME team This file is part of DeSmuME diff --git a/desmume/src/addons.h b/desmume/src/addons.h index 9c5dbfc52..341d4e48a 100644 --- a/desmume/src/addons.h +++ b/desmume/src/addons.h @@ -1,8 +1,4 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2009 CrazyMax +/* Copyright (C) 2009 CrazyMax Copyright (C) 2009 DeSmuME team This file is part of DeSmuME diff --git a/desmume/src/commandline.cpp b/desmume/src/commandline.cpp index ccd0bbe2b..70ef44d04 100644 --- a/desmume/src/commandline.cpp +++ b/desmume/src/commandline.cpp @@ -31,6 +31,7 @@ #include "NDSSystem.h" int scanline_filter_a = 2, scanline_filter_b = 4; +int _commandline_linux_nojoy = 0; CommandLine::CommandLine() : is_cflash_configured(false) @@ -77,6 +78,9 @@ void CommandLine::loadCommonOptions() { "num-cores", 0, 0, G_OPTION_ARG_INT, &_num_cores, "Override numcores detection and use this many", "NUM_CORES"}, { "scanline-filter-a", 0, 0, G_OPTION_ARG_INT, &scanline_filter_a, "Intensity of fadeout for scanlines filter (edge) (default 2)", "SCANLINE_FILTER_A"}, { "scanline-filter-b", 0, 0, G_OPTION_ARG_INT, &scanline_filter_b, "Intensity of fadeout for scanlines filter (corner) (default 4)", "SCANLINE_FILTER_B"}, + #ifndef _MSC_VER + { "nojoy", 0, 0, G_OPTION_ARG_INT, &_commandline_linux_nojoy, "Disables joystick support", "NOJOY"}, + #endif #ifdef GDB_STUB { "arm9gdb", 0, 0, G_OPTION_ARG_INT, &arm9_gdb_port, "Enable the ARM9 GDB stub on the given port", "PORT_NUM"}, { "arm7gdb", 0, 0, G_OPTION_ARG_INT, &arm7_gdb_port, "Enable the ARM7 GDB stub on the given port", "PORT_NUM"}, @@ -108,6 +112,7 @@ bool CommandLine::parse(int argc,char **argv) if(_bios_arm9) { CommonSettings.UseExtBIOS = true; strcpy(CommonSettings.ARM9BIOS,_bios_arm9); } if(_bios_arm7) { CommonSettings.UseExtBIOS = true; strcpy(CommonSettings.ARM7BIOS,_bios_arm7); } if(_bios_swi) CommonSettings.SWIFromBIOS = true; + if(_bios_swi) CommonSettings.SWIFromBIOS = true; if (argc == 2) nds_file = argv[1]; diff --git a/desmume/src/commandline.h b/desmume/src/commandline.h index 2f377f072..7f1f0cf19 100644 --- a/desmume/src/commandline.h +++ b/desmume/src/commandline.h @@ -28,6 +28,9 @@ typedef struct _GOptionContext GOptionContext; typedef struct _GError GError; +//hacky commandline options that i didnt want to route through commonoptions +extern int _commandline_linux_nojoy; + //this class will also eventually try to take over the responsibility of using the args that it handles //for example: preparing the emulator run by loading the rom, savestate, and/or movie in the correct pattern. //it should also populate CommonSettings with its initial values diff --git a/desmume/src/ctrlssdl.cpp b/desmume/src/ctrlssdl.cpp index 5c85f4c81..eefab18a4 100644 --- a/desmume/src/ctrlssdl.cpp +++ b/desmume/src/ctrlssdl.cpp @@ -23,6 +23,7 @@ #include "ctrlssdl.h" #include "saves.h" #include "SPU.h" +#include "commandline.h" u16 keyboard_cfg[NB_KEYS]; u16 joypad_cfg[NB_KEYS]; @@ -90,6 +91,12 @@ BOOL init_joy( void) { int i; BOOL joy_init_good = TRUE; + //user asked for no joystick + if(_commandline_linux_nojoy) { + printf("skipping joystick init\n"); + return TRUE; + } + set_joy_keys(default_joypad_cfg); if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1)