Post subject: FCEU Input Display patch
Joined: 12/3/2005
Posts: 20
I hacked together a quick and dirty input display patch, taking advantage of FCEU_DispMessage. Use -inputdisp x to tell fceu how many controllers' inputs you want to see, 0 is off (like normal). There won't be an option in the windows gui, because I couldn't have tested it if I had tried to put one in, but maybe the command line argument will work. I don't know for sure. I don't know how to generate a good diff, but hopefully this will work well enough. When I tested it, running patch -p0 < patchfile from the fceu-nitsuja-src directory worked ok after I made sure the carrieage returns were correct.
diff -NaHudr --strip-trailing-cr orig.fceu-nitsuja-src/src/driver.h fceu-nitsuja-src/src/driver.h
--- orig.fceu-nitsuja-src/src/driver.h	2005-12-08 14:02:47.000000000 -0600
+++ fceu-nitsuja-src/src/driver.h	2005-12-08 18:14:50.000000000 -0600
@@ -126,6 +126,9 @@
 /* Deallocates all allocated memory.  Call after FCEUI_Emulate() returns. */
 void FCEUI_Kill(void);
 
+/* Set number of controllers to display input of */
+void FCEUI_SetInputDisplay(int a);
+
 /* Enable/Disable game genie. a=0 disable, a=1 enable */
 void FCEUI_SetGameGenie(int a);
 
diff -NaHudr --strip-trailing-cr orig.fceu-nitsuja-src/src/drivers/pc/main.c fceu-nitsuja-src/src/drivers/pc/main.c
--- orig.fceu-nitsuja-src/src/drivers/pc/main.c	2005-12-08 14:02:22.000000000 -0600
+++ fceu-nitsuja-src/src/drivers/pc/main.c	2005-12-08 18:13:15.000000000 -0600
@@ -44,6 +44,7 @@
 static char *soundrecfn=0;	/* File name of sound recording. */
 
 static int ntsccol=0,ntschue=0,ntsctint=0;
+int inputdisp=0;
 int soundvol=100;
 long soundq=0;
 int _sound=1;
@@ -111,6 +112,7 @@
 extern CFGSTRUCT GUIConfig;
 #endif
 static CFGSTRUCT fceuconfig[]={
+	AC(inputdisp),
 	AC(soundrate),
 	AC(soundq),
 	AC(_sound),
@@ -224,6 +226,8 @@
          {"-cpalette",0,&cpalette,0x4001},
 	 {"-soundrecord",0,&soundrecfn,0x4001},
 
+	 {"-inputdisp",0,&inputdisp,0},
+
          {"-ntsccol",0,&ntsccol,0},
          {"-pal",0,&eoptions,0x8000|EO_PAL},
 
@@ -258,6 +262,8 @@
         FCEUI_DisableSpriteLimitation(eoptions&1);
 	FCEUI_SetSnapName(eoptions&EO_SNAPNAME);
 
+	FCEUI_SetInputDisplay(inputdisp);
+
 	for(x=0;x<2;x++)
 	{
          if(srendlinev[x]<0 || srendlinev[x]>239) srendlinev[x]=0;
diff -NaHudr --strip-trailing-cr orig.fceu-nitsuja-src/src/drivers/pc/main.h fceu-nitsuja-src/src/drivers/pc/main.h
--- orig.fceu-nitsuja-src/src/drivers/pc/main.h	2005-12-08 14:02:23.000000000 -0600
+++ fceu-nitsuja-src/src/drivers/pc/main.h	2005-12-08 17:27:57.000000000 -0600
@@ -41,6 +41,7 @@
 extern int srendlinev[2],erendlinev[2];
 extern int NoWaiting;
 
+extern int inputdisp;
 extern int soundvol;
 extern long soundq;
 extern int _sound;
diff -NaHudr --strip-trailing-cr orig.fceu-nitsuja-src/src/drivers/pc/usage.h fceu-nitsuja-src/src/drivers/pc/usage.h
--- orig.fceu-nitsuja-src/src/drivers/pc/usage.h	2005-12-08 14:02:24.000000000 -0600
+++ fceu-nitsuja-src/src/drivers/pc/usage.h	2005-12-08 17:27:10.000000000 -0600
@@ -41,6 +41,7 @@
 -fcexp str	Select Famicom expansion port device.\n\
 		 str may be: none, shadow, arkanoid, 4player, fkb\n\
 -inputcfg s	Configure virtual input device \"s\".\n\
+-inputdisp x	Display input from first x controllers.\n\
 -nofs x		Disables Four-Score emulation if x is 1.\n\
 -gg x           Enable Game Genie emulation if x is 1.\n\
 -no8lim x       Disables the 8 sprites per scanline limitation.\n\
diff -NaHudr --strip-trailing-cr orig.fceu-nitsuja-src/src/fceu.c fceu-nitsuja-src/src/fceu.c
--- orig.fceu-nitsuja-src/src/fceu.c	2005-12-08 14:02:46.000000000 -0600
+++ fceu-nitsuja-src/src/fceu.c	2005-12-08 18:19:39.000000000 -0600
@@ -556,6 +556,11 @@
  return(PAL);
 }
 
+void FCEUI_SetInputDisplay(int a)
+{
+ FSettings.InputDisplay=a;
+}
+
 void FCEUI_SetGameGenie(int a)
 {
  FSettings.GameGenie=a?1:0;
diff -NaHudr --strip-trailing-cr orig.fceu-nitsuja-src/src/fceu.h fceu-nitsuja-src/src/fceu.h
--- orig.fceu-nitsuja-src/src/fceu.h	2005-12-08 14:02:47.000000000 -0600
+++ fceu-nitsuja-src/src/fceu.h	2005-12-08 16:39:46.000000000 -0600
@@ -71,6 +71,7 @@
 	   uint32 SndRate;
 	   int soundq;
 	   int lowpass;
+	   int InputDisplay;
 } FCEUS;
 
 extern FCEUS FSettings;
diff -NaHudr --strip-trailing-cr orig.fceu-nitsuja-src/src/input.c fceu-nitsuja-src/src/input.c
--- orig.fceu-nitsuja-src/src/input.c	2005-12-08 14:02:46.000000000 -0600
+++ fceu-nitsuja-src/src/input.c	2005-12-08 16:56:50.000000000 -0600
@@ -169,6 +169,43 @@
 static INPUTC GPC={ReadGP,0,StrobeGP,0,0,0};
 static INPUTC GPCVS={ReadGPVS,0,StrobeGP,0,0,0};
 
+void FCEU_PrintInput()
+{
+	char inputs[37];
+	char buttons[] = "ABsS^v<>";
+	int x,n;
+	switch(FSettings.InputDisplay)
+	{
+		case 1:
+			strcpy(inputs," --------");
+			break;
+		case 2:
+			strcpy(inputs," -------- --------");
+			break;
+		case 3:
+			strcpy(inputs," -------- -------- --------");
+			break;
+		case 4:
+			strcpy(inputs," -------- -------- -------- --------");
+			break;
+		default:
+			FSettings.InputDisplay = 0;
+			return;
+	}
+
+	for (x=0;x<FSettings.InputDisplay;x++)
+	{
+		for (n=0;n<8;n++)
+		{
+			if (1 & (joy[x] >> n))
+			{
+				inputs[1+4*x+n] = buttons[n];
+			}
+		}
+	}
+	FCEU_DispMessage(inputs);
+}
+
 void FCEU_DrawInput(uint8 *buf)
 {
  int x;
diff -NaHudr --strip-trailing-cr orig.fceu-nitsuja-src/src/video.c fceu-nitsuja-src/src/video.c
--- orig.fceu-nitsuja-src/src/video.c	2005-12-08 14:02:46.000000000 -0600
+++ fceu-nitsuja-src/src/video.c	2005-12-08 16:47:27.000000000 -0600
@@ -182,6 +182,8 @@
         }
 //		if(!movieDrawInAVI)
 	        DrawMessage();
+	if(FSettings.InputDisplay)
+		FCEU_PrintInput();
         FCEU_DrawInput(XBuf);
 }

Active player (411)
Joined: 3/16/2004
Posts: 2623
Location: America, Québec
There's already that feature for Win version.
Emulator Coder, Skilled player (1310)
Joined: 12/21/2004
Posts: 2687
Well, it might as well be added to the non-Win version. Actually, there's nothing platform-specific about the implementation for Windows except that its code would need to be duplicated for each platform (going by the current code structure), but this is implemented fairly differently and possibly makes more sense for this platform.
Joined: 12/3/2005
Posts: 20
Hm, I was planning to clean this one up a little (mostly fix it so that it doesn't take over the message bar), but I'll take a look at the windows input display code first. A quick question, in the drivers directory, the linux/bsd port builds with the pc/ directory, but does it build with win/ and NOT pc/ when compiled for windows, or does it use code from both directories? I don't have a copy of the source on this computer, but it seemed like they had some of the same files, so I wasn't sure if changes in drivers/pc/ would affect the windows version at all or not. Also, someone might want to update the Emulator Tools page on the FAQ to say that Input Display is available for windows FCEU. At the moment it says the option is not available at all.
Joined: 12/3/2005
Posts: 20
Ok, I looked at the existing InputDisplay code, and I'm a little embarrased that I spent so much time writing a patch for an existing feature. Here's the new 'patch'.
diff -NaHudr --strip-trailing-cr orig.fceu-nitsuja-src/src/drivers/pc/input.c fc
eu-nitsuja-src/src/drivers/pc/input.c
--- orig.fceu-nitsuja-src/src/drivers/pc/input.c        2005-12-08 14:02:22.0000
00000 -0600
+++ fceu-nitsuja-src/src/drivers/pc/input.c     2005-12-11 13:35:44.000000000 -0
600
@@ -195,6 +195,7 @@
   if(keyonly(MINUS)) DecreaseEmulationSpeed();
   if(keyonly(EQUAL)) IncreaseEmulationSpeed();
   if(keyonly(BACKSPACE)) FCEUI_MovieToggleFrameDisplay();
+  if(keyonly(COMMA)) FCEUI_ToggleInputDisplay();
   if(keyonly(BACKSLASH)) FCEUI_ToggleEmulationPause();
   if(keyonly(RIGHTCONTROL)) FCEUI_FrameAdvance();
Yeah, it's just one line. Oh well. I learned a lot about the fceu source, so it wasn't a complete waste of time. Also, is there a way that I can become an editor of the wiki? There are a couple things that need updated on the Emulator Tools page, and I seem to be finding more every day or two.
Former player
Joined: 10/27/2004
Posts: 518
question (s): -how do i apply this patch (very specifically, im no good when it comes to something more than just UNZIP rar file)? -if this IS in the windows version (meaning i wont need this patch?) how do i get it to show the input? i checked all through the options. thanks for any help.
Emulator Coder, Skilled player (1310)
Joined: 12/21/2004
Posts: 2687
/*- wrote:
if this IS in the windows version (meaning i wont need this patch?) how do i get it to show the input? i checked all through the options.
It is in the windows version already. First, make sure you have the right version. Choose Help->About... from FCEU and it should say "FCE Ultra 0.98.15". If it doesn't say that, download the new version from the emulators download page. Now, you should be able to press comma (,) to turn on input display in that version. But it's a configurable hotkey, so there's a chance that its hotkey isn't set right. Go to Config->Map Hotkeys... and scroll down to something with type="Misc." and Command="Toggle Input Display", and set that if it's not already set. (Or you could just hit Restore Defaults if you don't mind resetting the hotkeys.)
Former player
Joined: 10/27/2004
Posts: 518
ah... i still had one of the earlier left+right versions. should have figured that it'd be improved upon. thanks, nitsuja.