| 1 | n/a | |
|---|
| 2 | n/a | /* ========================== Module _Evt =========================== */ |
|---|
| 3 | n/a | |
|---|
| 4 | n/a | #include "Python.h" |
|---|
| 5 | n/a | |
|---|
| 6 | n/a | #ifndef __LP64__ |
|---|
| 7 | n/a | |
|---|
| 8 | n/a | |
|---|
| 9 | n/a | #include "pymactoolbox.h" |
|---|
| 10 | n/a | |
|---|
| 11 | n/a | /* Macro to test whether a weak-loaded CFM function exists */ |
|---|
| 12 | n/a | #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ |
|---|
| 13 | n/a | PyErr_SetString(PyExc_NotImplementedError, \ |
|---|
| 14 | n/a | "Not available in this shared library/OS version"); \ |
|---|
| 15 | n/a | return NULL; \ |
|---|
| 16 | n/a | }} while(0) |
|---|
| 17 | n/a | |
|---|
| 18 | n/a | |
|---|
| 19 | n/a | #include <Carbon/Carbon.h> |
|---|
| 20 | n/a | |
|---|
| 21 | n/a | |
|---|
| 22 | n/a | static PyObject *Evt_Error; |
|---|
| 23 | n/a | |
|---|
| 24 | n/a | static PyObject *Evt_GetMouse(PyObject *_self, PyObject *_args) |
|---|
| 25 | n/a | { |
|---|
| 26 | n/a | PyObject *_res = NULL; |
|---|
| 27 | n/a | Point mouseLoc; |
|---|
| 28 | n/a | #ifndef GetMouse |
|---|
| 29 | n/a | PyMac_PRECHECK(GetMouse); |
|---|
| 30 | n/a | #endif |
|---|
| 31 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 32 | n/a | return NULL; |
|---|
| 33 | n/a | GetMouse(&mouseLoc); |
|---|
| 34 | n/a | _res = Py_BuildValue("O&", |
|---|
| 35 | n/a | PyMac_BuildPoint, mouseLoc); |
|---|
| 36 | n/a | return _res; |
|---|
| 37 | n/a | } |
|---|
| 38 | n/a | |
|---|
| 39 | n/a | static PyObject *Evt_Button(PyObject *_self, PyObject *_args) |
|---|
| 40 | n/a | { |
|---|
| 41 | n/a | PyObject *_res = NULL; |
|---|
| 42 | n/a | Boolean _rv; |
|---|
| 43 | n/a | #ifndef Button |
|---|
| 44 | n/a | PyMac_PRECHECK(Button); |
|---|
| 45 | n/a | #endif |
|---|
| 46 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 47 | n/a | return NULL; |
|---|
| 48 | n/a | _rv = Button(); |
|---|
| 49 | n/a | _res = Py_BuildValue("b", |
|---|
| 50 | n/a | _rv); |
|---|
| 51 | n/a | return _res; |
|---|
| 52 | n/a | } |
|---|
| 53 | n/a | |
|---|
| 54 | n/a | static PyObject *Evt_StillDown(PyObject *_self, PyObject *_args) |
|---|
| 55 | n/a | { |
|---|
| 56 | n/a | PyObject *_res = NULL; |
|---|
| 57 | n/a | Boolean _rv; |
|---|
| 58 | n/a | #ifndef StillDown |
|---|
| 59 | n/a | PyMac_PRECHECK(StillDown); |
|---|
| 60 | n/a | #endif |
|---|
| 61 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 62 | n/a | return NULL; |
|---|
| 63 | n/a | _rv = StillDown(); |
|---|
| 64 | n/a | _res = Py_BuildValue("b", |
|---|
| 65 | n/a | _rv); |
|---|
| 66 | n/a | return _res; |
|---|
| 67 | n/a | } |
|---|
| 68 | n/a | |
|---|
| 69 | n/a | static PyObject *Evt_WaitMouseUp(PyObject *_self, PyObject *_args) |
|---|
| 70 | n/a | { |
|---|
| 71 | n/a | PyObject *_res = NULL; |
|---|
| 72 | n/a | Boolean _rv; |
|---|
| 73 | n/a | #ifndef WaitMouseUp |
|---|
| 74 | n/a | PyMac_PRECHECK(WaitMouseUp); |
|---|
| 75 | n/a | #endif |
|---|
| 76 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 77 | n/a | return NULL; |
|---|
| 78 | n/a | _rv = WaitMouseUp(); |
|---|
| 79 | n/a | _res = Py_BuildValue("b", |
|---|
| 80 | n/a | _rv); |
|---|
| 81 | n/a | return _res; |
|---|
| 82 | n/a | } |
|---|
| 83 | n/a | |
|---|
| 84 | n/a | static PyObject *Evt_GetCaretTime(PyObject *_self, PyObject *_args) |
|---|
| 85 | n/a | { |
|---|
| 86 | n/a | PyObject *_res = NULL; |
|---|
| 87 | n/a | UInt32 _rv; |
|---|
| 88 | n/a | #ifndef GetCaretTime |
|---|
| 89 | n/a | PyMac_PRECHECK(GetCaretTime); |
|---|
| 90 | n/a | #endif |
|---|
| 91 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 92 | n/a | return NULL; |
|---|
| 93 | n/a | _rv = GetCaretTime(); |
|---|
| 94 | n/a | _res = Py_BuildValue("l", |
|---|
| 95 | n/a | _rv); |
|---|
| 96 | n/a | return _res; |
|---|
| 97 | n/a | } |
|---|
| 98 | n/a | |
|---|
| 99 | n/a | static PyObject *Evt_GetKeys(PyObject *_self, PyObject *_args) |
|---|
| 100 | n/a | { |
|---|
| 101 | n/a | PyObject *_res = NULL; |
|---|
| 102 | n/a | KeyMap theKeys__out__; |
|---|
| 103 | n/a | #ifndef GetKeys |
|---|
| 104 | n/a | PyMac_PRECHECK(GetKeys); |
|---|
| 105 | n/a | #endif |
|---|
| 106 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 107 | n/a | return NULL; |
|---|
| 108 | n/a | GetKeys(theKeys__out__); |
|---|
| 109 | n/a | _res = Py_BuildValue("s#", |
|---|
| 110 | n/a | (char *)&theKeys__out__, (int)sizeof(KeyMap)); |
|---|
| 111 | n/a | return _res; |
|---|
| 112 | n/a | } |
|---|
| 113 | n/a | |
|---|
| 114 | n/a | static PyObject *Evt_GetDblTime(PyObject *_self, PyObject *_args) |
|---|
| 115 | n/a | { |
|---|
| 116 | n/a | PyObject *_res = NULL; |
|---|
| 117 | n/a | UInt32 _rv; |
|---|
| 118 | n/a | #ifndef GetDblTime |
|---|
| 119 | n/a | PyMac_PRECHECK(GetDblTime); |
|---|
| 120 | n/a | #endif |
|---|
| 121 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 122 | n/a | return NULL; |
|---|
| 123 | n/a | _rv = GetDblTime(); |
|---|
| 124 | n/a | _res = Py_BuildValue("l", |
|---|
| 125 | n/a | _rv); |
|---|
| 126 | n/a | return _res; |
|---|
| 127 | n/a | } |
|---|
| 128 | n/a | |
|---|
| 129 | n/a | static PyObject *Evt_SetEventMask(PyObject *_self, PyObject *_args) |
|---|
| 130 | n/a | { |
|---|
| 131 | n/a | PyObject *_res = NULL; |
|---|
| 132 | n/a | EventMask value; |
|---|
| 133 | n/a | #ifndef SetEventMask |
|---|
| 134 | n/a | PyMac_PRECHECK(SetEventMask); |
|---|
| 135 | n/a | #endif |
|---|
| 136 | n/a | if (!PyArg_ParseTuple(_args, "H", |
|---|
| 137 | n/a | &value)) |
|---|
| 138 | n/a | return NULL; |
|---|
| 139 | n/a | SetEventMask(value); |
|---|
| 140 | n/a | Py_INCREF(Py_None); |
|---|
| 141 | n/a | _res = Py_None; |
|---|
| 142 | n/a | return _res; |
|---|
| 143 | n/a | } |
|---|
| 144 | n/a | |
|---|
| 145 | n/a | static PyObject *Evt_GetNextEvent(PyObject *_self, PyObject *_args) |
|---|
| 146 | n/a | { |
|---|
| 147 | n/a | PyObject *_res = NULL; |
|---|
| 148 | n/a | Boolean _rv; |
|---|
| 149 | n/a | EventMask eventMask; |
|---|
| 150 | n/a | EventRecord theEvent; |
|---|
| 151 | n/a | #ifndef GetNextEvent |
|---|
| 152 | n/a | PyMac_PRECHECK(GetNextEvent); |
|---|
| 153 | n/a | #endif |
|---|
| 154 | n/a | if (!PyArg_ParseTuple(_args, "H", |
|---|
| 155 | n/a | &eventMask)) |
|---|
| 156 | n/a | return NULL; |
|---|
| 157 | n/a | _rv = GetNextEvent(eventMask, |
|---|
| 158 | n/a | &theEvent); |
|---|
| 159 | n/a | _res = Py_BuildValue("bO&", |
|---|
| 160 | n/a | _rv, |
|---|
| 161 | n/a | PyMac_BuildEventRecord, &theEvent); |
|---|
| 162 | n/a | return _res; |
|---|
| 163 | n/a | } |
|---|
| 164 | n/a | |
|---|
| 165 | n/a | static PyObject *Evt_EventAvail(PyObject *_self, PyObject *_args) |
|---|
| 166 | n/a | { |
|---|
| 167 | n/a | PyObject *_res = NULL; |
|---|
| 168 | n/a | Boolean _rv; |
|---|
| 169 | n/a | EventMask eventMask; |
|---|
| 170 | n/a | EventRecord theEvent; |
|---|
| 171 | n/a | #ifndef EventAvail |
|---|
| 172 | n/a | PyMac_PRECHECK(EventAvail); |
|---|
| 173 | n/a | #endif |
|---|
| 174 | n/a | if (!PyArg_ParseTuple(_args, "H", |
|---|
| 175 | n/a | &eventMask)) |
|---|
| 176 | n/a | return NULL; |
|---|
| 177 | n/a | _rv = EventAvail(eventMask, |
|---|
| 178 | n/a | &theEvent); |
|---|
| 179 | n/a | _res = Py_BuildValue("bO&", |
|---|
| 180 | n/a | _rv, |
|---|
| 181 | n/a | PyMac_BuildEventRecord, &theEvent); |
|---|
| 182 | n/a | return _res; |
|---|
| 183 | n/a | } |
|---|
| 184 | n/a | |
|---|
| 185 | n/a | static PyObject *Evt_PostEvent(PyObject *_self, PyObject *_args) |
|---|
| 186 | n/a | { |
|---|
| 187 | n/a | PyObject *_res = NULL; |
|---|
| 188 | n/a | OSErr _err; |
|---|
| 189 | n/a | EventKind eventNum; |
|---|
| 190 | n/a | UInt32 eventMsg; |
|---|
| 191 | n/a | #ifndef PostEvent |
|---|
| 192 | n/a | PyMac_PRECHECK(PostEvent); |
|---|
| 193 | n/a | #endif |
|---|
| 194 | n/a | if (!PyArg_ParseTuple(_args, "Hl", |
|---|
| 195 | n/a | &eventNum, |
|---|
| 196 | n/a | &eventMsg)) |
|---|
| 197 | n/a | return NULL; |
|---|
| 198 | n/a | _err = PostEvent(eventNum, |
|---|
| 199 | n/a | eventMsg); |
|---|
| 200 | n/a | if (_err != noErr) return PyMac_Error(_err); |
|---|
| 201 | n/a | Py_INCREF(Py_None); |
|---|
| 202 | n/a | _res = Py_None; |
|---|
| 203 | n/a | return _res; |
|---|
| 204 | n/a | } |
|---|
| 205 | n/a | |
|---|
| 206 | n/a | static PyObject *Evt_FlushEvents(PyObject *_self, PyObject *_args) |
|---|
| 207 | n/a | { |
|---|
| 208 | n/a | PyObject *_res = NULL; |
|---|
| 209 | n/a | EventMask whichMask; |
|---|
| 210 | n/a | EventMask stopMask; |
|---|
| 211 | n/a | #ifndef FlushEvents |
|---|
| 212 | n/a | PyMac_PRECHECK(FlushEvents); |
|---|
| 213 | n/a | #endif |
|---|
| 214 | n/a | if (!PyArg_ParseTuple(_args, "HH", |
|---|
| 215 | n/a | &whichMask, |
|---|
| 216 | n/a | &stopMask)) |
|---|
| 217 | n/a | return NULL; |
|---|
| 218 | n/a | FlushEvents(whichMask, |
|---|
| 219 | n/a | stopMask); |
|---|
| 220 | n/a | Py_INCREF(Py_None); |
|---|
| 221 | n/a | _res = Py_None; |
|---|
| 222 | n/a | return _res; |
|---|
| 223 | n/a | } |
|---|
| 224 | n/a | |
|---|
| 225 | n/a | static PyObject *Evt_GetGlobalMouse(PyObject *_self, PyObject *_args) |
|---|
| 226 | n/a | { |
|---|
| 227 | n/a | PyObject *_res = NULL; |
|---|
| 228 | n/a | Point globalMouse; |
|---|
| 229 | n/a | #ifndef GetGlobalMouse |
|---|
| 230 | n/a | PyMac_PRECHECK(GetGlobalMouse); |
|---|
| 231 | n/a | #endif |
|---|
| 232 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 233 | n/a | return NULL; |
|---|
| 234 | n/a | GetGlobalMouse(&globalMouse); |
|---|
| 235 | n/a | _res = Py_BuildValue("O&", |
|---|
| 236 | n/a | PyMac_BuildPoint, globalMouse); |
|---|
| 237 | n/a | return _res; |
|---|
| 238 | n/a | } |
|---|
| 239 | n/a | |
|---|
| 240 | n/a | static PyObject *Evt_GetCurrentKeyModifiers(PyObject *_self, PyObject *_args) |
|---|
| 241 | n/a | { |
|---|
| 242 | n/a | PyObject *_res = NULL; |
|---|
| 243 | n/a | UInt32 _rv; |
|---|
| 244 | n/a | #ifndef GetCurrentKeyModifiers |
|---|
| 245 | n/a | PyMac_PRECHECK(GetCurrentKeyModifiers); |
|---|
| 246 | n/a | #endif |
|---|
| 247 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 248 | n/a | return NULL; |
|---|
| 249 | n/a | _rv = GetCurrentKeyModifiers(); |
|---|
| 250 | n/a | _res = Py_BuildValue("l", |
|---|
| 251 | n/a | _rv); |
|---|
| 252 | n/a | return _res; |
|---|
| 253 | n/a | } |
|---|
| 254 | n/a | |
|---|
| 255 | n/a | static PyObject *Evt_CheckEventQueueForUserCancel(PyObject *_self, PyObject *_args) |
|---|
| 256 | n/a | { |
|---|
| 257 | n/a | PyObject *_res = NULL; |
|---|
| 258 | n/a | Boolean _rv; |
|---|
| 259 | n/a | #ifndef CheckEventQueueForUserCancel |
|---|
| 260 | n/a | PyMac_PRECHECK(CheckEventQueueForUserCancel); |
|---|
| 261 | n/a | #endif |
|---|
| 262 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 263 | n/a | return NULL; |
|---|
| 264 | n/a | _rv = CheckEventQueueForUserCancel(); |
|---|
| 265 | n/a | _res = Py_BuildValue("b", |
|---|
| 266 | n/a | _rv); |
|---|
| 267 | n/a | return _res; |
|---|
| 268 | n/a | } |
|---|
| 269 | n/a | |
|---|
| 270 | n/a | static PyObject *Evt_KeyScript(PyObject *_self, PyObject *_args) |
|---|
| 271 | n/a | { |
|---|
| 272 | n/a | PyObject *_res = NULL; |
|---|
| 273 | n/a | short code; |
|---|
| 274 | n/a | #ifndef KeyScript |
|---|
| 275 | n/a | PyMac_PRECHECK(KeyScript); |
|---|
| 276 | n/a | #endif |
|---|
| 277 | n/a | if (!PyArg_ParseTuple(_args, "h", |
|---|
| 278 | n/a | &code)) |
|---|
| 279 | n/a | return NULL; |
|---|
| 280 | n/a | KeyScript(code); |
|---|
| 281 | n/a | Py_INCREF(Py_None); |
|---|
| 282 | n/a | _res = Py_None; |
|---|
| 283 | n/a | return _res; |
|---|
| 284 | n/a | } |
|---|
| 285 | n/a | |
|---|
| 286 | n/a | static PyObject *Evt_IsCmdChar(PyObject *_self, PyObject *_args) |
|---|
| 287 | n/a | { |
|---|
| 288 | n/a | PyObject *_res = NULL; |
|---|
| 289 | n/a | Boolean _rv; |
|---|
| 290 | n/a | EventRecord event; |
|---|
| 291 | n/a | short test; |
|---|
| 292 | n/a | #ifndef IsCmdChar |
|---|
| 293 | n/a | PyMac_PRECHECK(IsCmdChar); |
|---|
| 294 | n/a | #endif |
|---|
| 295 | n/a | if (!PyArg_ParseTuple(_args, "O&h", |
|---|
| 296 | n/a | PyMac_GetEventRecord, &event, |
|---|
| 297 | n/a | &test)) |
|---|
| 298 | n/a | return NULL; |
|---|
| 299 | n/a | _rv = IsCmdChar(&event, |
|---|
| 300 | n/a | test); |
|---|
| 301 | n/a | _res = Py_BuildValue("b", |
|---|
| 302 | n/a | _rv); |
|---|
| 303 | n/a | return _res; |
|---|
| 304 | n/a | } |
|---|
| 305 | n/a | |
|---|
| 306 | n/a | static PyObject *Evt_LMGetKeyThresh(PyObject *_self, PyObject *_args) |
|---|
| 307 | n/a | { |
|---|
| 308 | n/a | PyObject *_res = NULL; |
|---|
| 309 | n/a | SInt16 _rv; |
|---|
| 310 | n/a | #ifndef LMGetKeyThresh |
|---|
| 311 | n/a | PyMac_PRECHECK(LMGetKeyThresh); |
|---|
| 312 | n/a | #endif |
|---|
| 313 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 314 | n/a | return NULL; |
|---|
| 315 | n/a | _rv = LMGetKeyThresh(); |
|---|
| 316 | n/a | _res = Py_BuildValue("h", |
|---|
| 317 | n/a | _rv); |
|---|
| 318 | n/a | return _res; |
|---|
| 319 | n/a | } |
|---|
| 320 | n/a | |
|---|
| 321 | n/a | static PyObject *Evt_LMSetKeyThresh(PyObject *_self, PyObject *_args) |
|---|
| 322 | n/a | { |
|---|
| 323 | n/a | PyObject *_res = NULL; |
|---|
| 324 | n/a | SInt16 value; |
|---|
| 325 | n/a | #ifndef LMSetKeyThresh |
|---|
| 326 | n/a | PyMac_PRECHECK(LMSetKeyThresh); |
|---|
| 327 | n/a | #endif |
|---|
| 328 | n/a | if (!PyArg_ParseTuple(_args, "h", |
|---|
| 329 | n/a | &value)) |
|---|
| 330 | n/a | return NULL; |
|---|
| 331 | n/a | LMSetKeyThresh(value); |
|---|
| 332 | n/a | Py_INCREF(Py_None); |
|---|
| 333 | n/a | _res = Py_None; |
|---|
| 334 | n/a | return _res; |
|---|
| 335 | n/a | } |
|---|
| 336 | n/a | |
|---|
| 337 | n/a | static PyObject *Evt_LMGetKeyRepThresh(PyObject *_self, PyObject *_args) |
|---|
| 338 | n/a | { |
|---|
| 339 | n/a | PyObject *_res = NULL; |
|---|
| 340 | n/a | SInt16 _rv; |
|---|
| 341 | n/a | #ifndef LMGetKeyRepThresh |
|---|
| 342 | n/a | PyMac_PRECHECK(LMGetKeyRepThresh); |
|---|
| 343 | n/a | #endif |
|---|
| 344 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 345 | n/a | return NULL; |
|---|
| 346 | n/a | _rv = LMGetKeyRepThresh(); |
|---|
| 347 | n/a | _res = Py_BuildValue("h", |
|---|
| 348 | n/a | _rv); |
|---|
| 349 | n/a | return _res; |
|---|
| 350 | n/a | } |
|---|
| 351 | n/a | |
|---|
| 352 | n/a | static PyObject *Evt_LMSetKeyRepThresh(PyObject *_self, PyObject *_args) |
|---|
| 353 | n/a | { |
|---|
| 354 | n/a | PyObject *_res = NULL; |
|---|
| 355 | n/a | SInt16 value; |
|---|
| 356 | n/a | #ifndef LMSetKeyRepThresh |
|---|
| 357 | n/a | PyMac_PRECHECK(LMSetKeyRepThresh); |
|---|
| 358 | n/a | #endif |
|---|
| 359 | n/a | if (!PyArg_ParseTuple(_args, "h", |
|---|
| 360 | n/a | &value)) |
|---|
| 361 | n/a | return NULL; |
|---|
| 362 | n/a | LMSetKeyRepThresh(value); |
|---|
| 363 | n/a | Py_INCREF(Py_None); |
|---|
| 364 | n/a | _res = Py_None; |
|---|
| 365 | n/a | return _res; |
|---|
| 366 | n/a | } |
|---|
| 367 | n/a | |
|---|
| 368 | n/a | static PyObject *Evt_LMGetKbdLast(PyObject *_self, PyObject *_args) |
|---|
| 369 | n/a | { |
|---|
| 370 | n/a | PyObject *_res = NULL; |
|---|
| 371 | n/a | UInt8 _rv; |
|---|
| 372 | n/a | #ifndef LMGetKbdLast |
|---|
| 373 | n/a | PyMac_PRECHECK(LMGetKbdLast); |
|---|
| 374 | n/a | #endif |
|---|
| 375 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 376 | n/a | return NULL; |
|---|
| 377 | n/a | _rv = LMGetKbdLast(); |
|---|
| 378 | n/a | _res = Py_BuildValue("b", |
|---|
| 379 | n/a | _rv); |
|---|
| 380 | n/a | return _res; |
|---|
| 381 | n/a | } |
|---|
| 382 | n/a | |
|---|
| 383 | n/a | static PyObject *Evt_LMSetKbdLast(PyObject *_self, PyObject *_args) |
|---|
| 384 | n/a | { |
|---|
| 385 | n/a | PyObject *_res = NULL; |
|---|
| 386 | n/a | UInt8 value; |
|---|
| 387 | n/a | #ifndef LMSetKbdLast |
|---|
| 388 | n/a | PyMac_PRECHECK(LMSetKbdLast); |
|---|
| 389 | n/a | #endif |
|---|
| 390 | n/a | if (!PyArg_ParseTuple(_args, "b", |
|---|
| 391 | n/a | &value)) |
|---|
| 392 | n/a | return NULL; |
|---|
| 393 | n/a | LMSetKbdLast(value); |
|---|
| 394 | n/a | Py_INCREF(Py_None); |
|---|
| 395 | n/a | _res = Py_None; |
|---|
| 396 | n/a | return _res; |
|---|
| 397 | n/a | } |
|---|
| 398 | n/a | |
|---|
| 399 | n/a | static PyObject *Evt_LMGetKbdType(PyObject *_self, PyObject *_args) |
|---|
| 400 | n/a | { |
|---|
| 401 | n/a | PyObject *_res = NULL; |
|---|
| 402 | n/a | UInt8 _rv; |
|---|
| 403 | n/a | #ifndef LMGetKbdType |
|---|
| 404 | n/a | PyMac_PRECHECK(LMGetKbdType); |
|---|
| 405 | n/a | #endif |
|---|
| 406 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 407 | n/a | return NULL; |
|---|
| 408 | n/a | _rv = LMGetKbdType(); |
|---|
| 409 | n/a | _res = Py_BuildValue("b", |
|---|
| 410 | n/a | _rv); |
|---|
| 411 | n/a | return _res; |
|---|
| 412 | n/a | } |
|---|
| 413 | n/a | |
|---|
| 414 | n/a | static PyObject *Evt_LMSetKbdType(PyObject *_self, PyObject *_args) |
|---|
| 415 | n/a | { |
|---|
| 416 | n/a | PyObject *_res = NULL; |
|---|
| 417 | n/a | UInt8 value; |
|---|
| 418 | n/a | #ifndef LMSetKbdType |
|---|
| 419 | n/a | PyMac_PRECHECK(LMSetKbdType); |
|---|
| 420 | n/a | #endif |
|---|
| 421 | n/a | if (!PyArg_ParseTuple(_args, "b", |
|---|
| 422 | n/a | &value)) |
|---|
| 423 | n/a | return NULL; |
|---|
| 424 | n/a | LMSetKbdType(value); |
|---|
| 425 | n/a | Py_INCREF(Py_None); |
|---|
| 426 | n/a | _res = Py_None; |
|---|
| 427 | n/a | return _res; |
|---|
| 428 | n/a | } |
|---|
| 429 | n/a | |
|---|
| 430 | n/a | static PyObject *Evt_TickCount(PyObject *_self, PyObject *_args) |
|---|
| 431 | n/a | { |
|---|
| 432 | n/a | PyObject *_res = NULL; |
|---|
| 433 | n/a | UInt32 _rv; |
|---|
| 434 | n/a | #ifndef TickCount |
|---|
| 435 | n/a | PyMac_PRECHECK(TickCount); |
|---|
| 436 | n/a | #endif |
|---|
| 437 | n/a | if (!PyArg_ParseTuple(_args, "")) |
|---|
| 438 | n/a | return NULL; |
|---|
| 439 | n/a | _rv = TickCount(); |
|---|
| 440 | n/a | _res = Py_BuildValue("l", |
|---|
| 441 | n/a | _rv); |
|---|
| 442 | n/a | return _res; |
|---|
| 443 | n/a | } |
|---|
| 444 | n/a | |
|---|
| 445 | n/a | static PyObject *Evt_WaitNextEvent(PyObject *_self, PyObject *_args) |
|---|
| 446 | n/a | { |
|---|
| 447 | n/a | PyObject *_res = NULL; |
|---|
| 448 | n/a | |
|---|
| 449 | n/a | Boolean _rv; |
|---|
| 450 | n/a | EventMask eventMask; |
|---|
| 451 | n/a | EventRecord theEvent; |
|---|
| 452 | n/a | UInt32 sleep; |
|---|
| 453 | n/a | Handle mouseregion = (Handle)0; |
|---|
| 454 | n/a | |
|---|
| 455 | n/a | if (!PyArg_ParseTuple(_args, "Hl|O&", |
|---|
| 456 | n/a | &eventMask, |
|---|
| 457 | n/a | &sleep, |
|---|
| 458 | n/a | OptResObj_Convert, &mouseregion)) |
|---|
| 459 | n/a | return NULL; |
|---|
| 460 | n/a | _rv = WaitNextEvent(eventMask, |
|---|
| 461 | n/a | &theEvent, |
|---|
| 462 | n/a | sleep, |
|---|
| 463 | n/a | (RgnHandle)mouseregion); |
|---|
| 464 | n/a | _res = Py_BuildValue("bO&", |
|---|
| 465 | n/a | _rv, |
|---|
| 466 | n/a | PyMac_BuildEventRecord, &theEvent); |
|---|
| 467 | n/a | return _res; |
|---|
| 468 | n/a | |
|---|
| 469 | n/a | } |
|---|
| 470 | n/a | |
|---|
| 471 | n/a | static PyMethodDef Evt_methods[] = { |
|---|
| 472 | n/a | {"GetMouse", (PyCFunction)Evt_GetMouse, 1, |
|---|
| 473 | n/a | PyDoc_STR("() -> (Point mouseLoc)")}, |
|---|
| 474 | n/a | {"Button", (PyCFunction)Evt_Button, 1, |
|---|
| 475 | n/a | PyDoc_STR("() -> (Boolean _rv)")}, |
|---|
| 476 | n/a | {"StillDown", (PyCFunction)Evt_StillDown, 1, |
|---|
| 477 | n/a | PyDoc_STR("() -> (Boolean _rv)")}, |
|---|
| 478 | n/a | {"WaitMouseUp", (PyCFunction)Evt_WaitMouseUp, 1, |
|---|
| 479 | n/a | PyDoc_STR("() -> (Boolean _rv)")}, |
|---|
| 480 | n/a | {"GetCaretTime", (PyCFunction)Evt_GetCaretTime, 1, |
|---|
| 481 | n/a | PyDoc_STR("() -> (UInt32 _rv)")}, |
|---|
| 482 | n/a | {"GetKeys", (PyCFunction)Evt_GetKeys, 1, |
|---|
| 483 | n/a | PyDoc_STR("() -> (KeyMap theKeys)")}, |
|---|
| 484 | n/a | {"GetDblTime", (PyCFunction)Evt_GetDblTime, 1, |
|---|
| 485 | n/a | PyDoc_STR("() -> (UInt32 _rv)")}, |
|---|
| 486 | n/a | {"SetEventMask", (PyCFunction)Evt_SetEventMask, 1, |
|---|
| 487 | n/a | PyDoc_STR("(EventMask value) -> None")}, |
|---|
| 488 | n/a | {"GetNextEvent", (PyCFunction)Evt_GetNextEvent, 1, |
|---|
| 489 | n/a | PyDoc_STR("(EventMask eventMask) -> (Boolean _rv, EventRecord theEvent)")}, |
|---|
| 490 | n/a | {"EventAvail", (PyCFunction)Evt_EventAvail, 1, |
|---|
| 491 | n/a | PyDoc_STR("(EventMask eventMask) -> (Boolean _rv, EventRecord theEvent)")}, |
|---|
| 492 | n/a | {"PostEvent", (PyCFunction)Evt_PostEvent, 1, |
|---|
| 493 | n/a | PyDoc_STR("(EventKind eventNum, UInt32 eventMsg) -> None")}, |
|---|
| 494 | n/a | {"FlushEvents", (PyCFunction)Evt_FlushEvents, 1, |
|---|
| 495 | n/a | PyDoc_STR("(EventMask whichMask, EventMask stopMask) -> None")}, |
|---|
| 496 | n/a | {"GetGlobalMouse", (PyCFunction)Evt_GetGlobalMouse, 1, |
|---|
| 497 | n/a | PyDoc_STR("() -> (Point globalMouse)")}, |
|---|
| 498 | n/a | {"GetCurrentKeyModifiers", (PyCFunction)Evt_GetCurrentKeyModifiers, 1, |
|---|
| 499 | n/a | PyDoc_STR("() -> (UInt32 _rv)")}, |
|---|
| 500 | n/a | {"CheckEventQueueForUserCancel", (PyCFunction)Evt_CheckEventQueueForUserCancel, 1, |
|---|
| 501 | n/a | PyDoc_STR("() -> (Boolean _rv)")}, |
|---|
| 502 | n/a | {"KeyScript", (PyCFunction)Evt_KeyScript, 1, |
|---|
| 503 | n/a | PyDoc_STR("(short code) -> None")}, |
|---|
| 504 | n/a | {"IsCmdChar", (PyCFunction)Evt_IsCmdChar, 1, |
|---|
| 505 | n/a | PyDoc_STR("(EventRecord event, short test) -> (Boolean _rv)")}, |
|---|
| 506 | n/a | {"LMGetKeyThresh", (PyCFunction)Evt_LMGetKeyThresh, 1, |
|---|
| 507 | n/a | PyDoc_STR("() -> (SInt16 _rv)")}, |
|---|
| 508 | n/a | {"LMSetKeyThresh", (PyCFunction)Evt_LMSetKeyThresh, 1, |
|---|
| 509 | n/a | PyDoc_STR("(SInt16 value) -> None")}, |
|---|
| 510 | n/a | {"LMGetKeyRepThresh", (PyCFunction)Evt_LMGetKeyRepThresh, 1, |
|---|
| 511 | n/a | PyDoc_STR("() -> (SInt16 _rv)")}, |
|---|
| 512 | n/a | {"LMSetKeyRepThresh", (PyCFunction)Evt_LMSetKeyRepThresh, 1, |
|---|
| 513 | n/a | PyDoc_STR("(SInt16 value) -> None")}, |
|---|
| 514 | n/a | {"LMGetKbdLast", (PyCFunction)Evt_LMGetKbdLast, 1, |
|---|
| 515 | n/a | PyDoc_STR("() -> (UInt8 _rv)")}, |
|---|
| 516 | n/a | {"LMSetKbdLast", (PyCFunction)Evt_LMSetKbdLast, 1, |
|---|
| 517 | n/a | PyDoc_STR("(UInt8 value) -> None")}, |
|---|
| 518 | n/a | {"LMGetKbdType", (PyCFunction)Evt_LMGetKbdType, 1, |
|---|
| 519 | n/a | PyDoc_STR("() -> (UInt8 _rv)")}, |
|---|
| 520 | n/a | {"LMSetKbdType", (PyCFunction)Evt_LMSetKbdType, 1, |
|---|
| 521 | n/a | PyDoc_STR("(UInt8 value) -> None")}, |
|---|
| 522 | n/a | {"TickCount", (PyCFunction)Evt_TickCount, 1, |
|---|
| 523 | n/a | PyDoc_STR("() -> (UInt32 _rv)")}, |
|---|
| 524 | n/a | {"WaitNextEvent", (PyCFunction)Evt_WaitNextEvent, 1, |
|---|
| 525 | n/a | PyDoc_STR("(EventMask eventMask, UInt32 sleep [,RegionHandle]) -> (Boolean _rv, EventRecord theEvent)")}, |
|---|
| 526 | n/a | {NULL, NULL, 0} |
|---|
| 527 | n/a | }; |
|---|
| 528 | n/a | |
|---|
| 529 | n/a | |
|---|
| 530 | n/a | #else /* __LP64__ */ |
|---|
| 531 | n/a | |
|---|
| 532 | n/a | static PyMethodDef Evt_methods[] = { |
|---|
| 533 | n/a | {NULL, NULL, 0} |
|---|
| 534 | n/a | }; |
|---|
| 535 | n/a | #endif /* __LP64__ */ |
|---|
| 536 | n/a | |
|---|
| 537 | n/a | |
|---|
| 538 | n/a | void init_Evt(void) |
|---|
| 539 | n/a | { |
|---|
| 540 | n/a | PyObject *m; |
|---|
| 541 | n/a | #ifndef __LP64__ |
|---|
| 542 | n/a | PyObject *d; |
|---|
| 543 | n/a | #endif /* __LP64__ */ |
|---|
| 544 | n/a | |
|---|
| 545 | n/a | |
|---|
| 546 | n/a | |
|---|
| 547 | n/a | |
|---|
| 548 | n/a | m = Py_InitModule("_Evt", Evt_methods); |
|---|
| 549 | n/a | #ifndef __LP64__ |
|---|
| 550 | n/a | d = PyModule_GetDict(m); |
|---|
| 551 | n/a | Evt_Error = PyMac_GetOSErrException(); |
|---|
| 552 | n/a | if (Evt_Error == NULL || |
|---|
| 553 | n/a | PyDict_SetItemString(d, "Error", Evt_Error) != 0) |
|---|
| 554 | n/a | return; |
|---|
| 555 | n/a | #endif /* __LP64__ */ |
|---|
| 556 | n/a | } |
|---|
| 557 | n/a | |
|---|
| 558 | n/a | /* ======================== End module _Evt ========================= */ |
|---|
| 559 | n/a | |
|---|