1/* xi.vapi 2 * 3 * Copyright (C) 2014 Rico Tzschichholz 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 * 19 * Authors: 20 * Rico Tzschichholz <ricotz@ubuntu.com> 21 */ 22 23[CCode (cheader_filename = "X11/extensions/XI2.h,X11/extensions/XInput2.h")] 24namespace XInput { 25 [CCode (cname = "XIAllMasterDevices")] 26 public const int ALL_MASTER_DEVICES; 27 28 [CCode (cname = "XIBarrierPointerReleased")] 29 public const int BARRIER_POINTER_RELEASED; 30 [CCode (cname = "XIBarrierDeviceIsGrabbed")] 31 public const int BARRIER_DEVICE_IS_GRABBED; 32 33 [CCode (cname = "XISetMask")] 34 public static void set_mask (uchar* mask, XInput.EventType event); 35 [CCode (cname = "XIClearMask")] 36 public static void clear_mask (uchar* mask, XInput.EventType event); 37 [CCode (cname = "XIMaskIsSet")] 38 public static bool mask_is_set (uchar* mask, XInput.EventType event); 39 [CCode (cname = "XIMaskLen")] 40 public static int mask_length (XInput.EventType event); 41 42 [CCode (has_type_id = false)] 43 public enum EventType { 44 [CCode (cname = "XI_DeviceChanged")] 45 DEVICE_CHANGED, 46 [CCode (cname = "XI_KeyPress")] 47 KEY_PRESS, 48 [CCode (cname = "XI_KeyRelease")] 49 KEY_RELEASE, 50 [CCode (cname = "XI_ButtonPress")] 51 BUTTON_PRESS, 52 [CCode (cname = "XI_ButtonRelease")] 53 BUTTON_RELEASE, 54 [CCode (cname = "XI_Motion")] 55 MOTION, 56 [CCode (cname = "XI_Enter")] 57 ENTER, 58 [CCode (cname = "XI_Leave")] 59 LEAVE, 60 [CCode (cname = "XI_FocusIn")] 61 FOCUS_IN, 62 [CCode (cname = "XI_FocusOut")] 63 FOCUS_OUT, 64 [CCode (cname = "XI_HierarchyChanged")] 65 HIERARCHY_CHANGED, 66 [CCode (cname = "XI_PropertyEvent")] 67 PROPERTY_EVENT, 68 [CCode (cname = "XI_RawKeyPress")] 69 RAW_KEY_PRESS, 70 [CCode (cname = "XI_RawKeyRelease")] 71 RAW_KEY_RELEASE, 72 [CCode (cname = "XI_RawButtonPress")] 73 RAW_BUTTON_PRESS, 74 [CCode (cname = "XI_RawButtonRelease")] 75 RAW_BUTTON_RELEASE, 76 [CCode (cname = "XI_RawMotion")] 77 RAW_MOTION, 78 [CCode (cname = "XI_TouchBegin")] 79 TOUCH_BEGIN, 80 [CCode (cname = "XI_TouchUpdate")] 81 TOUCH_UPDATE, 82 [CCode (cname = "XI_TouchEnd")] 83 TOUCH_END, 84 [CCode (cname = "XI_TouchOwnership")] 85 TOUCH_OWNERSHIP, 86 [CCode (cname = "XI_RawTouchBegin")] 87 RAW_TOUCH_BEGIN, 88 [CCode (cname = "XI_RawTouchUpdate")] 89 RAW_TOUCH_UPDATE, 90 [CCode (cname = "XI_RawTouchEnd")] 91 RAW_TOUCH_END, 92 [CCode (cname = "XI_BarrierHit")] 93 BARRIER_HIT, 94 [CCode (cname = "XI_BarrierLeave")] 95 BARRIER_LEAVE, 96 97 [CCode (cname = "XI_LASTEVENT")] 98 LASTEVENT; 99 } 100 101 [CCode (has_type_id = false)] 102 [Flags] 103 public enum EventFlags { 104 [CCode (cname = "XI_DeviceChangedMask")] 105 DEVICE_CHANGED_MASK, 106 [CCode (cname = "XI_KeyPressMask")] 107 KEY_PRESS_MASK, 108 [CCode (cname = "XI_KeyReleaseMask")] 109 KEY_RELEASE_MASK, 110 [CCode (cname = "XI_ButtonPressMask")] 111 BUTTON_PRESS_MASK, 112 [CCode (cname = "XI_ButtonReleaseMask")] 113 BUTTON_RELEASE_MASK, 114 [CCode (cname = "XI_MotionMask")] 115 MOTION_MASK, 116 [CCode (cname = "XI_EnterMask")] 117 ENTER_MASK, 118 [CCode (cname = "XI_LeaveMask")] 119 LEAVE_MASK, 120 [CCode (cname = "XI_FocusInMask")] 121 FOCUS_IN_MASK, 122 [CCode (cname = "XI_FocusOutMask")] 123 FOCUS_OUT_MASK, 124 [CCode (cname = "XI_HierarchyChangedMask")] 125 HIERARCHY_CHANGED_MASK, 126 [CCode (cname = "XI_PropertyEventMask")] 127 PROPERTY_EVENT_MASK, 128 [CCode (cname = "XI_RawKeyPressMask")] 129 RAW_KEY_PRESS_MASK, 130 [CCode (cname = "XI_RawKeyReleaseMask")] 131 RAW_KEY_RELEASE_MASK, 132 [CCode (cname = "XI_RawButtonPressMask")] 133 RAW_BUTTON_PRESS_MASK, 134 [CCode (cname = "XI_RawButtonReleaseMask")] 135 RAW_BUTTON_RELEASE_MASK, 136 [CCode (cname = "XI_RawMotionMask")] 137 RAW_MOTION_MASK, 138 139 /* XI 2.2 */ 140 [CCode (cname = "XI_TouchBeginMask")] 141 TOUCH_BEGIN_MASK, 142 [CCode (cname = "XI_TouchUpdateMask")] 143 TOUCH_UPDATE_MASK, 144 [CCode (cname = "XI_TouchEndMask")] 145 TOUCH_END_MASK, 146 [CCode (cname = "XI_TouchOwnershipMask")] 147 TOUCH_OWNERSHIP_MASK, 148 [CCode (cname = "XI_RawTouchBeginMask")] 149 RAW_TOUCH_BEGIN_MASK, 150 [CCode (cname = "XI_RawTouchUpdateMask")] 151 RAW_TOUCH_UPDATE_MASK, 152 [CCode (cname = "XI_RawTouchEndMask")] 153 RAW_TOUCH_END_MASK, 154 155 /* XI 2.3 */ 156 [CCode (cname = "XI_BarrierHitMask")] 157 BARRIER_HIT_MASK, 158 [CCode (cname = "XI_BarrierLeaveMask")] 159 BARRIER_LEAVE_MASK; 160 } 161 162 [CCode (cname = "XIAddMasterInfo", has_type_id = false)] 163 public struct AddMasterInfo { 164 int type; 165 string name; 166 bool send_core; 167 bool enable; 168 } 169 170 [CCode (cname = "XIRemoveMasterInfo", has_type_id = false)] 171 public struct RemoveMasterInfo { 172 int type; 173 int deviceid; 174 int return_mode; 175 int return_pointer; 176 int return_keyboard; 177 } 178 179 [CCode (cname = "XIAttachSlaveInfo", has_type_id = false)] 180 public struct AttachSlaveInfo { 181 int type; 182 int deviceid; 183 int new_master; 184 } 185 186 [CCode (cname = "XIDetachSlaveInfo", has_type_id = false)] 187 public struct DetachSlaveInfo { 188 int type; 189 int deviceid; 190 } 191 192 // union 193 [CCode (cname = "XIAnyHierarchyChangeInfo", has_type_id = false)] 194 public struct AnyHierarchyChangeInfo { 195 int type; 196 XInput.AddMasterInfo add; 197 XInput.RemoveMasterInfo remove; 198 XInput.AttachSlaveInfo attach; 199 XInput.DetachSlaveInfo detach; 200 } 201 202 [CCode (cname = "XIModifierState", has_type_id = false)] 203 public struct ModifierState { 204 int @base; 205 int latched; 206 int locked; 207 int effective; 208 } 209 210 [CCode (cname = "XIGroupState", has_type_id = false)] 211 public struct GroupState : ModifierState { 212 } 213 214 [CCode (cname = "XIButtonState", has_type_id = false)] 215 public struct ButtonState { 216 int mask_len; 217 [CCode (array_length_cname = "mask_len")] 218 uchar[] mask; 219 } 220 221 [CCode (cname = "XIValuatorState", has_type_id = false)] 222 public struct ValuatorState { 223 int mask_len; 224 [CCode (array_length_cname = "mask_len")] 225 uchar[] mask; 226 [CCode (array_length_cname = "mask_len")] 227 double[] values; 228 } 229 230 [CCode (cname = "XIEventMask", has_destroy_function = false, has_type_id = false)] 231 public struct EventMask { 232 int deviceid; 233 int mask_len; 234 [CCode (array_length_cname = "mask_len")] 235 uchar[] mask; 236 } 237 238 [CCode (cname = "XIAnyClassInfo", has_type_id = false)] 239 public struct AnyClassInfo { 240 int type; 241 int sourceid; 242 } 243 244 [CCode (cname = "XIButtonClassInfo", has_type_id = false)] 245 public struct ButtonClassInfo { 246 int type; 247 int sourceid; 248 int num_buttons; 249 [CCode (array_length = false)] 250 X.Atom[] labels; 251 XInput.ButtonState state; 252 } 253 254 [CCode (cname = "XIKeyClassInfo", has_type_id = false)] 255 public struct KeyClassInfo { 256 int type; 257 int sourceid; 258 int num_keycodes; 259 [CCode (array_length_cname = "num_keycodes")] 260 int[] keycodes; 261 } 262 263 [CCode (cname = "XIValuatorClassInfo", has_type_id = false)] 264 public struct ValuatorClassInfo { 265 int type; 266 int sourceid; 267 int number; 268 X.Atom label; 269 double min; 270 double max; 271 double @value; 272 int resolution; 273 int mode; 274 } 275 276 [CCode (cname = "XIScrollClassInfo", has_type_id = false)] 277 public struct ScrollClassInfo { 278 int type; 279 int sourceid; 280 int number; 281 int scroll_type; 282 double increment; 283 int flags; 284 } 285 286 [CCode (cname = "XITouchClassInfo", has_type_id = false)] 287 public struct TouchClassInfo { 288 int type; 289 int sourceid; 290 int mode; 291 int num_touches; 292 } 293 294 [CCode (cname = "XIDeviceInfo", free_function = "XIFreeDeviceInfo", has_type_id = false)] 295 public struct DeviceInfo { 296 int deviceid; 297 string name; 298 int use; 299 int attachment; 300 bool enabled; 301 int num_classes; 302 [CCode (array_length_cname = "num_classes")] 303 XInput.AnyClassInfo[] classes; 304 } 305 306 [CCode (cname = "XIGrabModifiers", has_type_id = false)] 307 public struct GrabModifiers { 308 int modifiers; 309 int status; 310 } 311 312 [SimpleType] 313 [CCode (cname = "BarrierEventID", has_type_id = false)] 314 public struct BarrierEventID : uint { 315 } 316 317 [CCode (cname = "XIBarrierReleasePointerInfo", has_type_id = false)] 318 public struct BarrierReleasePointerInfo { 319 int deviceid; 320 XFixes.PointerBarrier barrier; 321 XInput.BarrierEventID eventid; 322 } 323 324 [CCode (cname = "XIEvent", has_type_id = false)] 325 public struct Event { 326 int type; 327 ulong serial; 328 bool send_event; 329 unowned X.Display display; 330 int extension; 331 int evtype; 332 ulong time; 333 } 334 335 [CCode (cname = "XIHierarchyInfo", has_type_id = false)] 336 public struct HierarchyInfo { 337 int deviceid; 338 int attachment; 339 int use; 340 bool enabled; 341 int flags; 342 } 343 344 [CCode (cname = "XIHierarchyEvent", has_type_id = false)] 345 public struct HierarchyEvent { 346 int type; 347 ulong serial; 348 bool send_event; 349 unowned X.Display display; 350 int extension; 351 int evtype; 352 ulong time; 353 int flags; 354 int num_info; 355 XInput.HierarchyInfo info; 356 } 357 358 [CCode (cname = "XIDeviceChangedEvent", has_type_id = false)] 359 public struct DeviceChangedEvent { 360 int type; 361 ulong serial; 362 bool send_event; 363 unowned X.Display display; 364 int extension; 365 int evtype; 366 ulong time; 367 int deviceid; 368 int sourceid; 369 int reason; 370 int num_classes; 371 [CCode (array_length_cname = "num_classes")] 372 XInput.AnyClassInfo[] classes; 373 } 374 375 [CCode (cname = "XIDeviceEvent", has_type_id = false)] 376 public struct DeviceEvent { 377 int type; 378 ulong serial; 379 bool send_event; 380 unowned X.Display display; 381 int extension; 382 int evtype; 383 ulong time; 384 int deviceid; 385 int sourceid; 386 int detail; 387 X.Window root; 388 X.Window event; 389 X.Window child; 390 double root_x; 391 double root_y; 392 double event_x; 393 double event_y; 394 int flags; 395 XInput.ButtonState buttons; 396 XInput.ValuatorState valuators; 397 XInput.ModifierState mods; 398 XInput.GroupState group; 399 } 400 401 [CCode (cname = "XIRawEvent", has_type_id = false)] 402 public struct RawEvent { 403 int type; 404 ulong serial; 405 bool send_event; 406 unowned X.Display display; 407 int extension; 408 int evtype; 409 ulong time; 410 int deviceid; 411 int sourceid; 412 int detail; 413 int flags; 414 XInput.ValuatorState valuators; 415 [CCode (array_length = false)] 416 double[] raw_values; 417 } 418 419 [CCode (cname = "XIEnterEvent", has_type_id = false)] 420 public struct EnterEvent { 421 int type; 422 ulong serial; 423 bool send_event; 424 unowned X.Display display; 425 int extension; 426 int evtype; 427 ulong time; 428 int deviceid; 429 int sourceid; 430 int detail; 431 X.Window root; 432 X.Window event; 433 X.Window child; 434 double root_x; 435 double root_y; 436 double event_x; 437 double event_y; 438 int mode; 439 bool focus; 440 bool same_screen; 441 XInput.ButtonState buttons; 442 XInput.ModifierState mods; 443 XInput.GroupState group; 444 } 445 446 [CCode (cname = "XILeaveEvent", has_type_id = false)] 447 public struct LeaveEvent : EnterEvent { 448 } 449 450 [CCode (cname = "XIFocusInEvent", has_type_id = false)] 451 public struct FocusInEvent : EnterEvent { 452 } 453 454 [CCode (cname = "XIFocusOutEvent", has_type_id = false)] 455 public struct FocusOutEvent : EnterEvent { 456 } 457 458 [CCode (cname = "XIPropertyEvent", has_type_id = false)] 459 public struct PropertyEvent { 460 int type; 461 ulong serial; 462 bool send_event; 463 unowned X.Display display; 464 int extension; 465 int evtype; 466 ulong time; 467 int deviceid; 468 X.Atom property; 469 int what; 470 } 471 472 [CCode (cname = "XITouchOwnershipEvent", has_type_id = false)] 473 public struct TouchOwnershipEvent { 474 int type; 475 ulong serial; 476 bool send_event; 477 unowned X.Display display; 478 int extension; 479 int evtype; 480 ulong time; 481 int deviceid; 482 int sourceid; 483 uint touchid; 484 X.Window root; 485 X.Window event; 486 X.Window child; 487 int flags; 488 } 489 490 [CCode (cname = "XIBarrierEvent", has_type_id = false)] 491 public struct BarrierEvent { 492 int type; 493 ulong serial; 494 bool send_event; 495 unowned X.Display display; 496 int extension; 497 int evtype; 498 ulong time; 499 int deviceid; 500 int sourceid; 501 X.Window event; 502 X.Window root; 503 double root_x; 504 double root_y; 505 double dx; 506 double dy; 507 int dtime; 508 int flags; 509 XFixes.PointerBarrier barrier; 510 XInput.BarrierEventID eventid; 511 } 512 513 [CCode (cname = "XIQueryPointer")] 514 public static bool query_pointer (X.Display display, int deviceid, X.Window win, out X.Window root, out X.Window child, out double root_x, out double root_y, out double win_x, out double win_y, out XInput.ButtonState buttons, out XInput.ModifierState mods, out XInput.GroupState group); 515 516 [CCode (cname = "XIWarpPointer")] 517 public static bool warp_pointer (X.Display display, int deviceid, X.Window src_win, X.Window dst_win, double src_x, double src_y, uint src_width, uint src_height, double dst_x, double dst_y); 518 519 [CCode (cname = "XIDefineCursor")] 520 public static X.Status define_cursor (X.Display display, int deviceid, X.Window win, X.Cursor cursor); 521 522 [CCode (cname = "XIUndefineCursor")] 523 public static X.Status undefine_cursor (X.Display display, int deviceid, X.Window win); 524 525 [CCode (cname = "XIChangeHierarchy")] 526 public static X.Status change_hierarchy (X.Display display, [CCode (array_length_cname = "num_changes", array_length_pos = 2.1, array_length_type = "int")] XInput.AnyHierarchyChangeInfo[] changes); 527 528 [CCode (cname = "XISetClientPointer")] 529 public static X.Status set_client_pointer (X.Display display, X.Window win, int deviceid); 530 531 [CCode (cname = "XIGetClientPointer")] 532 public static bool get_client_pointer (X.Display display, X.Window win, out int deviceid); 533 534 [CCode (cname = "XISelectEvents")] 535 public static int select_events (X.Display display, X.Window window, XInput.EventMask* masks, int masks_len); 536 537 [CCode (cname = "XIGetSelectedEvents", array_length_cname = "num_masks_return")] 538 public static XInput.EventMask[] get_selected_events (X.Display display, X.Window window); 539 540 [CCode (cname = "XIQueryVersion")] 541 public static X.Status query_version (X.Display display, ref int major_version, ref int minor_version); 542 543 [CCode (cname = "XIQueryDevice", array_length_cname = "ndevices_return")] 544 public static XInput.DeviceInfo[] query_device (X.Display display, X.Window window); 545 546 [CCode (cname = "XISetFocus")] 547 public static X.Status set_focus (X.Display display, int deviceid, X.Window win, ulong time); 548 549 [CCode (cname = "XIGetFocus")] 550 public static X.Status get_focus (X.Display display, int deviceid, out X.Window focus_return); 551 552 [CCode (cname = "XIGrabDevice")] 553 public static X.Status grab_device (X.Display display, int deviceid, X.Window grab_window, ulong time, X.Cursor cursor, int grab_mode, int paired_device_mode, bool owner_events, XInput.EventMask mask); 554 555 [CCode (cname = "XIUngrabDevice")] 556 public static X.Status ungrab_device (X.Display display, int deviceid, ulong time); 557 558 [CCode (cname = "XIAllowEvents")] 559 public static X.Status allow_events (X.Display display, int deviceid, int event_mode, ulong time); 560 561 [CCode (cname = "XIAllowTouchEvents")] 562 public static X.Status allow_touch_events (X.Display display, int deviceid, uint touchid, X.Window grab_window, int event_mode); 563 564 [CCode (cname = "XIGrabButton")] 565 public static int grab_button (X.Display display, int deviceid, int button, X.Window grab_window, X.Cursor cursor, int grab_mode, int paired_device_mode, int owner_events, XInput.EventMask mask, [CCode (array_length_cname = "num_modifiers", array_length_pos = 8.9, array_length_type = "int")] ref XInput.GrabModifiers[] modifiers_inout); 566 567 [CCode (cname = "XIGrabKeycode")] 568 public static int grab_keycode (X.Display display, int deviceid, int keycode, X.Window grab_window, int grab_mode, int paired_device_mode, int owner_events, XInput.EventMask mask, [CCode (array_length_cname = "num_modifiers", array_length_pos = 4.9, array_length_type = "int")] ref XInput.GrabModifiers[] modifiers_inout); 569 570 571 572 573 [CCode (cname = "XIBarrierReleasePointers")] 574 public static void barrier_release_pointers (X.Display display, [CCode (array_length_cname = "num_barriers", array_length_pos = 2.1, array_length_type = "int")] XInput.BarrierReleasePointerInfo[] barriers); 575 576 [CCode (cname = "XIBarrierReleasePointer")] 577 public static void barrier_release_pointer (X.Display display, int deviceid, XFixes.PointerBarrier barrier, XInput.BarrierEventID eventid); 578 579} 580 581