/usr/share/doc/libghc-glut-doc/html/src/Graphics-UI-GLUT-DeviceControl.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 | <?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/DeviceControl.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.DeviceControl</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'>-- GLUT offers some routines for controlling the key repeat and polling the</span>
<a name="line-12"></a><span class='hs-comment'>-- joystick.</span>
<a name="line-13"></a><span class='hs-comment'>--</span>
<a name="line-14"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-15"></a>
<a name="line-16"></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'>DeviceControl</span> <span class='hs-layout'>(</span>
<a name="line-17"></a> <span class='hs-conid'>GlobalKeyRepeat</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-varid'>globalKeyRepeat</span><span class='hs-layout'>,</span>
<a name="line-18"></a> <span class='hs-conid'>PerWindowKeyRepeat</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span><span class='hs-layout'>,</span> <span class='hs-varid'>perWindowKeyRepeat</span><span class='hs-layout'>,</span>
<a name="line-19"></a> <span class='hs-varid'>forceJoystickCallback</span>
<a name="line-20"></a><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-21"></a>
<a name="line-22"></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-23"></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'>StateVar</span><span class='hs-layout'>,</span> <span class='hs-varid'>makeStateVar</span> <span class='hs-layout'>)</span>
<a name="line-24"></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'>QueryUtils</span>
<a name="line-25"></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-26"></a>
<a name="line-27"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-28"></a>
<a name="line-29"></a><span class='hs-comment'>-- | The state of the global key repeat</span>
<a name="line-30"></a>
<a name="line-31"></a><a name="GlobalKeyRepeat"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>GlobalKeyRepeat</span>
<a name="line-32"></a> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>GlobalKeyRepeatOff</span>
<a name="line-33"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>GlobalKeyRepeatOn</span>
<a name="line-34"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>GlobalKeyRepeatDefault</span>
<a name="line-35"></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-36"></a>
<a name="line-37"></a><a name="marshalGlobalKeyRepeat"></a><span class='hs-definition'>marshalGlobalKeyRepeat</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>GlobalKeyRepeat</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>CInt</span>
<a name="line-38"></a><span class='hs-definition'>marshalGlobalKeyRepeat</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>case</span> <span class='hs-varid'>x</span> <span class='hs-keyword'>of</span>
<a name="line-39"></a> <span class='hs-conid'>GlobalKeyRepeatOff</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>glut_KEY_REPEAT_OFF</span>
<a name="line-40"></a> <span class='hs-conid'>GlobalKeyRepeatOn</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>glut_KEY_REPEAT_ON</span>
<a name="line-41"></a> <span class='hs-conid'>GlobalKeyRepeatDefault</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>glut_KEY_REPEAT_DEFAULT</span>
<a name="line-42"></a>
<a name="line-43"></a><a name="unmarshalGlobalKeyRepeat"></a><span class='hs-definition'>unmarshalGlobalKeyRepeat</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>CInt</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>GlobalKeyRepeat</span>
<a name="line-44"></a><span class='hs-definition'>unmarshalGlobalKeyRepeat</span> <span class='hs-varid'>x</span>
<a name="line-45"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_REPEAT_OFF</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>GlobalKeyRepeatOff</span>
<a name="line-46"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_REPEAT_ON</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>GlobalKeyRepeatOn</span>
<a name="line-47"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-varid'>glut_KEY_REPEAT_DEFAULT</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>GlobalKeyRepeatDefault</span>
<a name="line-48"></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'>"unmarshalGlobalKeyRepeat: 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-49"></a>
<a name="line-50"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-51"></a>
<a name="line-52"></a><span class='hs-comment'>-- | Controls the key repeat mode for the window system on a global basis if</span>
<a name="line-53"></a><span class='hs-comment'>-- possible. If supported by the window system, the key repeat can either be</span>
<a name="line-54"></a><span class='hs-comment'>-- disabled, enabled, or set to the window system\'s default key repeat state.</span>
<a name="line-55"></a><span class='hs-comment'>--</span>
<a name="line-56"></a><span class='hs-comment'>-- /X Implementation Notes:/ X11 sends @KeyPress@ events repeatedly when the</span>
<a name="line-57"></a><span class='hs-comment'>-- window system\'s global auto repeat is enabled. 'perWindowKeyRepeat' can</span>
<a name="line-58"></a><span class='hs-comment'>-- prevent these auto repeated keystrokes from being reported as keyboard or</span>
<a name="line-59"></a><span class='hs-comment'>-- special callbacks, but there is still some minimal overhead by the X server</span>
<a name="line-60"></a><span class='hs-comment'>-- to continually stream @KeyPress@ events to the GLUT application. The</span>
<a name="line-61"></a><span class='hs-comment'>-- 'globalKeyRepeat' state variable can be used to actually disable the global</span>
<a name="line-62"></a><span class='hs-comment'>-- sending of auto repeated @KeyPress@ events. Note that 'globalKeyRepeat'</span>
<a name="line-63"></a><span class='hs-comment'>-- affects the global window system auto repeat state so other applications</span>
<a name="line-64"></a><span class='hs-comment'>-- will not auto repeat if you disable auto repeat globally through</span>
<a name="line-65"></a><span class='hs-comment'>-- 'globalKeyRepeat'. GLUT applications using the X11 GLUT implementation</span>
<a name="line-66"></a><span class='hs-comment'>-- should disable key repeat with 'globalKeyRepeat' to disable key repeats most</span>
<a name="line-67"></a><span class='hs-comment'>-- efficiently, but are responsible for explicitly restoring the default key</span>
<a name="line-68"></a><span class='hs-comment'>-- repeat state on exit.</span>
<a name="line-69"></a><span class='hs-comment'>--</span>
<a name="line-70"></a><span class='hs-comment'>-- /Win32 Implementation Notes:/ The Win32 implementation of 'globalKeyRepeat'</span>
<a name="line-71"></a><span class='hs-comment'>-- does nothing. The 'perWindowKeyRepeat' can be used in the Win32 GLUT</span>
<a name="line-72"></a><span class='hs-comment'>-- implementation to ignore repeated keys on a per-window basis without changing</span>
<a name="line-73"></a><span class='hs-comment'>-- the global window system key repeat.</span>
<a name="line-74"></a>
<a name="line-75"></a><a name="globalKeyRepeat"></a><span class='hs-definition'>globalKeyRepeat</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>StateVar</span> <span class='hs-conid'>GlobalKeyRepeat</span>
<a name="line-76"></a><span class='hs-definition'>globalKeyRepeat</span> <span class='hs-keyglyph'>=</span>
<a name="line-77"></a> <span class='hs-varid'>makeStateVar</span> <span class='hs-layout'>(</span><span class='hs-varid'>deviceGet</span> <span class='hs-varid'>unmarshalGlobalKeyRepeat</span> <span class='hs-varid'>glut_DEVICE_KEY_REPEAT</span><span class='hs-layout'>)</span>
<a name="line-78"></a> <span class='hs-layout'>(</span><span class='hs-varid'>glutSetKeyRepeat</span> <span class='hs-varop'>.</span> <span class='hs-varid'>marshalGlobalKeyRepeat</span><span class='hs-layout'>)</span>
<a name="line-79"></a>
<a name="line-80"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-81"></a>
<a name="line-82"></a><span class='hs-comment'>-- | The state of the per-window key repeat</span>
<a name="line-83"></a>
<a name="line-84"></a><a name="PerWindowKeyRepeat"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>PerWindowKeyRepeat</span>
<a name="line-85"></a> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>PerWindowKeyRepeatOff</span>
<a name="line-86"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>PerWindowKeyRepeatOn</span>
<a name="line-87"></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-88"></a>
<a name="line-89"></a><a name="marshalPerWindowKeyRepeat"></a><span class='hs-definition'>marshalPerWindowKeyRepeat</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>PerWindowKeyRepeat</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>CInt</span>
<a name="line-90"></a><span class='hs-definition'>marshalPerWindowKeyRepeat</span> <span class='hs-varid'>x</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>case</span> <span class='hs-varid'>x</span> <span class='hs-keyword'>of</span>
<a name="line-91"></a> <span class='hs-conid'>PerWindowKeyRepeatOn</span> <span class='hs-keyglyph'>-></span> <span class='hs-num'>0</span>
<a name="line-92"></a> <span class='hs-conid'>PerWindowKeyRepeatOff</span> <span class='hs-keyglyph'>-></span> <span class='hs-num'>1</span>
<a name="line-93"></a>
<a name="line-94"></a><a name="unmarshalPerWindowKeyRepeat"></a><span class='hs-definition'>unmarshalPerWindowKeyRepeat</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>CInt</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>PerWindowKeyRepeat</span>
<a name="line-95"></a><span class='hs-definition'>unmarshalPerWindowKeyRepeat</span> <span class='hs-varid'>x</span>
<a name="line-96"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>x</span> <span class='hs-varop'>==</span> <span class='hs-num'>0</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>PerWindowKeyRepeatOn</span>
<a name="line-97"></a> <span class='hs-keyglyph'>|</span> <span class='hs-varid'>otherwise</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>PerWindowKeyRepeatOff</span>
<a name="line-98"></a>
<a name="line-99"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-100"></a>
<a name="line-101"></a><span class='hs-comment'>-- | Controls if auto repeat keystrokes are reported to the /current window./</span>
<a name="line-102"></a><span class='hs-comment'>-- Ignoring auto repeated keystrokes is generally done in conjunction with using</span>
<a name="line-103"></a><span class='hs-comment'>-- the 'Graphics.UI.GLUT.Callbacks.Window.keyboardMouseCallback'. If you do</span>
<a name="line-104"></a><span class='hs-comment'>-- not ignore auto repeated keystrokes, your GLUT application will experience</span>
<a name="line-105"></a><span class='hs-comment'>-- repeated release\/press callbacks. Games using the keyboard will typically</span>
<a name="line-106"></a><span class='hs-comment'>-- want to ignore key repeat.</span>
<a name="line-107"></a>
<a name="line-108"></a><a name="perWindowKeyRepeat"></a><span class='hs-definition'>perWindowKeyRepeat</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>StateVar</span> <span class='hs-conid'>PerWindowKeyRepeat</span>
<a name="line-109"></a><span class='hs-definition'>perWindowKeyRepeat</span> <span class='hs-keyglyph'>=</span>
<a name="line-110"></a> <span class='hs-varid'>makeStateVar</span>
<a name="line-111"></a> <span class='hs-layout'>(</span><span class='hs-varid'>deviceGet</span> <span class='hs-varid'>unmarshalPerWindowKeyRepeat</span> <span class='hs-varid'>glut_DEVICE_IGNORE_KEY_REPEAT</span><span class='hs-layout'>)</span>
<a name="line-112"></a> <span class='hs-layout'>(</span><span class='hs-varid'>glutIgnoreKeyRepeat</span> <span class='hs-varop'>.</span> <span class='hs-varid'>marshalPerWindowKeyRepeat</span><span class='hs-layout'>)</span>
<a name="line-113"></a>
<a name="line-114"></a><span class='hs-comment'>--------------------------------------------------------------------------------</span>
<a name="line-115"></a>
<a name="line-116"></a><span class='hs-comment'>-- | Execute the joystick callback set by</span>
<a name="line-117"></a><span class='hs-comment'>-- 'Graphics.UI.GLUT.Callbacks.Window.joystickCallback' once (if one exists).</span>
<a name="line-118"></a><span class='hs-comment'>-- This is done in a synchronous fashion within the current context, i.e. when</span>
<a name="line-119"></a><span class='hs-comment'>-- 'forceJoystickCallback' returns, the callback will have already happened.</span>
<a name="line-120"></a>
<a name="line-121"></a><a name="forceJoystickCallback"></a><span class='hs-definition'>forceJoystickCallback</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-122"></a><span class='hs-definition'>forceJoystickCallback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>glutForceJoystickFunc</span>
</pre></body>
</html>
|