/*------------------------------------------------- * push_mouse_leave_event - pushes a * mouse leave event to the specified render_target * -------------------------------------------------*/ public void push_mouse_leave_event(render_target target) { ui_event evt = new ui_event(ui_event.type.NONE); evt.event_type = ui_event.type.MOUSE_LEAVE; evt.target = target; push_event(evt); }
/*------------------------------------------------- * push_char_event - pushes a char event * to the specified render_target * -------------------------------------------------*/ public void push_char_event(render_target target, char32_t ch) { ui_event evt = new ui_event(ui_event.type.NONE); evt.event_type = ui_event.type.IME_CHAR; evt.target = target; evt.ch = ch; push_event(evt); }
//void push_mouse_rdown_event(render_target* target, INT32 x, INT32 y); //void push_mouse_rup_event(render_target* target, INT32 x, INT32 y); /*------------------------------------------------- * push_mouse_double_click_event - pushes * a mouse double-click event to the specified * render_target * -------------------------------------------------*/ public void push_mouse_double_click_event(render_target target, s32 x, s32 y) { ui_event evt = new ui_event(ui_event.type.NONE); evt.event_type = ui_event.type.MOUSE_DOUBLE_CLICK; evt.target = target; evt.mouse_x = x; evt.mouse_y = y; push_event(evt); }
/*------------------------------------------------- * push_mouse_down_event - pushes a mouse * down event to the specified render_target * -------------------------------------------------*/ public void push_mouse_up_event(render_target target, s32 x, s32 y) { ui_event evt = new ui_event(ui_event.type.NONE); evt.event_type = ui_event.type.MOUSE_UP; evt.target = target; evt.mouse_x = x; evt.mouse_y = y; push_event(evt); }
/*------------------------------------------------- * push_mouse_down_event - pushes a mouse * down event to the specified render_target * -------------------------------------------------*/ public void push_mouse_down_event(render_target target, int x, int y) { ui_event evt = new ui_event(ui_event.type.NONE); evt.event_type = ui_event.type.MOUSE_DOWN; evt.target = target; evt.mouse_x = x; evt.mouse_y = y; push_event(evt); }
/*------------------------------------------------- * push_mouse_wheel_event - pushes a mouse * wheel event to the specified render_target * -------------------------------------------------*/ public void push_mouse_wheel_event(render_target target, s32 x, s32 y, short delta, int ucNumLines) { ui_event event_ = new ui_event(ui_event.type.NONE); event_.event_type = ui_event.type.MOUSE_WHEEL; event_.target = target; event_.mouse_x = x; event_.mouse_y = y; event_.zdelta = delta; event_.num_lines = ucNumLines; push_event(event_); }
// construction/destruction //------------------------------------------------- // ui_input_manager - constructor //------------------------------------------------- public ui_input_manager(running_machine machine) { m_machine = machine; m_current_mouse_target = null; m_current_mouse_down = false; m_current_mouse_field = null; m_events_start = 0; m_events_end = 0; /* create the private data */ m_current_mouse_x = -1; m_current_mouse_y = -1; /* add a frame callback to poll inputs */ machine.add_notifier(machine_notification.MACHINE_NOTIFY_FRAME, frame_update); }
// pushes a single event onto the queue /*------------------------------------------------- * push_event - pushes a single event * onto the queue * -------------------------------------------------*/ bool push_event(ui_event evt) { // some pre-processing (this is an icky place to do this stuff!) switch (evt.event_type) { case ui_event.type.MOUSE_MOVE: m_current_mouse_target = evt.target; m_current_mouse_x = evt.mouse_x; m_current_mouse_y = evt.mouse_y; break; case ui_event.type.MOUSE_LEAVE: if (m_current_mouse_target == evt.target) { m_current_mouse_target = null; m_current_mouse_x = -1; m_current_mouse_y = -1; } break; case ui_event.type.MOUSE_DOWN: m_current_mouse_down = true; break; case ui_event.type.MOUSE_UP: m_current_mouse_down = false; break; default: /* do nothing */ break; } // is the queue filled up? if ((m_events_end + 1) % (int)std.size(m_events) == m_events_start) { return(false); } m_events[m_events_end++] = evt; m_events_end %= (int)std.size(m_events); return(true); }
// construction/destruction //------------------------------------------------- // ui_input_manager - constructor //------------------------------------------------- public ui_input_manager(running_machine machine) { m_machine = machine; m_presses_enabled = true; m_current_mouse_target = null; m_current_mouse_x = -1; m_current_mouse_y = -1; m_current_mouse_down = false; m_current_mouse_field = null; m_events_start = 0; m_events_end = 0; std.fill(m_next_repeat, (osd_ticks_t)0); std.fill(m_seqpressed, (u8)0); // add a frame callback to poll inputs machine.add_notifier(machine_notification.MACHINE_NOTIFY_FRAME, frame_update); }
// construction/destruction //------------------------------------------------- // video_manager - constructor //------------------------------------------------- public video_manager(running_machine machine) { m_machine = machine; m_screenless_frame_timer = null; m_output_changed = false; m_throttle_realtime = attotime.zero; m_throttle_emutime = attotime.zero; m_throttle_history = 0; m_speed_last_realtime = 0; m_speed_last_emutime = attotime.zero; m_speed_percent = 1.0; m_overall_real_seconds = 0; m_overall_real_ticks = 0; m_overall_emutime = attotime.zero; m_overall_valid_counter = 0; m_frame_update_counter = 0; m_throttled = true; m_throttle_rate = 1.0f; m_fastforward = false; m_seconds_to_run = (u32)machine.options().seconds_to_run(); m_auto_frameskip = machine.options().auto_frameskip(); m_speed = (u32)original_speed_setting(); m_low_latency = machine.options().low_latency(); m_empty_skip_count = 0; m_frameskip_max = m_auto_frameskip ? (u8)machine.options().frameskip() : (u8)0; m_frameskip_level = m_auto_frameskip ? (u8)0 : (u8)machine.options().frameskip(); m_frameskip_counter = 0; m_frameskip_adjust = 0; m_skipping_this_frame = false; m_average_oversleep = 0; m_snap_target = null; m_snap_native = true; m_snap_width = 0; m_snap_height = 0; // request a callback upon exiting machine.add_notifier(machine_notification.MACHINE_NOTIFY_EXIT, exit); machine.save().register_postload(postload); // extract initial execution state from global configuration settings update_refresh_speed(); unsigned screen_count = (unsigned)(new screen_device_enumerator(machine.root_device()).count()); bool no_screens = screen_count == 0; // create a render target for snapshots string viewname = machine.options().snap_view(); m_snap_native = !no_screens && std.strcmp(viewname, "native") == 0; // the native target is hard-coded to our internal layout and has all options disabled if (m_snap_native) { throw new emu_unimplemented(); } else { // other targets select the specified view and turn off effects m_snap_target = machine.render().target_alloc(null, RENDER_CREATE_HIDDEN); m_snap_target.set_view(m_snap_target.configured_view(viewname, 0, 1)); m_snap_target.set_screen_overlay_enabled(false); } // extract snap resolution if present //if (sscanf(machine.options().snap_size(), "%dx%d", &m_snap_width, &m_snap_height) != 2) var parts = machine.options().snap_size().Split('x'); if (parts.Length == 2) { m_snap_width = Convert.ToInt32(parts[0]); m_snap_height = Convert.ToInt32(parts[1]); } else { m_snap_width = m_snap_height = 0; } // if no screens, create a periodic timer to drive updates if (no_screens) { m_screenless_frame_timer = machine.scheduler().timer_alloc(screenless_update_callback, this); m_screenless_frame_timer.adjust(screen_device.DEFAULT_FRAME_PERIOD, 0, screen_device.DEFAULT_FRAME_PERIOD); machine.output().set_global_notifier(video_notifier_callback, this); } }
protected machine_static_info(ui_options options, machine_config config, ioport_list ports) { m_options = options; m_flags = config.gamedrv().flags; m_unemulated_features = config.gamedrv().type.unemulated_features(); m_imperfect_features = config.gamedrv().type.imperfect_features(); m_has_bioses = false; m_has_dips = false; m_has_configs = false; m_has_keyboard = false; m_has_test_switch = false; m_has_analog = false; ioport_list local_ports = new ioport_list(); string sink; foreach (device_t device in new device_enumerator(config.root_device())) { // the "no sound hardware" warning doesn't make sense when you plug in a sound card if (device.GetClassInterface <device_sound_interface>() != null) // dynamic_cast<device_sound_interface *>(&device)) { m_flags &= ~machine_flags.type.NO_SOUND_HW; } // build overall emulation status m_unemulated_features |= device.type().unemulated_features(); m_imperfect_features |= device.type().imperfect_features(); // look for BIOS options device_t parent = device.owner(); device_slot_interface slot = device.GetClassInterface <device_slot_interface>(); //device_slot_interface const *const slot(dynamic_cast<device_slot_interface const *>(parent)); if (parent == null || (slot != null && (slot.get_card_device() == device))) { for (Pointer <tiny_rom_entry> rom = device.rom_region(); !m_has_bioses && rom != null && !ROMENTRY_ISEND(rom.op); ++rom) //for (tiny_rom_entry const *rom = device.rom_region(); !m_has_bioses && rom && !ROMENTRY_ISEND(rom); ++rom) { if (ROMENTRY_ISSYSTEM_BIOS(rom.op)) { m_has_bioses = true; } } } } // suppress "requires external artwork" warning when external artwork was loaded if (config.root_device().has_running_machine()) { for (render_target target = config.root_device().machine().render().first_target(); target != null; target = target.next()) { if (!target.hidden() && target.external_artwork()) { m_flags &= ~machine_flags.type.REQUIRES_ARTWORK; break; } } } // unemulated trumps imperfect when aggregating (always be pessimistic) m_imperfect_features &= ~m_unemulated_features; // scan the input port array to see what options we need to enable foreach (var port in (ports != null ? ports : local_ports)) { foreach (ioport_field field in port.Value.fields()) { switch (field.type()) { case ioport_type.IPT_DIPSWITCH: m_has_dips = true; break; case ioport_type.IPT_CONFIG: m_has_configs = true; break; case ioport_type.IPT_KEYBOARD: m_has_keyboard = true; break; case ioport_type.IPT_SERVICE: m_has_test_switch = true; break; default: break; } if (field.is_analog()) { m_has_analog = true; } } } }
public override void init(running_machine machine) { // call our parent base.init(machine); set_verbose(true); string stemp; osd_options_WinForms options = (osd_options_WinForms)machine.options(); // determine if we are benchmarking, and adjust options appropriately int bench = options.bench(); if (bench > 0) { options.set_value(emu_options.OPTION_THROTTLE, 0, OPTION_PRIORITY_MAXIMUM); options.set_value(osd_options.OSDOPTION_SOUND, "none", OPTION_PRIORITY_MAXIMUM); options.set_value(osd_options.OSDOPTION_VIDEO, "none", OPTION_PRIORITY_MAXIMUM); options.set_value(emu_options.OPTION_SECONDS_TO_RUN, bench, OPTION_PRIORITY_MAXIMUM); } // determine if we are profiling, and adjust options appropriately int profile = options.profile(); if (profile > 0) { options.set_value(emu_options.OPTION_THROTTLE, 0, OPTION_PRIORITY_MAXIMUM); options.set_value(osd_options.OSDOPTION_NUMPROCESSORS, 1, OPTION_PRIORITY_MAXIMUM); } #if false // thread priority if ((machine.debug_flags_get() & running_machine.DEBUG_FLAG_OSD_ENABLED) == 0) SetThreadPriority(GetCurrentThread(), options.priority()); #endif // get number of processors stemp = options.numprocessors(); #if false osd_num_processors = 0; if (stemp != "auto") { osd_num_processors = Convert.ToInt32(stemp); if (osd_num_processors < 1) { osdcore_global.m_osdcore.osd_printf_warning("Warning: numprocessors < 1 doesn't make much sense. Assuming auto ...\n"); osd_num_processors = 0; } } #endif // initialize the subsystems init_subsystems(); #if false // notify listeners of screen configuration string tempstring; for (win_window_info info = win_window_list; info != null; info = info.m_next) { string tmp = utf8_from_tstring(info.m_monitor.info.szDevice); string tempstring = string.Format("Orientation({0})", tmp); output_set_value(tempstring, info.m_targetorient); //osd_free(tmp); } #endif // hook up the debugger log if (options.oslog()) machine.add_logerror_callback(osdcore_interface.osd_printf_debug); #if false // crank up the multimedia timer resolution to its max // this gives the system much finer timeslices timeresult = timeGetDevCaps(&timecaps, sizeof(timecaps)); if (timeresult == TIMERR_NOERROR) timeBeginPeriod(timecaps.wPeriodMin); #endif #if false // if a watchdog thread is requested, create one int watchdog = options.watchdog(); if (watchdog != 0) { watchdog_reset_event = CreateEvent(NULL, FALSE, FALSE, NULL); emucore_global.assert_always(watchdog_reset_event != null, "Failed to create watchdog reset event"); watchdog_exit_event = CreateEvent(NULL, TRUE, FALSE, NULL); emucore_global.assert_always(watchdog_exit_event != null, "Failed to create watchdog exit event"); watchdog_thread = CreateThread(NULL, 0, watchdog_thread_entry, (LPVOID)(FPTR)watchdog, 0, NULL); emucore_global.assert_always(watchdog_thread != null, "Failed to create watchdog thread"); } #endif #if false // create and start the profiler if (profile > 0) { profiler = new sampling_profiler(1000, profile - 1)); profiler.start(); } #endif #if false // initialize sockets win_init_sockets(); #endif #if false // note the existence of a machine g_current_machine = &machine; #endif ///////////////////////////////////////////// // custom code below validity_checker valid = new validity_checker(machine.options()); valid.set_validate_all(true); string sysname = machine.options().system_name(); bool result = valid.check_all_matching(string.IsNullOrEmpty(sysname) ? "*" : sysname); if (!result) throw new emu_fatalerror(main_global.EMU_ERR_FAILED_VALIDITY, "Validity check failed ({0} errors, {1} warnings in total)\n", valid.errors(), valid.warnings()); valid.Dispose(); /** * Save away the machine, we'll need it in osd_customize_input_type_list **/ //g_state.machine = machine; /** * Create the render_target that tells MAME the rendering parameters it * will use. **/ m_target = machine.render().target_alloc(); /** * Have this target hold every view since we only support one target **/ m_target.set_view(m_target.configured_view("auto", 0, 1)); /** * Set render target bounds to 10000 x 10000 and allow the callback to * scale that to whatever they want. **/ //m_target.set_bounds(640, 480, 1.0f); m_target.set_bounds(400, 400, 1.0f); screenbufferptr = new RawBufferPointer(screenbuffer); { keyboard_state = new intref[(int)input_item_id.ITEM_ID_ABSOLUTE_MAXIMUM]; for (int i = 0; i < (int)input_item_id.ITEM_ID_ABSOLUTE_MAXIMUM; i++) keyboard_state[i] = new intref(); input_device keyboard_device; keyboard_device = machine.input().device_class(input_device_class.DEVICE_CLASS_KEYBOARD).add_device("Keyboard", "Keyboard0"); if (keyboard_device == null) throw new emu_fatalerror("osd_interface.init() - FAILED - add_device() failed\n"); foreach (var entry in mameForm.Form1.keymap) { string defname = entry.Key.ToString(); //string.Format("Scan{0}", count++); input_item_id itemid = entry.Value; keyboard_device.add_item(defname, itemid, keyboard_get_state, keyboard_state[(int)itemid]); } } { mouse_axis_state = new intref[2]; for (int i = 0; i < 2; i++) mouse_axis_state[i] = new intref(); input_device mouse_device; mouse_device = machine.input().device_class(input_device_class.DEVICE_CLASS_MOUSE).add_device("Mouse", "Mouse0"); if (mouse_device == null) throw new emu_fatalerror("osd_interface.init() - FAILED - add_device() failed\n"); string defname; defname = string.Format("X {0}", mouse_device.name()); mouse_device.add_item(defname, input_item_id.ITEM_ID_XAXIS, mouse_axis_get_state, mouse_axis_state[0]); defname = string.Format("Y {0}", mouse_device.name()); mouse_device.add_item(defname, input_item_id.ITEM_ID_YAXIS, mouse_axis_get_state, mouse_axis_state[1]); mouse_button_state = new intref[5]; for (int i = 0; i < 5; i++) mouse_button_state[i] = new intref(); defname = string.Format("B1"); mouse_device.add_item(defname, input_item_id.ITEM_ID_BUTTON1, mouse_button_get_state, mouse_button_state[0]); defname = string.Format("B2"); mouse_device.add_item(defname, input_item_id.ITEM_ID_BUTTON2, mouse_button_get_state, mouse_button_state[1]); defname = string.Format("B3"); mouse_device.add_item(defname, input_item_id.ITEM_ID_BUTTON3, mouse_button_get_state, mouse_button_state[2]); defname = string.Format("B4"); mouse_device.add_item(defname, input_item_id.ITEM_ID_BUTTON4, mouse_button_get_state, mouse_button_state[3]); defname = string.Format("B5"); mouse_device.add_item(defname, input_item_id.ITEM_ID_BUTTON5, mouse_button_get_state, mouse_button_state[4]); } //System.Windows.Forms.Application.Run(new mameForm.Form1()); //System.Windows.Forms.Form mainForm = new mameForm.Form1(); //mainForm.FormClosed += (_sender, _args) => { System.Windows.Forms.Application.ExitThread(); }; //mainForm.Show(); //Console.WriteLine("After Show()"); }