/usr/share/doc/libghc-glut-doc/html/src/Graphics-UI-GLUT-Callbacks-Window.html is in libghc-glut-doc 2.4.0.0-1.
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 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
<title>Graphics/UI/GLUT/Callbacks/Window.hs</title>
<link type='text/css' rel='stylesheet' href='hscolour.css' />
</head>
<body>
<pre><a name="line-1"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-2"></a><span class='hs-comment'>-- |</span>
<a name="line-3"></a><span class='hs-comment'>-- Module : Graphics.UI.GLUT.Callbacks.Window</span>
<a name="line-4"></a><span class='hs-comment'>-- Copyright : (c) Sven Panne 2002-2005</span>
<a name="line-5"></a><span class='hs-comment'>-- License : BSD-style (see the file libraries/GLUT/LICENSE)</span>
<a name="line-6"></a><span class='hs-comment'>--</span>
<a name="line-7"></a><span class='hs-comment'>-- Maintainer : sven.panne@aedion.de</span>
<a name="line-8"></a><span class='hs-comment'>-- Stability : stable</span>
<a name="line-9"></a><span class='hs-comment'>-- Portability : portable</span>
<a name="line-10"></a><span class='hs-comment'>--</span>
<a name="line-11"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-12"></a>
<a name="line-13"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>Graphics</span><span class='hs-varop'>.</span><span class='hs-conid'>UI</span><span class='hs-varop'>.</span><span class='hs-conid'>GLUT</span><span class='hs-varop'>.</span><span class='hs-conid'>Callbacks</span><span class='hs-varop'>.</span><span class='hs-conid'>Window</span> <span class='hs-layout'>(</span>
<a name="line-14"></a> <span class='hs-comment'>-- * Redisplay callbacks</span>
<a name="line-15"></a> <span class='hs-conid'>DisplayCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>displayCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>overlayDisplayCallback</span><span class='hs-layout'>,</span>
<a name="line-16"></a>
<a name="line-17"></a> <span class='hs-comment'>-- * Reshape callback</span>
<a name="line-18"></a> <span class='hs-conid'>ReshapeCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>reshapeCallback</span><span class='hs-layout'>,</span>
<a name="line-19"></a>
<a name="line-20"></a> <span class='hs-comment'>-- * Callbacks for visibility changes</span>
<a name="line-21"></a> <span class='hs-conid'>Visibility</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-conid'>VisibilityCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>visibilityCallback</span><span class='hs-layout'>,</span>
<a name="line-22"></a> <span class='hs-conid'>WindowState</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-conid'>WindowStateCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>windowStateCallback</span><span class='hs-layout'>,</span>
<a name="line-23"></a>
<a name="line-24"></a> <span class='hs-comment'>-- * Window close callback</span>
<a name="line-25"></a> <span class='hs-conid'>CloseCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>closeCallback</span><span class='hs-layout'>,</span>
<a name="line-26"></a>
<a name="line-27"></a> <span class='hs-comment'>-- * Keyboard callback</span>
<a name="line-28"></a> <span class='hs-conid'>KeyboardCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>keyboardCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>keyboardUpCallback</span><span class='hs-layout'>,</span>
<a name="line-29"></a>
<a name="line-30"></a> <span class='hs-comment'>-- * Special callback</span>
<a name="line-31"></a> <span class='hs-conid'>SpecialCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>specialCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>specialUpCallback</span><span class='hs-layout'>,</span>
<a name="line-32"></a>
<a name="line-33"></a> <span class='hs-comment'>-- * Mouse callback</span>
<a name="line-34"></a> <span class='hs-conid'>MouseCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>mouseCallback</span><span class='hs-layout'>,</span>
<a name="line-35"></a>
<a name="line-36"></a> <span class='hs-comment'>-- * Keyboard and mouse input callback</span>
<a name="line-37"></a> <span class='hs-conid'>Key</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-conid'>SpecialKey</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-conid'>MouseButton</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-conid'>KeyState</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-conid'>Modifiers</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span>
<a name="line-38"></a> <span class='hs-conid'>KeyboardMouseCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>keyboardMouseCallback</span><span class='hs-layout'>,</span>
<a name="line-39"></a>
<a name="line-40"></a> <span class='hs-comment'>-- * Mouse wheel callback</span>
<a name="line-41"></a> <span class='hs-conid'>WheelNumber</span><span class='hs-layout'>,</span> <span class='hs-conid'>WheelDirection</span><span class='hs-layout'>,</span> <span class='hs-conid'>MouseWheelCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>mouseWheelCallback</span><span class='hs-layout'>,</span>
<a name="line-42"></a>
<a name="line-43"></a> <span class='hs-comment'>-- * Mouse movement callbacks</span>
<a name="line-44"></a> <span class='hs-conid'>MotionCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>motionCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>passiveMotionCallback</span><span class='hs-layout'>,</span>
<a name="line-45"></a> <span class='hs-conid'>Crossing</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-conid'>CrossingCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>crossingCallback</span><span class='hs-layout'>,</span>
<a name="line-46"></a>
<a name="line-47"></a> <span class='hs-comment'>-- * Spaceball callback</span>
<a name="line-48"></a> <span class='hs-conid'>SpaceballMotion</span><span class='hs-layout'>,</span> <span class='hs-conid'>SpaceballRotation</span><span class='hs-layout'>,</span> <span class='hs-conid'>ButtonIndex</span><span class='hs-layout'>,</span> <span class='hs-conid'>SpaceballInput</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span>
<a name="line-49"></a> <span class='hs-conid'>SpaceballCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>spaceballCallback</span><span class='hs-layout'>,</span>
<a name="line-50"></a>
<a name="line-51"></a> <span class='hs-comment'>-- * Dial & button box callback</span>
<a name="line-52"></a> <span class='hs-conid'>DialAndButtonBoxInput</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-conid'>DialIndex</span><span class='hs-layout'>,</span>
<a name="line-53"></a> <span class='hs-conid'>DialAndButtonBoxCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>dialAndButtonBoxCallback</span><span class='hs-layout'>,</span>
<a name="line-54"></a>
<a name="line-55"></a> <span class='hs-comment'>-- * Tablet callback</span>
<a name="line-56"></a> <span class='hs-conid'>TabletPosition</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-conid'>TabletInput</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-conid'>TabletCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>tabletCallback</span><span class='hs-layout'>,</span>
<a name="line-57"></a>
<a name="line-58"></a> <span class='hs-comment'>-- * Joystick callback</span>
<a name="line-59"></a> <span class='hs-conid'>JoystickButtons</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-conid'>JoystickPosition</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span>
<a name="line-60"></a> <span class='hs-conid'>JoystickCallback</span><span class='hs-layout'>,</span> <span class='hs-varid'>joystickCallback</span>
<a name="line-61"></a><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-62"></a>
<a name="line-63"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Bits</span> <span class='hs-varid'>hiding</span> <span class='hs-layout'>(</span> <span class='hs-varid'>shift</span> <span class='hs-layout'>)</span>
<a name="line-64"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Char</span>
<a name="line-65"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Maybe</span>
<a name="line-66"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>C</span><span class='hs-varop'>.</span><span class='hs-conid'>Types</span>
<a name="line-67"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Graphics</span><span class='hs-varop'>.</span><span class='hs-conid'>Rendering</span><span class='hs-varop'>.</span><span class='hs-conid'>OpenGL</span> <span class='hs-layout'>(</span> <span class='hs-conid'>Position</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-conid'>Size</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span>
<a name="line-68"></a> <span class='hs-layout'>,</span> <span class='hs-conid'>SettableStateVar</span><span class='hs-layout'>,</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-layout'>)</span>
<a name="line-69"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Graphics</span><span class='hs-varop'>.</span><span class='hs-conid'>UI</span><span class='hs-varop'>.</span><span class='hs-conid'>GLUT</span><span class='hs-varop'>.</span><span class='hs-conid'>Callbacks</span><span class='hs-varop'>.</span><span class='hs-conid'>Registration</span>
<a name="line-70"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Graphics</span><span class='hs-varop'>.</span><span class='hs-conid'>UI</span><span class='hs-varop'>.</span><span class='hs-conid'>GLUT</span><span class='hs-varop'>.</span><span class='hs-conid'>Raw</span>
<a name="line-71"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Graphics</span><span class='hs-varop'>.</span><span class='hs-conid'>UI</span><span class='hs-varop'>.</span><span class='hs-conid'>GLUT</span><span class='hs-varop'>.</span><span class='hs-conid'>State</span>
<a name="line-72"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Graphics</span><span class='hs-varop'>.</span><span class='hs-conid'>UI</span><span class='hs-varop'>.</span><span class='hs-conid'>GLUT</span><span class='hs-varop'>.</span><span class='hs-conid'>Types</span>
<a name="line-73"></a>
<a name="line-74"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-75"></a>
<a name="line-76"></a><span class='hs-comment'>-- | A display callback</span>
<a name="line-77"></a>
<a name="line-78"></a><a name="DisplayCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>DisplayCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-79"></a>
<a name="line-80"></a><span class='hs-comment'>-- | Controls the display callback for the /current window./ When GLUT determines</span>
<a name="line-81"></a><span class='hs-comment'>-- that the normal plane for the window needs to be redisplayed, the display</span>
<a name="line-82"></a><span class='hs-comment'>-- callback for the window is called. Before the callback, the /current window/</span>
<a name="line-83"></a><span class='hs-comment'>-- is set to the window needing to be redisplayed and (if no overlay display</span>
<a name="line-84"></a><span class='hs-comment'>-- callback is registered) the /layer in use/ is set to the normal plane. The</span>
<a name="line-85"></a><span class='hs-comment'>-- entire normal plane region should be redisplayed in response to the callback</span>
<a name="line-86"></a><span class='hs-comment'>-- (this includes ancillary buffers if your program depends on their state).</span>
<a name="line-87"></a><span class='hs-comment'>--</span>
<a name="line-88"></a><span class='hs-comment'>-- GLUT determines when the display callback should be triggered based on the</span>
<a name="line-89"></a><span class='hs-comment'>-- window\'s redisplay state. The redisplay state for a window can be either set</span>
<a name="line-90"></a><span class='hs-comment'>-- explicitly by calling 'Graphics.UI.GLUT.Window.postRedisplay' or implicitly</span>
<a name="line-91"></a><span class='hs-comment'>-- as the result of window damage reported by the window system. Multiple posted</span>
<a name="line-92"></a><span class='hs-comment'>-- redisplays for a window are coalesced by GLUT to minimize the number of</span>
<a name="line-93"></a><span class='hs-comment'>-- display callbacks called.</span>
<a name="line-94"></a><span class='hs-comment'>--</span>
<a name="line-95"></a><span class='hs-comment'>-- When an overlay is established for a window, but there is no overlay display</span>
<a name="line-96"></a><span class='hs-comment'>-- callback registered, the display callback is used for redisplaying both the</span>
<a name="line-97"></a><span class='hs-comment'>-- overlay and normal plane (that is, it will be called if either the redisplay</span>
<a name="line-98"></a><span class='hs-comment'>-- state or overlay redisplay state is set). In this case, the /layer in use/ is</span>
<a name="line-99"></a><span class='hs-comment'>-- not implicitly changed on entry to the display callback.</span>
<a name="line-100"></a><span class='hs-comment'>--</span>
<a name="line-101"></a><span class='hs-comment'>-- See 'overlayDisplayCallback' to understand how distinct callbacks for the</span>
<a name="line-102"></a><span class='hs-comment'>-- overlay and normal plane of a window may be established.</span>
<a name="line-103"></a><span class='hs-comment'>--</span>
<a name="line-104"></a><span class='hs-comment'>-- When a window is created, no display callback exists for the window. It is</span>
<a name="line-105"></a><span class='hs-comment'>-- the responsibility of the programmer to install a display callback for the</span>
<a name="line-106"></a><span class='hs-comment'>-- window before the window is shown. A display callback must be registered for</span>
<a name="line-107"></a><span class='hs-comment'>-- any window that is shown. If a window becomes displayed without a display</span>
<a name="line-108"></a><span class='hs-comment'>-- callback being registered, a fatal error occurs. There is no way to</span>
<a name="line-109"></a><span class='hs-comment'>-- \"deregister\" a display callback (though another callback routine can always</span>
<a name="line-110"></a><span class='hs-comment'>-- be registered).</span>
<a name="line-111"></a><span class='hs-comment'>--</span>
<a name="line-112"></a><span class='hs-comment'>-- Upon return from the display callback, the normal damaged state of the window</span>
<a name="line-113"></a><span class='hs-comment'>-- (see 'Graphics.UI.GLUT.State.damaged') is cleared. If there is no overlay</span>
<a name="line-114"></a><span class='hs-comment'>-- display callback registered the overlay damaged state of the window (see</span>
<a name="line-115"></a><span class='hs-comment'>-- 'Graphics.UI.GLUT.State.damaged') is also cleared.</span>
<a name="line-116"></a>
<a name="line-117"></a><a name="displayCallback"></a><span class='hs-definition'>displayCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-conid'>DisplayCallback</span>
<a name="line-118"></a><span class='hs-definition'>displayCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varop'>$</span>
<a name="line-119"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>DisplayCB</span> <span class='hs-varid'>glutDisplayFunc</span> <span class='hs-varid'>makeDisplayFunc</span> <span class='hs-varop'>.</span> <span class='hs-conid'>Just</span>
<a name="line-120"></a>
<a name="line-121"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-122"></a>
<a name="line-123"></a><span class='hs-comment'>-- | Controls the overlay display callback for the /current window./ The overlay</span>
<a name="line-124"></a><span class='hs-comment'>-- display callback is functionally the same as the window\'s display callback</span>
<a name="line-125"></a><span class='hs-comment'>-- except that the overlay display callback is used to redisplay the window\'s</span>
<a name="line-126"></a><span class='hs-comment'>-- overlay.</span>
<a name="line-127"></a><span class='hs-comment'>--</span>
<a name="line-128"></a><span class='hs-comment'>-- When GLUT determines that the overlay plane for the window needs to be</span>
<a name="line-129"></a><span class='hs-comment'>-- redisplayed, the overlay display callback for the window is called. Before</span>
<a name="line-130"></a><span class='hs-comment'>-- the callback, the /current window/ is set to the window needing to be</span>
<a name="line-131"></a><span class='hs-comment'>-- redisplayed and the /layer in use/ is set to the overlay. The entire overlay</span>
<a name="line-132"></a><span class='hs-comment'>-- region should be redisplayed in response to the callback (this includes</span>
<a name="line-133"></a><span class='hs-comment'>-- ancillary buffers if your program depends on their state).</span>
<a name="line-134"></a><span class='hs-comment'>--</span>
<a name="line-135"></a><span class='hs-comment'>-- GLUT determines when the overlay display callback should be triggered based</span>
<a name="line-136"></a><span class='hs-comment'>-- on the window\'s overlay redisplay state. The overlay redisplay state for a</span>
<a name="line-137"></a><span class='hs-comment'>-- window can be either set explicitly by calling</span>
<a name="line-138"></a><span class='hs-comment'>-- 'Graphics.UI.GLUT.Overlay.postOverlayRedisplay' or implicitly as the result</span>
<a name="line-139"></a><span class='hs-comment'>-- of window damage reported by the window system. Multiple posted overlay</span>
<a name="line-140"></a><span class='hs-comment'>-- redisplays for a window are coalesced by GLUT to minimize the number of</span>
<a name="line-141"></a><span class='hs-comment'>-- overlay display callbacks called.</span>
<a name="line-142"></a><span class='hs-comment'>--</span>
<a name="line-143"></a><span class='hs-comment'>-- Upon return from the overlay display callback, the overlay damaged state of</span>
<a name="line-144"></a><span class='hs-comment'>-- the window (see 'Graphics.UI.GLUT.State.damaged') is cleared.</span>
<a name="line-145"></a><span class='hs-comment'>--</span>
<a name="line-146"></a><span class='hs-comment'>-- Initially there is no overlay display callback registered when an overlay is</span>
<a name="line-147"></a><span class='hs-comment'>-- established. See 'displayCallback' to understand how the display callback</span>
<a name="line-148"></a><span class='hs-comment'>-- alone is used if an overlay display callback is not registered.</span>
<a name="line-149"></a>
<a name="line-150"></a><a name="overlayDisplayCallback"></a><span class='hs-definition'>overlayDisplayCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>DisplayCallback</span><span class='hs-layout'>)</span>
<a name="line-151"></a><span class='hs-definition'>overlayDisplayCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varop'>$</span>
<a name="line-152"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>OverlayDisplayCB</span> <span class='hs-varid'>glutOverlayDisplayFunc</span> <span class='hs-varid'>makeOverlayDisplayFunc</span>
<a name="line-153"></a>
<a name="line-154"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-155"></a>
<a name="line-156"></a><span class='hs-comment'>-- | A reshape callback</span>
<a name="line-157"></a>
<a name="line-158"></a><a name="ReshapeCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>ReshapeCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Size</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-159"></a>
<a name="line-160"></a><span class='hs-comment'>-- | Controls the reshape callback for the /current window./ The reshape callback</span>
<a name="line-161"></a><span class='hs-comment'>-- is triggered when a window is reshaped. A reshape callback is also triggered</span>
<a name="line-162"></a><span class='hs-comment'>-- immediately before a window\'s first display callback after a window is</span>
<a name="line-163"></a><span class='hs-comment'>-- created or whenever an overlay for the window is established. The parameter</span>
<a name="line-164"></a><span class='hs-comment'>-- of the callback specifies the new window size in pixels. Before the callback,</span>
<a name="line-165"></a><span class='hs-comment'>-- the /current window/ is set to the window that has been reshaped.</span>
<a name="line-166"></a><span class='hs-comment'>--</span>
<a name="line-167"></a><span class='hs-comment'>-- If a reshape callback is not registered for a window or 'reshapeCallback' is</span>
<a name="line-168"></a><span class='hs-comment'>-- set to 'Nothing' (to deregister a previously registered callback), the</span>
<a name="line-169"></a><span class='hs-comment'>-- default reshape callback is used. This default callback will simply call</span>
<a name="line-170"></a><span class='hs-comment'>--</span>
<a name="line-171"></a><span class='hs-comment'>-- @</span>
<a name="line-172"></a><span class='hs-comment'>-- 'Graphics.Rendering.OpenGL.GL.CoordTrans.viewport' ('Graphics.Rendering.OpenGL.GL.CoordTrans.Position' 0 0) ('Graphics.Rendering.OpenGL.GL.CoordTrans.Size' /width/ /height/)</span>
<a name="line-173"></a><span class='hs-comment'>-- @</span>
<a name="line-174"></a><span class='hs-comment'>--</span>
<a name="line-175"></a><span class='hs-comment'>-- on the normal plane (and on the overlay if one exists).</span>
<a name="line-176"></a><span class='hs-comment'>--</span>
<a name="line-177"></a><span class='hs-comment'>-- If an overlay is established for the window, a single reshape callback is</span>
<a name="line-178"></a><span class='hs-comment'>-- generated. It is the callback\'s responsibility to update both the normal</span>
<a name="line-179"></a><span class='hs-comment'>-- plane and overlay for the window (changing the layer in use as necessary).</span>
<a name="line-180"></a><span class='hs-comment'>--</span>
<a name="line-181"></a><span class='hs-comment'>-- When a top-level window is reshaped, subwindows are not reshaped. It is up to</span>
<a name="line-182"></a><span class='hs-comment'>-- the GLUT program to manage the size and positions of subwindows within a</span>
<a name="line-183"></a><span class='hs-comment'>-- top-level window. Still, reshape callbacks will be triggered for subwindows</span>
<a name="line-184"></a><span class='hs-comment'>-- when their size is changed using 'Graphics.UI.GLUT.Window.windowSize'.</span>
<a name="line-185"></a>
<a name="line-186"></a><a name="reshapeCallback"></a><span class='hs-definition'>reshapeCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>ReshapeCallback</span><span class='hs-layout'>)</span>
<a name="line-187"></a><span class='hs-definition'>reshapeCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varop'>$</span>
<a name="line-188"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>ReshapeCB</span> <span class='hs-varid'>glutReshapeFunc</span> <span class='hs-layout'>(</span><span class='hs-varid'>makeReshapeFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-189"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-varid'>w</span> <span class='hs-varid'>h</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-conid'>Size</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>w</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>h</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-190"></a>
<a name="line-191"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-192"></a>
<a name="line-193"></a><span class='hs-comment'>-- | The visibility state of the /current window/</span>
<a name="line-194"></a>
<a name="line-195"></a><a name="Visibility"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>Visibility</span>
<a name="line-196"></a> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>NotVisible</span> <span class='hs-comment'>-- ^ No part of the /current window/ is visible, i.e., until the</span>
<a name="line-197"></a> <span class='hs-comment'>-- window\'s visibility changes, all further rendering to the</span>
<a name="line-198"></a> <span class='hs-comment'>-- window is discarded.</span>
<a name="line-199"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>Visible</span> <span class='hs-comment'>-- ^ The /current window/ is totally or partially visible. GLUT</span>
<a name="line-200"></a> <span class='hs-comment'>-- considers a window visible if any pixel of the window is</span>
<a name="line-201"></a> <span class='hs-comment'>-- visible or any pixel of any descendant window is visible on</span>
<a name="line-202"></a> <span class='hs-comment'>-- the screen.</span>
<a name="line-203"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span> <span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Ord</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span> <span class='hs-layout'>)</span>
<a name="line-204"></a>
<a name="line-205"></a><a name="unmarshalVisibility"></a><span class='hs-definition'>unmarshalVisibility</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>CInt</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Visibility</span>
<a name="line-206"></a><span class='hs-definition'>unmarshalVisibility</span> <span class='hs-varid'>x</span>
<a name="line-207"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_NOT_VISIBLE</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>NotVisible</span>
<a name="line-208"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_VISIBLE</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Visible</span>
<a name="line-209"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>error</span> <span class='hs-layout'>(</span><span class='hs-str'>"unmarshalVisibility: illegal value "</span> <span class='hs-varop'>++</span> <span class='hs-varid'>show</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span>
<a name="line-210"></a>
<a name="line-211"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-212"></a>
<a name="line-213"></a><span class='hs-comment'>-- | A visibility callback</span>
<a name="line-214"></a>
<a name="line-215"></a><a name="VisibilityCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>VisibilityCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Visibility</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-216"></a>
<a name="line-217"></a><span class='hs-comment'>-- | Controls the visibility callback for the /current window./ The visibility</span>
<a name="line-218"></a><span class='hs-comment'>-- callback for a window is called when the visibility of a window changes.</span>
<a name="line-219"></a><span class='hs-comment'>--</span>
<a name="line-220"></a><span class='hs-comment'>-- If the visibility callback for a window is disabled and later re-enabled, the</span>
<a name="line-221"></a><span class='hs-comment'>-- visibility status of the window is undefined; any change in window visibility</span>
<a name="line-222"></a><span class='hs-comment'>-- will be reported, that is if you disable a visibility callback and re-enable</span>
<a name="line-223"></a><span class='hs-comment'>-- the callback, you are guaranteed the next visibility change will be reported.</span>
<a name="line-224"></a><span class='hs-comment'>--</span>
<a name="line-225"></a><span class='hs-comment'>-- Note that you can either use 'visibilityCallback' or 'windowStateCallback',</span>
<a name="line-226"></a><span class='hs-comment'>-- but not both, because the former is implemented via the latter.</span>
<a name="line-227"></a>
<a name="line-228"></a><a name="visibilityCallback"></a><span class='hs-definition'>visibilityCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>VisibilityCallback</span><span class='hs-layout'>)</span>
<a name="line-229"></a><span class='hs-definition'>visibilityCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varop'>$</span>
<a name="line-230"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>VisibilityCB</span> <span class='hs-varid'>glutVisibilityFunc</span>
<a name="line-231"></a> <span class='hs-layout'>(</span><span class='hs-varid'>makeVisibilityFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-232"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cb</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshalVisibility</span>
<a name="line-233"></a>
<a name="line-234"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-235"></a>
<a name="line-236"></a><span class='hs-comment'>-- | The window state of the /current window/</span>
<a name="line-237"></a>
<a name="line-238"></a><a name="WindowState"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>WindowState</span>
<a name="line-239"></a> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Unmapped</span> <span class='hs-comment'>-- ^ The /current window/ is unmapped.</span>
<a name="line-240"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>FullyRetained</span> <span class='hs-comment'>-- ^ The /current window/ is unobscured.</span>
<a name="line-241"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>PartiallyRetained</span> <span class='hs-comment'>-- ^ The /current window/ is partially obscured.</span>
<a name="line-242"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>FullyCovered</span> <span class='hs-comment'>-- ^ The /current window/ is fully obscured.</span>
<a name="line-243"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span> <span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Ord</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span> <span class='hs-layout'>)</span>
<a name="line-244"></a>
<a name="line-245"></a><a name="unmarshalWindowState"></a><span class='hs-definition'>unmarshalWindowState</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>CInt</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>WindowState</span>
<a name="line-246"></a><span class='hs-definition'>unmarshalWindowState</span> <span class='hs-varid'>x</span>
<a name="line-247"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_HIDDEN</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Unmapped</span>
<a name="line-248"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_FULLY_RETAINED</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>FullyRetained</span>
<a name="line-249"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_PARTIALLY_RETAINED</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>PartiallyRetained</span>
<a name="line-250"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_FULLY_COVERED</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>FullyCovered</span>
<a name="line-251"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>error</span> <span class='hs-layout'>(</span><span class='hs-str'>"unmarshalWindowState: illegal value "</span> <span class='hs-varop'>++</span> <span class='hs-varid'>show</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span>
<a name="line-252"></a>
<a name="line-253"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-254"></a>
<a name="line-255"></a><span class='hs-comment'>-- | A window state callback</span>
<a name="line-256"></a>
<a name="line-257"></a><a name="WindowStateCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>WindowStateCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>WindowState</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-258"></a>
<a name="line-259"></a><span class='hs-comment'>-- | Controls the window state callback for the</span>
<a name="line-260"></a><span class='hs-comment'>-- /current window./ The window state callback for a window is called when the</span>
<a name="line-261"></a><span class='hs-comment'>-- window state of a window changes.</span>
<a name="line-262"></a><span class='hs-comment'>--</span>
<a name="line-263"></a><span class='hs-comment'>-- If the window state callback for a window is disabled and later re-enabled,</span>
<a name="line-264"></a><span class='hs-comment'>-- the window state state of the window is undefined; any change in the window</span>
<a name="line-265"></a><span class='hs-comment'>-- state will be reported, that is if you disable a window state callback and</span>
<a name="line-266"></a><span class='hs-comment'>-- re-enable the callback, you are guaranteed the next window state change will</span>
<a name="line-267"></a><span class='hs-comment'>-- be reported.</span>
<a name="line-268"></a><span class='hs-comment'>--</span>
<a name="line-269"></a><span class='hs-comment'>-- Note that you can either use 'visibilityCallback' or 'windowStateCallback',</span>
<a name="line-270"></a><span class='hs-comment'>-- but not both, because the former is implemented via the latter.</span>
<a name="line-271"></a>
<a name="line-272"></a><a name="windowStateCallback"></a><span class='hs-definition'>windowStateCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>WindowStateCallback</span><span class='hs-layout'>)</span>
<a name="line-273"></a><span class='hs-definition'>windowStateCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varop'>$</span>
<a name="line-274"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>WindowStatusCB</span> <span class='hs-varid'>glutWindowStatusFunc</span>
<a name="line-275"></a> <span class='hs-layout'>(</span><span class='hs-varid'>makeWindowStatusFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-276"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cb</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshalWindowState</span>
<a name="line-277"></a>
<a name="line-278"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-279"></a>
<a name="line-280"></a><a name="CloseCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>CloseCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-281"></a>
<a name="line-282"></a><a name="closeCallback"></a><span class='hs-definition'>closeCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>CloseCallback</span><span class='hs-layout'>)</span>
<a name="line-283"></a><span class='hs-definition'>closeCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varop'>$</span>
<a name="line-284"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>CloseCB</span> <span class='hs-varid'>glutCloseFunc</span> <span class='hs-varid'>makeCloseFunc</span>
<a name="line-285"></a>
<a name="line-286"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-287"></a>
<a name="line-288"></a><a name="KeyboardCallback"></a><span class='hs-comment'>-- | A keyboard callback</span>
<a name="line-289"></a><a name="KeyboardCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>KeyboardCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Char</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Position</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-290"></a>
<a name="line-291"></a><a name="setKeyboardCallback"></a><span class='hs-definition'>setKeyboardCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>KeyboardCallback</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-292"></a><span class='hs-definition'>setKeyboardCallback</span> <span class='hs-keyglyph'>=</span>
<a name="line-293"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>KeyboardCB</span> <span class='hs-varid'>glutKeyboardFunc</span> <span class='hs-layout'>(</span><span class='hs-varid'>makeKeyboardFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-294"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-varid'>c</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-varid'>chr</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-295"></a> <span class='hs-layout'>(</span><span class='hs-conid'>Position</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-296"></a>
<a name="line-297"></a><a name="keyboardCallback"></a><span class='hs-comment'>-- | Controls the keyboard callback for the /current window/. This is</span>
<a name="line-298"></a><span class='hs-comment'>-- activated only when a key is pressed.</span>
<a name="line-299"></a><span class='hs-definition'>keyboardCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>KeyboardCallback</span><span class='hs-layout'>)</span>
<a name="line-300"></a><span class='hs-definition'>keyboardCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varid'>setKeyboardCallback</span>
<a name="line-301"></a>
<a name="line-302"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-303"></a>
<a name="line-304"></a><a name="setKeyboardUpCallback"></a><span class='hs-definition'>setKeyboardUpCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>KeyboardCallback</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-305"></a><span class='hs-definition'>setKeyboardUpCallback</span> <span class='hs-keyglyph'>=</span>
<a name="line-306"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>KeyboardUpCB</span> <span class='hs-varid'>glutKeyboardUpFunc</span>
<a name="line-307"></a> <span class='hs-layout'>(</span><span class='hs-varid'>makeKeyboardUpFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-308"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-varid'>c</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-varid'>chr</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-309"></a> <span class='hs-layout'>(</span><span class='hs-conid'>Position</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-310"></a>
<a name="line-311"></a><a name="keyboardUpCallback"></a><span class='hs-comment'>-- | Controls the keyboard callback for the /current window/. This is</span>
<a name="line-312"></a><span class='hs-comment'>-- activated only when a key is released.</span>
<a name="line-313"></a><span class='hs-definition'>keyboardUpCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>KeyboardCallback</span><span class='hs-layout'>)</span>
<a name="line-314"></a><span class='hs-definition'>keyboardUpCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varid'>setKeyboardUpCallback</span>
<a name="line-315"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-316"></a>
<a name="line-317"></a><span class='hs-comment'>-- | Special keys</span>
<a name="line-318"></a>
<a name="line-319"></a><a name="SpecialKey"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>SpecialKey</span>
<a name="line-320"></a> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyF1</span>
<a name="line-321"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyF2</span>
<a name="line-322"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyF3</span>
<a name="line-323"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyF4</span>
<a name="line-324"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyF5</span>
<a name="line-325"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyF6</span>
<a name="line-326"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyF7</span>
<a name="line-327"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyF8</span>
<a name="line-328"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyF9</span>
<a name="line-329"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyF10</span>
<a name="line-330"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyF11</span>
<a name="line-331"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyF12</span>
<a name="line-332"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyLeft</span>
<a name="line-333"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyUp</span>
<a name="line-334"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyRight</span>
<a name="line-335"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyDown</span>
<a name="line-336"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyPageUp</span>
<a name="line-337"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyPageDown</span>
<a name="line-338"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyHome</span>
<a name="line-339"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyEnd</span>
<a name="line-340"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyInsert</span>
<a name="line-341"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyNumLock</span>
<a name="line-342"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyBegin</span>
<a name="line-343"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyDelete</span>
<a name="line-344"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>KeyUnknown</span> <span class='hs-conid'>Int</span>
<a name="line-345"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span> <span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Ord</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span> <span class='hs-layout'>)</span>
<a name="line-346"></a>
<a name="line-347"></a><a name="unmarshalSpecialKey"></a><span class='hs-definition'>unmarshalSpecialKey</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>CInt</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>SpecialKey</span>
<a name="line-348"></a><span class='hs-definition'>unmarshalSpecialKey</span> <span class='hs-varid'>x</span>
<a name="line-349"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_F1</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyF1</span>
<a name="line-350"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_F2</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyF2</span>
<a name="line-351"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_F3</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyF3</span>
<a name="line-352"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_F4</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyF4</span>
<a name="line-353"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_F5</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyF5</span>
<a name="line-354"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_F6</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyF6</span>
<a name="line-355"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_F7</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyF7</span>
<a name="line-356"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_F8</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyF8</span>
<a name="line-357"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_F9</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyF9</span>
<a name="line-358"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_F10</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyF10</span>
<a name="line-359"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_F11</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyF11</span>
<a name="line-360"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_F12</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyF12</span>
<a name="line-361"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_LEFT</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyLeft</span>
<a name="line-362"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_UP</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyUp</span>
<a name="line-363"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_RIGHT</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyRight</span>
<a name="line-364"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_DOWN</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyDown</span>
<a name="line-365"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_PAGE_UP</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyPageUp</span>
<a name="line-366"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_PAGE_DOWN</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyPageDown</span>
<a name="line-367"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_HOME</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyHome</span>
<a name="line-368"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_END</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyEnd</span>
<a name="line-369"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_INSERT</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyInsert</span>
<a name="line-370"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_NUM_LOCK</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyNumLock</span>
<a name="line-371"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_BEGIN</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyBegin</span>
<a name="line-372"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_DELETE</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyDelete</span>
<a name="line-373"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>KeyUnknown</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span>
<a name="line-374"></a>
<a name="line-375"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-376"></a>
<a name="line-377"></a><a name="SpecialCallback"></a><span class='hs-comment'>-- | A special key callback</span>
<a name="line-378"></a><a name="SpecialCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>SpecialCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>SpecialKey</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Position</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-379"></a>
<a name="line-380"></a><a name="setSpecialCallback"></a><span class='hs-definition'>setSpecialCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>SpecialCallback</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-381"></a><span class='hs-definition'>setSpecialCallback</span> <span class='hs-keyglyph'>=</span>
<a name="line-382"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>SpecialCB</span> <span class='hs-varid'>glutSpecialFunc</span> <span class='hs-layout'>(</span><span class='hs-varid'>makeSpecialFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-383"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-varid'>k</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-varid'>unmarshalSpecialKey</span> <span class='hs-varid'>k</span><span class='hs-layout'>)</span>
<a name="line-384"></a> <span class='hs-layout'>(</span><span class='hs-conid'>Position</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-385"></a>
<a name="line-386"></a><a name="specialCallback"></a><span class='hs-comment'>-- | Controls the special key callback for the /current window/. This is</span>
<a name="line-387"></a><span class='hs-comment'>-- activated only when a special key is pressed.</span>
<a name="line-388"></a><span class='hs-definition'>specialCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>SpecialCallback</span><span class='hs-layout'>)</span>
<a name="line-389"></a><span class='hs-definition'>specialCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varid'>setSpecialCallback</span>
<a name="line-390"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-391"></a>
<a name="line-392"></a><a name="setSpecialUpCallback"></a><span class='hs-definition'>setSpecialUpCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>SpecialCallback</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-393"></a><span class='hs-definition'>setSpecialUpCallback</span> <span class='hs-keyglyph'>=</span>
<a name="line-394"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>SpecialUpCB</span> <span class='hs-varid'>glutSpecialUpFunc</span> <span class='hs-layout'>(</span><span class='hs-varid'>makeSpecialUpFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-395"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-varid'>k</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-varid'>unmarshalSpecialKey</span> <span class='hs-varid'>k</span><span class='hs-layout'>)</span>
<a name="line-396"></a> <span class='hs-layout'>(</span><span class='hs-conid'>Position</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-397"></a>
<a name="line-398"></a><a name="specialUpCallback"></a><span class='hs-comment'>-- | Controls the special key callback for the /current window/. This is</span>
<a name="line-399"></a><span class='hs-comment'>-- activated only when a special key is released.</span>
<a name="line-400"></a><span class='hs-definition'>specialUpCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>SpecialCallback</span><span class='hs-layout'>)</span>
<a name="line-401"></a><span class='hs-definition'>specialUpCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varid'>setSpecialUpCallback</span>
<a name="line-402"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-403"></a>
<a name="line-404"></a><span class='hs-comment'>-- | The current state of a key or button</span>
<a name="line-405"></a>
<a name="line-406"></a><a name="KeyState"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>KeyState</span>
<a name="line-407"></a> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Down</span>
<a name="line-408"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>Up</span>
<a name="line-409"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span> <span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Ord</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span> <span class='hs-layout'>)</span>
<a name="line-410"></a>
<a name="line-411"></a><a name="unmarshalKeyState"></a><span class='hs-definition'>unmarshalKeyState</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>CInt</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>KeyState</span>
<a name="line-412"></a><span class='hs-definition'>unmarshalKeyState</span> <span class='hs-varid'>x</span>
<a name="line-413"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_DOWN</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Down</span>
<a name="line-414"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_UP</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Up</span>
<a name="line-415"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>error</span> <span class='hs-layout'>(</span><span class='hs-str'>"unmarshalKeyState: illegal value "</span> <span class='hs-varop'>++</span> <span class='hs-varid'>show</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span>
<a name="line-416"></a>
<a name="line-417"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-418"></a>
<a name="line-419"></a><a name="MouseCallback"></a><span class='hs-comment'>-- | A mouse callback</span>
<a name="line-420"></a><a name="MouseCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>MouseCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>MouseButton</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>KeyState</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Position</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-421"></a>
<a name="line-422"></a><a name="setMouseCallback"></a><span class='hs-definition'>setMouseCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>MouseCallback</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-423"></a><span class='hs-definition'>setMouseCallback</span> <span class='hs-keyglyph'>=</span>
<a name="line-424"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>MouseCB</span> <span class='hs-varid'>glutMouseFunc</span> <span class='hs-layout'>(</span><span class='hs-varid'>makeMouseFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-425"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-varid'>b</span> <span class='hs-varid'>s</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-varid'>unmarshalMouseButton</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span>
<a name="line-426"></a> <span class='hs-layout'>(</span><span class='hs-varid'>unmarshalKeyState</span> <span class='hs-varid'>s</span><span class='hs-layout'>)</span>
<a name="line-427"></a> <span class='hs-layout'>(</span><span class='hs-conid'>Position</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-428"></a>
<a name="line-429"></a><a name="mouseCallback"></a><span class='hs-comment'>-- | Controls the mouse callback for the /current window/.</span>
<a name="line-430"></a><span class='hs-definition'>mouseCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>MouseCallback</span><span class='hs-layout'>)</span>
<a name="line-431"></a><span class='hs-definition'>mouseCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varid'>setMouseCallback</span>
<a name="line-432"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-433"></a>
<a name="line-434"></a><span class='hs-comment'>-- | The state of the keyboard modifiers</span>
<a name="line-435"></a>
<a name="line-436"></a><a name="Modifiers"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>Modifiers</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Modifiers</span> <span class='hs-layout'>{</span> <span class='hs-varid'>shift</span><span class='hs-layout'>,</span> <span class='hs-varid'>ctrl</span><span class='hs-layout'>,</span> <span class='hs-varid'>alt</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>KeyState</span> <span class='hs-layout'>}</span>
<a name="line-437"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span> <span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Ord</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span> <span class='hs-layout'>)</span>
<a name="line-438"></a>
<a name="line-439"></a><a name="unmarshalModifiers"></a><span class='hs-comment'>-- Could use fromBitfield + Enum/Bounded instances + marshalModifier instead...</span>
<a name="line-440"></a><span class='hs-definition'>unmarshalModifiers</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>CInt</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Modifiers</span>
<a name="line-441"></a><span class='hs-definition'>unmarshalModifiers</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Modifiers</span> <span class='hs-layout'>{</span>
<a name="line-442"></a> <span class='hs-varid'>shift</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>if</span> <span class='hs-layout'>(</span><span class='hs-varid'>m</span> <span class='hs-varop'>.&.</span> <span class='hs-varid'>glut_ACTIVE_SHIFT</span><span class='hs-layout'>)</span> <span class='hs-varop'>/=</span> <span class='hs-num'>0</span> <span class='hs-keyword'>then</span> <span class='hs-conid'>Down</span> <span class='hs-keyword'>else</span> <span class='hs-conid'>Up</span><span class='hs-layout'>,</span>
<a name="line-443"></a> <span class='hs-varid'>ctrl</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>if</span> <span class='hs-layout'>(</span><span class='hs-varid'>m</span> <span class='hs-varop'>.&.</span> <span class='hs-varid'>glut_ACTIVE_CTRL</span> <span class='hs-layout'>)</span> <span class='hs-varop'>/=</span> <span class='hs-num'>0</span> <span class='hs-keyword'>then</span> <span class='hs-conid'>Down</span> <span class='hs-keyword'>else</span> <span class='hs-conid'>Up</span><span class='hs-layout'>,</span>
<a name="line-444"></a> <span class='hs-varid'>alt</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>if</span> <span class='hs-layout'>(</span><span class='hs-varid'>m</span> <span class='hs-varop'>.&.</span> <span class='hs-varid'>glut_ACTIVE_ALT</span> <span class='hs-layout'>)</span> <span class='hs-varop'>/=</span> <span class='hs-num'>0</span> <span class='hs-keyword'>then</span> <span class='hs-conid'>Down</span> <span class='hs-keyword'>else</span> <span class='hs-conid'>Up</span> <span class='hs-layout'>}</span>
<a name="line-445"></a>
<a name="line-446"></a><a name="getModifiers"></a><span class='hs-definition'>getModifiers</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Modifiers</span>
<a name="line-447"></a><span class='hs-definition'>getModifiers</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fmap</span> <span class='hs-varid'>unmarshalModifiers</span> <span class='hs-varid'>glutGetModifiers</span>
<a name="line-448"></a>
<a name="line-449"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-450"></a>
<a name="line-451"></a><span class='hs-comment'>-- | A generalized view of keys</span>
<a name="line-452"></a>
<a name="line-453"></a><a name="Key"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>Key</span>
<a name="line-454"></a> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Char</span> <span class='hs-conid'>Char</span>
<a name="line-455"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>SpecialKey</span> <span class='hs-conid'>SpecialKey</span>
<a name="line-456"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>MouseButton</span> <span class='hs-conid'>MouseButton</span>
<a name="line-457"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span> <span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Ord</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span> <span class='hs-layout'>)</span>
<a name="line-458"></a>
<a name="line-459"></a><span class='hs-comment'>-- | A keyboard\/mouse callback</span>
<a name="line-460"></a>
<a name="line-461"></a><a name="KeyboardMouseCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>KeyboardMouseCallback</span> <span class='hs-keyglyph'>=</span>
<a name="line-462"></a> <span class='hs-conid'>Key</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>KeyState</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Modifiers</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Position</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-463"></a>
<a name="line-464"></a><span class='hs-comment'>-- | Controls the keyboard\/mouse callback for the /current window./ The</span>
<a name="line-465"></a><span class='hs-comment'>-- keyboard\/mouse callback for a window is called when the state of a key or</span>
<a name="line-466"></a><span class='hs-comment'>-- mouse button changes. The callback parameters indicate the new state of the</span>
<a name="line-467"></a><span class='hs-comment'>-- key\/button, the state of the keyboard modifiers, and the mouse location in</span>
<a name="line-468"></a><span class='hs-comment'>-- window relative coordinates.</span>
<a name="line-469"></a><span class='hs-comment'>--</span>
<a name="line-470"></a><span class='hs-comment'>-- Note that this is a convenience function that should not ordinarily be used</span>
<a name="line-471"></a><span class='hs-comment'>-- in conjunction with `keyboardCallback`, `keyboardUpCallback`,</span>
<a name="line-472"></a><span class='hs-comment'>-- `specialCallback`, `specialUpCallback`, or `mouseCallback`.</span>
<a name="line-473"></a>
<a name="line-474"></a><a name="keyboardMouseCallback"></a><span class='hs-definition'>keyboardMouseCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>KeyboardMouseCallback</span><span class='hs-layout'>)</span>
<a name="line-475"></a><span class='hs-definition'>keyboardMouseCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varid'>setKeyboardMouseCallback</span>
<a name="line-476"></a>
<a name="line-477"></a><a name="setKeyboardMouseCallback"></a><span class='hs-definition'>setKeyboardMouseCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>KeyboardMouseCallback</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-478"></a><span class='hs-definition'>setKeyboardMouseCallback</span> <span class='hs-conid'>Nothing</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
<a name="line-479"></a> <span class='hs-varid'>setKeyboardCallback</span> <span class='hs-conid'>Nothing</span>
<a name="line-480"></a> <span class='hs-varid'>setKeyboardUpCallback</span> <span class='hs-conid'>Nothing</span>
<a name="line-481"></a> <span class='hs-varid'>setSpecialCallback</span> <span class='hs-conid'>Nothing</span>
<a name="line-482"></a> <span class='hs-varid'>setSpecialUpCallback</span> <span class='hs-conid'>Nothing</span>
<a name="line-483"></a> <span class='hs-varid'>setMouseCallback</span> <span class='hs-conid'>Nothing</span>
<a name="line-484"></a><span class='hs-definition'>setKeyboardMouseCallback</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-varid'>cb</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
<a name="line-485"></a> <span class='hs-varid'>setKeyboardCallback</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>c</span> <span class='hs-varid'>p</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getModifiers</span>
<a name="line-486"></a> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-conid'>Char</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span> <span class='hs-conid'>Down</span> <span class='hs-varid'>m</span> <span class='hs-varid'>p</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-487"></a> <span class='hs-varid'>setKeyboardUpCallback</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>c</span> <span class='hs-varid'>p</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getModifiers</span>
<a name="line-488"></a> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-conid'>Char</span> <span class='hs-varid'>c</span><span class='hs-layout'>)</span> <span class='hs-conid'>Up</span> <span class='hs-varid'>m</span> <span class='hs-varid'>p</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-489"></a> <span class='hs-varid'>setSpecialCallback</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>s</span> <span class='hs-varid'>p</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getModifiers</span>
<a name="line-490"></a> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-conid'>SpecialKey</span> <span class='hs-varid'>s</span><span class='hs-layout'>)</span> <span class='hs-conid'>Down</span> <span class='hs-varid'>m</span> <span class='hs-varid'>p</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-491"></a> <span class='hs-varid'>setSpecialUpCallback</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>s</span> <span class='hs-varid'>p</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getModifiers</span>
<a name="line-492"></a> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-conid'>SpecialKey</span> <span class='hs-varid'>s</span><span class='hs-layout'>)</span> <span class='hs-conid'>Up</span> <span class='hs-varid'>m</span> <span class='hs-varid'>p</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-493"></a> <span class='hs-varid'>setMouseCallback</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>b</span> <span class='hs-varid'>s</span> <span class='hs-varid'>p</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>getModifiers</span>
<a name="line-494"></a> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-conid'>MouseButton</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-varid'>s</span> <span class='hs-varid'>m</span> <span class='hs-varid'>p</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-495"></a>
<a name="line-496"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-497"></a>
<a name="line-498"></a><a name="WheelNumber"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>WheelNumber</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Int</span>
<a name="line-499"></a>
<a name="line-500"></a><a name="WheelDirection"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>WheelDirection</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Int</span>
<a name="line-501"></a>
<a name="line-502"></a><a name="MouseWheelCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>MouseWheelCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>WheelNumber</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>WheelDirection</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Position</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-503"></a>
<a name="line-504"></a><span class='hs-comment'>-- | (/freeglut only/) Controls the mouse wheel callback for the</span>
<a name="line-505"></a><span class='hs-comment'>-- /current window./ The mouse wheel callback for a window is called when a</span>
<a name="line-506"></a><span class='hs-comment'>-- mouse wheel is used and the wheel number is greater than or equal to</span>
<a name="line-507"></a><span class='hs-comment'>-- 'Graphics.UI.GLUT.State.numMouseButtons'.</span>
<a name="line-508"></a>
<a name="line-509"></a><a name="mouseWheelCallback"></a><span class='hs-definition'>mouseWheelCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>MouseWheelCallback</span><span class='hs-layout'>)</span>
<a name="line-510"></a><span class='hs-definition'>mouseWheelCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varop'>$</span>
<a name="line-511"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>MouseWheelCB</span> <span class='hs-varid'>glutMouseWheelFunc</span> <span class='hs-layout'>(</span><span class='hs-varid'>makeMouseWheelFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-512"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-varid'>n</span> <span class='hs-varid'>d</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>n</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>d</span><span class='hs-layout'>)</span>
<a name="line-513"></a> <span class='hs-layout'>(</span><span class='hs-conid'>Position</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-514"></a>
<a name="line-515"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-516"></a>
<a name="line-517"></a><span class='hs-comment'>-- | A motion callback</span>
<a name="line-518"></a>
<a name="line-519"></a><a name="MotionCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>MotionCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Position</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-520"></a>
<a name="line-521"></a><span class='hs-comment'>-- | Controls the motion callback for the /current window./ The motion callback</span>
<a name="line-522"></a><span class='hs-comment'>-- for a window is called when the mouse moves within the window while one or</span>
<a name="line-523"></a><span class='hs-comment'>-- more mouse buttons are pressed. The callback parameter indicates the mouse</span>
<a name="line-524"></a><span class='hs-comment'>-- location in window relative coordinates.</span>
<a name="line-525"></a>
<a name="line-526"></a><a name="motionCallback"></a><span class='hs-definition'>motionCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>MotionCallback</span><span class='hs-layout'>)</span>
<a name="line-527"></a><span class='hs-definition'>motionCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varop'>$</span>
<a name="line-528"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>MotionCB</span> <span class='hs-varid'>glutMotionFunc</span> <span class='hs-layout'>(</span><span class='hs-varid'>makeMotionFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-529"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-conid'>Position</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-530"></a>
<a name="line-531"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-532"></a>
<a name="line-533"></a><span class='hs-comment'>-- | Controls the passive motion callback for the /current window./ The passive</span>
<a name="line-534"></a><span class='hs-comment'>-- motion callback for a window is called when the mouse moves within the window</span>
<a name="line-535"></a><span class='hs-comment'>-- while /no/ mouse buttons are pressed. The callback parameter indicates the</span>
<a name="line-536"></a><span class='hs-comment'>-- mouse location in window relative coordinates.</span>
<a name="line-537"></a>
<a name="line-538"></a><a name="passiveMotionCallback"></a><span class='hs-definition'>passiveMotionCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>MotionCallback</span><span class='hs-layout'>)</span>
<a name="line-539"></a><span class='hs-definition'>passiveMotionCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varop'>$</span>
<a name="line-540"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>PassiveMotionCB</span> <span class='hs-varid'>glutPassiveMotionFunc</span>
<a name="line-541"></a> <span class='hs-layout'>(</span><span class='hs-varid'>makePassiveMotionFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-542"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-conid'>Position</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-543"></a>
<a name="line-544"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-545"></a>
<a name="line-546"></a><span class='hs-comment'>-- | The relation between the mouse pointer and the /current window/ has</span>
<a name="line-547"></a><span class='hs-comment'>-- changed.</span>
<a name="line-548"></a>
<a name="line-549"></a><a name="Crossing"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>Crossing</span>
<a name="line-550"></a> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>WindowLeft</span> <span class='hs-comment'>-- ^ The mouse pointer has left the /current window./</span>
<a name="line-551"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>WindowEntered</span> <span class='hs-comment'>-- ^ The mouse pointer has entered the /current window./</span>
<a name="line-552"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span> <span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Ord</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span> <span class='hs-layout'>)</span>
<a name="line-553"></a>
<a name="line-554"></a><a name="unmarshalCrossing"></a><span class='hs-definition'>unmarshalCrossing</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>CInt</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Crossing</span>
<a name="line-555"></a><span class='hs-definition'>unmarshalCrossing</span> <span class='hs-varid'>x</span>
<a name="line-556"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_LEFT</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>WindowLeft</span>
<a name="line-557"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_ENTERED</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>WindowEntered</span>
<a name="line-558"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>error</span> <span class='hs-layout'>(</span><span class='hs-str'>"unmarshalCrossing: illegal value "</span> <span class='hs-varop'>++</span> <span class='hs-varid'>show</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span>
<a name="line-559"></a>
<a name="line-560"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-561"></a>
<a name="line-562"></a><span class='hs-comment'>-- | An enter\/leave callback</span>
<a name="line-563"></a>
<a name="line-564"></a><a name="CrossingCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>CrossingCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Crossing</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-565"></a>
<a name="line-566"></a><span class='hs-comment'>-- | Controls the mouse enter\/leave callback for the /current window./ Note</span>
<a name="line-567"></a><span class='hs-comment'>-- that some window systems may not generate accurate enter\/leave callbacks.</span>
<a name="line-568"></a><span class='hs-comment'>--</span>
<a name="line-569"></a><span class='hs-comment'>-- /X Implementation Notes:/ An X implementation of GLUT should generate</span>
<a name="line-570"></a><span class='hs-comment'>-- accurate enter\/leave callbacks.</span>
<a name="line-571"></a>
<a name="line-572"></a><a name="crossingCallback"></a><span class='hs-definition'>crossingCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>CrossingCallback</span><span class='hs-layout'>)</span>
<a name="line-573"></a><span class='hs-definition'>crossingCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varop'>$</span>
<a name="line-574"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>CrossingCB</span> <span class='hs-varid'>glutEntryFunc</span> <span class='hs-layout'>(</span><span class='hs-varid'>makeEntryFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-575"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cb</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshalCrossing</span>
<a name="line-576"></a>
<a name="line-577"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-578"></a>
<a name="line-579"></a><span class='hs-comment'>-- | Translation of the Spaceball along one axis, normalized to be in the range</span>
<a name="line-580"></a><span class='hs-comment'>-- of -1000 to +1000 inclusive</span>
<a name="line-581"></a>
<a name="line-582"></a><a name="SpaceballMotion"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>SpaceballMotion</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Int</span>
<a name="line-583"></a>
<a name="line-584"></a><span class='hs-comment'>-- | Rotation of the Spaceball along one axis, normalized to be in the range</span>
<a name="line-585"></a><span class='hs-comment'>-- of -1800 .. +1800 inclusive</span>
<a name="line-586"></a>
<a name="line-587"></a><a name="SpaceballRotation"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>SpaceballRotation</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Int</span>
<a name="line-588"></a>
<a name="line-589"></a><span class='hs-comment'>-- | The index of a specific buttons of an input device.</span>
<a name="line-590"></a>
<a name="line-591"></a><a name="ButtonIndex"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>ButtonIndex</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Int</span>
<a name="line-592"></a>
<a name="line-593"></a><span class='hs-comment'>-- | The state of the Spaceball has changed.</span>
<a name="line-594"></a>
<a name="line-595"></a><a name="SpaceballInput"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>SpaceballInput</span>
<a name="line-596"></a> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>SpaceballMotion</span> <span class='hs-conid'>SpaceballMotion</span> <span class='hs-conid'>SpaceballMotion</span> <span class='hs-conid'>SpaceballMotion</span>
<a name="line-597"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>SpaceballRotation</span> <span class='hs-conid'>SpaceballRotation</span> <span class='hs-conid'>SpaceballRotation</span> <span class='hs-conid'>SpaceballRotation</span>
<a name="line-598"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>SpaceballButton</span> <span class='hs-conid'>ButtonIndex</span> <span class='hs-conid'>KeyState</span>
<a name="line-599"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span> <span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Ord</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span> <span class='hs-layout'>)</span>
<a name="line-600"></a>
<a name="line-601"></a><span class='hs-comment'>-- | A SpaceballButton callback</span>
<a name="line-602"></a>
<a name="line-603"></a><a name="SpaceballCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>SpaceballCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>SpaceballInput</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-604"></a>
<a name="line-605"></a><span class='hs-comment'>-- | Controls the Spaceball callback for the /current window./ The Spaceball</span>
<a name="line-606"></a><span class='hs-comment'>-- callback for a window is called when the window has Spaceball input focus</span>
<a name="line-607"></a><span class='hs-comment'>-- (normally, when the mouse is in the window) and the user generates Spaceball</span>
<a name="line-608"></a><span class='hs-comment'>-- translations, rotations, or button presses. The number of available Spaceball</span>
<a name="line-609"></a><span class='hs-comment'>-- buttons can be determined with 'Graphics.UI.GLUT.State.numSpaceballButtons'.</span>
<a name="line-610"></a><span class='hs-comment'>--</span>
<a name="line-611"></a><span class='hs-comment'>-- Registering a Spaceball callback when a Spaceball device is not available has</span>
<a name="line-612"></a><span class='hs-comment'>-- no effect and is not an error. In this case, no Spaceball callbacks will be</span>
<a name="line-613"></a><span class='hs-comment'>-- generated.</span>
<a name="line-614"></a>
<a name="line-615"></a><a name="spaceballCallback"></a><span class='hs-definition'>spaceballCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>SpaceballCallback</span><span class='hs-layout'>)</span>
<a name="line-616"></a><span class='hs-definition'>spaceballCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varid'>setSpaceballCallback</span>
<a name="line-617"></a>
<a name="line-618"></a><a name="setSpaceballCallback"></a><span class='hs-definition'>setSpaceballCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>SpaceballCallback</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-619"></a><span class='hs-definition'>setSpaceballCallback</span> <span class='hs-conid'>Nothing</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
<a name="line-620"></a> <span class='hs-varid'>setSpaceballMotionCallback</span> <span class='hs-conid'>Nothing</span>
<a name="line-621"></a> <span class='hs-varid'>setSpaceballRotationCallback</span> <span class='hs-conid'>Nothing</span>
<a name="line-622"></a> <span class='hs-varid'>setSpaceballButtonCallback</span> <span class='hs-conid'>Nothing</span>
<a name="line-623"></a><span class='hs-definition'>setSpaceballCallback</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-varid'>cb</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
<a name="line-624"></a> <span class='hs-varid'>setSpaceballMotionCallback</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-varid'>z</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-conid'>SpaceballMotion</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-varid'>z</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-625"></a> <span class='hs-varid'>setSpaceballRotationCallback</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-varid'>z</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-conid'>SpaceballRotation</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-varid'>z</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-626"></a> <span class='hs-varid'>setSpaceballButtonCallback</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>b</span> <span class='hs-varid'>s</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-conid'>SpaceballButton</span> <span class='hs-varid'>b</span> <span class='hs-varid'>s</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-627"></a>
<a name="line-628"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-629"></a>
<a name="line-630"></a><a name="SpaceballMotionCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>SpaceballMotionCallback</span> <span class='hs-keyglyph'>=</span>
<a name="line-631"></a> <span class='hs-conid'>SpaceballMotion</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>SpaceballMotion</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>SpaceballMotion</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-632"></a>
<a name="line-633"></a><a name="setSpaceballMotionCallback"></a><span class='hs-definition'>setSpaceballMotionCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>SpaceballMotionCallback</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-634"></a><span class='hs-definition'>setSpaceballMotionCallback</span> <span class='hs-keyglyph'>=</span>
<a name="line-635"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>SpaceballMotionCB</span> <span class='hs-varid'>glutSpaceballMotionFunc</span>
<a name="line-636"></a> <span class='hs-layout'>(</span><span class='hs-varid'>makeSpaceballMotionFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-637"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-varid'>z</span> <span class='hs-keyglyph'>=</span>
<a name="line-638"></a> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>z</span><span class='hs-layout'>)</span>
<a name="line-639"></a>
<a name="line-640"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-641"></a>
<a name="line-642"></a><a name="SpaceballRotationCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>SpaceballRotationCallback</span> <span class='hs-keyglyph'>=</span>
<a name="line-643"></a> <span class='hs-conid'>SpaceballRotation</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>SpaceballRotation</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>SpaceballRotation</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-644"></a>
<a name="line-645"></a><a name="setSpaceballRotationCallback"></a><span class='hs-definition'>setSpaceballRotationCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>SpaceballRotationCallback</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-646"></a><span class='hs-definition'>setSpaceballRotationCallback</span> <span class='hs-keyglyph'>=</span>
<a name="line-647"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>SpaceballRotateCB</span> <span class='hs-varid'>glutSpaceballRotateFunc</span>
<a name="line-648"></a> <span class='hs-layout'>(</span><span class='hs-varid'>makeSpaceballRotateFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-649"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-varid'>z</span> <span class='hs-keyglyph'>=</span>
<a name="line-650"></a> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>z</span><span class='hs-layout'>)</span>
<a name="line-651"></a>
<a name="line-652"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-653"></a>
<a name="line-654"></a><a name="SpaceballButtonCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>SpaceballButtonCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>ButtonIndex</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>KeyState</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-655"></a>
<a name="line-656"></a><a name="setSpaceballButtonCallback"></a><span class='hs-definition'>setSpaceballButtonCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>SpaceballButtonCallback</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-657"></a><span class='hs-definition'>setSpaceballButtonCallback</span> <span class='hs-keyglyph'>=</span>
<a name="line-658"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>SpaceballButtonCB</span> <span class='hs-varid'>glutSpaceballButtonFunc</span>
<a name="line-659"></a> <span class='hs-layout'>(</span><span class='hs-varid'>makeSpaceballButtonFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-660"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-varid'>b</span> <span class='hs-varid'>s</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>unmarshalKeyState</span> <span class='hs-varid'>s</span><span class='hs-layout'>)</span>
<a name="line-661"></a>
<a name="line-662"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-663"></a>
<a name="line-664"></a><span class='hs-comment'>-- | The index of a specific dial of a dial and button box.</span>
<a name="line-665"></a>
<a name="line-666"></a><a name="DialIndex"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>DialIndex</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Int</span>
<a name="line-667"></a>
<a name="line-668"></a><span class='hs-comment'>-- | The dial & button box state has changed.</span>
<a name="line-669"></a>
<a name="line-670"></a><a name="DialAndButtonBoxInput"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>DialAndButtonBoxInput</span>
<a name="line-671"></a> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>DialAndButtonBoxButton</span> <span class='hs-conid'>ButtonIndex</span> <span class='hs-conid'>KeyState</span>
<a name="line-672"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>DialAndButtonBoxDial</span> <span class='hs-conid'>DialIndex</span> <span class='hs-conid'>Int</span>
<a name="line-673"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span> <span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Ord</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span> <span class='hs-layout'>)</span>
<a name="line-674"></a>
<a name="line-675"></a><span class='hs-comment'>-- | A dial & button box callback</span>
<a name="line-676"></a>
<a name="line-677"></a><a name="DialAndButtonBoxCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>DialAndButtonBoxCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>DialAndButtonBoxInput</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-678"></a>
<a name="line-679"></a><span class='hs-comment'>-- | Controls the dial & button box callback for the /current window./ The dial</span>
<a name="line-680"></a><span class='hs-comment'>-- & button box button callback for a window is called when the window has dial</span>
<a name="line-681"></a><span class='hs-comment'>-- & button box input focus (normally, when the mouse is in the window) and the</span>
<a name="line-682"></a><span class='hs-comment'>-- user generates dial & button box button presses or dial changes. The number</span>
<a name="line-683"></a><span class='hs-comment'>-- of available dial & button box buttons and dials can be determined with</span>
<a name="line-684"></a><span class='hs-comment'>-- 'Graphics.UI.GLUT.State.numDialsAndButtons'.</span>
<a name="line-685"></a><span class='hs-comment'>--</span>
<a name="line-686"></a><span class='hs-comment'>-- Registering a dial & button box callback when a dial & button box device is</span>
<a name="line-687"></a><span class='hs-comment'>-- not available is ineffectual and not an error. In this case, no dial & button</span>
<a name="line-688"></a><span class='hs-comment'>-- box button will be generated.</span>
<a name="line-689"></a>
<a name="line-690"></a><a name="dialAndButtonBoxCallback"></a><span class='hs-definition'>dialAndButtonBoxCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>DialAndButtonBoxCallback</span><span class='hs-layout'>)</span>
<a name="line-691"></a><span class='hs-definition'>dialAndButtonBoxCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varid'>setDialAndButtonBoxCallback</span>
<a name="line-692"></a>
<a name="line-693"></a><a name="setDialAndButtonBoxCallback"></a><span class='hs-definition'>setDialAndButtonBoxCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>DialAndButtonBoxCallback</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-694"></a><span class='hs-definition'>setDialAndButtonBoxCallback</span> <span class='hs-conid'>Nothing</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
<a name="line-695"></a> <span class='hs-varid'>setButtonBoxCallback</span> <span class='hs-conid'>Nothing</span>
<a name="line-696"></a> <span class='hs-varid'>setDialsCallback</span> <span class='hs-conid'>Nothing</span>
<a name="line-697"></a><span class='hs-definition'>setDialAndButtonBoxCallback</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-varid'>cb</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
<a name="line-698"></a> <span class='hs-varid'>setButtonBoxCallback</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>b</span> <span class='hs-varid'>s</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-conid'>DialAndButtonBoxButton</span> <span class='hs-varid'>b</span> <span class='hs-varid'>s</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-699"></a> <span class='hs-varid'>setDialsCallback</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>d</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-conid'>DialAndButtonBoxDial</span> <span class='hs-varid'>d</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-700"></a>
<a name="line-701"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-702"></a>
<a name="line-703"></a><a name="ButtonBoxCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>ButtonBoxCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>ButtonIndex</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>KeyState</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-704"></a>
<a name="line-705"></a><a name="setButtonBoxCallback"></a><span class='hs-definition'>setButtonBoxCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>ButtonBoxCallback</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-706"></a><span class='hs-definition'>setButtonBoxCallback</span> <span class='hs-keyglyph'>=</span>
<a name="line-707"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>ButtonBoxCB</span> <span class='hs-varid'>glutButtonBoxFunc</span> <span class='hs-layout'>(</span><span class='hs-varid'>makeButtonBoxFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-708"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-varid'>b</span> <span class='hs-varid'>s</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>unmarshalKeyState</span> <span class='hs-varid'>s</span><span class='hs-layout'>)</span>
<a name="line-709"></a>
<a name="line-710"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-711"></a>
<a name="line-712"></a><a name="DialsCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>DialsCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>DialIndex</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Int</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-713"></a>
<a name="line-714"></a><a name="setDialsCallback"></a><span class='hs-definition'>setDialsCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>DialsCallback</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-715"></a><span class='hs-definition'>setDialsCallback</span> <span class='hs-keyglyph'>=</span>
<a name="line-716"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>DialsCB</span> <span class='hs-varid'>glutDialsFunc</span> <span class='hs-layout'>(</span><span class='hs-varid'>makeDialsFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-717"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-varid'>d</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>d</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span>
<a name="line-718"></a>
<a name="line-719"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-720"></a>
<a name="line-721"></a><span class='hs-comment'>-- | Absolute tablet position, with coordinates normalized to be in the range of</span>
<a name="line-722"></a><span class='hs-comment'>-- 0 to 2000 inclusive</span>
<a name="line-723"></a>
<a name="line-724"></a><a name="TabletPosition"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>TabletPosition</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>TabletPosition</span> <span class='hs-conid'>Int</span> <span class='hs-conid'>Int</span>
<a name="line-725"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span> <span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Ord</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span> <span class='hs-layout'>)</span>
<a name="line-726"></a>
<a name="line-727"></a><span class='hs-comment'>-- | The table state has changed.</span>
<a name="line-728"></a>
<a name="line-729"></a><a name="TabletInput"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>TabletInput</span>
<a name="line-730"></a> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>TabletMotion</span>
<a name="line-731"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>TabletButton</span> <span class='hs-conid'>ButtonIndex</span> <span class='hs-conid'>KeyState</span>
<a name="line-732"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span> <span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Ord</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span> <span class='hs-layout'>)</span>
<a name="line-733"></a>
<a name="line-734"></a><span class='hs-comment'>-- | A tablet callback</span>
<a name="line-735"></a>
<a name="line-736"></a><a name="TabletCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>TabletCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>TabletInput</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>TabletPosition</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-737"></a>
<a name="line-738"></a><span class='hs-comment'>-- | Controls the tablet callback for the /current window./ The tablet callback</span>
<a name="line-739"></a><span class='hs-comment'>-- for a window is called when the window has tablet input focus (normally, when</span>
<a name="line-740"></a><span class='hs-comment'>-- the mouse is in the window) and the user generates tablet motion or button</span>
<a name="line-741"></a><span class='hs-comment'>-- presses. The number of available tablet buttons can be determined with</span>
<a name="line-742"></a><span class='hs-comment'>-- 'Graphics.UI.GLUT.State.numTabletButtons'.</span>
<a name="line-743"></a><span class='hs-comment'>--</span>
<a name="line-744"></a><span class='hs-comment'>-- Registering a tablet callback when a tablet device is not available is</span>
<a name="line-745"></a><span class='hs-comment'>-- ineffectual and not an error. In this case, no tablet callbacks will be</span>
<a name="line-746"></a><span class='hs-comment'>-- generated.</span>
<a name="line-747"></a>
<a name="line-748"></a><a name="tabletCallback"></a><span class='hs-definition'>tabletCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>TabletCallback</span><span class='hs-layout'>)</span>
<a name="line-749"></a><span class='hs-definition'>tabletCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varid'>setTabletCallback</span>
<a name="line-750"></a>
<a name="line-751"></a><a name="setTabletCallback"></a><span class='hs-definition'>setTabletCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>TabletCallback</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-752"></a><span class='hs-definition'>setTabletCallback</span> <span class='hs-conid'>Nothing</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
<a name="line-753"></a> <span class='hs-varid'>setTabletMotionCallback</span> <span class='hs-conid'>Nothing</span>
<a name="line-754"></a> <span class='hs-varid'>setTabletButtonCallback</span> <span class='hs-conid'>Nothing</span>
<a name="line-755"></a><span class='hs-definition'>setTabletCallback</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-varid'>cb</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
<a name="line-756"></a> <span class='hs-varid'>setTabletMotionCallback</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>p</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>cb</span> <span class='hs-conid'>TabletMotion</span> <span class='hs-varid'>p</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-757"></a> <span class='hs-varid'>setTabletButtonCallback</span> <span class='hs-layout'>(</span><span class='hs-conid'>Just</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>b</span> <span class='hs-varid'>s</span> <span class='hs-varid'>p</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-conid'>TabletButton</span> <span class='hs-varid'>b</span> <span class='hs-varid'>s</span><span class='hs-layout'>)</span> <span class='hs-varid'>p</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-758"></a>
<a name="line-759"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-760"></a>
<a name="line-761"></a><a name="TabletMotionCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>TabletMotionCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>TabletPosition</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-762"></a>
<a name="line-763"></a><a name="setTabletMotionCallback"></a><span class='hs-definition'>setTabletMotionCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>TabletMotionCallback</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-764"></a><span class='hs-definition'>setTabletMotionCallback</span> <span class='hs-keyglyph'>=</span>
<a name="line-765"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>TabletMotionCB</span> <span class='hs-varid'>glutTabletMotionFunc</span>
<a name="line-766"></a> <span class='hs-layout'>(</span><span class='hs-varid'>makeTabletMotionFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-767"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span>
<a name="line-768"></a> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-conid'>TabletPosition</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-769"></a>
<a name="line-770"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-771"></a>
<a name="line-772"></a><a name="TabletButtonCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>TabletButtonCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>ButtonIndex</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>KeyState</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>TabletPosition</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-773"></a>
<a name="line-774"></a><a name="setTabletButtonCallback"></a><span class='hs-definition'>setTabletButtonCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>Maybe</span> <span class='hs-conid'>TabletButtonCallback</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-775"></a><span class='hs-definition'>setTabletButtonCallback</span> <span class='hs-keyglyph'>=</span>
<a name="line-776"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>TabletButtonCB</span> <span class='hs-varid'>glutTabletButtonFunc</span>
<a name="line-777"></a> <span class='hs-layout'>(</span><span class='hs-varid'>makeTabletButtonFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-778"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-varid'>b</span> <span class='hs-varid'>s</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-keyglyph'>=</span>
<a name="line-779"></a> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>unmarshalKeyState</span> <span class='hs-varid'>s</span><span class='hs-layout'>)</span>
<a name="line-780"></a> <span class='hs-layout'>(</span><span class='hs-conid'>TabletPosition</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-781"></a>
<a name="line-782"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-783"></a>
<a name="line-784"></a><span class='hs-comment'>-- | The state of the joystick buttons</span>
<a name="line-785"></a>
<a name="line-786"></a><a name="JoystickButtons"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>JoystickButtons</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>JoystickButtons</span> <span class='hs-layout'>{</span>
<a name="line-787"></a> <span class='hs-varid'>joystickButtonA</span><span class='hs-layout'>,</span> <span class='hs-varid'>joystickButtonB</span><span class='hs-layout'>,</span>
<a name="line-788"></a> <span class='hs-varid'>joystickButtonC</span><span class='hs-layout'>,</span> <span class='hs-varid'>joystickButtonD</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>KeyState</span> <span class='hs-layout'>}</span>
<a name="line-789"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span> <span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Ord</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span> <span class='hs-layout'>)</span>
<a name="line-790"></a>
<a name="line-791"></a><a name="unmarshalJoystickButtons"></a><span class='hs-comment'>-- Could use fromBitfield + Enum/Bounded instances + unmarshalJoystickButton</span>
<a name="line-792"></a><span class='hs-comment'>-- instead...</span>
<a name="line-793"></a><span class='hs-definition'>unmarshalJoystickButtons</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>CUInt</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>JoystickButtons</span>
<a name="line-794"></a><span class='hs-definition'>unmarshalJoystickButtons</span> <span class='hs-varid'>m</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>JoystickButtons</span> <span class='hs-layout'>{</span>
<a name="line-795"></a> <span class='hs-varid'>joystickButtonA</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>if</span> <span class='hs-layout'>(</span><span class='hs-varid'>m</span> <span class='hs-varop'>.&.</span> <span class='hs-varid'>glut_JOYSTICK_BUTTON_A</span><span class='hs-layout'>)</span> <span class='hs-varop'>/=</span> <span class='hs-num'>0</span> <span class='hs-keyword'>then</span> <span class='hs-conid'>Down</span> <span class='hs-keyword'>else</span> <span class='hs-conid'>Up</span><span class='hs-layout'>,</span>
<a name="line-796"></a> <span class='hs-varid'>joystickButtonB</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>if</span> <span class='hs-layout'>(</span><span class='hs-varid'>m</span> <span class='hs-varop'>.&.</span> <span class='hs-varid'>glut_JOYSTICK_BUTTON_B</span><span class='hs-layout'>)</span> <span class='hs-varop'>/=</span> <span class='hs-num'>0</span> <span class='hs-keyword'>then</span> <span class='hs-conid'>Down</span> <span class='hs-keyword'>else</span> <span class='hs-conid'>Up</span><span class='hs-layout'>,</span>
<a name="line-797"></a> <span class='hs-varid'>joystickButtonC</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>if</span> <span class='hs-layout'>(</span><span class='hs-varid'>m</span> <span class='hs-varop'>.&.</span> <span class='hs-varid'>glut_JOYSTICK_BUTTON_C</span><span class='hs-layout'>)</span> <span class='hs-varop'>/=</span> <span class='hs-num'>0</span> <span class='hs-keyword'>then</span> <span class='hs-conid'>Down</span> <span class='hs-keyword'>else</span> <span class='hs-conid'>Up</span><span class='hs-layout'>,</span>
<a name="line-798"></a> <span class='hs-varid'>joystickButtonD</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>if</span> <span class='hs-layout'>(</span><span class='hs-varid'>m</span> <span class='hs-varop'>.&.</span> <span class='hs-varid'>glut_JOYSTICK_BUTTON_D</span><span class='hs-layout'>)</span> <span class='hs-varop'>/=</span> <span class='hs-num'>0</span> <span class='hs-keyword'>then</span> <span class='hs-conid'>Down</span> <span class='hs-keyword'>else</span> <span class='hs-conid'>Up</span> <span class='hs-layout'>}</span>
<a name="line-799"></a>
<a name="line-800"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-801"></a>
<a name="line-802"></a><span class='hs-comment'>-- | Absolute joystick position, with coordinates normalized to be in the range</span>
<a name="line-803"></a><span class='hs-comment'>-- of -1000 to 1000 inclusive. The signs of the three axes mean the following:</span>
<a name="line-804"></a><span class='hs-comment'>--</span>
<a name="line-805"></a><span class='hs-comment'>-- * negative = left, positive = right</span>
<a name="line-806"></a><span class='hs-comment'>--</span>
<a name="line-807"></a><span class='hs-comment'>-- * negative = towards player, positive = away</span>
<a name="line-808"></a><span class='hs-comment'>--</span>
<a name="line-809"></a><span class='hs-comment'>-- * if available (e.g. rudder): negative = down, positive = up</span>
<a name="line-810"></a>
<a name="line-811"></a><a name="JoystickPosition"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>JoystickPosition</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>JoystickPosition</span> <span class='hs-conid'>Int</span> <span class='hs-conid'>Int</span> <span class='hs-conid'>Int</span>
<a name="line-812"></a> <span class='hs-keyword'>deriving</span> <span class='hs-layout'>(</span> <span class='hs-conid'>Eq</span><span class='hs-layout'>,</span> <span class='hs-conid'>Ord</span><span class='hs-layout'>,</span> <span class='hs-conid'>Show</span> <span class='hs-layout'>)</span>
<a name="line-813"></a>
<a name="line-814"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-815"></a>
<a name="line-816"></a><span class='hs-comment'>-- | A joystick callback</span>
<a name="line-817"></a>
<a name="line-818"></a><a name="JoystickCallback"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>JoystickCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>JoystickButtons</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>JoystickPosition</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-819"></a>
<a name="line-820"></a><span class='hs-comment'>-- | Controls the joystick callback for the /current window./ The joystick</span>
<a name="line-821"></a><span class='hs-comment'>-- callback is called either due to polling of the joystick at the uniform timer</span>
<a name="line-822"></a><span class='hs-comment'>-- interval specified (if > 0) or in response to an explicit call of</span>
<a name="line-823"></a><span class='hs-comment'>-- 'Graphics.UI.GLUT.DeviceControl.forceJoystickCallback'.</span>
<a name="line-824"></a><span class='hs-comment'>--</span>
<a name="line-825"></a><span class='hs-comment'>-- /X Implementation Notes:/ Currently GLUT has no joystick support for X11.</span>
<a name="line-826"></a>
<a name="line-827"></a><a name="joystickCallback"></a><span class='hs-comment'>-- joystickCallback :: SettableStateVar (Maybe JoystickCallback, PollRate)</span>
<a name="line-828"></a><span class='hs-definition'>joystickCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>SettableStateVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-layout'>(</span><span class='hs-conid'>JoystickCallback</span><span class='hs-layout'>,</span> <span class='hs-conid'>PollRate</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-829"></a><span class='hs-definition'>joystickCallback</span> <span class='hs-keyglyph'>=</span>
<a name="line-830"></a> <span class='hs-varid'>makeSettableStateVar</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>maybeCBAndRate</span> <span class='hs-keyglyph'>-></span>
<a name="line-831"></a> <span class='hs-varid'>setCallback</span> <span class='hs-conid'>JoystickCB</span>
<a name="line-832"></a> <span class='hs-layout'>(</span><span class='hs-keyglyph'>\</span><span class='hs-varid'>f</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>glutJoystickFunc</span> <span class='hs-varid'>f</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-layout'>(</span><span class='hs-varid'>snd</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromJust</span> <span class='hs-varid'>maybeCBAndRate</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
<a name="line-833"></a> <span class='hs-layout'>(</span><span class='hs-varid'>makeJoystickFunc</span> <span class='hs-varop'>.</span> <span class='hs-varid'>unmarshal</span><span class='hs-layout'>)</span>
<a name="line-834"></a> <span class='hs-layout'>(</span><span class='hs-varid'>fmap</span> <span class='hs-varid'>fst</span> <span class='hs-varid'>maybeCBAndRate</span><span class='hs-layout'>)</span>
<a name="line-835"></a> <span class='hs-keyword'>where</span> <span class='hs-varid'>unmarshal</span> <span class='hs-varid'>cb</span> <span class='hs-varid'>b</span> <span class='hs-varid'>x</span> <span class='hs-varid'>y</span> <span class='hs-varid'>z</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cb</span> <span class='hs-layout'>(</span><span class='hs-varid'>unmarshalJoystickButtons</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span>
<a name="line-836"></a> <span class='hs-layout'>(</span><span class='hs-conid'>JoystickPosition</span> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span>
<a name="line-837"></a> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>y</span><span class='hs-layout'>)</span>
<a name="line-838"></a> <span class='hs-layout'>(</span><span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>z</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span>
</pre></body>
</html>
|