trunk/src/osd/sdl/video.c
| r244684 | r244685 | |
| 63 | 63 | |
| 64 | 64 | osd_video_config video_config; |
| 65 | 65 | |
| 66 | // monitor info |
| 66 | 67 | osd_monitor_info *osd_monitor_info::list = NULL; |
| 67 | 68 | |
| 69 | |
| 68 | 70 | //============================================================ |
| 69 | 71 | // LOCAL VARIABLES |
| 70 | 72 | //============================================================ |
| 71 | 73 | |
| 74 | |
| 72 | 75 | //============================================================ |
| 73 | 76 | // PROTOTYPES |
| 74 | 77 | //============================================================ |
| r244684 | r244685 | |
| 318 | 321 | // poll the joystick values here |
| 319 | 322 | sdlinput_poll(machine()); |
| 320 | 323 | check_osd_inputs(machine()); |
| 321 | | |
| 324 | // if we're running, disable some parts of the debugger |
| 322 | 325 | if ((machine().debug_flags & DEBUG_FLAG_OSD_ENABLED) != 0) |
| 323 | 326 | debugger_update(); |
| 324 | 327 | } |
| r244684 | r244685 | |
| 450 | 453 | // pick_monitor |
| 451 | 454 | //============================================================ |
| 452 | 455 | |
| 453 | | #if (SDLMAME_SDL2) || defined(SDLMAME_WIN32) |
| 454 | 456 | osd_monitor_info *osd_monitor_info::pick_monitor(sdl_options &options, int index) |
| 455 | 457 | { |
| 456 | 458 | osd_monitor_info *monitor; |
| r244684 | r244685 | |
| 472 | 474 | // look for a match in the name first |
| 473 | 475 | if (scrname != NULL && (scrname[0] != 0)) |
| 474 | 476 | { |
| 475 | | for (monitor = sdl_monitor_info::list; monitor != NULL; monitor = monitor->next()) |
| 477 | for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->next()) |
| 476 | 478 | { |
| 477 | 479 | moncount++; |
| 478 | 480 | if (strcmp(scrname, monitor->devicename()) == 0) |
| r244684 | r244685 | |
| 482 | 484 | |
| 483 | 485 | // didn't find it; alternate monitors until we hit the jackpot |
| 484 | 486 | index %= moncount; |
| 485 | | for (monitor = sdl_monitor_info::list; monitor != NULL; monitor = monitor->next()) |
| 487 | for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->next()) |
| 486 | 488 | if (index-- == 0) |
| 487 | 489 | goto finishit; |
| 488 | 490 | |
| 489 | 491 | // return the primary just in case all else fails |
| 490 | | for (monitor = sdl_monitor_info::list; monitor != NULL; monitor = monitor->next()) |
| 492 | for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->next()) |
| 491 | 493 | if (monitor->is_primary()) |
| 492 | 494 | goto finishit; |
| 493 | 495 | |
| r244684 | r244685 | |
| 499 | 501 | } |
| 500 | 502 | return monitor; |
| 501 | 503 | } |
| 502 | | #else |
| 503 | | osd_monitor_info *osd_monitor_info::pick_monitor(sdl_options &options, int index) |
| 504 | | { |
| 505 | | osd_monitor_info *monitor; |
| 506 | | float aspect; |
| 507 | 504 | |
| 508 | | // get the aspect ratio |
| 509 | | aspect = get_aspect(options.aspect(), options.aspect(index), TRUE); |
| 510 | 505 | |
| 511 | | // return the primary just in case all else fails |
| 512 | | monitor = osd_monitor_info::list; |
| 513 | | |
| 514 | | if (aspect != 0) |
| 515 | | { |
| 516 | | monitor->m_aspect = aspect; |
| 517 | | } |
| 518 | | return monitor; |
| 519 | | } |
| 520 | | #endif |
| 521 | | |
| 522 | | |
| 523 | 506 | //============================================================ |
| 524 | 507 | // check_osd_inputs |
| 525 | 508 | //============================================================ |
trunk/src/osd/windows/video.c
| r244684 | r244685 | |
| 29 | 29 | #include "config.h" |
| 30 | 30 | |
| 31 | 31 | //============================================================ |
| 32 | // CONSTANTS |
| 33 | //============================================================ |
| 34 | |
| 35 | |
| 36 | //============================================================ |
| 32 | 37 | // GLOBAL VARIABLES |
| 33 | 38 | //============================================================ |
| 34 | 39 | |
| 35 | 40 | osd_video_config video_config; |
| 36 | 41 | |
| 42 | // monitor info |
| 43 | osd_monitor_info *osd_monitor_info::list = NULL; |
| 37 | 44 | |
| 38 | 45 | |
| 39 | 46 | //============================================================ |
| 40 | 47 | // LOCAL VARIABLES |
| 41 | 48 | //============================================================ |
| 42 | 49 | |
| 43 | | // monitor info |
| 44 | | osd_monitor_info *osd_monitor_info::list = NULL; |
| 45 | 50 | |
| 46 | 51 | //============================================================ |
| 47 | 52 | // PROTOTYPES |
| 48 | 53 | //============================================================ |
| 49 | 54 | |
| 50 | 55 | static void init_monitors(void); |
| 51 | | static osd_monitor_info *pick_monitor(windows_options &options, int index); |
| 52 | 56 | |
| 53 | 57 | static void check_osd_inputs(running_machine &machine); |
| 54 | 58 | |
| r244684 | r244685 | |
| 56 | 60 | static void get_resolution(const char *defdata, const char *data, osd_window_config *config, int report_error); |
| 57 | 61 | |
| 58 | 62 | |
| 59 | | |
| 60 | 63 | //============================================================ |
| 61 | 64 | // video_init |
| 62 | 65 | //============================================================ |
| r244684 | r244685 | |
| 80 | 83 | // create the windows |
| 81 | 84 | windows_options &options = downcast<windows_options &>(machine().options()); |
| 82 | 85 | for (index = 0; index < video_config.numscreens; index++) |
| 83 | | win_window_info::create(machine(), index, pick_monitor(options, index), &windows[index]); |
| 86 | win_window_info::create(machine(), index, osd_monitor_info::pick_monitor(options, index), &windows[index]); |
| 84 | 87 | if (video_config.mode != VIDEO_MODE_NONE) |
| 85 | 88 | SetForegroundWindow(win_window_list->m_hwnd); |
| 86 | 89 | |
| r244684 | r244685 | |
| 184 | 187 | |
| 185 | 188 | // if we're not skipping this redraw, update all windows |
| 186 | 189 | if (!skip_redraw) |
| 190 | { |
| 191 | // profiler_mark(PROFILER_BLIT); |
| 187 | 192 | for (win_window_info *window = win_window_list; window != NULL; window = window->m_next) |
| 188 | 193 | window->update(); |
| 194 | // profiler_mark(PROFILER_END); |
| 195 | } |
| 189 | 196 | |
| 190 | 197 | // poll the joystick values here |
| 191 | 198 | winwindow_process_events(machine(), TRUE, FALSE); |
| r244684 | r244685 | |
| 198 | 205 | |
| 199 | 206 | |
| 200 | 207 | |
| 201 | | //============================================================ |
| 202 | | // init_monitors |
| 203 | | //============================================================ |
| 204 | 208 | |
| 205 | | static void init_monitors(void) |
| 206 | | { |
| 207 | | osd_monitor_info **tailptr; |
| 208 | 209 | |
| 209 | | // make a list of monitors |
| 210 | | osd_monitor_info::list = NULL; |
| 211 | | tailptr = &osd_monitor_info::list; |
| 212 | | EnumDisplayMonitors(NULL, NULL, win_monitor_info::monitor_enum_callback, (LPARAM)&tailptr); |
| 213 | | |
| 214 | | // if we're verbose, print the list of monitors |
| 215 | | { |
| 216 | | osd_monitor_info *monitor; |
| 217 | | for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->m_next) |
| 218 | | { |
| 219 | | osd_printf_verbose("Video: Monitor %p = \"%s\" %s\n", monitor->oshandle(), monitor->devicename(), monitor->is_primary() ? "(primary)" : ""); |
| 220 | | } |
| 221 | | } |
| 222 | | } |
| 223 | | |
| 224 | | |
| 225 | | |
| 226 | 210 | //============================================================ |
| 227 | 211 | // monitor_enum_callback |
| 228 | 212 | //============================================================ |
| r244684 | r244685 | |
| 240 | 224 | assert(result); |
| 241 | 225 | (void)result; // to silence gcc 4.6 |
| 242 | 226 | |
| 227 | // guess the aspect ratio assuming square pixels |
| 228 | float aspect = (float)(info.rcMonitor.right - info.rcMonitor.left) / (float)(info.rcMonitor.bottom - info.rcMonitor.top); |
| 229 | |
| 243 | 230 | // allocate a new monitor info |
| 244 | | monitor = global_alloc(win_monitor_info(handle, "", 1.0f)); |
| 231 | char *temp = utf8_from_wstring(info.szDevice); |
| 245 | 232 | // copy in the data |
| 246 | | //monitor->refresh(); |
| 233 | monitor = global_alloc(win_monitor_info(handle, temp, aspect)); |
| 234 | osd_free(temp); |
| 247 | 235 | |
| 248 | | // guess the aspect ratio assuming square pixels |
| 249 | | monitor->set_aspect((float)(info.rcMonitor.right - info.rcMonitor.left) / (float)(info.rcMonitor.bottom - info.rcMonitor.top)); |
| 250 | | |
| 251 | 236 | // hook us into the list |
| 252 | 237 | **tailptr = monitor; |
| 253 | 238 | *tailptr = &monitor->m_next; |
| r244684 | r244685 | |
| 257 | 242 | } |
| 258 | 243 | |
| 259 | 244 | |
| 245 | //============================================================ |
| 246 | // init_monitors |
| 247 | //============================================================ |
| 260 | 248 | |
| 249 | static void init_monitors(void) |
| 250 | { |
| 251 | osd_monitor_info **tailptr; |
| 252 | |
| 253 | // make a list of monitors |
| 254 | osd_monitor_info::list = NULL; |
| 255 | tailptr = &osd_monitor_info::list; |
| 256 | EnumDisplayMonitors(NULL, NULL, win_monitor_info::monitor_enum_callback, (LPARAM)&tailptr); |
| 257 | |
| 258 | // if we're verbose, print the list of monitors |
| 259 | { |
| 260 | osd_monitor_info *monitor; |
| 261 | for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->m_next) |
| 262 | { |
| 263 | osd_printf_verbose("Video: Monitor %p = \"%s\" %s\n", monitor->oshandle(), monitor->devicename(), monitor->is_primary() ? "(primary)" : ""); |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | |
| 261 | 269 | //============================================================ |
| 262 | 270 | // pick_monitor |
| 263 | 271 | //============================================================ |
| 264 | 272 | |
| 265 | | static osd_monitor_info *pick_monitor(windows_options &options, int index) |
| 273 | osd_monitor_info *osd_monitor_info::pick_monitor(windows_options &options, int index) |
| 266 | 274 | { |
| 275 | osd_monitor_info *monitor; |
| 267 | 276 | const char *scrname, *scrname2; |
| 268 | | osd_monitor_info *monitor; |
| 269 | 277 | int moncount = 0; |
| 270 | 278 | float aspect; |
| 271 | 279 | |
| r244684 | r244685 | |
| 283 | 291 | // look for a match in the name first |
| 284 | 292 | if (scrname != NULL && (scrname[0] != 0)) |
| 285 | 293 | { |
| 286 | | for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->m_next) |
| 294 | for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->next()) |
| 287 | 295 | { |
| 288 | 296 | moncount++; |
| 289 | 297 | if (strcmp(scrname, monitor->devicename()) == 0) |
| r244684 | r244685 | |
| 293 | 301 | |
| 294 | 302 | // didn't find it; alternate monitors until we hit the jackpot |
| 295 | 303 | index %= moncount; |
| 296 | | for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->m_next) |
| 304 | for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->next()) |
| 297 | 305 | if (index-- == 0) |
| 298 | 306 | goto finishit; |
| 299 | 307 | |
| 300 | 308 | // return the primary just in case all else fails |
| 301 | | for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->m_next) |
| 309 | for (monitor = osd_monitor_info::list; monitor != NULL; monitor = monitor->next()) |
| 302 | 310 | if (monitor->is_primary()) |
| 303 | 311 | goto finishit; |
| 304 | 312 | |
| 313 | // FIXME: FatalError? |
| 305 | 314 | finishit: |
| 306 | 315 | if (aspect != 0) |
| 307 | 316 | { |
| r244684 | r244685 | |
| 311 | 320 | } |
| 312 | 321 | |
| 313 | 322 | |
| 314 | | |
| 315 | 323 | //============================================================ |
| 316 | 324 | // check_osd_inputs |
| 317 | 325 | //============================================================ |
| r244684 | r244685 | |
| 492 | 500 | |
| 493 | 501 | static void get_resolution(const char *defdata, const char *data, osd_window_config *config, int report_error) |
| 494 | 502 | { |
| 495 | | config->width = config->height = config->refresh = 0; |
| 503 | config->width = config->height = config->depth = config->refresh = 0; |
| 496 | 504 | if (strcmp(data, OSDOPTVAL_AUTO) == 0) |
| 497 | 505 | { |
| 498 | 506 | if (strcmp(defdata, OSDOPTVAL_AUTO) == 0) |