示例#1
0
/*
 * Reset emulator
 */
static void do_reset_machine (int hardreset)
{
#ifdef SAVESTATE
    if (savestate_state == STATE_RESTORE)
	restore_state (savestate_fname);
    else if (savestate_state == STATE_REWIND)
	savestate_rewind ();
#endif
    /* following three lines must not be reordered or
     * fastram state restore breaks
     */
    reset_all_systems ();
    customreset ();
    m68k_reset ();
    if (hardreset) {
	memset (chipmemory, 0, allocated_chipmem);
	write_log ("chipmem cleared\n");
    }
#ifdef SAVESTATE
    /* We may have been restoring state, but we're done now.  */
    if (savestate_state == STATE_RESTORE || savestate_state == STATE_REWIND)
    {
	map_overlay (1);
	fill_prefetch_slow (&regs); /* compatibility with old state saves */
    }
    savestate_restore_finish ();
#endif

    fill_prefetch_slow (&regs);
    if (currprefs.produce_sound == 0)
	eventtab[ev_audio].active = 0;
    handle_active_events ();

    inputdevice_updateconfig (&currprefs);
}
示例#2
0
文件: main.cpp 项目: Vairn/WinUAE
void do_start_program (void)
{
	if (quit_program == -1)
		return;
	if (!canbang && candirect < 0)
		candirect = 0;
	if (canbang && candirect < 0)
		candirect = 1;
	/* Do a reset on startup. Whether this is elegant is debatable. */
	inputdevice_updateconfig (&currprefs);
	if (quit_program >= 0)
		quit_program = 2;
#if (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER)
	extern int EvalException (LPEXCEPTION_POINTERS blah, int n_except);
	__try
#endif
	{
		m68k_go (1);
	}
#if (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER)
#ifdef JIT
	__except (EvalException (GetExceptionInformation (), GetExceptionCode ()))
#else
	__except (DummyException (GetExceptionInformation (), GetExceptionCode ()))
#endif
	{
		// EvalException does the good stuff...
	}
#endif
}
示例#3
0
文件: main.cpp 项目: Luis45ccs/WinUAE
void do_start_program (void)
{
	if (quit_program == -UAE_QUIT)
		return;
	/* Do a reset on startup. Whether this is elegant is debatable. */
	inputdevice_updateconfig (&changed_prefs, &currprefs);
	if (quit_program >= 0)
		quit_program = UAE_RESET;
#ifdef WITH_LUA
	uae_lua_loadall ();
#endif
#ifdef USE_STRUCTURED_EXCEPTION_HANDLING
	__try
#endif
	{
		m68k_go (1);
	}
#ifdef USE_STRUCTURED_EXCEPTION_HANDLING
#ifdef JIT
	__except (EvalException(GetExceptionInformation()))
#else
	__except (DummyException (GetExceptionInformation (), GetExceptionCode ()))
#endif
	{
		// EvalException does the good stuff...
	}
#endif
}
示例#4
0
void do_start_program (void)
{
	if (quit_program == -UAE_QUIT)
		return;
	/* Do a reset on startup. Whether this is elegant is debatable. */
	inputdevice_updateconfig (&changed_prefs, &currprefs);
	if (quit_program >= 0)
		quit_program = UAE_RESET;
#ifdef WITH_LUA
	uae_lua_loadall ();
#endif
#if (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER)
	extern int EvalException (LPEXCEPTION_POINTERS blah, int n_except);
	__try
#endif
	{
		m68k_go (1);
	}
#if (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER)
#ifdef JIT
	__except (EvalException (GetExceptionInformation (), GetExceptionCode ()))
#else
	__except (DummyException (GetExceptionInformation (), GetExceptionCode ()))
#endif
	{
		// EvalException does the good stuff...
	}
#endif
}
示例#5
0
void do_start_program (void)
{
    if (quit_program == -1)
        return;
    /* Do a reset on startup. Whether this is elegant is debatable. */
    inputdevice_updateconfig (&currprefs);
//    if (quit_program >= 0)
        quit_program = 2;
    m68k_go (1);
}
示例#6
0
文件: main.c 项目: ezgranny420/PUAE
void do_start_program (void)
{
	if (quit_program == -1)
		return;
#ifdef JIT
	if (!canbang && candirect < 0)
		candirect = 0;
	if (canbang && candirect < 0)
		candirect = 1;
#endif
	/* Do a reset on startup. Whether this is elegant is debatable. */
	inputdevice_updateconfig (&currprefs);
	if (quit_program >= 0)
		quit_program = 2;
	m68k_go (1);
}
示例#7
0
int gui_init (void)
{
//  MyThread *QT_GUI_Thread=new MyThread;
//	QT_GUI_Thread->start();
	int ret;
	
	read_rom_list ();
	inputdevice_updateconfig (&workprefs, &currprefs);
 
        for (;;) {
                ret = GetSettings (1);
                if (!restart_requested)
                        break;
                restart_requested = 0;
        }
#ifdef AVIOUTPUT
        if (ret > 0) {
                AVIOutput_Begin ();
        }
#endif
        return ret;
}
示例#8
0
static void values_to_dialog(void)
{
	inputdevice_updateconfig (NULL, &workprefs);

  RefreshPanelGamePort();
}
示例#9
0
void clearallkeys (void)
{
	inputdevice_updateconfig (&currprefs);
}
示例#10
0
文件: rp.cpp 项目: biglad/WinUAE
int port_insert_custom (int inputmap_port, int devicetype, DWORD flags, const TCHAR *custom)
{
	const TCHAR *p = custom;
	int mode, *events, *axistable;
	int max, evtnum;
	int kb;
	const TCHAR **eventorder;

	eventorder = getcustomeventorder (&devicetype);
	if (!eventorder)
		return FALSE;

	kb = inputdevice_get_device_total (IDTYPE_JOYSTICK) + inputdevice_get_device_total (IDTYPE_MOUSE);

	inputdevice_updateconfig_internal (&changed_prefs);
	inputdevice_compa_prepare_custom (&changed_prefs, inputmap_port, devicetype);
	inputdevice_updateconfig_internal (&changed_prefs);
	max = inputdevice_get_compatibility_input (&changed_prefs, inputmap_port, &mode, &events, &axistable);
	write_log (_T("custom='%s' max=%d port=%d dt=%d kb=%d kbnum=%d\n"), custom, max, inputmap_port, devicetype, kb, inputdevice_get_device_total (IDTYPE_KEYBOARD));
	if (!max)
		return FALSE;

	while (p && p[0]) {
		int idx = -1, kc = -1;
		int flags = 0;
		int eventlen;

		const TCHAR *p2 = _tcschr (p, '=');
		if (!p2)
			break;
		const TCHAR *p4 = p;
		eventlen = -1;
		for (;;) {
			const TCHAR *p3 = _tcschr (p4, '.');
			if (!p3 || p3 >= p2) {
				p3 = NULL;
				if (eventlen < 0)
					eventlen = p2 - p;
				break;
			}
			if (eventlen < 0)
				eventlen = p3 - p;
			if (!_tcsnicmp (p3 + 1, L"autorepeat", 10))
				flags |= IDEV_MAPPED_AUTOFIRE_SET;
			p4 = p3 + 1;
		}
		
		for (int i = 0; eventorder[i]; i++) {
			if (_tcslen (eventorder[i]) == eventlen && !_tcsncmp (p, eventorder[i], eventlen)) {
				idx = i;
				break;
			}
		}
		p2++;
		if (p2[0] == '0' && (p2[1] == 'x' || p2[1] == 'X'))
			kc = _tcstol (p2 + 2, NULL, 16);
		else
			kc = _tstol (p2);
		p = _tcschr (p2, ' ');
		if (p)
			p++;

		if (idx < 0)
			continue;
		if (kc < 0)
			continue;

		evtnum = events[idx];

		write_log (_T("kb=%d evt=%d kc=%02x flags=%08x\n"), kb, evtnum, kc, flags);

		for (int j = 0; j < inputdevice_get_device_total (IDTYPE_KEYBOARD); j++) {
			int wdnum = -1;
			for (int i = 0; i < inputdevicefunc_keyboard.get_widget_num (j); i++) {
				uae_u32 kc2 = 0;
				inputdevicefunc_keyboard.get_widget_type (j, i, NULL, &kc2);
				if (kc == kc2) {
					wdnum = i;
					break;
				}
			}
			if (wdnum >= 0) {
				//write_log (_T("kb=%d (%s) wdnum=%d\n"), j, inputdevicefunc_keyboard.get_friendlyname (j), wdnum);
				inputdevice_set_gameports_mapping (&changed_prefs, kb + j, wdnum, evtnum, flags, inputmap_port);
				inputdevice_set_gameports_mapping (&currprefs, kb + j, wdnum, evtnum, flags, inputmap_port);
			} else {
				write_log (_T("kb=%d (%): keycode %02x not found!\n"), j, inputdevicefunc_keyboard.get_friendlyname (j), kc);
			}
		}
	}

	inputdevice_updateconfig_internal (&changed_prefs);
	inputdevice_updateconfig (&currprefs);
	return TRUE;
}
示例#11
0
    void action(const gcn::ActionEvent& actionEvent)
    {
      if (actionEvent.getSource() == cboPort0) {
        // Handle new device in port 0
        switch(cboPort0->getSelected()) {
          case 0: changed_prefs.jports[0].id = JSEM_MICE;     changed_prefs.jports[0].mode = JSEM_MODE_MOUSE; break;
          case 1: changed_prefs.jports[0].id = JSEM_MICE + 1; changed_prefs.jports[0].mode = JSEM_MODE_MOUSE; break;
          case 2: changed_prefs.jports[0].id = JSEM_JOYS;     changed_prefs.jports[0].mode = JSEM_MODE_JOYSTICK; break;
          case 3: changed_prefs.jports[0].id = JSEM_JOYS;     changed_prefs.jports[0].mode = JSEM_MODE_JOYSTICK_CD32; break;
          case 4: changed_prefs.jports[0].id = -1;            changed_prefs.jports[0].mode = JSEM_MODE_DEFAULT; break;
          default:changed_prefs.jports[0].id = JSEM_JOYS + cboPort0->getSelected() - 4;
                  changed_prefs.jports[0].mode = JSEM_MODE_JOYSTICK;
                  break;
        }
        inputdevice_updateconfig(NULL, &changed_prefs);
      }
      
      else if (actionEvent.getSource() == cboPort1) {
        // Handle new device in port 1
        switch(cboPort1->getSelected()) {
          case 0: changed_prefs.jports[1].id = JSEM_MICE;     changed_prefs.jports[1].mode = JSEM_MODE_MOUSE; break;
          case 1: changed_prefs.jports[1].id = JSEM_MICE + 1; changed_prefs.jports[1].mode = JSEM_MODE_MOUSE; break;
          case 2: changed_prefs.jports[1].id = JSEM_JOYS;     changed_prefs.jports[1].mode = JSEM_MODE_JOYSTICK; break;
          case 3: changed_prefs.jports[1].id = JSEM_JOYS;     changed_prefs.jports[1].mode = JSEM_MODE_JOYSTICK_CD32; break;
          case 4: changed_prefs.jports[1].id = -1;            changed_prefs.jports[1].mode = JSEM_MODE_DEFAULT; break;
          default:changed_prefs.jports[1].id = JSEM_JOYS + cboPort1->getSelected() - 4;
                  changed_prefs.jports[1].mode = JSEM_MODE_JOYSTICK;
                  break;
        }
        inputdevice_updateconfig(NULL, &changed_prefs);
      }
      
      else if (actionEvent.getSource() == cboAutofire)
      {
        if(cboAutofire->getSelected() == 0)
          changed_prefs.input_autofire_linecnt = 0;
        else if(cboAutofire->getSelected() == 1)
          changed_prefs.input_autofire_linecnt = 12 * 312;
        else if (cboAutofire->getSelected() == 2)
          changed_prefs.input_autofire_linecnt = 8 * 312;
        else
          changed_prefs.input_autofire_linecnt = 4 * 312;
      }
      
 	    else if (actionEvent.getSource() == sldMouseSpeed)
 	    {
    		changed_prefs.input_joymouse_multiplier = mousespeed_values[(int)(sldMouseSpeed->getValue())];
    		RefreshPanelInput();
    	}
#ifndef RASPBERRY
      else if (actionEvent.getSource() == cboTapDelay)
      {
        if(cboTapDelay->getSelected() == 0)
          changed_prefs.pandora_tapDelay = 10;
        else if (cboTapDelay->getSelected() == 1)
          changed_prefs.pandora_tapDelay = 5;
        else
          changed_prefs.pandora_tapDelay = 2;
      }

    	else if (actionEvent.getSource() == chkMouseHack)
  	  {
  	    changed_prefs.input_tablet = chkMouseHack->isSelected() ? TABLET_MOUSEHACK : TABLET_OFF;
  	  }
#endif
 	    else if (actionEvent.getSource() == chkCustomCtrl)
 	      changed_prefs.pandora_customControls = chkCustomCtrl->isSelected() ? 1 : 0;
 	        
 	    else if (actionEvent.getSource() == cboA)
        customControlMap[VK_A] = amigaKey[cboA->getSelected()];

 	    else if (actionEvent.getSource() == cboB)
        customControlMap[VK_B] = amigaKey[cboB->getSelected()];

 	    else if (actionEvent.getSource() == cboX)
        customControlMap[VK_X] = amigaKey[cboX->getSelected()];

 	    else if (actionEvent.getSource() == cboY)
        customControlMap[VK_Y] = amigaKey[cboY->getSelected()];

 	    else if (actionEvent.getSource() == cboL)
        customControlMap[VK_L] = amigaKey[cboL->getSelected()];

 	    else if (actionEvent.getSource() == cboR)
        customControlMap[VK_R] = amigaKey[cboR->getSelected()];

 	    else if (actionEvent.getSource() == cboUp)
        customControlMap[VK_UP] = amigaKey[cboUp->getSelected()];

 	    else if (actionEvent.getSource() == cboDown)
        customControlMap[VK_DOWN] = amigaKey[cboDown->getSelected()];

 	    else if (actionEvent.getSource() == cboLeft)
        customControlMap[VK_LEFT] = amigaKey[cboLeft->getSelected()];

 	    else if (actionEvent.getSource() == cboRight)
        customControlMap[VK_RIGHT] = amigaKey[cboRight->getSelected()];

 	    else if (actionEvent.getSource() == KeyForMenu)
        changed_prefs.key_for_menu = ControlKey_SDLKeyValues[KeyForMenu->getSelected()] ;

    }
示例#12
0
/* handle_message()
 *
 * This is called from the GUI when a GUI event happened. Specifically,
 * HandleMessage (PPP_Messaging) forwards dispatched UI action
 * messages posted from JavaScript to handle_message().
 */
int32_t handle_message(const char* msg) {
    /* Grammar for messages from the UI:
     *
     * message ::= 'insert' drive fileURL
     *           | 'rom' fileURL
     *           | 'connect' port input
     *           | 'eject' drive
     *           | 'reset' | 'pause' | 'resume'
     *           | 'resize' <width> <height>
     * device  ::= 'kickstart' | drive
     * drive   ::= 'df0' | 'df1'
     * port    ::= 'port0' | 'port1'
     * input   ::= 'mouse' | 'joy0' | 'joy1' | 'kbd0' | 'kbd1'
     * fileURL ::= <a URL of the form blob://>
     */

    DEBUG_LOG("%s\n", msg);
    if (!gui_initialized) {
        DEBUG_LOG("GUI message refused; not yet initialized.\n");
        return -1;
    }

    /* TODO(cstefansen): scan the string instead of these shenanigans. */

    /* Copy to non-const buffer. */
    char buf[1024];
    (void) strncpy(buf, msg, sizeof(buf) - 1);
    buf[sizeof(buf) - 1] = '\0'; /* Ensure NUL termination. */

    /* Tokenize message up to 3 tokens (max given the grammar). */
    int32_t i = 0;
    char *t[3], *token, *rest = NULL, *sep = " ";

    for (token = strtok_r(buf, sep, &rest);
         token != NULL && i <= 3;
         token = strtok_r(NULL, sep, &rest), ++i) {
        t[i] = token;
    }

    /* Pipe message to UAE main thread. */
    if (i == 1 && !strcmp(t[0], "reset")) {
        write_comm_pipe_int(&from_gui_pipe, UAECMD_RESET, 1);
    } else if (i == 1 && !strcmp(t[0], "pause")) {
        /* It would be cleaner to call pause_sound and resume_sound in
         * gui_handle_events below, i.e, on the emulator thread. However,
         * if we're pausing because the tab is no longer in the foreground,
         * no graphics flush calls will unblock and no graphics callbacks will
         * be delivered until the tab is back in front. This means that the
         * emulator is probably already stuck in some call and won't get to
         * our UI request to pause the sound. */
        /* TODO(cstefansen)People are reporting pausing/resuming problems; let's
           not do this until investigated. */
        /* pause_sound(); */
        write_comm_pipe_int(&from_gui_pipe, UAECMD_PAUSE, 1);
    } else if (i == 1 && !strcmp(t[0], "resume")) {
        /* resume_sound(); */
        write_comm_pipe_int(&from_gui_pipe, UAECMD_RESUME, 1);
    } else if (i == 2 && !strcmp(t[0], "eject")) {
        int32_t drive_num;
        if (!strcmp(t[1], "df0")) {
            drive_num = 0;
        } else if (!strcmp(t[1], "df1")) {
            drive_num = 1;
        } else {
            return -1;
        }
        write_comm_pipe_int(&from_gui_pipe, UAECMD_EJECTDISK, 0);
        write_comm_pipe_int(&from_gui_pipe, drive_num, 1);
    } else if (i == 3 && !strcmp(t[0], "resize")) {
        long width = strtol(t[1], NULL, 10);
        long height = strtol(t[2], NULL, 10);
        if (width > INT_MAX || height > INT_MAX || errno == ERANGE
            || width <= 0  || height <= 0) {
            write_log("Could not parse width/height in message: %s\n", msg);
            return -1;
        }
        write_comm_pipe_int(&from_gui_pipe, UAECMD_RESIZE, 0);
        write_comm_pipe_int(&from_gui_pipe, (int32_t) width, 0);
        write_comm_pipe_int(&from_gui_pipe, (int32_t) height, 1);
    } else if (i == 3 && !strcmp(t[0], "insert")) {
        int32_t drive_num;
        if (!strcmp(t[1], "df0")) {
            drive_num = 0;
        } else if (!strcmp(t[1], "df1")) {
            drive_num = 1;
        } else {
            return -1;
        }
        uae_sem_wait(&gui_sem);
        if (new_disk_string[drive_num] != 0)
            free (new_disk_string[drive_num]);
        new_disk_string[drive_num] = strdup(t[2]);
        uae_sem_post(&gui_sem);
        write_comm_pipe_int (&from_gui_pipe, UAECMD_INSERTDISK, 0);
        write_comm_pipe_int (&from_gui_pipe, drive_num, 1);
    } else if (i == 2 && !strcmp(t[0], "rom")) {
        uae_sem_wait(&gui_sem);
        if (gui_romname != 0)
            free (gui_romname);
        gui_romname = strdup(t[1]);
        uae_sem_post(&gui_sem);
        write_comm_pipe_int(&from_gui_pipe, UAECMD_SELECT_ROM, 1);
    } else if (i == 3 && !strcmp(t[0], "connect")) {
        int32_t port_num;
        if (!strcmp(t[1], "port0")) {
            port_num = 0;
        } else if (!strcmp(t[1], "port1")) {
            port_num = 1;
        } else {
            return -1;
        }

        int32_t input_device =
                !strcmp(t[2], "mouse") ? JSEM_MICE :
                !strcmp(t[2], "joy0") ? JSEM_JOYS :
                !strcmp(t[2], "joy1") ? JSEM_JOYS + 1 :
                !strcmp(t[2], "kbd0") ? JSEM_KBDLAYOUT + 1 :
                !strcmp(t[2], "kbd1") ? JSEM_KBDLAYOUT + 2 :
                JSEM_END;

        changed_prefs.jports[port_num].id = input_device;
        if (changed_prefs.jports[port_num].id !=
            currprefs.jports[port_num].id) {
            /* It's a little fishy that the typical way to update input
             * devices doesn't use the comm pipe.
             */
            inputdevice_updateconfig (&changed_prefs);
            inputdevice_config_change();
        }
    } else {
        return -1;
    }
    return 0;
}