summaryrefslogtreecommitdiff
path: root/uisimulator
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator')
-rw-r--r--uisimulator/sdl/button-sdl.h6
-rw-r--r--uisimulator/sdl/button.c449
-rw-r--r--uisimulator/sdl/uisdl.c108
3 files changed, 548 insertions, 15 deletions
diff --git a/uisimulator/sdl/button-sdl.h b/uisimulator/sdl/button-sdl.h
index 8159d24729..948af62c5b 100644
--- a/uisimulator/sdl/button-sdl.h
+++ b/uisimulator/sdl/button-sdl.h
@@ -32,6 +32,12 @@
32#undef button_init_device 32#undef button_init_device
33#define button_init_device() 33#define button_init_device()
34 34
35struct button_map {
36 int button, x, y, radius;
37 char *description;
38};
39
40int xy2button( int x, int y);
35bool button_hold(void); 41bool button_hold(void);
36void button_init_sdl(void); 42void button_init_sdl(void);
37#undef button_init_device 43#undef button_init_device
diff --git a/uisimulator/sdl/button.c b/uisimulator/sdl/button.c
index a102925ed2..52646220e7 100644
--- a/uisimulator/sdl/button.c
+++ b/uisimulator/sdl/button.c
@@ -1092,6 +1092,9 @@ void button_event(int key, bool pressed)
1092 case SDLK_DOWN: 1092 case SDLK_DOWN:
1093 new_btn = BUTTON_DOWN; 1093 new_btn = BUTTON_DOWN;
1094 break; 1094 break;
1095 case SDLK_KP1:
1096 new_btn = BUTTON_MENU;
1097 break;
1095 case SDLK_KP5: 1098 case SDLK_KP5:
1096 case SDLK_SPACE: 1099 case SDLK_SPACE:
1097 new_btn = BUTTON_PLAY; 1100 new_btn = BUTTON_PLAY;
@@ -1392,3 +1395,449 @@ void button_init_sdl(void)
1392#endif 1395#endif
1393} 1396}
1394 1397
1398/* Button maps: simulated key, x, y, radius, name */
1399/* Run sim with --mapping to get coordinates */
1400/* or --debugbuttons to check */
1401/* The First matching button is returned */
1402
1403#ifdef SANSA_FUZE
1404struct button_map bm[] = {
1405 { SDLK_KP8, 70, 265, 35, "Scroll Back" },
1406 { SDLK_KP9, 141, 255, 31, "Play" },
1407 { SDLK_KP_MULTIPLY, 228, 267, 18, "Home" },
1408 { SDLK_LEFT, 69, 329, 31, "Left" },
1409 { SDLK_SPACE, 141, 330, 20, "Select" },
1410 { SDLK_RIGHT, 214, 331, 23, "Right" },
1411 { SDLK_KP3, 142, 406, 30, "Menu" },
1412 { SDLK_DOWN, 221, 384, 24, "Scroll Fwd" },
1413 { SDLK_KP_MINUS, 270, 299, 25, "Power" },
1414 { SDLK_h, 269, 358, 26, "Hold" },
1415 { 0, 0, 0, 0, "None" }
1416};
1417#elif defined (SANSA_CLIP)
1418struct button_map bm[] = {
1419 { SDLK_KP_MULTIPLY, 165, 158, 17, "Home" },
1420 { SDLK_KP5, 102, 230, 29, "Select" },
1421 { SDLK_KP8, 100, 179, 25, "Play" },
1422 { SDLK_KP4, 53, 231, 21, "Left" },
1423 { SDLK_KP6, 147, 232, 19, "Right" },
1424 { SDLK_KP2, 105, 275, 22, "Menu" },
1425 { 0, 0, 0, 0, "None" }
1426};
1427#elif defined (SANSA_C200) || defined(SANSA_C200V2)
1428struct button_map bm[] = {
1429
1430 { SDLK_KP7, 84, 7, 21, "Vol Down" },
1431 { SDLK_KP9, 158, 7, 20, "Vol Up" },
1432 { SDLK_KP1, 173, 130, 27, "Record" },
1433 { SDLK_KP5, 277, 75, 21, "Select" },
1434 { SDLK_KP4, 233, 75, 24, "Left" },
1435 { SDLK_KP6, 313, 74, 18, "Right" },
1436 { SDLK_KP8, 276, 34, 15, "Play" },
1437 { SDLK_KP2, 277, 119, 17, "Down" },
1438 { SDLK_KP3, 314, 113, 19, "Menu" },
1439 { 0, 0, 0, 0, "None" }
1440};
1441#elif defined (SANSA_E200V2) || defined(SANSA_E200)
1442struct button_map bm[] = {
1443 { SDLK_KP7, 5, 92, 18, "Record" },
1444 { SDLK_KP9, 128, 295, 43, "Play" },
1445 { SDLK_KP4, 42, 380, 33, "Left" },
1446 { SDLK_KP5, 129, 378, 36, "Select" },
1447 { SDLK_KP6, 218, 383, 30, "Right" },
1448 { SDLK_KP3, 129, 461, 29, "Down" },
1449 { SDLK_KP1, 55, 464, 20, "Menu" },
1450 { SDLK_KP8, 92, 338, 17, "Scroll Back" },
1451 { SDLK_KP2, 167, 342, 17, "Scroll Fwd" },
1452 { 0, 0, 0, 0, "None" }
1453};
1454#elif defined (SANSA_M200V4)
1455struct button_map bm[] = {
1456 { SDLK_KP_PLUS, 54, 14, 16, "Power" },
1457 { SDLK_KP7, 96, 13, 12, "Vol Down" },
1458 { SDLK_KP9, 139, 14, 14, "Vol Up" },
1459 { SDLK_KP5, 260, 82, 20, "Select" },
1460 { SDLK_KP8, 258, 35, 30, "Play" },
1461 { SDLK_KP4, 214, 84, 25, "Left" },
1462 { SDLK_KP6, 300, 83, 24, "Right" },
1463 { SDLK_KP2, 262, 125, 28, "Repeat" },
1464 { SDLK_h, 113, 151, 21, "Hold" },
1465 { 0, 0, 0, 0, "None" }
1466};
1467#elif defined (IPOD_VIDEO)
1468struct button_map bm[] = {
1469 { SDLK_KP_PERIOD, 174, 350, 35, "Menu" },
1470 { SDLK_KP8, 110, 380, 33, "Scroll Back" },
1471 { SDLK_KP2, 234, 377, 34, "Scroll Fwd" },
1472 { SDLK_KP4, 78, 438, 47, "Left" },
1473 { SDLK_KP5, 172, 435, 43, "Select" },
1474 { SDLK_KP6, 262, 438, 52, "Right" },
1475 { SDLK_KP_PLUS, 172, 519, 43, "Play" },
1476 { 0, 0, 0 , 0, "None" }
1477};
1478#elif defined (IPOD_MINI) || defined(IPOD_MINI2G)
1479struct button_map bm[] = {
1480 { SDLK_KP5, 92, 267, 29, "Select" },
1481 { SDLK_KP4, 31, 263, 37, "Left" },
1482 { SDLK_KP6, 150, 268, 33, "Right" },
1483 { SDLK_KP_PERIOD, 93, 209, 30, "Menu" },
1484 { SDLK_KP_PLUS, 93, 324, 25, "Play" },
1485 { SDLK_KP8, 53, 220, 29, "Scroll Back" },
1486 { SDLK_KP2, 134, 219, 31, "Scroll Fwd" },
1487 { 0, 0, 0 , 0, "None" }
1488};
1489#elif defined (IPOD_3G)
1490struct button_map bm[] = {
1491 { SDLK_KP5, 108, 296, 26, "Select" },
1492 { SDLK_KP8, 70, 255, 26, "Scroll Back" },
1493 { SDLK_KP2, 149, 256, 28, "Scroll Fwd" },
1494 { SDLK_KP4, 27, 186, 22, "Left" },
1495 { SDLK_KP_PERIOD, 82, 185, 22, "Menu" },
1496 { SDLK_KP_PERIOD, 133, 185, 21, "Play" },
1497 { SDLK_KP6, 189, 188, 21, "Right" },
1498 { 0, 0, 0 , 0, "None" }
1499};
1500#elif defined (IPOD_4G)
1501struct button_map bm[] = {
1502 { SDLK_KP5, 96, 269, 27, "Select" },
1503 { SDLK_KP4, 39, 267, 30, "Left" },
1504 { SDLK_KP6, 153, 270, 27, "Right" },
1505 { SDLK_KP_PERIOD, 96, 219, 30, "Menu" },
1506 { SDLK_KP_PLUS, 95, 326, 27, "Play" },
1507 { SDLK_KP8, 57, 233, 29, "Scroll Back" },
1508 { SDLK_KP2, 132, 226, 29, "Scroll Fwd" },
1509 { 0, 0, 0 , 0, "None" }
1510};
1511#elif defined (IPOD_COLOR)
1512struct button_map bm[] = {
1513 { SDLK_KP5, 128, 362, 35, "Select" },
1514 { SDLK_KP4, 55, 358, 38, "Left" },
1515 { SDLK_KP6, 203, 359, 39, "Right" },
1516 { SDLK_KP_PERIOD, 128, 282, 34, "Menu" },
1517 { SDLK_KP_PLUS, 129, 439, 41, "Play" },
1518 { SDLK_KP8, 76, 309, 34, "Scroll Back" },
1519 { SDLK_KP2, 182, 311, 45, "Scroll Fwd" },
1520 { 0, 0, 0 , 0, "None" }
1521};
1522#elif defined (IPOD_1G2G)
1523struct button_map bm[] = {
1524 { SDLK_KP5, 112, 265, 31, "Select" },
1525 { SDLK_KP8, 74, 224, 28, "Scroll Back" },
1526 { SDLK_KP2, 146, 228, 28, "Scroll Fwd" },
1527 /* Dummy button to make crescent shape */
1528 { SDLK_y, 112, 265, 76, "None" },
1529 { SDLK_KP8, 74, 224, 28, "Scroll Back" },
1530 { SDLK_KP2, 146, 228, 28, "Scroll Fwd" },
1531 { SDLK_KP6, 159, 268, 64, "Right" },
1532 { SDLK_KP4, 62, 266, 62, "Left" },
1533 { SDLK_KP_PERIOD, 111, 216, 64, "Menu" },
1534 { SDLK_KP_PLUS, 111, 326, 55, "Down" },
1535 { 0, 0, 0 , 0, "None" }
1536};
1537#elif defined (IPOD_NANO)
1538struct button_map bm[] = {
1539 { SDLK_KP5, 98, 316, 37, "Select" },
1540 { SDLK_KP4, 37, 312, 28, "Left" },
1541 { SDLK_KP6, 160, 313, 25, "Right" },
1542 { SDLK_KP_PERIOD,102, 256, 23, "Menu" },
1543 { SDLK_KP_PLUS, 99, 378, 28, "Play" },
1544 { SDLK_KP8, 58, 272, 24, "Scroll Back" },
1545 { SDLK_KP2, 141, 274, 22, "Scroll Fwd" },
1546 { 0, 0, 0 , 0, "None" }
1547};
1548#elif defined (IPOD_NANO2G)
1549struct button_map bm[] = {
1550 { SDLK_KP5, 118, 346, 37, "Select" },
1551 { SDLK_KP4, 51, 345, 28, "Left" },
1552 { SDLK_KP6, 180, 346, 26, "Right" },
1553 { SDLK_KP_PERIOD, 114, 286, 23, "Menu" },
1554 { SDLK_KP_PLUS, 115, 412, 27, "Down" },
1555 { SDLK_KP8, 67, 303, 28, "Scroll Back" },
1556 { SDLK_KP2, 163, 303, 27, "Scroll Fwd" },
1557 { 0, 0, 0 , 0, "None" }
1558};
1559#elif defined (COWON_D2)
1560struct button_map bm[] = {
1561 { SDLK_DELETE, 51, 14, 17, "Power" },
1562 { SDLK_h, 138, 14, 16, "Hold" },
1563 { SDLK_MINUS, 320, 14, 10, "Minus" },
1564 { SDLK_INSERT, 347, 13, 13, "Menu" },
1565 { SDLK_KP_PLUS, 374, 14, 12, "Plus" },
1566 { 0, 0, 0, 0, "None" }
1567};
1568#elif defined (IAUDIO_M3)
1569struct button_map bm[] = {
1570 { SDLK_KP5, 256, 72, 29, "Play" },
1571 { SDLK_KP6, 255, 137, 28, "Right" },
1572 { SDLK_KP4, 257, 201, 26, "Left" },
1573 { SDLK_KP8, 338, 31, 27, "Up" },
1574 { SDLK_KP2, 339, 92, 23, "Down" },
1575 { SDLK_KP_DIVIDE, 336, 147, 23, "Rec" },
1576 { SDLK_h, 336, 212, 30, "Hold" },
1577 { 0, 0, 0, 0, "None" }
1578};
1579#elif defined (IAUDIO_M5)
1580struct button_map bm[] = {
1581 { SDLK_KP_ENTER, 333, 41, 17, "Enter" },
1582 { SDLK_h, 334, 74, 21, "Hold" },
1583 { SDLK_KP_DIVIDE, 333, 142, 24, "Record" },
1584 { SDLK_KP_PLUS, 332, 213, 20, "Play" },
1585 { SDLK_KP5, 250, 291, 19, "Select" },
1586 { SDLK_KP8, 249, 236, 32, "Up" },
1587 { SDLK_KP4, 194, 292, 29, "Left" },
1588 { SDLK_KP6, 297, 290, 27, "Right" },
1589 { SDLK_KP2, 252, 335, 28, "Down" },
1590 { 0, 0, 0, 0, "None" }
1591};
1592#elif defined (IAUDIO_7)
1593struct button_map bm[] = {
1594 { 0, 0, 0, 0, "None" }
1595};
1596#elif defined (IAUDIO_X5)
1597struct button_map bm[] = {
1598 { SDLK_KP_ENTER, 275, 38, 17, "Power" },
1599 { SDLK_h, 274, 83, 16, "Hold" },
1600 { SDLK_KP_DIVIDE, 276, 128, 22, "Record" },
1601 { SDLK_KP_PLUS, 274, 186, 22, "Play" },
1602 { SDLK_KP5, 200, 247, 16, "Select" },
1603 { SDLK_KP8, 200, 206, 16, "Up" },
1604 { SDLK_KP4, 163, 248, 19, "Left" },
1605 { SDLK_KP6, 225, 247, 24, "Right" },
1606 { SDLK_KP2, 199, 279, 20, "Down" },
1607 { 0, 0, 0, 0, "None" }
1608};
1609#elif defined (ARCHOS_PLAYER)
1610struct button_map bm[] = {
1611 { SDLK_KP_PLUS, 79, 252, 23, "On" },
1612 { SDLK_KP_PERIOD, 81, 310, 20, "Menu" },
1613 { SDLK_KP8, 154, 237, 28, "Play" },
1614 { SDLK_KP4, 121, 282, 23, "Left" },
1615 { SDLK_KP6, 187, 282, 22, "Right" },
1616 { SDLK_KP2, 157, 312, 20, "Down" },
1617 { 0, 0, 0, 0, "None" }
1618};
1619#elif defined (ARCHOS_RECORDER)
1620struct button_map bm[] = {
1621 { SDLK_F1, 94, 205, 22, "F1" },
1622 { SDLK_F2, 136, 204, 21, "F2" },
1623 { SDLK_F3, 174, 204, 24, "F3" },
1624 { SDLK_KP_PLUS, 75, 258, 19, "On" },
1625 { SDLK_KP_ENTER, 76, 307, 15, "Off" },
1626 { SDLK_KP5, 151, 290, 20, "Select" },
1627 { SDLK_KP8, 152, 251, 23, "Up" },
1628 { SDLK_KP4, 113, 288, 26, "Left" },
1629 { SDLK_KP6, 189, 291, 23, "Right" },
1630 { SDLK_KP2, 150, 327, 27, "Down" },
1631 { 0, 0, 0, 0, "None" }
1632};
1633#elif defined (ARCHOS_FMRECORDER) || defined (ARCHOS_RECORDERV2)
1634struct button_map bm[] = {
1635 { SDLK_F1, 88, 210, 28, "F1" },
1636 { SDLK_F2, 144, 212, 28, "F2" },
1637 { SDLK_F3, 197, 212, 28, "F3" },
1638 { SDLK_KP5, 144, 287, 21, "Select" },
1639 { SDLK_KP_PLUS, 86, 320, 13, "Menu" },
1640 { SDLK_KP_ENTER, 114, 347, 13, "Stop" },
1641 { SDLK_y, 144, 288, 31, "None" },
1642 { SDLK_KP8, 144, 259, 25, "Up" },
1643 { SDLK_KP2, 144, 316, 31, "Down" },
1644 { SDLK_KP6, 171, 287, 32, "Right" },
1645 { SDLK_KP4, 117, 287, 31, "Left" },
1646 { 0, 0, 0, 0, "None" }
1647};
1648#elif defined (ARCHOS_ONDIOSP) || defined (ARCHOS_ONDIOFM)
1649struct button_map bm[] = {
1650 { SDLK_KP_ENTER, 75, 23, 30, "Enter" },
1651 { SDLK_KP8, 75, 174, 33, "KP8" },
1652 { SDLK_KP4, 26, 186, 48, "KP4" },
1653 { SDLK_KP6, 118, 196, 32, "KP6" },
1654 { SDLK_KP2, 75, 234, 16, "KP2" },
1655 { SDLK_KP_PERIOD, 54, 250, 24, "Period" },
1656 { 0, 0, 0, 0, "None" }
1657};
1658#elif defined (IRIVER_H10)
1659struct button_map bm[] = {
1660 { SDLK_KP_PLUS, 38, 70, 37, "Power" },
1661 { SDLK_KP4, 123, 194, 26, "Cancel" },
1662 { SDLK_KP6, 257, 195, 34, "Select" },
1663 { SDLK_KP8, 190, 221, 28, "Up" },
1664 { SDLK_KP2, 192, 320, 27, "Down" },
1665 { SDLK_KP_DIVIDE, 349, 49, 20, "Rew" },
1666 { SDLK_KP5, 349, 96, 20, "Play" },
1667 { SDLK_KP_MULTIPLY, 350, 141, 23, "FF" },
1668 { 0, 0, 0, 0, "None" }
1669};
1670#elif defined (IRIVER_H10_5GB)
1671struct button_map bm[] = {
1672 { SDLK_KP_PLUS, 34, 76, 23, "Power" },
1673 { SDLK_KP4, 106, 222, 28, "Cancel" },
1674 { SDLK_KP6, 243, 220, 31, "Select" },
1675 { SDLK_KP8, 176, 254, 34, "Up" },
1676 { SDLK_KP2, 175, 371, 35, "Down" },
1677 { SDLK_KP_DIVIDE, 319, 63, 26, "Rew" },
1678 { SDLK_KP5, 320, 124, 26, "Play" },
1679 { SDLK_KP_MULTIPLY, 320, 181, 32, "FF" },
1680 { 0, 0, 0, 0, "None" }
1681};
1682#elif defined (IRIVER_H120) || defined (IRIVER_H100)
1683struct button_map bm[] = {
1684 { SDLK_KP_DIVIDE, 46, 162, 13, "Record" },
1685 { SDLK_KP_PLUS, 327, 36, 16, "Play" },
1686 { SDLK_KP_ENTER, 330, 99, 18, "Stop" },
1687 { SDLK_KP_PERIOD, 330, 163, 18, "AB" },
1688 { SDLK_KP5, 186, 227, 27, "5" },
1689 { SDLK_KP8, 187, 185, 19, "8" },
1690 { SDLK_KP4, 142, 229, 23, "4" },
1691 { SDLK_KP6, 231, 229, 22, "6" },
1692 { SDLK_KP2, 189, 272, 28, "2" },
1693/* Remote Buttons */
1694 { SDLK_KP_ENTER, 250, 404, 20, "Stop" },
1695 { SDLK_SPACE, 285, 439, 29, "Space" },
1696 { SDLK_h, 336, 291, 24, "Hold" },
1697 { 0, 0, 0, 0, "None" }
1698};
1699#elif defined (IRIVER_H300)
1700struct button_map bm[] = {
1701 { SDLK_KP_PLUS, 56, 335, 20, "Play" },
1702 { SDLK_KP8, 140, 304, 29, "Up" },
1703 { SDLK_KP_DIVIDE, 233, 331, 23, "Record" },
1704 { SDLK_KP_ENTER, 54, 381, 24, "Stop" },
1705 { SDLK_KP4, 100, 353, 17, "Left" },
1706 { SDLK_KP5, 140, 351, 19, "Navi" },
1707 { SDLK_KP6, 185, 356, 19, "Right" },
1708 { SDLK_KP_PERIOD, 230, 380, 20, "AB" },
1709 { SDLK_KP2, 142, 402, 24, "Down" },
1710 { SDLK_KP_ENTER, 211, 479, 21, "Stop" },
1711 { SDLK_KP_PLUS, 248, 513, 29, "Play" },
1712 { 0, 0, 0, 0, "None" }
1713};
1714#elif defined (MROBE_500)
1715struct button_map bm[] = {
1716 { SDLK_KP9, 171, 609, 9, "Play" },
1717 { SDLK_KP4, 158, 623, 9, "Left" },
1718 { SDLK_KP6, 184, 622, 9, "Right" },
1719 { SDLK_KP7, 171, 638, 11, "Menu" },
1720 { 0, 0, 0, 0, "None" }
1721};
1722#elif defined (MROBE_100)
1723struct button_map bm[] = {
1724 { SDLK_KP7, 80, 233, 30, "Menu" },
1725 { SDLK_KP8, 138, 250, 19, "Up" },
1726 { SDLK_KP9, 201, 230, 27, "Play" },
1727 { SDLK_KP4, 63, 305, 25, "Left" },
1728 { SDLK_KP5, 125, 309, 28, "Select" },
1729 { SDLK_KP6, 200, 307, 35, "Right" },
1730 { SDLK_KP1, 52, 380, 32, "Display" },
1731 { SDLK_KP2, 125, 363, 30, "Down" },
1732 { SDLK_KP9, 168, 425, 10, "Play" },
1733 { SDLK_KP4, 156, 440, 11, "Left" },
1734 { SDLK_KP6, 180, 440, 13, "Right" },
1735 { SDLK_KP7, 169, 452, 10, "Menu" },
1736 { SDLK_KP_MULTIPLY, 222, 15, 16, "Power" },
1737 { 0, 0, 0, 0, "None" }
1738};
1739#elif defined (GIGABEAT_F)
1740struct button_map bm[] = {
1741 { SDLK_KP_PLUS, 361, 187, 22, "Power" },
1742 { SDLK_KP_PERIOD, 361, 270, 17, "Menu" },
1743 { SDLK_KP9, 365, 345, 26, "Vol Up" },
1744 { SDLK_KP3, 363, 433, 25, "Vol Down" },
1745 { SDLK_KP_ENTER, 365, 520, 19, "A" },
1746 { SDLK_KP8, 167, 458, 35, "Up" },
1747 { SDLK_KP4, 86, 537, 29, "Left" },
1748 { SDLK_KP5, 166, 536, 30, "Select" },
1749 { SDLK_KP6, 248, 536, 30, "Right" },
1750 { SDLK_KP2, 169, 617, 28, "Down" },
1751 { 0, 0, 0, 0, "None" }
1752};
1753#elif defined (GIGABEAT_S)
1754struct button_map bm[] = {
1755 { SDLK_KP_PLUS, 416, 383, 23, "Play" },
1756 { SDLK_KP7, 135, 442, 46, "Back" },
1757 { SDLK_KP9, 288, 447, 35, "Menu" },
1758 { SDLK_KP8, 214, 480, 32, "Up" },
1759 { SDLK_KP4, 128, 558, 33, "Left" },
1760 { SDLK_KP5, 214, 556, 34, "Select" },
1761 { SDLK_KP6, 293, 558, 35, "Right" },
1762 { SDLK_KP2, 214, 637, 38, "Down" },
1763 { 0, 0, 0, 0, "None" }
1764};
1765#elif defined (SAMSUNG_YH820)
1766struct button_map bm[] = {
1767 { SDLK_KP_PLUS, 330, 53, 23, "Record" },
1768 { SDLK_KP7, 132, 208, 21, "Left" },
1769 { SDLK_KP5, 182, 210, 18, "Play" },
1770 { SDLK_KP9, 234, 211, 22, "Right" },
1771 { SDLK_KP8, 182, 260, 15, "Up" },
1772 { SDLK_KP4, 122, 277, 29, "Menu" },
1773 { SDLK_KP6, 238, 276, 25, "Select" },
1774 { SDLK_KP2, 183, 321, 24, "Down" },
1775 { 0, 0, 0, 0, "None" }
1776};
1777#elif defined (SAMSUNG_YH920) || defined (SAMSUNG_YH925)
1778struct button_map bm[] = {
1779 { SDLK_KP9, 370, 32, 15, "FF" },
1780 { SDLK_KP5, 369, 84, 25, "Play" },
1781 { SDLK_KP5, 367, 125, 27, "Play" },
1782 { SDLK_KP3, 369, 188, 17, "Rew" },
1783 { SDLK_KP_PLUS, 370, 330, 30, "Record" },
1784 { SDLK_KP4, 146, 252, 32, "Menu" },
1785 { SDLK_KP8, 204, 226, 27, "Up" },
1786 { SDLK_KP6, 257, 250, 34, "Select" },
1787 { SDLK_KP2, 205, 294, 35, "Down" },
1788 { 0, 0, 0, 0, "None" }
1789};
1790#elif defined (ONDA_VX747) || defined (ONDA_VX747P)
1791struct button_map bm[] = {
1792 { SDLK_MINUS, 113, 583, 28, "Minus" },
1793 { SDLK_PLUS, 227, 580, 28, "Plus" },
1794 { SDLK_RETURN, 171, 583, 34, "Menu" },
1795 { 0, 0, 0, 0, "None" }
1796};
1797#elif defined (PHILIPS_SA9200)
1798struct button_map bm[] = {
1799 { SDLK_KP_ENTER, 25, 155, 33, "Power" },
1800 { SDLK_PAGEUP, 210, 98, 31, "Vol Up" },
1801 { SDLK_PAGEDOWN, 210, 168, 34, "Vol Down" },
1802 { SDLK_KP7, 40, 249, 26, "Prev" },
1803 { SDLK_KP8, 110, 247, 22, "Up" },
1804 { SDLK_KP9, 183, 249, 31, "Next" },
1805 { SDLK_KP4, 45, 305, 25, "Left" },
1806 { SDLK_KP5, 111, 304, 24, "Play" },
1807 { SDLK_KP6, 183, 304, 21, "Right" },
1808 { SDLK_KP1, 43, 377, 21, "Menu" },
1809 { SDLK_KP2, 112, 371, 24, "Down" },
1810 { 0, 0, 0, 0, "None" }
1811};
1812#elif defined (CREATIVE_ZVM) || defined (CREATIVE_ZVM60GB) || \
1813 defined (CREATIVE_ZV)
1814struct button_map bm[] = {
1815 { SDLK_KP7, 52, 414, 35, "Custom" },
1816 { SDLK_KP8, 185, 406, 55, "Up" },
1817 { SDLK_KP9, 315, 421, 46, "Play" },
1818 { SDLK_KP4, 122, 500, 41, "Left" },
1819 { SDLK_KP6, 247, 493, 49, "Right" },
1820 { SDLK_KP1, 58, 577, 49, "Back" },
1821 { SDLK_KP2, 186, 585, 46, "Down" },
1822 { SDLK_KP3, 311, 569, 47, "Menu" },
1823 { 0, 0, 0, 0, "None" }
1824};
1825#else
1826struct button_map bm[] = {
1827 { 0, 0, 0, 0, ""}
1828};
1829#endif
1830
1831int xy2button( int x, int y) {
1832 int i;
1833 extern bool debug_buttons;
1834
1835 for ( i = 0; bm[i].button; i++ )
1836 /* check distance from center of button < radius */
1837 if ( ( (x-bm[i].x)*(x-bm[i].x) ) + ( ( y-bm[i].y)*(y-bm[i].y) ) < bm[i].radius*bm[i].radius ) {
1838 if (debug_buttons)
1839 printf("Button: %s\n", bm[i].description );
1840 return bm[i].button;
1841 }
1842 return 0;
1843}
diff --git a/uisimulator/sdl/uisdl.c b/uisimulator/sdl/uisdl.c
index 3ab098e5ba..8cf4b42ba0 100644
--- a/uisimulator/sdl/uisdl.c
+++ b/uisimulator/sdl/uisdl.c
@@ -40,10 +40,12 @@
40#include "thread-sdl.h" 40#include "thread-sdl.h"
41#include "SDL_mutex.h" 41#include "SDL_mutex.h"
42#include "SDL_thread.h" 42#include "SDL_thread.h"
43#include "math.h"
44
43 45
44/* extern functions */ 46/* extern functions */
45extern void new_key(int key); 47extern void new_key(int key);
46 48extern int xy2button( int x, int y);
47void button_event(int key, bool pressed); 49void button_event(int key, bool pressed);
48 50
49SDL_Surface *gui_surface; 51SDL_Surface *gui_surface;
@@ -51,6 +53,8 @@ bool background = true; /* use backgrounds by default */
51#ifdef HAVE_REMOTE_LCD 53#ifdef HAVE_REMOTE_LCD
52static bool showremote = true; /* include remote by default */ 54static bool showremote = true; /* include remote by default */
53#endif 55#endif
56bool mapping = false;
57bool debug_buttons = false;
54 58
55bool lcd_display_redraw = true; /* Used for player simulator */ 59bool lcd_display_redraw = true; /* Used for player simulator */
56char having_new_lcd = true; /* Used for player simulator */ 60char having_new_lcd = true; /* Used for player simulator */
@@ -62,39 +66,102 @@ bool debug_audio = false;
62bool debug_wps = false; 66bool debug_wps = false;
63int wps_verbose_level = 3; 67int wps_verbose_level = 3;
64 68
69
70void irq_button_event(int key, bool pressed) {
71 sim_enter_irq_handler();
72 button_event( key, pressed );
73 sim_exit_irq_handler();
74}
75
76int sqr( int a ) {
77 return a*a;
78}
79
65void gui_message_loop(void) 80void gui_message_loop(void)
66{ 81{
67 SDL_Event event; 82 SDL_Event event;
68 bool done = false; 83 bool done = false;
84 static int x,y,xybutton = 0;
69 85
70 while(!done && SDL_WaitEvent(&event)) 86 while(!done && SDL_WaitEvent(&event))
71 { 87 {
72 switch(event.type) 88 switch(event.type)
73 { 89 {
74 case SDL_KEYDOWN: 90 case SDL_KEYDOWN:
75 sim_enter_irq_handler(); 91 irq_button_event(event.key.keysym.sym, true);
76 button_event(event.key.keysym.sym, true);
77 sim_exit_irq_handler();
78 break; 92 break;
79 case SDL_KEYUP: 93 case SDL_KEYUP:
80 sim_enter_irq_handler(); 94 irq_button_event(event.key.keysym.sym, false);
81 button_event(event.key.keysym.sym, false);
82 sim_exit_irq_handler();
83 break;
84#ifndef HAVE_TOUCHSCREEN
85 case SDL_MOUSEBUTTONDOWN: 95 case SDL_MOUSEBUTTONDOWN:
96 switch ( event.button.button ) {
97#ifdef HAVE_SCROLLWHEEL
98 case SDL_BUTTON_WHEELUP:
99 irq_button_event( SDLK_UP, true );
100 break;
101 case SDL_BUTTON_WHEELDOWN:
102 irq_button_event( SDLK_DOWN, true );
103 break;
104#endif
105 case SDL_BUTTON_LEFT:
106 case SDL_BUTTON_MIDDLE:
107 if ( mapping && background ) {
108 x = event.button.x;
109 y = event.button.y;
110 }
111 if ( background ) {
112 xybutton = xy2button( event.button.x, event.button.y );
113 if( xybutton )
114 irq_button_event( xybutton, true );
115 }
116 break;
117 default:
118 break;
119 }
120
86 if (debug_wps && event.button.button == 1) 121 if (debug_wps && event.button.button == 1)
87 { 122 {
88 printf("Mouse at: (%d, %d)\n", event.button.x, event.button.y); 123 if ( background )
124#ifdef HAVE_REMOTE
125 if ( event.button.y < UI_REMOTE_POSY ) /* Main Screen */
126 printf("Mouse at: (%d, %d)\n", event.button.x - UI_LCD_POSX -1 , event.button.y - UI_LCD_POSY - 1 );
127 else
128 printf("Mouse at: (%d, %d)\n", event.button.x - UI_REMOTE_POSX -1 , event.button.y - UI_REMOTE_POSY - 1 );
129#else
130 printf("Mouse at: (%d, %d)\n", event.button.x - UI_LCD_POSX -1 , event.button.y - UI_LCD_POSY - 1 );
131#endif
132 else
133 if ( event.button.y/display_zoom < LCD_HEIGHT ) /* Main Screen */
134 printf("Mouse at: (%d, %d)\n", event.button.x/display_zoom, event.button.y/display_zoom );
135#ifdef HAVE_REMOTE
136 else
137 printf("Mouse at: (%d, %d)\n", event.button.x/display_zoom, event.button.y/display_zoom - LCD_HEIGHT );
138#endif
89 } 139 }
90 break; 140 break;
91#else
92 case SDL_MOUSEBUTTONUP: 141 case SDL_MOUSEBUTTONUP:
93 sim_enter_irq_handler(); 142 switch ( event.button.button ) {
94 button_event(BUTTON_TOUCHSCREEN, false); 143 /* The scrollwheel button up events are ignored as they are queued immediately */
95 sim_exit_irq_handler(); 144 case SDL_BUTTON_LEFT:
96 break; 145 case SDL_BUTTON_MIDDLE:
146 if ( mapping && background ) {
147 printf(" { SDLK_, %d, %d, %d, \"\" },\n", x, y, (int)sqrt( sqr(x-(int)event.button.x) + sqr(y-(int)event.button.y)) );
148 }
149 if ( background && xybutton ) {
150 irq_button_event( xybutton, false );
151 xybutton = 0;
152 }
153#ifdef HAVE_TOUCHSCREEN
154 else {
155 irq_button_event(BUTTON_TOUCHSCREEN, false);
156 }
97#endif 157#endif
158 break;
159 default:
160 break;
161 }
162 break;
163
164
98 case SDL_QUIT: 165 case SDL_QUIT:
99 done = true; 166 done = true;
100 break; 167 break;
@@ -244,6 +311,16 @@ int main(int argc, char *argv[])
244 printf("Root directory: %s\n", sim_root_dir); 311 printf("Root directory: %s\n", sim_root_dir);
245 } 312 }
246 } 313 }
314 else if (!strcmp("--mapping", argv[x]))
315 {
316 mapping = true;
317 printf("Printing click coords with drag radii.\n");
318 }
319 else if (!strcmp("--debugbuttons", argv[x]))
320 {
321 debug_buttons = true;
322 printf("Printing background button clicks.\n");
323 }
247 else 324 else
248 { 325 {
249 printf("rockboxui\n"); 326 printf("rockboxui\n");
@@ -258,6 +335,7 @@ int main(int argc, char *argv[])
258 printf(" --zoom [VAL]\t Window zoom (will disable backgrounds)\n"); 335 printf(" --zoom [VAL]\t Window zoom (will disable backgrounds)\n");
259 printf(" --alarm \t Simulate a wake-up on alarm\n"); 336 printf(" --alarm \t Simulate a wake-up on alarm\n");
260 printf(" --root [DIR]\t Set root directory\n"); 337 printf(" --root [DIR]\t Set root directory\n");
338 printf(" --mapping \t Output coordinates and radius for mapping backgrounds\n");
261 exit(0); 339 exit(0);
262 } 340 }
263 } 341 }