/usr/include/libinput.h is in libinput-dev 0.6.0+dfsg-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 | /*
* Copyright © 2013 Jonas Ådahl
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of the copyright holders not be used in
* advertising or publicity pertaining to distribution of the software
* without specific, written prior permission. The copyright holders make
* no representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef LIBINPUT_H
#define LIBINPUT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <stdint.h>
#include <libudev.h>
#define LIBINPUT_ATTRIBUTE_PRINTF(_format, _args) \
__attribute__ ((format (printf, _format, _args)))
#define LIBINPUT_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated))
/**
* @mainpage
* libinput is a generic input device handling library. It abstracts
* commonly-used concepts such as keyboard, pointer and touchpad handling
* behind an API.
*/
/**
* @page tpbuttons Touchpad button behavior
*
* For touchpad devices without physical buttons, libinput enables an
* emulated right button area through either of two methods.
*
* Software button areas
* =====================
* On most touchpads, the bottom area of the touchpad is split into a left
* and a right-button area. Pressing the touchpad down with a finger in
* those areas will generate clicks as shown in the diagram below:
*
* @code
+------------------------+
| |
| |
| LEFT |
| |
| |
+------------------------+
| LEFT | RIGHT |
+------------------------+
* @endcode
*
* Generally, the touchpad will emulate a right-button click if the finger
* was set down in the right button area and did not leave the
* right button area before clicking, even if another finger was already
* down on the touchpad in another area.
* A middle click is generated by clicking the touchpad when one finger is
* in the bottom left button area, and one finger is in the botton right
* button area.
* The exact behavior of the touchpad is implementation-dependent.
*
* Top software button area
* ========================
* On selected touchpads, the top area of the touchpad is a separate set of
* software buttons split into a left, middle and right button area.
* Pressing the touchpad down with a finger in those areas will generate
* clicks as shown in the diagram below:
*
* @code
+------------------------+
| LEFT | MIDDLE | RIGHT |
+------------------------+
| |
| LEFT |
| |
+------------------------+
| LEFT | RIGHT |
+------------------------+
* @endcode
* This behavior is enabled on the Lenovo *40 series (T440, T540, T240...)
* and the Lenovo Helix, Yoga S1 and Carbon X1 2nd.
*
* Clickfinger
* ===========
* On Apple touchpads, no button areas are provided. Instead, use a
* two-finger click for a right button click, and a three-finger click for a
* middle button click.
*/
/**
* @page udev_config Static device configuration via udev
*
* libinput supports some static configuration through udev properties.
* These propertiesare read when the device is initially added
* to libinput's device list, i.e. before the @ref
* LIBINPUT_EVENT_DEVICE_ADDED event is generated.
*
* The following udev properties are supported:
* <dl>
* <dt>LIBINPUT_CALIBRATION_MATRIX</dt>
* <dd>Sets the calibration matrix, see
* libinput_device_config_calibration_get_default_matrix(). If unset,
* defaults to the identity matrix.</dd>
* <dt>ID_SEAT</dt>
* <dd>Assigns the physical seat for this device. See
* libinput_seat_get_physical_name(). Defaults to "seat0".</dd>
* <dt>WL_SEAT</dt>
* <dd>Assigns the logical seat for this device. See
* libinput_seat_get_logical_name()
* context. Defaults to "default".</dd>
* </dl>
*
* Below is an example udev rule to assign "seat1" to a device from vendor
* 0x012a with the model ID of 0x034b.
* @code
* ACTION=="add|change", KERNEL=="event[0-9]*", ENV{ID_VENDOR_ID}=="012a", \
* ENV{ID_MODEL_ID}=="034b", ENV{ID_SEAT}="seat1"
* @endcode
*
*/
/**
* Log priority for internal logging messages.
*/
enum libinput_log_priority {
LIBINPUT_LOG_PRIORITY_DEBUG = 10,
LIBINPUT_LOG_PRIORITY_INFO = 20,
LIBINPUT_LOG_PRIORITY_ERROR = 30,
};
/**
* @ingroup device
*
* Capabilities on a device. A device may have one or more capabilities
* at a time, and capabilities may appear or disappear during the
* lifetime of the device.
*/
enum libinput_device_capability {
LIBINPUT_DEVICE_CAP_KEYBOARD = 0,
LIBINPUT_DEVICE_CAP_POINTER = 1,
LIBINPUT_DEVICE_CAP_TOUCH = 2
};
/**
* @ingroup device
*
* Logical state of a key. Note that the logical state may not represent
* the physical state of the key.
*/
enum libinput_key_state {
LIBINPUT_KEY_STATE_RELEASED = 0,
LIBINPUT_KEY_STATE_PRESSED = 1
};
/**
* @ingroup device
*
* Mask reflecting LEDs on a device.
*/
enum libinput_led {
LIBINPUT_LED_NUM_LOCK = (1 << 0),
LIBINPUT_LED_CAPS_LOCK = (1 << 1),
LIBINPUT_LED_SCROLL_LOCK = (1 << 2)
};
/**
* @ingroup device
*
* Logical state of a physical button. Note that the logical state may not
* represent the physical state of the button.
*/
enum libinput_button_state {
LIBINPUT_BUTTON_STATE_RELEASED = 0,
LIBINPUT_BUTTON_STATE_PRESSED = 1
};
/**
* @ingroup device
*
* Axes on a device that are not x or y coordinates.
*/
enum libinput_pointer_axis {
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL = 0,
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL = 1,
};
/**
* @ingroup base
*
* Event type for events returned by libinput_get_event().
*/
enum libinput_event_type {
/**
* This is not a real event type, and is only used to tell the user that
* no new event is available in the queue. See
* libinput_next_event_type().
*/
LIBINPUT_EVENT_NONE = 0,
/**
* Signals that a device has been added to the context. The device will
* not be read until the next time the user calls libinput_dispatch()
* and data is available.
*
* This allows setting up initial device configuration before any events
* are created.
*/
LIBINPUT_EVENT_DEVICE_ADDED,
/**
* Signals that a device has been removed. No more events from the
* associated device will be in the queue or be queued after this event.
*/
LIBINPUT_EVENT_DEVICE_REMOVED,
LIBINPUT_EVENT_KEYBOARD_KEY = 300,
LIBINPUT_EVENT_POINTER_MOTION = 400,
LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE,
LIBINPUT_EVENT_POINTER_BUTTON,
LIBINPUT_EVENT_POINTER_AXIS,
LIBINPUT_EVENT_TOUCH_DOWN = 500,
LIBINPUT_EVENT_TOUCH_UP,
LIBINPUT_EVENT_TOUCH_MOTION,
LIBINPUT_EVENT_TOUCH_CANCEL,
/**
* Signals the end of a set of touchpoints at one device sample
* time. This event has no coordinate information attached.
*/
LIBINPUT_EVENT_TOUCH_FRAME
};
struct libinput;
struct libinput_device;
struct libinput_seat;
struct libinput_event;
struct libinput_event_device_notify;
struct libinput_event_keyboard;
struct libinput_event_pointer;
/**
* @ingroup event_touch
* @struct libinput_event_touch
*
* Touch event representing a touch down, move or up, as well as a touch
* cancel and touch frame events. Valid event types for this event are @ref
* LIBINPUT_EVENT_TOUCH_DOWN, @ref LIBINPUT_EVENT_TOUCH_MOTION, @ref
* LIBINPUT_EVENT_TOUCH_UP, @ref LIBINPUT_EVENT_TOUCH_CANCEL and @ref
* LIBINPUT_EVENT_TOUCH_FRAME.
*/
struct libinput_event_touch;
/**
* @defgroup event Accessing and destruction of events
*/
/**
* @ingroup event
*
* Destroy the event.
*
* @param event An event retrieved by libinput_get_event().
*/
void
libinput_event_destroy(struct libinput_event *event);
/**
* @ingroup event
*
* Get the type of the event.
*
* @param event An event retrieved by libinput_get_event().
*/
enum libinput_event_type
libinput_event_get_type(struct libinput_event *event);
/**
* @ingroup event
*
* Get the libinput context from the event.
*
* @param event The libinput event
* @return The libinput context for this event.
*/
struct libinput *
libinput_event_get_context(struct libinput_event *event);
/**
* @ingroup event
*
* Return the device associated with this event, if applicable. For device
* added/removed events this is the device added or removed. For all other
* device events, this is the device that generated the event.
*
* This device is not refcounted and its lifetime is that of the event. Use
* libinput_device_ref() before using the device outside of this scope.
*
* @return The device associated with this event
*/
struct libinput_device *
libinput_event_get_device(struct libinput_event *event);
/**
* @ingroup event
*
* Return the pointer event that is this input event. If the event type does
* not match the pointer event types, this function returns NULL.
*
* The inverse of this function is libinput_event_pointer_get_base_event().
*
* @return A pointer event, or NULL for other events
*/
struct libinput_event_pointer *
libinput_event_get_pointer_event(struct libinput_event *event);
/**
* @ingroup event
*
* Return the keyboard event that is this input event. If the event type does
* not match the keyboard event types, this function returns NULL.
*
* The inverse of this function is libinput_event_keyboard_get_base_event().
*
* @return A keyboard event, or NULL for other events
*/
struct libinput_event_keyboard *
libinput_event_get_keyboard_event(struct libinput_event *event);
/**
* @ingroup event
*
* Return the touch event that is this input event. If the event type does
* not match the touch event types, this function returns NULL.
*
* The inverse of this function is libinput_event_touch_get_base_event().
*
* @return A touch event, or NULL for other events
*/
struct libinput_event_touch *
libinput_event_get_touch_event(struct libinput_event *event);
/**
* @ingroup event
*
* Return the device event that is this input event. If the event type does
* not match the device event types, this function returns NULL.
*
* The inverse of this function is
* libinput_event_device_notify_get_base_event().
*
* @return A device event, or NULL for other events
*/
struct libinput_event_device_notify *
libinput_event_get_device_notify_event(struct libinput_event *event);
/**
* @ingroup event
*
* @return The generic libinput_event of this event
*/
struct libinput_event *
libinput_event_device_notify_get_base_event(struct libinput_event_device_notify *event);
/**
* @defgroup event_keyboard Keyboard events
*
* Key events are generated when a key changes its logical state, usually by
* being pressed or released.
*/
/**
* @ingroup event_keyboard
*
* @return The event time for this event
*/
uint32_t
libinput_event_keyboard_get_time(struct libinput_event_keyboard *event);
/**
* @ingroup event_keyboard
*
* @return The keycode that triggered this key event
*/
uint32_t
libinput_event_keyboard_get_key(struct libinput_event_keyboard *event);
/**
* @ingroup event_keyboard
*
* @return The state change of the key
*/
enum libinput_key_state
libinput_event_keyboard_get_key_state(struct libinput_event_keyboard *event);
/**
* @ingroup event_keyboard
*
* @return The generic libinput_event of this event
*/
struct libinput_event *
libinput_event_keyboard_get_base_event(struct libinput_event_keyboard *event);
/**
* @ingroup event_keyboard
*
* For the key of a LIBINPUT_EVENT_KEYBOARD_KEY event, return the total number
* of keys pressed on all devices on the associated seat after the event was
* triggered.
*
" @note It is an application bug to call this function for events other than
* LIBINPUT_EVENT_KEYBOARD_KEY. For other events, this function returns 0.
*
* @return the seat wide pressed key count for the key of this event
*/
uint32_t
libinput_event_keyboard_get_seat_key_count(
struct libinput_event_keyboard *event);
/**
* @defgroup event_pointer Pointer events
*
* Pointer events reflect motion, button and scroll events, as well as
* events from other axes.
*/
/**
* @ingroup event_pointer
*
* @return The event time for this event
*/
uint32_t
libinput_event_pointer_get_time(struct libinput_event_pointer *event);
/**
* @ingroup event_pointer
*
* Return the delta between the last event and the current event. For pointer
* events that are not of type LIBINPUT_EVENT_POINTER_MOTION, this function
* returns 0.
*
* If a device employs pointer acceleration, the delta returned by this
* function is the accelerated delta.
*
* @note It is an application bug to call this function for events other than
* LIBINPUT_EVENT_POINTER_MOTION.
*
* @return the relative x movement since the last event
*/
double
libinput_event_pointer_get_dx(struct libinput_event_pointer *event);
/**
* @ingroup event_pointer
*
* Return the delta between the last event and the current event. For pointer
* events that are not of type LIBINPUT_EVENT_POINTER_MOTION, this function
* returns 0.
*
* If a device employs pointer acceleration, the delta returned by this
* function is the accelerated delta.
*
* @note It is an application bug to call this function for events other than
* LIBINPUT_EVENT_POINTER_MOTION.
*
* @return the relative y movement since the last event
*/
double
libinput_event_pointer_get_dy(struct libinput_event_pointer *event);
/**
* @ingroup event_pointer
*
* Return the current absolute x coordinate of the pointer event, in mm from
* the top left corner of the device. To get the corresponding output screen
* coordinate, use libinput_event_pointer_get_absolute_x_transformed().
*
* For pointer events that are not of type
* LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE, this function returns 0.
*
* @note It is an application bug to call this function for events other than
* LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE.
*
* @return the current absolute x coordinate
*/
double
libinput_event_pointer_get_absolute_x(struct libinput_event_pointer *event);
/**
* @ingroup event_pointer
*
* Return the current absolute y coordinate of the pointer event, in mm from
* the top left corner of the device. To get the corresponding output screen
* coordinate, use libinput_event_pointer_get_absolute_y_transformed().
*
* For pointer events that are not of type
* LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE, this function returns 0.
*
* @note It is an application bug to call this function for events other than
* LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE.
*
* @return the current absolute y coordinate
*/
double
libinput_event_pointer_get_absolute_y(struct libinput_event_pointer *event);
/**
* @ingroup event_pointer
*
* Return the current absolute x coordinate of the pointer event, transformed to
* screen coordinates.
*
* For pointer events that are not of type
* LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE, the return value of this function is
* undefined.
*
* @note It is an application bug to call this function for events other than
* LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE.
*
* @param event The libinput pointer event
* @param width The current output screen width
* @return the current absolute x coordinate transformed to a screen coordinate
*/
double
libinput_event_pointer_get_absolute_x_transformed(
struct libinput_event_pointer *event,
uint32_t width);
/**
* @ingroup event_pointer
*
* Return the current absolute y coordinate of the pointer event, transformed to
* screen coordinates.
*
* For pointer events that are not of type
* LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE, the return value of this function is
* undefined.
*
* @note It is an application bug to call this function for events other than
* LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE.
*
* @param event The libinput pointer event
* @param height The current output screen height
* @return the current absolute y coordinate transformed to a screen coordinate
*/
double
libinput_event_pointer_get_absolute_y_transformed(
struct libinput_event_pointer *event,
uint32_t height);
/**
* @ingroup event_pointer
*
* Return the button that triggered this event.
* For pointer events that are not of type LIBINPUT_EVENT_POINTER_BUTTON,
* this function returns 0.
*
* @note It is an application bug to call this function for events other than
* LIBINPUT_EVENT_POINTER_BUTTON.
*
* @return the button triggering this event
*/
uint32_t
libinput_event_pointer_get_button(struct libinput_event_pointer *event);
/**
* @ingroup event_pointer
*
* Return the button state that triggered this event.
* For pointer events that are not of type LIBINPUT_EVENT_POINTER_BUTTON,
* this function returns 0.
*
* @note It is an application bug to call this function for events other than
* LIBINPUT_EVENT_POINTER_BUTTON.
*
* @return the button state triggering this event
*/
enum libinput_button_state
libinput_event_pointer_get_button_state(struct libinput_event_pointer *event);
/**
* @ingroup event_pointer
*
* For the button of a LIBINPUT_EVENT_POINTER_BUTTON event, return the total
* number of buttons pressed on all devices on the associated seat after the
* the event was triggered.
*
" @note It is an application bug to call this function for events other than
* LIBINPUT_EVENT_POINTER_BUTTON. For other events, this function returns 0.
*
* @return the seat wide pressed button count for the key of this event
*/
uint32_t
libinput_event_pointer_get_seat_button_count(
struct libinput_event_pointer *event);
/**
* @ingroup event_pointer
*
* Return the axis that triggered this event.
* For pointer events that are not of type LIBINPUT_EVENT_POINTER_AXIS,
* this function returns 0.
*
* @note It is an application bug to call this function for events other than
* LIBINPUT_EVENT_POINTER_AXIS.
*
* @return the axis triggering this event
*/
enum libinput_pointer_axis
libinput_event_pointer_get_axis(struct libinput_event_pointer *event);
/**
* @ingroup event_pointer
*
* Return the axis value of the given axis. The interpretation of the value
* is dependent on the axis. For the two scrolling axes
* LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL and
* LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, the value of the event is in
* relative scroll units, with the positive direction being down or right,
* respectively. The dimension of a scroll unit is equal to one unit of
* motion in the respective axis, where applicable (e.g. touchpad two-finger
* scrolling).
*
* For pointer events that are not of type LIBINPUT_EVENT_POINTER_AXIS,
* this function returns 0.
*
* @note It is an application bug to call this function for events other than
* LIBINPUT_EVENT_POINTER_AXIS.
*
* @return the axis value of this event
*/
double
libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event);
/**
* @ingroup event_pointer
*
* @return The generic libinput_event of this event
*/
struct libinput_event *
libinput_event_pointer_get_base_event(struct libinput_event_pointer *event);
/**
* @defgroup event_touch Touch events
*
* Events from absolute touch devices.
*/
/**
* @ingroup event_touch
*
* @return The event time for this event
*/
uint32_t
libinput_event_touch_get_time(struct libinput_event_touch *event);
/**
* @ingroup event_touch
*
* Get the slot of this touch event. See the kernel's multitouch
* protocol B documentation for more information.
*
* If the touch event has no assigned slot, for example if it is from a
* single touch device, this function returns -1.
*
* @note this function should not be called for LIBINPUT_EVENT_TOUCH_CANCEL or
* LIBINPUT_EVENT_TOUCH_FRAME.
*
* @return The slot of this touch event
*/
int32_t
libinput_event_touch_get_slot(struct libinput_event_touch *event);
/**
* @ingroup event_touch
*
* Get the seat slot of the touch event. A seat slot is a non-negative seat
* wide unique identifier of an active touch point.
*
* Events from single touch devices will be represented as one individual
* touch point per device.
*
* @note this function should not be called for LIBINPUT_EVENT_TOUCH_CANCEL or
* LIBINPUT_EVENT_TOUCH_FRAME.
*
* @return The seat slot of the touch event
*/
int32_t
libinput_event_touch_get_seat_slot(struct libinput_event_touch *event);
/**
* @ingroup event_touch
*
* Return the current absolute x coordinate of the touch event, in mm from
* the top left corner of the device. To get the corresponding output screen
* coordinate, use libinput_event_touch_get_x_transformed().
*
* @note this function should only be called for LIBINPUT_EVENT_TOUCH_DOWN and
* LIBINPUT_EVENT_TOUCH_MOTION.
*
* @param event The libinput touch event
* @return the current absolute x coordinate
*/
double
libinput_event_touch_get_x(struct libinput_event_touch *event);
/**
* @ingroup event_touch
*
* Return the current absolute y coordinate of the touch event, in mm from
* the top left corner of the device. To get the corresponding output screen
* coordinate, use libinput_event_touch_get_y_transformed().
*
* For LIBINPUT_EVENT_TOUCH_UP 0 is returned.
*
* @note this function should only be called for LIBINPUT_EVENT_TOUCH_DOWN and
* LIBINPUT_EVENT_TOUCH_MOTION.
*
* @param event The libinput touch event
* @return the current absolute y coordinate
*/
double
libinput_event_touch_get_y(struct libinput_event_touch *event);
/**
* @ingroup event_touch
*
* Return the current absolute x coordinate of the touch event, transformed to
* screen coordinates.
*
* @note this function should only be called for LIBINPUT_EVENT_TOUCH_DOWN and
* LIBINPUT_EVENT_TOUCH_MOTION.
*
* @param event The libinput touch event
* @param width The current output screen width
* @return the current absolute x coordinate transformed to a screen coordinate
*/
double
libinput_event_touch_get_x_transformed(struct libinput_event_touch *event,
uint32_t width);
/**
* @ingroup event_touch
*
* Return the current absolute y coordinate of the touch event, transformed to
* screen coordinates.
*
* @note this function should only be called for LIBINPUT_EVENT_TOUCH_DOWN and
* LIBINPUT_EVENT_TOUCH_MOTION.
*
* @param event The libinput touch event
* @param height The current output screen height
* @return the current absolute y coordinate transformed to a screen coordinate
*/
double
libinput_event_touch_get_y_transformed(struct libinput_event_touch *event,
uint32_t height);
/**
* @ingroup event_touch
*
* @return The generic libinput_event of this event
*/
struct libinput_event *
libinput_event_touch_get_base_event(struct libinput_event_touch *event);
/**
* @defgroup base Initialization and manipulation of libinput contexts
*/
struct libinput_interface {
/**
* Open the device at the given path with the flags provided and
* return the fd.
*
* @param path The device path to open
* @param flags Flags as defined by open(2)
* @param user_data The user_data provided in
* libinput_udev_create_context()
*
* @return the file descriptor, or a negative errno on failure.
*/
int (*open_restricted)(const char *path, int flags, void *user_data);
/**
* Close the file descriptor.
*
* @param fd The file descriptor to close
* @param user_data The user_data provided in
* libinput_udev_create_context()
*/
void (*close_restricted)(int fd, void *user_data);
};
/**
* @ingroup base
*
* Create a new libinput context from udev. This context is inactive until
* assigned a seat ID with libinput_udev_assign_seat().
*
* @param interface The callback interface
* @param user_data Caller-specific data passed to the various callback
* interfaces.
* @param udev An already initialized udev context
*
* @return An initialized, but inactive libinput context or NULL on error
*/
struct libinput *
libinput_udev_create_context(const struct libinput_interface *interface,
void *user_data,
struct udev *udev);
/**
* @ingroup base
*
* Assign a seat to this libinput context. New devices or the removal of
* existing devices will appear as events during libinput_dispatch().
*
* libinput_udev_assign_seat() succeeds even if no input devices are currently
* available on this seat, or if devices are available but fail to open in
* @ref libinput_interface::open_restricted. Devices that do not have the
* minimum capabilities to be recognized as pointer, keyboard or touch
* device are ignored. Such devices and those that failed to open
* ignored until the next call to libinput_resume().
*
* This function may only be called once per context.
*
* @param libinput A libinput context initialized with
* libinput_udev_create_context()
* @param seat_id A seat identifier. This string must not be NULL.
*
* @return 0 on success or -1 on failure.
*/
int
libinput_udev_assign_seat(struct libinput *libinput,
const char *seat_id);
/**
* @ingroup base
*
* Create a new libinput context that requires the caller to manually add or
* remove devices with libinput_path_add_device() and
* libinput_path_remove_device().
*
* The context is fully initialized but will not generate events until at
* least one device has been added.
*
* The reference count of the context is initialized to 1. See @ref
* libinput_unref.
*
* @param interface The callback interface
* @param user_data Caller-specific data passed to the various callback
* interfaces.
*
* @return An initialized, empty libinput context.
*/
struct libinput *
libinput_path_create_context(const struct libinput_interface *interface,
void *user_data);
/**
* @ingroup base
*
* Add a device to a libinput context initialized with
* libinput_path_create_context(). If successful, the device will be
* added to the internal list and re-opened on libinput_resume(). The device
* can be removed with libinput_path_remove_device().
*
* If the device was successfully initialized, it is returned in the device
* argument. The lifetime of the returned device pointer is limited until
* the next libinput_dispatch(), use libinput_device_ref() to keep a permanent
* reference.
*
* @param libinput A previously initialized libinput context
* @param path Path to an input device
* @return The newly initiated device on success, or NULL on failure.
*
* @note It is an application bug to call this function on a libinput
* context initialized with libinput_udev_create_context().
*/
struct libinput_device *
libinput_path_add_device(struct libinput *libinput,
const char *path);
/**
* @ingroup base
*
* Remove a device from a libinput context initialized with
* libinput_path_create_context() or added to such a context with
* libinput_path_add_device().
*
* Events already processed from this input device are kept in the queue,
* the LIBINPUT_EVENT_DEVICE_REMOVED event marks the end of events for this
* device.
*
* If no matching device exists, this function does nothing.
*
* @param device A libinput device
*
* @note It is an application bug to call this function on a libinput
* context initialized with libinput_udev_create_context().
*/
void
libinput_path_remove_device(struct libinput_device *device);
/**
* @ingroup base
*
* libinput keeps a single file descriptor for all events. Call into
* libinput_dispatch() if any events become available on this fd.
*
* @return the file descriptor used to notify of pending events.
*/
int
libinput_get_fd(struct libinput *libinput);
/**
* @ingroup base
*
* Main event dispatchment function. Reads events of the file descriptors
* and processes them internally. Use libinput_get_event() to retrieve the
* events.
*
* Dispatching does not necessarily queue libinput events.
*
* @param libinput A previously initialized libinput context
*
* @return 0 on success, or a negative errno on failure
*/
int
libinput_dispatch(struct libinput *libinput);
/**
* @ingroup base
*
* Retrieve the next event from libinput's internal event queue.
*
* After handling the retrieved event, the caller must destroy it using
* libinput_event_destroy().
*
* @param libinput A previously initialized libinput context
* @return The next available event, or NULL if no event is available.
*/
struct libinput_event *
libinput_get_event(struct libinput *libinput);
/**
* @ingroup base
*
* Return the type of the next event in the internal queue. This function
* does not pop the event off the queue and the next call to
* libinput_get_event() returns that event.
*
* @param libinput A previously initialized libinput context
* @return The event type of the next available event or LIBINPUT_EVENT_NONE
* if no event is availble.
*/
enum libinput_event_type
libinput_next_event_type(struct libinput *libinput);
/**
* @ingroup base
*
* @param libinput A previously initialized libinput context
* @return the caller-specific data previously assigned in
* libinput_create_udev().
*/
void *
libinput_get_user_data(struct libinput *libinput);
/**
* @ingroup base
*
* Resume a suspended libinput context. This re-enables device
* monitoring and adds existing devices.
*
* @param libinput A previously initialized libinput context
* @see libinput_suspend
*
* @return 0 on success or -1 on failure
*/
int
libinput_resume(struct libinput *libinput);
/**
* @ingroup base
*
* Suspend monitoring for new devices and close existing devices.
* This all but terminates libinput but does keep the context
* valid to be resumed with libinput_resume().
*
* @param libinput A previously initialized libinput context
*/
void
libinput_suspend(struct libinput *libinput);
/**
* @ingroup base
*
* Add a reference to the context. A context is destroyed whenever the
* reference count reaches 0. See @ref libinput_unref.
*
* @param libinput A previously initialized valid libinput context
* @return The passed libinput context
*/
struct libinput *
libinput_ref(struct libinput *libinput);
/**
* @ingroup base
*
* Dereference the libinput context. After this, the context may have been
* destroyed, if the last reference was dereferenced. If so, the context is
* invalid and may not be interacted with.
*
* @param libinput A previously initialized libinput context
* @return NULL if context was destroyed otherwise the passed context
*/
struct libinput *
libinput_unref(struct libinput *libinput);
/**
* @ingroup base
*
* Set the global log priority. Messages with priorities equal to or
* higher than the argument will be printed to the current log handler.
*
* The default log priority is LIBINPUT_LOG_PRIORITY_ERROR.
*
* @param libinput A previously initialized libinput context
* @param priority The minimum priority of log messages to print.
*
* @see libinput_log_set_handler
* @see libinput_log_get_priority
*/
void
libinput_log_set_priority(struct libinput *libinput,
enum libinput_log_priority priority);
/**
* @ingroup base
*
* Get the global log priority. Messages with priorities equal to or
* higher than the argument will be printed to the current log handler.
*
* The default log priority is LIBINPUT_LOG_PRIORITY_ERROR.
*
* @param libinput A previously initialized libinput context
* @return The minimum priority of log messages to print.
*
* @see libinput_log_set_handler
* @see libinput_log_set_priority
*/
enum libinput_log_priority
libinput_log_get_priority(const struct libinput *libinput);
/**
* @ingroup base
*
* Log handler type for custom logging.
*
* @param libinput The libinput context
* @param priority The priority of the current message
* @param format Message format in printf-style
* @param args Message arguments
*
* @see libinput_set_log_priority
* @see libinput_log_set_handler
*/
typedef void (*libinput_log_handler)(struct libinput *libinput,
enum libinput_log_priority priority,
const char *format, va_list args)
LIBINPUT_ATTRIBUTE_PRINTF(3, 0);
/**
* @ingroup base
*
* Set the global log handler. Messages with priorities equal to or higher
* than the current log priority will be passed to the given
* log handler.
*
* The default log handler prints to stderr.
*
* @param libinput A previously initialized libinput context
* @param log_handler The log handler for library messages.
* @param user_data Caller-specific data pointer, passed into the log
* handler.
*
* @see libinput_log_set_handler
*/
void
libinput_log_set_handler(struct libinput *libinput,
libinput_log_handler log_handler);
/**
* @defgroup seat Initialization and manipulation of seats
*
* A seat has two identifiers, the physical name and the logical name. The
* physical name is summarized as the list of devices a process on the same
* physical seat has access to.
*
* The logical seat name is the seat name for a logical group of devices. A
* compositor may use that to create additonal seats as independent device
* sets. Alternatively, a compositor may limit itself to a single logical
* seat, leaving a second compositor to manage devices on the other logical
* seats.
*
* @code
* +---+--------+------------+------------------------+------------+
* | | event0 | | | log seat A |
* | K +--------+ | +------------+
* | e | event1 | phys seat0 | libinput context 1 | |
* | r +--------+ | | log seat B |
* | n | event2 | | | |
* | e +--------+------------+------------------------+------------+
* | l | event3 | phys seat1 | libinput context 2 | log seat C |
* +---+--------+------------+------------------------+------------+
* @endcode
*/
/**
* @ingroup seat
*
* Increase the refcount of the seat. A seat will be freed whenever the
* refcount reaches 0. This may happen during dispatch if the
* seat was removed from the system. A caller must ensure to reference
* the seat correctly to avoid dangling pointers.
*
* @param seat A previously obtained seat
* @return The passed seat
*/
struct libinput_seat *
libinput_seat_ref(struct libinput_seat *seat);
/**
* @ingroup seat
*
* Decrease the refcount of the seat. A seat will be freed whenever the
* refcount reaches 0. This may happen during dispatch if the
* seat was removed from the system. A caller must ensure to reference
* the seat correctly to avoid dangling pointers.
*
* @param seat A previously obtained seat
* @return NULL if seat was destroyed, otherwise the passed seat
*/
struct libinput_seat *
libinput_seat_unref(struct libinput_seat *seat);
/**
* @ingroup seat
*
* Set caller-specific data associated with this seat. libinput does
* not manage, look at, or modify this data. The caller must ensure the
* data is valid.
*
* @param seat A previously obtained seat
* @param user_data Caller-specific data pointer
* @see libinput_seat_get_user_data
*/
void
libinput_seat_set_user_data(struct libinput_seat *seat, void *user_data);
/**
* @ingroup seat
*
* Get the caller-specific data associated with this seat, if any.
*
* @param seat A previously obtained seat
* @return Caller-specific data pointer or NULL if none was set
* @see libinput_seat_set_user_data
*/
void *
libinput_seat_get_user_data(struct libinput_seat *seat);
/**
* @ingroup seat
*
* Return the physical name of the seat. For libinput contexts created from
* udev, this is always the same value as passed into
* libinput_udev_assign_seat() and all seats from that context will have
* the same physical name.
*
* The physical name of the seat is one that is usually set by the system or
* lower levels of the stack. In most cases, this is the base filter for
* devices - devices assigned to seats outside the current seat will not
* be available to the caller.
*
* @param seat A previously obtained seat
* @return the physical name of this seat
*/
const char *
libinput_seat_get_physical_name(struct libinput_seat *seat);
/**
* @ingroup seat
*
* Return the logical name of the seat. This is an identifier to group sets
* of devices within the compositor.
*
* @param seat A previously obtained seat
* @return the logical name of this seat
*/
const char *
libinput_seat_get_logical_name(struct libinput_seat *seat);
/**
* @defgroup device Initialization and manipulation of input devices
*/
/**
* @ingroup device
*
* Increase the refcount of the input device. An input device will be freed
* whenever the refcount reaches 0. This may happen during dispatch if the
* device was removed from the system. A caller must ensure to reference
* the device correctly to avoid dangling pointers.
*
* @param device A previously obtained device
* @return The passed device
*/
struct libinput_device *
libinput_device_ref(struct libinput_device *device);
/**
* @ingroup device
*
* Decrease the refcount of the input device. An input device will be freed
* whenever the refcount reaches 0. This may happen during dispatch if the
* device was removed from the system. A caller must ensure to reference
* the device correctly to avoid dangling pointers.
*
* @param device A previously obtained device
* @return NULL if device was destroyed, otherwise the passed device
*/
struct libinput_device *
libinput_device_unref(struct libinput_device *device);
/**
* @ingroup device
*
* Set caller-specific data associated with this input device. libinput does
* not manage, look at, or modify this data. The caller must ensure the
* data is valid.
*
* @param device A previously obtained device
* @param user_data Caller-specific data pointer
* @see libinput_device_get_user_data
*/
void
libinput_device_set_user_data(struct libinput_device *device, void *user_data);
/**
* @ingroup device
*
* Get the caller-specific data associated with this input device, if any.
*
* @param device A previously obtained device
* @return Caller-specific data pointer or NULL if none was set
* @see libinput_device_set_user_data
*/
void *
libinput_device_get_user_data(struct libinput_device *device);
/**
* @ingroup device
*
* Get the system name of the device.
*
* To get the descriptive device name, use libinput_device_get_name().
*
* @param device A previously obtained device
* @return System name of the device
*
*/
const char *
libinput_device_get_sysname(struct libinput_device *device);
/**
* @ingroup device
*
* The descriptive device name as advertised by the kernel and/or the
* hardware itself. To get the sysname for this device, use
* libinput_device_get_sysname().
*
* The lifetime of the returned string is tied to the struct
* libinput_device. The string may be the empty string but is never NULL.
*
* @param device A previously obtained device
* @return The device name
*/
const char *
libinput_device_get_name(struct libinput_device *device);
/**
* @ingroup device
*
* Get the product ID for this device.
*
* @param device A previously obtained device
* @return The product ID of this device
*/
unsigned int
libinput_device_get_id_product(struct libinput_device *device);
/**
* @ingroup device
*
* Get the vendor ID for this device.
*
* @param device A previously obtained device
* @return The vendor ID of this device
*/
unsigned int
libinput_device_get_id_vendor(struct libinput_device *device);
/**
* @ingroup device
*
* A device may be mapped to a single output, or all available outputs. If a
* device is mapped to a single output only, a relative device may not move
* beyond the boundaries of this output. An absolute device has its input
* coordinates mapped to the extents of this output.
*
* @return the name of the output this device is mapped to, or NULL if no
* output is set
*/
const char *
libinput_device_get_output_name(struct libinput_device *device);
/**
* @ingroup device
*
* Get the seat associated with this input device.
*
* A seat can be uniquely identified by the physical and logical seat name.
* There will ever be only one seat instance with a given physical and logical
* seat name pair at any given time, but if no external reference is kept, it
* may be destroyed if no device belonging to it is left.
*
* @param device A previously obtained device
* @return The seat this input device belongs to
*/
struct libinput_seat *
libinput_device_get_seat(struct libinput_device *device);
/**
* @ingroup device
*
* Update the LEDs on the device, if any. If the device does not have
* LEDs, or does not have one or more of the LEDs given in the mask, this
* function does nothing.
*
* @param device A previously obtained device
* @param leds A mask of the LEDs to set, or unset.
*/
void
libinput_device_led_update(struct libinput_device *device,
enum libinput_led leds);
/**
* @ingroup device
*
* Set the bitmask in keys to the bitmask of the keys present on the device
* (see linux/input.h), up to size characters.
*
* @param device A current input device
* @param keys An array filled with the bitmask for the keys
* @param size Size of the keys array
*
* @return The number of valid bytes in keys, or a negative errno on failure
*/
int
libinput_device_get_keys(struct libinput_device *device,
char *keys, size_t size)
LIBINPUT_ATTRIBUTE_DEPRECATED;
/**
* @ingroup device
*
* @deprecated Use libinput_device_config_calibration_set_matrix() instead.
*/
void
libinput_device_calibrate(struct libinput_device *device,
float calibration[6])
LIBINPUT_ATTRIBUTE_DEPRECATED;
/**
* @ingroup device
*
* Check if the given device has the specified capability
*
* @return 1 if the given device has the capability or 0 if not
*/
int
libinput_device_has_capability(struct libinput_device *device,
enum libinput_device_capability capability);
/**
* @ingroup device
*
* Get the physical size of a device in mm, where meaningful. This function
* only succeeds on devices with the required data, i.e. tablets, touchpads
* and touchscreens.
*
* If this function returns nonzero, width and height are unmodified.
*
* @param device The device
* @param width Set to the width of the device
* @param height Set to the height of the device
* @return 0 on success, or nonzero otherwise
*/
int
libinput_device_get_size(struct libinput_device *device,
double *width,
double *height);
/**
* @defgroup config Device configuration
*
* Enable, disable, change and/or check for device-specific features. For
* all features, libinput assigns a default based on the hardware
* configuration. This default can be obtained with the respective
* get_default call.
*
* Some configuration option may be dependent on or mutually exclusive with
* with other options. The behavior in those cases is
* implementation-defined, the caller must ensure that the options are set
* in the right order.
*/
/**
* @ingroup config
*
* Status codes returned when applying configuration settings.
*/
enum libinput_config_status {
LIBINPUT_CONFIG_STATUS_SUCCESS = 0, /**< Config applied successfully */
LIBINPUT_CONFIG_STATUS_UNSUPPORTED, /**< Configuration not available on
this device */
LIBINPUT_CONFIG_STATUS_INVALID, /**< Invalid parameter range */
};
/**
* @ingroup config
*
* Return a string describing the error.
*
* @param status The status to translate to a string
* @return A human-readable string representing the error or NULL for an
* invalid status.
*/
const char *
libinput_config_status_to_str(enum libinput_config_status status);
/**
* @ingroup config
*/
enum libinput_config_tap_state {
LIBINPUT_CONFIG_TAP_DISABLED, /**< Tapping is to be disabled, or is
currently disabled */
LIBINPUT_CONFIG_TAP_ENABLED, /**< Tapping is to be enabled, or is
currently enabled */
};
/**
* @ingroup config
*
* Check if the device supports tap-to-click. See
* libinput_device_config_tap_set_enabled() for more information.
*
* @param device The device to configure
* @return The number of fingers that can generate a tap event, or 0 if the
* device does not support tapping.
*
* @see libinput_device_config_tap_set_enabled
* @see libinput_device_config_tap_get_enabled
* @see libinput_device_config_tap_get_default_enabled
*/
int
libinput_device_config_tap_get_finger_count(struct libinput_device *device);
/**
* @ingroup config
*
* Enable or disable tap-to-click on this device, with a default mapping of
* 1, 2, 3 finger tap mapping to left, right, middle click, respectively.
* Tapping is limited by the number of simultaneous touches
* supported by the device, see
* libinput_device_config_tap_get_finger_count().
*
* @param device The device to configure
* @param enable @ref LIBINPUT_CONFIG_TAP_ENABLED to enable tapping or @ref
* LIBINPUT_CONFIG_TAP_DISABLED to disable tapping
*
* @return A config status code. Disabling tapping on a device that does not
* support tapping always succeeds.
*
* @see libinput_device_config_tap_get_finger_count
* @see libinput_device_config_tap_get_enabled
* @see libinput_device_config_tap_get_default_enabled
*/
enum libinput_config_status
libinput_device_config_tap_set_enabled(struct libinput_device *device,
enum libinput_config_tap_state enable);
/**
* @ingroup config
*
* Check if tap-to-click is enabled on this device. If the device does not
* support tapping, this function always returns 0.
*
* @param device The device to configure
*
* @return @ref LIBINPUT_CONFIG_TAP_ENABLED if tapping is currently enabled,
* or @ref LIBINPUT_CONFIG_TAP_DISABLED is currently disabled
*
* @see libinput_device_config_tap_get_finger_count
* @see libinput_device_config_tap_set_enabled
* @see libinput_device_config_tap_get_default_enabled
*/
enum libinput_config_tap_state
libinput_device_config_tap_get_enabled(struct libinput_device *device);
/**
* @ingroup config
*
* Return the default setting for whether tapping is enabled on this device.
*
* @param device The device to configure
* @return @ref LIBINPUT_CONFIG_TAP_ENABLED if tapping is enabled by default,
* or @ref LIBINPUT_CONFIG_TAP_DISABLED is disabled by default
*
* @see libinput_device_config_tap_get_finger_count
* @see libinput_device_config_tap_set_enabled
* @see libinput_device_config_tap_get_enabled
*/
enum libinput_config_tap_state
libinput_device_config_tap_get_default_enabled(struct libinput_device *device);
/**
* @ingroup config
*
* Check if the device can be calibrated via a calibration matrix.
*
* @param device The device to check
* @return non-zero if the device can be calibrated, zero otherwise.
*
* @see libinput_device_config_calibration_set_matrix
* @see libinput_device_config_calibration_get_matrix
* @see libinput_device_config_calibration_get_default_matrix
*/
int
libinput_device_config_calibration_has_matrix(struct libinput_device *device);
/**
* @ingroup config
*
* Apply the 3x3 transformation matrix to absolute device coordinates. This
* matrix has no effect on relative events.
*
* Given a 6-element array [a, b, c, d, e, f], the matrix is applied as
* @code
* [ a b c ] [ x ]
* [ d e f ] * [ y ]
* [ 0 0 1 ] [ 1 ]
* @endcode
*
* The translation component (c, f) is expected to be normalized to the
* device coordinate range. For example, the matrix
* @code
* [ 1 0 1 ]
* [ 0 1 -1 ]
* [ 0 0 1 ]
* @endcode
* moves all coordinates by 1 device-width to the right and 1 device-height
* up.
*
* The rotation matrix for rotation around the origin is defined as
* @code
* [ cos(a) -sin(a) 0 ]
* [ sin(a) cos(a) 0 ]
* [ 0 0 1 ]
* @endcode
* Note that any rotation requires an additional translation component to
* translate the rotated coordinates back into the original device space.
* The rotation matrixes for 90, 180 and 270 degrees clockwise are:
* @code
* 90 deg cw: 180 deg cw: 270 deg cw:
* [ 0 -1 1] [ -1 0 1] [ 0 1 0 ]
* [ 1 0 0] [ 0 -1 1] [ -1 0 1 ]
* [ 0 0 1] [ 0 0 1] [ 0 0 1 ]
* @endcode
*
* @param device The device to configure
* @param matrix An array representing the first two rows of a 3x3 matrix as
* described above.
*
* @return A config status code.
*
* @see libinput_device_config_calibration_has_matrix
* @see libinput_device_config_calibration_get_matrix
* @see libinput_device_config_calibration_get_default_matrix
*/
enum libinput_config_status
libinput_device_config_calibration_set_matrix(struct libinput_device *device,
const float matrix[6]);
/**
* @ingroup config
*
* Return the current calibration matrix for this device.
*
* @param device The device to configure
* @param matrix Set to the array representing the first two rows of a 3x3 matrix as
* described in libinput_device_config_calibration_set_matrix().
*
* @return 0 if no calibration is set and the returned matrix is the
* identity matrix, 1 otherwise
*
* @see libinput_device_config_calibration_has_matrix
* @see libinput_device_config_calibration_set_matrix
* @see libinput_device_config_calibration_get_default_matrix
*/
int
libinput_device_config_calibration_get_matrix(struct libinput_device *device,
float matrix[6]);
/**
* @ingroup config
*
* Return the default calibration matrix for this device. On most devices,
* this is the identity matrix. If the udev property
* <b>LIBINPUT_CALIBRATION_MATRIX</b> is set on the respective udev device,
* that property's value becomes the default matrix.
*
* The udev property is parsed as 6 floating point numbers separated by a
* single space each (scanf(3) format "%f %f %f %f %f %f").
* The 6 values represent the first two rows of the calibration matrix as
* described in libinput_device_config_calibration_set_matrix().
*
* Example values are:
* @code
* ENV{LIBINPUT_CALIBRATION_MATRIX}="1 0 0 0 1 0" # default
* ENV{LIBINPUT_CALIBRATION_MATRIX}="0 -1 1 1 0 0" # 90 degree clockwise
* ENV{LIBINPUT_CALIBRATION_MATRIX}="-1 0 1 0 -1 1" # 180 degree clockwise
* ENV{LIBINPUT_CALIBRATION_MATRIX}="0 1 0 -1 0 1" # 270 degree clockwise
* ENV{LIBINPUT_CALIBRATION_MATRIX}="-1 0 1 1 0 0" # reflect along y axis
* @endcode
*
* @param device The device to configure
* @param matrix Set to the array representing the first two rows of a 3x3 matrix as
* described in libinput_device_config_calibration_set_matrix().
*
* @return 0 if no calibration is set and the returned matrix is the
* identity matrix, 1 otherwise
*
* @see libinput_device_config_calibration_has_matrix
* @see libinput_device_config_calibration_set_matrix
* @see libinput_device_config_calibration_get_default_matrix
*/
int
libinput_device_config_calibration_get_default_matrix(struct libinput_device *device,
float matrix[6]);
#ifdef __cplusplus
}
#endif
#endif /* LIBINPUT_H */
|