src/osd/sdl/input.c
| r1048 | r1049 | |
| 160 | 160 | |
| 161 | 161 | // deivce list management |
| 162 | 162 | static void device_list_reset_devices(device_info *devlist_head); |
| 163 | | static int device_list_count(device_info *devlist_head); |
| 164 | 163 | static void device_list_free_devices(device_info *devlist_head); |
| 165 | 164 | |
| 166 | 165 | // generic device management |
| r1048 | r1049 | |
| 172 | 171 | static INT32 generic_axis_get_state(void *device_internal, void *item_internal); |
| 173 | 172 | static device_info *generic_device_find_index(device_info *devlist_head, int index); |
| 174 | 173 | |
| 175 | | // Win32-specific input code |
| 176 | | static void sdl_init(running_machine *machine); |
| 177 | | static void sdl_exit(running_machine *machine); |
| 178 | | static void sdl_keyboard_poll(device_info *devinfo); |
| 179 | | static void sdl_lightgun_poll(device_info *devinfo); |
| 180 | | |
| 181 | | static const char *default_button_name(int which); |
| 182 | | static const char *default_pov_name(int which); |
| 183 | | |
| 184 | | |
| 185 | | |
| 186 | 174 | //============================================================ |
| 187 | 175 | // KEYBOARD/JOYSTICK LIST |
| 188 | 176 | //============================================================ |
| r1048 | r1049 | |
| 708 | 696 | return index; |
| 709 | 697 | } |
| 710 | 698 | |
| 699 | #ifdef MESS |
| 711 | 700 | static int lookup_mame_code(const char *scode) |
| 712 | 701 | { |
| 713 | 702 | int index; |
| r1048 | r1049 | |
| 717 | 706 | else |
| 718 | 707 | return -1; |
| 719 | 708 | } |
| 709 | #endif |
| 720 | 710 | |
| 721 | 711 | //============================================================ |
| 722 | 712 | // sdlinput_init |
| r1048 | r1049 | |
| 1252 | 1242 | } |
| 1253 | 1243 | |
| 1254 | 1244 | //============================================================ |
| 1255 | | // device_list_count |
| 1256 | | //============================================================ |
| 1257 | | |
| 1258 | | static int device_list_count(device_info *devlist_head) |
| 1259 | | { |
| 1260 | | device_info *curdev; |
| 1261 | | int count = 0; |
| 1262 | | |
| 1263 | | for (curdev = devlist_head; curdev != NULL; curdev = curdev->next) |
| 1264 | | count++; |
| 1265 | | return count; |
| 1266 | | } |
| 1267 | | |
| 1268 | | |
| 1269 | | //============================================================ |
| 1270 | 1245 | // generic_device_alloc |
| 1271 | 1246 | //============================================================ |
| 1272 | 1247 | |
| r1048 | r1049 | |
| 1403 | 1378 | // return the current state |
| 1404 | 1379 | return *axisdata; |
| 1405 | 1380 | } |
| 1406 | | |
| 1407 | | |
| 1408 | | //============================================================ |
| 1409 | | // sdl_init |
| 1410 | | //============================================================ |
| 1411 | | |
| 1412 | | static void sdl_init(running_machine *machine) |
| 1413 | | { |
| 1414 | | } |
| 1415 | | |
| 1416 | | |
| 1417 | | //============================================================ |
| 1418 | | // sdl_exit |
| 1419 | | //============================================================ |
| 1420 | | |
| 1421 | | static void sdl_exit(running_machine *machine) |
| 1422 | | { |
| 1423 | | } |
| 1424 | | |
| 1425 | | |
| 1426 | | //============================================================ |
| 1427 | | // sdl_keyboard_poll |
| 1428 | | //============================================================ |
| 1429 | | |
| 1430 | | static void sdl_keyboard_poll(device_info *devinfo) |
| 1431 | | { |
| 1432 | | #if 0 |
| 1433 | | int keynum; |
| 1434 | | |
| 1435 | | // reset the keyboard state and then repopulate |
| 1436 | | memset(devinfo->keyboard.state, 0, sizeof(devinfo->keyboard.state)); |
| 1437 | | |
| 1438 | | // iterate over keys |
| 1439 | | for (keynum = 0; keynum < ARRAY_LENGTH(sdl_key_trans_table); keynum++) |
| 1440 | | { |
| 1441 | | int vk = sdl_key_trans_table[keynum][VIRTUAL_KEY]; |
| 1442 | | if (vk != 0 && (GetAsyncKeyState(vk) & 0x8000) != 0) |
| 1443 | | { |
| 1444 | | int dik = sdl_key_trans_table[keynum][SDL_KEY]; |
| 1445 | | |
| 1446 | | // conver the VK code to a scancode (DIK code) |
| 1447 | | if (dik != 0) |
| 1448 | | devinfo->keyboard.state[dik] = 0x80; |
| 1449 | | |
| 1450 | | // set this flag so that we continue to use win32 until all keys are up |
| 1451 | | keyboard_sdl_reported_key_down = TRUE; |
| 1452 | | } |
| 1453 | | } |
| 1454 | | #endif |
| 1455 | | } |
| 1456 | | |
| 1457 | | |
| 1458 | | //============================================================ |
| 1459 | | // sdl_lightgun_poll |
| 1460 | | //============================================================ |
| 1461 | | |
| 1462 | | static void sdl_lightgun_poll(device_info *devinfo) |
| 1463 | | { |
| 1464 | | #if 0 |
| 1465 | | INT32 xpos = 0, ypos = 0; |
| 1466 | | POINT mousepos; |
| 1467 | | |
| 1468 | | // if we are using the shared axis hack, the data is updated via Windows messages only |
| 1469 | | if (lightgun_shared_axis_mode) |
| 1470 | | return; |
| 1471 | | |
| 1472 | | // get the cursor position and transform into final results |
| 1473 | | GetCursorPos(&mousepos); |
| 1474 | | if (sdl_window_list != NULL) |
| 1475 | | { |
| 1476 | | RECT client_rect; |
| 1477 | | |
| 1478 | | // get the position relative to the window |
| 1479 | | GetClientRect(sdl_window_list->hwnd, &client_rect); |
| 1480 | | ScreenToClient(sdl_window_list->hwnd, &mousepos); |
| 1481 | | |
| 1482 | | // convert to absolute coordinates |
| 1483 | | xpos = normalize_absolute_axis(mousepos.x, client_rect.left, client_rect.right); |
| 1484 | | ypos = normalize_absolute_axis(mousepos.y, client_rect.top, client_rect.bottom); |
| 1485 | | } |
| 1486 | | |
| 1487 | | // update the X/Y positions |
| 1488 | | devinfo->mouse.state.lX = xpos; |
| 1489 | | devinfo->mouse.state.lY = ypos; |
| 1490 | | #endif |
| 1491 | | } |
| 1492 | | |
| 1493 | | //============================================================ |
| 1494 | | // default_button_name |
| 1495 | | //============================================================ |
| 1496 | | |
| 1497 | | static const char *default_button_name(int which) |
| 1498 | | { |
| 1499 | | static char buffer[20]; |
| 1500 | | snprintf(buffer, sizeof(buffer)-1, "B%d", which); |
| 1501 | | return buffer; |
| 1502 | | } |
| 1503 | | |
| 1504 | | |
| 1505 | | //============================================================ |
| 1506 | | // default_pov_name |
| 1507 | | //============================================================ |
| 1508 | | |
| 1509 | | static const char *default_pov_name(int which) |
| 1510 | | { |
| 1511 | | static char buffer[20]; |
| 1512 | | snprintf(buffer, strlen(buffer)-1, "POV%d", which); |
| 1513 | | return buffer; |
| 1514 | | } |
src/osd/sdl/sdlwork.c
| r1048 | r1049 | |
| 434 | 434 | |
| 435 | 435 | // free all the mutexes and conditions |
| 436 | 436 | pthread_cond_destroy(&queue->statecond); |
| 437 | pthread_mutex_unlock(&queue->statelock); |
| 437 | 438 | pthread_mutex_destroy(&queue->statelock); |
| 438 | 439 | |
| 439 | 440 | // free the critical section |
| 441 | pthread_mutex_unlock(&queue->critsect); |
| 440 | 442 | pthread_mutex_destroy(&queue->critsect); |
| 441 | 443 | |
| 442 | 444 | // free all items in the free list |
| r1048 | r1049 | |
| 447 | 449 | if (!(item->flags & WORK_ITEM_FLAG_AUTO_RELEASE)) |
| 448 | 450 | { |
| 449 | 451 | pthread_cond_destroy(&item->statecond); |
| 452 | pthread_mutex_unlock(&item->statelock); |
| 450 | 453 | pthread_mutex_destroy(&item->statelock); |
| 451 | 454 | } |
| 452 | 455 | free(item); |
| r1048 | r1049 | |
| 458 | 461 | osd_work_item *item = (osd_work_item *)queue->list; |
| 459 | 462 | queue->list = item->next; |
| 460 | 463 | pthread_cond_destroy(&item->statecond); |
| 464 | pthread_mutex_unlock(&item->statelock); |
| 461 | 465 | pthread_mutex_destroy(&item->statelock); |
| 462 | 466 | free(item); |
| 463 | 467 | } |
| r1048 | r1049 | |
| 590 | 594 | |
| 591 | 595 | // release the mutexes and conditions |
| 592 | 596 | pthread_cond_destroy(&item->statecond); |
| 597 | pthread_mutex_unlock(&item->statelock); |
| 593 | 598 | pthread_mutex_destroy(&item->statelock); |
| 594 | 599 | |
| 595 | 600 | // add us to the free list on our queue |