|  | @@ -466,6 +466,7 @@ static void scsiDiskLoadConfig(int target_idx, const char *section)
 | 
											
												
													
														|  |      img.rightAlignStrings = ini_getbool(section, "RightAlignStrings", 0, CONFIGFILE);
 |  |      img.rightAlignStrings = ini_getbool(section, "RightAlignStrings", 0, CONFIGFILE);
 | 
											
												
													
														|  |      img.prefetchbytes = ini_getl(section, "PrefetchBytes", img.prefetchbytes, CONFIGFILE);
 |  |      img.prefetchbytes = ini_getl(section, "PrefetchBytes", img.prefetchbytes, CONFIGFILE);
 | 
											
												
													
														|  |      img.reinsert_on_inquiry = ini_getbool(section, "ReinsertCDOnInquiry", 0, CONFIGFILE);
 |  |      img.reinsert_on_inquiry = ini_getbool(section, "ReinsertCDOnInquiry", 0, CONFIGFILE);
 | 
											
												
													
														|  | 
 |  | +    img.reinsert_after_eject = ini_getbool(section, "ReinsertAfterEject", 1, CONFIGFILE);
 | 
											
												
													
														|  |      img.ejectButton = ini_getl(section, "EjectButton", 0, CONFIGFILE);
 |  |      img.ejectButton = ini_getl(section, "EjectButton", 0, CONFIGFILE);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      char tmp[32];
 |  |      char tmp[32];
 | 
											
										
											
												
													
														|  | @@ -547,7 +548,7 @@ image_config_t &scsiDiskGetImageConfig(int target_idx)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  static void diskEjectAction(uint8_t buttonId)
 |  |  static void diskEjectAction(uint8_t buttonId)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
												
													
														|  | -    log("Eject button pressed for channel ", buttonId);
 |  | 
 | 
											
												
													
														|  | 
 |  | +    bool found = false;
 | 
											
												
													
														|  |      for (uint8_t i = 0; i < S2S_MAX_TARGETS; i++)
 |  |      for (uint8_t i = 0; i < S2S_MAX_TARGETS; i++)
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
												
													
														|  |          image_config_t &img = g_DiskImages[i];
 |  |          image_config_t &img = g_DiskImages[i];
 | 
											
										
											
												
													
														|  | @@ -555,10 +556,17 @@ static void diskEjectAction(uint8_t buttonId)
 | 
											
												
													
														|  |          {
 |  |          {
 | 
											
												
													
														|  |              if (img.deviceType == S2S_CFG_OPTICAL)
 |  |              if (img.deviceType == S2S_CFG_OPTICAL)
 | 
											
												
													
														|  |              {
 |  |              {
 | 
											
												
													
														|  | 
 |  | +                found = true;
 | 
											
												
													
														|  | 
 |  | +                log("Eject button ", (int)buttonId, " pressed, passing to CD drive SCSI", (int)i);
 | 
											
												
													
														|  |                  cdromPerformEject(img);
 |  |                  cdromPerformEject(img);
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    if (!found)
 | 
											
												
													
														|  | 
 |  | +    {
 | 
											
												
													
														|  | 
 |  | +        log("Eject button ", (int)buttonId, " pressed, but no drives with EjectButton=", (int)buttonId, " setting found!");
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  uint8_t diskEjectButtonUpdate(bool immediate)
 |  |  uint8_t diskEjectButtonUpdate(bool immediate)
 | 
											
										
											
												
													
														|  | @@ -904,9 +912,12 @@ static int doTestUnitReady()
 | 
											
												
													
														|  |          scsiDev.target->sense.asc = MEDIUM_NOT_PRESENT;
 |  |          scsiDev.target->sense.asc = MEDIUM_NOT_PRESENT;
 | 
											
												
													
														|  |          scsiDev.phase = STATUS;
 |  |          scsiDev.phase = STATUS;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        // We are now reporting to host that the drive is open.
 |  | 
 | 
											
												
													
														|  | -        // Simulate a "close" for next time the host polls.
 |  | 
 | 
											
												
													
														|  | -        cdromSwitchNextImage(img);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if (img.reinsert_after_eject)
 | 
											
												
													
														|  | 
 |  | +        {
 | 
											
												
													
														|  | 
 |  | +            // We are now reporting to host that the drive is open.
 | 
											
												
													
														|  | 
 |  | +            // Simulate a "close" for next time the host polls.
 | 
											
												
													
														|  | 
 |  | +            cdromSwitchNextImage(img);
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |      else if (unlikely(!(blockDev.state & DISK_PRESENT)))
 |  |      else if (unlikely(!(blockDev.state & DISK_PRESENT)))
 | 
											
												
													
														|  |      {
 |  |      {
 |