| Previous | 15994 Revisions | Next |
| r7938 Thursday 29th April, 2010 at 21:00:17 UTC by Firewave |
|---|
| Fixed strconv.c and other memory leaks (patch submitted to MAMEdev). Maybe cause breakage in newui/winui code - fixes pending. |
| [src/emu] | rendfont.c ui.c |
| [src/emu/debug] | debugvw.c |
| [src/lib/util] | pool.c |
| [src/osd] | osdcore.h |
| [src/osd/sdl] | main.c sdlos_macosx.c sdlos_unix.c sdlos_win32.c strconv.c strconv.h video.c |
| [src/osd/windows] | debugwin.c drawd3d.c input.c main.c strconv.c strconv.h video.c windir.c winfile.c winutf8.c |
| r7937 | r7938 | |
|---|---|---|
| 277 | 277 | length = CFDataGetLength (data_ref); |
| 278 | 278 | range = CFRangeMake (0,length); |
| 279 | 279 | |
| 280 | result = (char *)malloc (length+1); | |
| 280 | result = (char *)osd_malloc (length+1); | |
| 281 | 281 | if (result != NULL) |
| 282 | 282 | { |
| 283 | 283 | CFDataGetBytes (data_ref, range, (unsigned char *)result); |
| r7937 | r7938 | |
| 373 | 373 | } |
| 374 | 374 | else |
| 375 | 375 | { |
| 376 | *dst = (char *)malloc(strlen(path_buffer)+strlen(path)+3); | |
| 376 | *dst = (char *)osd_malloc(strlen(path_buffer)+strlen(path)+3); | |
| 377 | 377 | |
| 378 | 378 | // if it's already a full path, just pass it through |
| 379 | 379 | if (path[0] == '/') |
| r7937 | r7938 | |
|---|---|---|
| 38 | 38 | |
| 39 | 39 | // convert UTF-16 to MAME string (UTF-8) |
| 40 | 40 | char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL); |
| 41 | result = (CHAR *)malloc(char_count * sizeof(*result)); | |
| 41 | result = (CHAR *)osd_malloc(char_count * sizeof(*result)); | |
| 42 | 42 | if (result != NULL) |
| 43 | 43 | WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL); |
| 44 | 44 | |
| r7937 | r7938 | |
| 56 | 56 | |
| 57 | 57 | // convert UTF-16 to MAME string (UTF-8) |
| 58 | 58 | char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL); |
| 59 | result = (char *)malloc(char_count * sizeof(*result)); | |
| 59 | result = (char *)osd_malloc(char_count * sizeof(*result)); | |
| 60 | 60 | if (result != NULL) |
| 61 | 61 | WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL); |
| 62 | 62 |
| r7937 | r7938 | |
|---|---|---|
| 20 | 20 | |
| 21 | 21 | #ifdef SDLMAME_WIN32 |
| 22 | 22 | |
| 23 | CHAR *astring_from_utf8(const char *s) ATTR_MALLOC; | |
| 24 | char *utf8_from_astring(const CHAR *s) ATTR_MALLOC; | |
| 23 | // the result of these functions has to be released with osd_free() | |
| 25 | 24 | |
| 26 | WCHAR *wstring_from_utf8(const char *s) ATTR_MALLOC; | |
| 27 | char *utf8_from_wstring(const WCHAR *s) ATTR_MALLOC; | |
| 25 | CHAR *astring_from_utf8(const char *s); | |
| 26 | char *utf8_from_astring(const CHAR *s); | |
| 28 | 27 | |
| 28 | WCHAR *wstring_from_utf8(const char *s); | |
| 29 | char *utf8_from_wstring(const WCHAR *s); | |
| 30 | ||
| 29 | 31 | #ifdef UNICODE |
| 30 | 32 | #define tstring_from_utf8 wstring_from_utf8 |
| 31 | 33 | #define utf8_from_tstring utf8_from_wstring |
| r7937 | r7938 | |
|---|---|---|
| 377 | 377 | |
| 378 | 378 | // convert UTF-16 to "ANSI code page" string |
| 379 | 379 | char_count = WideCharToMultiByte(CP_ACP, 0, wstring, -1, NULL, 0, NULL, NULL); |
| 380 | result = (CHAR *)malloc(char_count * sizeof(*result)); | |
| 380 | result = (CHAR *)osd_malloc(char_count * sizeof(*result)); | |
| 381 | 381 | if (result != NULL) |
| 382 | 382 | WideCharToMultiByte(CP_ACP, 0, wstring, -1, result, char_count, NULL, NULL); |
| 383 | 383 | |
| r7937 | r7938 | |
| 395 | 395 | |
| 396 | 396 | // convert MAME string (UTF-8) to UTF-16 |
| 397 | 397 | char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0); |
| 398 | result = (WCHAR *)malloc(char_count * sizeof(*result)); | |
| 398 | result = (WCHAR *)osd_malloc(char_count * sizeof(*result)); | |
| 399 | 399 | if (result != NULL) |
| 400 | 400 | MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, result, char_count); |
| 401 | 401 | |
| r7937 | r7938 | |
| 449 | 449 | |
| 450 | 450 | done: |
| 451 | 451 | if (t_path) |
| 452 | free(t_path); | |
| 452 | osd_free(t_path); | |
| 453 | 453 | return result; |
| 454 | 454 | } |
| 455 | 455 | |
| r7937 | r7938 | |
| 549 | 549 | |
| 550 | 550 | done: |
| 551 | 551 | if (t_path != NULL) |
| 552 | free(t_path); | |
| 552 | osd_free(t_path); | |
| 553 | 553 | return err; |
| 554 | 554 | } |
| 555 | 555 |
| r7937 | r7938 | |
|---|---|---|
| 293 | 293 | } |
| 294 | 294 | else |
| 295 | 295 | { |
| 296 | *dst = (char *)malloc(strlen(path_buffer)+strlen(path)+3); | |
| 296 | *dst = (char *)osd_malloc(strlen(path_buffer)+strlen(path)+3); | |
| 297 | 297 | |
| 298 | 298 | // if it's already a full path, just pass it through |
| 299 | 299 | if (path[0] == '/') |
| r7937 | r7938 | |
|---|---|---|
| 192 | 192 | monitor->center_height = monitor->monitor_height = info.rcMonitor.bottom - info.rcMonitor.top; |
| 193 | 193 | char *temp = utf8_from_wstring(info.szDevice); |
| 194 | 194 | strcpy(monitor->monitor_device, temp); |
| 195 | | |
| 195 | | |
| 196 | 196 | #elif defined(SDLMAME_MACOSX) // Mac OS X Core Imaging version |
| 197 | 197 | CGDirectDisplayID primary; |
| 198 | 198 | CGRect dbounds; |
| r7937 | r7938 | |
| 421 | 421 | monitor->monitor_height = info.rcMonitor.bottom - info.rcMonitor.top; |
| 422 | 422 | char *temp = utf8_from_wstring(info.szDevice); |
| 423 | 423 | strcpy(monitor->monitor_device, temp); |
| 424 | | |
| 424 | | |
| 425 | 425 | |
| 426 | 426 | // guess the aspect ratio assuming square pixels |
| 427 | 427 | monitor->aspect = (float)(info.rcMonitor.right - info.rcMonitor.left) / (float)(info.rcMonitor.bottom - info.rcMonitor.top); |
| r7937 | r7938 | |
|---|---|---|
| 60 | 60 | |
| 61 | 61 | /* free arguments */ |
| 62 | 62 | for (i = 0; i < argc; i++) |
| 63 | free(utf8_argv[i]); | |
| 63 | osd_free(utf8_argv[i]); | |
| 64 | 64 | free(utf8_argv); |
| 65 | 65 | |
| 66 | 66 | #ifdef MALLOC_DEBUG |
| r7937 | r7938 | |
|---|---|---|
| 822 | 822 | |
| 823 | 823 | Return value: |
| 824 | 824 | |
| 825 | the returned string needs to be free()-ed! | |
| 825 | the returned string needs to be osd_free()-ed! | |
| 826 | 826 | |
| 827 | 827 | -----------------------------------------------------------------------------*/ |
| 828 | 828 | char *osd_get_clipboard_text(void); |
| r7937 | r7938 | |
| 858 | 858 | Parameters: |
| 859 | 859 | |
| 860 | 860 | path - the path in question |
| 861 | dst - pointer to receive new path; the returned string needs to be free()-ed! | |
| 861 | dst - pointer to receive new path; the returned string needs to be osd_free()-ed! | |
| 862 | 862 | |
| 863 | 863 | Return value: |
| 864 | 864 |
| r7937 | r7938 | |
|---|---|---|
| 65 | 65 | |
| 66 | 66 | // convert UTF-16 to "ANSI code page" string |
| 67 | 67 | char_count = WideCharToMultiByte(CP_ACP, 0, wstring, -1, NULL, 0, NULL, NULL); |
| 68 | result = (CHAR *)malloc(char_count * sizeof(*result)); | |
| 68 | result = (CHAR *)osd_malloc(char_count * sizeof(*result)); | |
| 69 | 69 | if (result != NULL) |
| 70 | 70 | WideCharToMultiByte(CP_ACP, 0, wstring, -1, result, char_count, NULL, NULL); |
| 71 | 71 | |
| r7937 | r7938 | |
| 90 | 90 | |
| 91 | 91 | // convert UTF-16 to MAME string (UTF-8) |
| 92 | 92 | char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL); |
| 93 | result = (CHAR *)malloc(char_count * sizeof(*result)); | |
| 93 | result = (CHAR *)osd_malloc(char_count * sizeof(*result)); | |
| 94 | 94 | if (result != NULL) |
| 95 | 95 | WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL); |
| 96 | 96 | |
| r7937 | r7938 | |
| 109 | 109 | |
| 110 | 110 | // convert MAME string (UTF-8) to UTF-16 |
| 111 | 111 | char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0); |
| 112 | result = (WCHAR *)malloc(char_count * sizeof(*result)); | |
| 112 | result = (WCHAR *)osd_malloc(char_count * sizeof(*result)); | |
| 113 | 113 | if (result != NULL) |
| 114 | 114 | MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, result, char_count); |
| 115 | 115 | |
| r7937 | r7938 | |
| 128 | 128 | |
| 129 | 129 | // convert UTF-16 to MAME string (UTF-8) |
| 130 | 130 | char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL); |
| 131 | result = (char *)malloc(char_count * sizeof(*result)); | |
| 131 | result = (char *)osd_malloc(char_count * sizeof(*result)); | |
| 132 | 132 | if (result != NULL) |
| 133 | 133 | WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL); |
| 134 | 134 |
| r7937 | r7938 | |
|---|---|---|
| 50 | 50 | // FUNCTION PROTOTYPES |
| 51 | 51 | //============================================================ |
| 52 | 52 | |
| 53 | CHAR *astring_from_utf8(const char *s) ATTR_MALLOC; | |
| 54 | char *utf8_from_astring(const CHAR *s) ATTR_MALLOC; | |
| 53 | // the result of these functions has to be released with osd_free() | |
| 55 | 54 | |
| 56 | WCHAR *wstring_from_utf8(const char *s) ATTR_MALLOC; | |
| 57 | char *utf8_from_wstring(const WCHAR *s) ATTR_MALLOC; | |
| 55 | CHAR *astring_from_utf8(const char *s); | |
| 56 | char *utf8_from_astring(const CHAR *s); | |
| 58 | 57 | |
| 58 | WCHAR *wstring_from_utf8(const char *s); | |
| 59 | char *utf8_from_wstring(const WCHAR *s); | |
| 60 | ||
| 59 | 61 | #ifdef UNICODE |
| 60 | 62 | #define tstring_from_utf8 wstring_from_utf8 |
| 61 | 63 | #define utf8_from_tstring utf8_from_wstring |
| r7937 | r7938 | |
|---|---|---|
| 110 | 110 | error: |
| 111 | 111 | // cleanup |
| 112 | 112 | if (t_dirname != NULL) |
| 113 | free(t_dirname); | |
| 113 | osd_free(t_dirname); | |
| 114 | 114 | if (dirfilter != NULL) |
| 115 | 115 | free(dirfilter); |
| 116 | 116 | if (dir != NULL && dir->find == INVALID_HANDLE_VALUE) |
| r7937 | r7938 | |
| 131 | 131 | // if we've previously allocated a name, free it now |
| 132 | 132 | if (dir->entry.name != NULL) |
| 133 | 133 | { |
| 134 | free((void *)dir->entry.name); | |
| 134 | osd_free((void *)dir->entry.name); | |
| 135 | 135 | dir->entry.name = NULL; |
| 136 | 136 | } |
| 137 | 137 | |
| r7937 | r7938 | |
| 162 | 162 | { |
| 163 | 163 | // free any data associated |
| 164 | 164 | if (dir->entry.name != NULL) |
| 165 | free((void *)dir->entry.name); | |
| 165 | osd_free((void *)dir->entry.name); | |
| 166 | 166 | if (dir->find != INVALID_HANDLE_VALUE) |
| 167 | 167 | FindClose(dir->find); |
| 168 | 168 | free(dir); |
| r7937 | r7938 | |
| 180 | 180 | if (t_path != NULL) |
| 181 | 181 | { |
| 182 | 182 | result = !PathIsRelative(t_path); |
| 183 | free(t_path); | |
| 183 | osd_free(t_path); | |
| 184 | 184 | } |
| 185 | 185 | return result; |
| 186 | 186 | } |
| r7937 | r7938 | |
|---|---|---|
| 181 | 181 | free(*file); |
| 182 | 182 | *file = NULL; |
| 183 | 183 | } |
| 184 | free(t_path); | |
| 184 | osd_free(t_path); | |
| 185 | 185 | return filerr; |
| 186 | 186 | } |
| 187 | 187 | |
| r7937 | r7938 | |
| 276 | 276 | |
| 277 | 277 | done: |
| 278 | 278 | if (tempstr) |
| 279 | free(tempstr); | |
| 279 | osd_free(tempstr); | |
| 280 | 280 | return filerr; |
| 281 | 281 | } |
| 282 | 282 | |
| r7937 | r7938 | |
| 302 | 302 | if (t_filename == NULL) |
| 303 | 303 | return FALSE; |
| 304 | 304 | file = CreateFile(t_filename, GENERIC_READ, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL); |
| 305 | free(t_filename); | |
| 305 | osd_free(t_filename); | |
| 306 | 306 | if (file == INVALID_HANDLE_VALUE) |
| 307 | 307 | return FALSE; |
| 308 | 308 | |
| r7937 | r7938 | |
| 456 | 456 | |
| 457 | 457 | done: |
| 458 | 458 | if (t_path != NULL) |
| 459 | free(t_path); | |
| 459 | osd_free(t_path); | |
| 460 | 460 | return result; |
| 461 | 461 | } |
| 462 | 462 | |
| r7937 | r7938 | |
| 497 | 497 | |
| 498 | 498 | done: |
| 499 | 499 | if (t_path != NULL) |
| 500 | free(t_path); | |
| 500 | osd_free(t_path); | |
| 501 | 501 | return err; |
| 502 | 502 | } |
| 503 | 503 |
| r7937 | r7938 | |
|---|---|---|
| 276 | 276 | static HRESULT dinput_set_dword_property(LPDIRECTINPUTDEVICE device, REFGUID property_guid, DWORD object, DWORD how, DWORD value); |
| 277 | 277 | static device_info *dinput_device_create(running_machine *machine, device_info **devlist_head_ptr, LPCDIDEVICEINSTANCE instance, LPCDIDATAFORMAT format1, LPCDIDATAFORMAT format2, DWORD cooperative_level); |
| 278 | 278 | static void dinput_device_release(device_info *devinfo); |
| 279 | static c | |
| 279 | static c | |
| 280 | 280 | static HRESULT dinput_device_poll(device_info *devinfo); |
| 281 | 281 | static BOOL CALLBACK dinput_keyboard_enum(LPCDIDEVICEINSTANCE instance, LPVOID ref); |
| 282 | 282 | static void dinput_keyboard_poll(device_info *devinfo); |
| r7937 | r7938 | |
| 853 | 853 | |
| 854 | 854 | // free the copy of the name if present |
| 855 | 855 | if (devinfo->name != NULL) |
| 856 | | |
| 856 | | |
| 857 | 857 | devinfo->name = NULL; |
| 858 | 858 | |
| 859 | 859 | // and now free the info |
| r7937 | r7938 | |
| 968 | 968 | // populate the axes |
| 969 | 969 | for (axisnum = 0; axisnum < 2; axisnum++) |
| 970 | 970 | { |
| 971 | c | |
| 971 | c | |
| 972 | 972 | input_device_item_add(devinfo->device, name, &devinfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state); |
| 973 | | |
| 973 | | |
| 974 | 974 | } |
| 975 | 975 | |
| 976 | 976 | // populate the buttons |
| 977 | 977 | for (butnum = 0; butnum < 2; butnum++) |
| 978 | 978 | { |
| 979 | c | |
| 979 | c | |
| 980 | 980 | input_device_item_add(devinfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], (input_item_id)(ITEM_ID_BUTTON1 + butnum), generic_button_get_state); |
| 981 | | |
| 981 | | |
| 982 | 982 | } |
| 983 | 983 | } |
| 984 | 984 | } |
| r7937 | r7938 | |
| 1264 | 1264 | // dinput_device_item_name |
| 1265 | 1265 | //============================================================ |
| 1266 | 1266 | |
| 1267 | static c | |
| 1267 | static c | |
| 1268 | 1268 | { |
| 1269 | 1269 | DIDEVICEOBJECTINSTANCE instance = { 0 }; |
| 1270 | 1270 | const TCHAR *namestring = instance.tszName; |
| r7937 | r7938 | |
| 1350 | 1350 | { |
| 1351 | 1351 | input_item_id itemid = keyboard_map_scancode_to_itemid(keynum); |
| 1352 | 1352 | TCHAR defname[20]; |
| 1353 | c | |
| 1353 | c | |
| 1354 | 1354 | |
| 1355 | 1355 | // generate/fetch the name |
| 1356 | 1356 | _sntprintf(defname, ARRAY_LENGTH(defname), TEXT("Scan%03d"), keynum); |
| r7937 | r7938 | |
| 1358 | 1358 | |
| 1359 | 1359 | // add the item to the device |
| 1360 | 1360 | input_device_item_add(devinfo->device, name, &devinfo->keyboard.state[keynum], itemid, generic_button_get_state); |
| 1361 | | |
| 1361 | | |
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | 1364 | exit: |
| r7937 | r7938 | |
| 1430 | 1430 | // populate the axes |
| 1431 | 1431 | for (axisnum = 0; axisnum < devinfo->dinput.caps.dwAxes; axisnum++) |
| 1432 | 1432 | { |
| 1433 | c | |
| 1433 | c | |
| 1434 | 1434 | |
| 1435 | 1435 | // add to the mouse device and optionally to the gun device as well |
| 1436 | 1436 | input_device_item_add(devinfo->device, name, &devinfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state); |
| 1437 | 1437 | if (guninfo != NULL && axisnum < 2) |
| 1438 | 1438 | input_device_item_add(guninfo->device, name, &guninfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state); |
| 1439 | 1439 | |
| 1440 | | |
| 1440 | | |
| 1441 | 1441 | } |
| 1442 | 1442 | |
| 1443 | 1443 | // populate the buttons |
| 1444 | 1444 | for (butnum = 0; butnum < devinfo->dinput.caps.dwButtons; butnum++) |
| 1445 | 1445 | { |
| 1446 | 1446 | FPTR offset = (FPTR)(&((DIMOUSESTATE *)NULL)->rgbButtons[butnum]); |
| 1447 | c | |
| 1447 | c | |
| 1448 | 1448 | |
| 1449 | 1449 | // add to the mouse device and optionally to the gun device as well |
| 1450 | 1450 | // note that the gun device points to the mouse buttons rather than its own |
| r7937 | r7938 | |
| 1452 | 1452 | if (guninfo != NULL) |
| 1453 | 1453 | input_device_item_add(guninfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], (input_item_id)(ITEM_ID_BUTTON1 + butnum), generic_button_get_state); |
| 1454 | 1454 | |
| 1455 | | |
| 1455 | | |
| 1456 | 1456 | } |
| 1457 | 1457 | |
| 1458 | 1458 | exit: |
| r7937 | r7938 | |
| 1528 | 1528 | for (axisnum = axiscount = 0; axiscount < devinfo->dinput.caps.dwAxes && axisnum < 8; axisnum++) |
| 1529 | 1529 | { |
| 1530 | 1530 | DIPROPRANGE dipr; |
| 1531 | c | |
| 1531 | c | |
| 1532 | 1532 | |
| 1533 | 1533 | // fetch the range of this axis |
| 1534 | 1534 | dipr.diph.dwSize = sizeof(dipr); |
| r7937 | r7938 | |
| 1544 | 1544 | // populate the item description as well |
| 1545 | 1545 | name = dinput_device_item_name(devinfo, offsetof(DIJOYSTATE2, lX) + axisnum * sizeof(LONG), default_axis_name[axisnum], NULL); |
| 1546 | 1546 | input_device_item_add(devinfo->device, name, &devinfo->joystick.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state); |
| 1547 | | |
| 1547 | | |
| 1548 | 1548 | |
| 1549 | 1549 | axiscount++; |
| 1550 | 1550 | } |
| r7937 | r7938 | |
| 1552 | 1552 | // populate the POVs |
| 1553 | 1553 | for (povnum = 0; povnum < devinfo->dinput.caps.dwPOVs; povnum++) |
| 1554 | 1554 | { |
| 1555 | c | |
| 1555 | c | |
| 1556 | 1556 | |
| 1557 | 1557 | // left |
| 1558 | 1558 | name = dinput_device_item_name(devinfo, offsetof(DIJOYSTATE2, rgdwPOV) + povnum * sizeof(DWORD), default_pov_name(povnum), TEXT("L")); |
| 1559 | 1559 | input_device_item_add(devinfo->device, name, (void *)(FPTR)(povnum * 4 + POVDIR_LEFT), ITEM_ID_OTHER_SWITCH, dinput_joystick_pov_get_state); |
| 1560 | | |
| 1560 | | |
| 1561 | 1561 | |
| 1562 | 1562 | // right |
| 1563 | 1563 | name = dinput_device_item_name(devinfo, offsetof(DIJOYSTATE2, rgdwPOV) + povnum * sizeof(DWORD), default_pov_name(povnum), TEXT("R")); |
| 1564 | 1564 | input_device_item_add(devinfo->device, name, (void *)(FPTR)(povnum * 4 + POVDIR_RIGHT), ITEM_ID_OTHER_SWITCH, dinput_joystick_pov_get_state); |
| 1565 | | |
| 1565 | | |
| 1566 | 1566 | |
| 1567 | 1567 | // up |
| 1568 | 1568 | name = dinput_device_item_name(devinfo, offsetof(DIJOYSTATE2, rgdwPOV) + povnum * sizeof(DWORD), default_pov_name(povnum), TEXT("U")); |
| 1569 | 1569 | input_device_item_add(devinfo->device, name, (void *)(FPTR)(povnum * 4 + POVDIR_UP), ITEM_ID_OTHER_SWITCH, dinput_joystick_pov_get_state); |
| 1570 | | |
| 1570 | | |
| 1571 | 1571 | |
| 1572 | 1572 | // down |
| 1573 | 1573 | name = dinput_device_item_name(devinfo, offsetof(DIJOYSTATE2, rgdwPOV) + povnum * sizeof(DWORD), default_pov_name(povnum), TEXT("D")); |
| 1574 | 1574 | input_device_item_add(devinfo->device, name, (void *)(FPTR)(povnum * 4 + POVDIR_DOWN), ITEM_ID_OTHER_SWITCH, dinput_joystick_pov_get_state); |
| 1575 | | |
| 1575 | | |
| 1576 | 1576 | } |
| 1577 | 1577 | |
| 1578 | 1578 | // populate the buttons |
| 1579 | 1579 | for (butnum = 0; butnum < devinfo->dinput.caps.dwButtons; butnum++) |
| 1580 | 1580 | { |
| 1581 | 1581 | FPTR offset = (FPTR)(&((DIJOYSTATE2 *)NULL)->rgbButtons[butnum]); |
| 1582 | c | |
| 1582 | c | |
| 1583 | 1583 | input_device_item_add(devinfo->device, name, &devinfo->joystick.state.rgbButtons[butnum], (butnum < 16) ? (input_item_id)(ITEM_ID_BUTTON1 + butnum) : ITEM_ID_OTHER_SWITCH, generic_button_get_state); |
| 1584 | | |
| 1584 | | |
| 1585 | 1585 | } |
| 1586 | 1586 | |
| 1587 | 1587 | exit: |
| r7937 | r7938 | |
| 1967 | 1967 | { |
| 1968 | 1968 | input_item_id itemid = keyboard_map_scancode_to_itemid(keynum); |
| 1969 | 1969 | TCHAR keyname[100]; |
| 1970 | c | |
| 1970 | c | |
| 1971 | 1971 | |
| 1972 | 1972 | // generate the name |
| 1973 | 1973 | if (GetKeyNameText(((keynum & 0x7f) << 16) | ((keynum & 0x80) << 17), keyname, ARRAY_LENGTH(keyname)) == 0) |
| r7937 | r7938 | |
| 1976 | 1976 | |
| 1977 | 1977 | // add the item to the device |
| 1978 | 1978 | input_device_item_add(devinfo->device, name, &devinfo->keyboard.state[keynum], itemid, generic_button_get_state); |
| 1979 | | |
| 1979 | | |
| 1980 | 1980 | } |
| 1981 | 1981 | } |
| 1982 | 1982 | |
| r7937 | r7938 | |
| 2043 | 2043 | // populate the axes |
| 2044 | 2044 | for (axisnum = 0; axisnum < 3; axisnum++) |
| 2045 | 2045 | { |
| 2046 | c | |
| 2046 | c | |
| 2047 | 2047 | |
| 2048 | 2048 | // add to the mouse device and optionally to the gun device as well |
| 2049 | 2049 | input_device_item_add(devinfo->device, name, &devinfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state); |
| 2050 | 2050 | if (guninfo != NULL && axisnum < 2) |
| 2051 | 2051 | input_device_item_add(guninfo->device, name, &guninfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state); |
| 2052 | 2052 | |
| 2053 | | |
| 2053 | | |
| 2054 | 2054 | } |
| 2055 | 2055 | |
| 2056 | 2056 | // populate the buttons |
| 2057 | 2057 | for (butnum = 0; butnum < 5; butnum++) |
| 2058 | 2058 | { |
| 2059 | c | |
| 2059 | c | |
| 2060 | 2060 | |
| 2061 | 2061 | // add to the mouse device and optionally to the gun device as well |
| 2062 | 2062 | input_device_item_add(devinfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], (input_item_id)(ITEM_ID_BUTTON1 + butnum), generic_button_get_state); |
| 2063 | 2063 | if (guninfo != NULL) |
| 2064 | 2064 | input_device_item_add(guninfo->device, name, &guninfo->mouse.state.rgbButtons[butnum], (input_item_id)(ITEM_ID_BUTTON1 + butnum), generic_button_get_state); |
| 2065 | 2065 | |
| 2066 | | |
| 2066 | | |
| 2067 | 2067 | } |
| 2068 | 2068 | } |
| 2069 | 2069 |
| r7937 | r7938 | |
|---|---|---|
| 60 | 60 | if (t_string != NULL) |
| 61 | 61 | { |
| 62 | 62 | OutputDebugString(t_string); |
| 63 | free(t_string); | |
| 63 | osd_free(t_string); | |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| r7937 | r7938 | |
| 83 | 83 | return 0; |
| 84 | 84 | |
| 85 | 85 | size = (DWORD) snprintf(filename, size, "%s", utf8_filename); |
| 86 | free(utf8_filename); | |
| 86 | osd_free(utf8_filename); | |
| 87 | 87 | return size; |
| 88 | 88 | } |
| 89 | 89 | |
| r7937 | r7938 | |
| 102 | 102 | |
| 103 | 103 | result = SetFileAttributes(t_filename, fileattributes); |
| 104 | 104 | |
| 105 | free(t_filename); | |
| 105 | osd_free(t_filename); | |
| 106 | 106 | |
| 107 | 107 | return result; |
| 108 | 108 | } |
| r7937 | r7938 | |
| 125 | 125 | |
| 126 | 126 | t_newfilename = tstring_from_utf8(newfilename); |
| 127 | 127 | if( !t_newfilename ) { |
| 128 | free(t_existingfilename); | |
| 128 | osd_free(t_existingfilename); | |
| 129 | 129 | return result; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | result = CopyFile(t_existingfilename, t_newfilename, failifexists); |
| 133 | 133 | |
| 134 | free(t_newfilename); | |
| 135 | free(t_existingfilename); | |
| 134 | osd_free(t_newfilename); | |
| 135 | osd_free(t_existingfilename); | |
| 136 | 136 | |
| 137 | 137 | return result; |
| 138 | 138 | } |
| r7937 | r7938 | |
| 161 | 161 | |
| 162 | 162 | result = MoveFile(t_existingfilename, t_newfilename); |
| 163 | 163 | |
| 164 | free(t_newfilename); | |
| 165 | free(t_existingfilename); | |
| 164 | osd_free(t_newfilename); | |
| 165 | osd_free(t_existingfilename); | |
| 166 | 166 | |
| 167 | 167 | return result; |
| 168 | 168 | } |
| r7937 | r7938 | |
| 197 | 197 | |
| 198 | 198 | done: |
| 199 | 199 | if (t_text) |
| 200 | free(t_text); | |
| 200 | osd_free(t_text); | |
| 201 | 201 | if (t_caption) |
| 202 | free(t_caption); | |
| 202 | osd_free(t_caption); | |
| 203 | 203 | return result; |
| 204 | 204 | } |
| 205 | 205 | |
| r7937 | r7938 | |
| 225 | 225 | |
| 226 | 226 | done: |
| 227 | 227 | if (t_text) |
| 228 | free(t_text); | |
| 228 | osd_free(t_text); | |
| 229 | 229 | return result; |
| 230 | 230 | } |
| 231 | 231 | |
| r7937 | r7938 | |
| 254 | 254 | |
| 255 | 255 | done: |
| 256 | 256 | if (utf8_buffer) |
| 257 | free(utf8_buffer); | |
| 257 | osd_free(utf8_buffer); | |
| 258 | 258 | return result; |
| 259 | 259 | } |
| 260 | 260 | |
| r7937 | r7938 | |
| 278 | 278 | |
| 279 | 279 | t_windowname = tstring_from_utf8(windowname); |
| 280 | 280 | if( !t_windowname ) { |
| 281 | free(t_classname); | |
| 281 | osd_free(t_classname); | |
| 282 | 282 | return result; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | result = CreateWindowEx(exstyle, t_classname, t_windowname, style, x, y, width, height, parent, |
| 286 | 286 | menu, instance, param); |
| 287 | 287 | |
| 288 | free(t_windowname); | |
| 289 | free(t_classname); | |
| 288 | osd_free(t_windowname); | |
| 289 | osd_free(t_classname); | |
| 290 | 290 | |
| 291 | 291 | return result; |
| 292 | 292 | } |
| r7937 | r7938 | |
|---|---|---|
| 430 | 430 | t_face = tstring_from_utf8(options_get_string(mame_options(), WINOPTION_DEBUGGER_FONT)); |
| 431 | 431 | debug_font = CreateFont(-MulDiv(size, GetDeviceCaps(temp_dc, LOGPIXELSY), 72), 0, 0, 0, FW_MEDIUM, FALSE, FALSE, FALSE, |
| 432 | 432 | ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, t_face); |
| 433 | | |
| 433 | | |
| 434 | 434 | |
| 435 | 435 | // fall back to Lucida Console 8 |
| 436 | 436 | if (debug_font == NULL) |
| r7937 | r7938 | |
| 1574 | 1574 | if (utf8_buffer != NULL) |
| 1575 | 1575 | { |
| 1576 | 1576 | (*info->process_string)(info, utf8_buffer); |
| 1577 | | |
| 1577 | | |
| 1578 | 1578 | } |
| 1579 | 1579 | } |
| 1580 | 1580 | break; |
| r7937 | r7938 | |
| 1777 | 1777 | { |
| 1778 | 1778 | TCHAR *t_name = tstring_from_utf8(subview->name); |
| 1779 | 1779 | int item = SendMessage(info->otherwnd[0], CB_ADDSTRING, 0, (LPARAM)t_name); |
| 1780 | | |
| 1780 | | |
| 1781 | 1781 | if (cursel == -1 && subview->space != NULL && subview->space->cpu == curcpu) |
| 1782 | 1782 | cursel = item; |
| 1783 | 1783 | } |
| r7937 | r7938 | |
| 2086 | 2086 | { |
| 2087 | 2087 | TCHAR *t_name = tstring_from_utf8(subview->name); |
| 2088 | 2088 | int item = SendMessage(info->otherwnd[0], CB_ADDSTRING, 0, (LPARAM)t_name); |
| 2089 | | |
| 2089 | | |
| 2090 | 2090 | if (cursel == 0 && subview->space->cpu == curcpu) |
| 2091 | 2091 | cursel = item; |
| 2092 | 2092 | } |
| r7937 | r7938 | |
|---|---|---|
| 263 | 263 | if (utf8_device != NULL) |
| 264 | 264 | { |
| 265 | 265 | mame_printf_verbose("Video: Monitor %p = \"%s\" %s\n", monitor->handle, utf8_device, (monitor == primary_monitor) ? "(primary)" : ""); |
| 266 | | |
| 266 | | |
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | } |
| r7937 | r7938 | |
| 349 | 349 | if (utf8_device != NULL) |
| 350 | 350 | { |
| 351 | 351 | rc = strcmp(scrname, utf8_device); |
| 352 | | |
| 352 | | |
| 353 | 353 | } |
| 354 | 354 | if (rc == 0) |
| 355 | 355 | goto finishit; |
| r7937 | r7938 | |
|---|---|---|
| 83 | 83 | |
| 84 | 84 | /* free arguments */ |
| 85 | 85 | for (i = 0; i < argc; i++) |
| 86 | free(utf8_argv[i]); | |
| 86 | osd_free(utf8_argv[i]); | |
| 87 | 87 | free(utf8_argv); |
| 88 | 88 | |
| 89 | 89 | return rc; |
| r7937 | r7938 | |
|---|---|---|
| 1200 | 1200 | if (utf8_device != NULL) |
| 1201 | 1201 | { |
| 1202 | 1202 | mame_printf_error("Device %s currently in an unsupported mode\n", utf8_device); |
| 1203 | | |
| 1203 | | |
| 1204 | 1204 | } |
| 1205 | 1205 | return 1; |
| 1206 | 1206 | } |
| r7937 | r7938 | |
| 1228 | 1228 | if (utf8_device != NULL) |
| 1229 | 1229 | { |
| 1230 | 1230 | mame_printf_error("Proposed video mode not supported on device %s\n", utf8_device); |
| 1231 | | |
| 1231 | | |
| 1232 | 1232 | } |
| 1233 | 1233 | return 1; |
| 1234 | 1234 | } |
| r7937 | r7938 | |
|---|---|---|
| 489 | 489 | if (size > view->viewdata_size) |
| 490 | 490 | { |
| 491 | 491 | view->viewdata_size = size; |
| 492 | | |
| 492 | | |
| 493 | 493 | view->viewdata = auto_alloc_array(view->machine, debug_view_char, view->viewdata_size); |
| 494 | 494 | } |
| 495 | 495 |
| r7937 | r7938 | |
|---|---|---|
| 482 | 482 | global_free(data); |
| 483 | 483 | |
| 484 | 484 | /* close the file */ |
| 485 | | |
| 485 | | |
| 486 | 486 | mame_fclose(file); |
| 487 | 487 | return result; |
| 488 | 488 | |
| 489 | 489 | error: |
| 490 | 490 | /* close the file */ |
| 491 | 491 | if (cachedname != NULL) |
| 492 | | |
| 492 | | |
| 493 | 493 | if (data != NULL) |
| 494 | 494 | global_free(data); |
| 495 | 495 | mame_fclose(file); |
| r7937 | r7938 | |
|---|---|---|
| 1246 | 1246 | inputx_post_utf8(machine, text); |
| 1247 | 1247 | |
| 1248 | 1248 | /* free the string */ |
| 1249 | free(text); | |
| 1249 | osd_free(text); | |
| 1250 | 1250 | } |
| 1251 | 1251 | } |
| 1252 | 1252 |
| r7937 | r7938 | |
|---|---|---|
| 247 | 247 | |
| 248 | 248 | |
| 249 | 249 | /*------------------------------------------------- |
| 250 | pool_free - frees a memory pool and all | |
| 250 | pool_free_lib - frees a memory pool and all | |
| 251 | 251 | contained memory blocks |
| 252 | 252 | -------------------------------------------------*/ |
| 253 | 253 |
| Previous | 15994 Revisions | Next |