home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 21 / macformat_21.iso / Shareware / Programación / VideoToolbox / VideoToolboxSources / MoveMouse.c < prev    next >
Text File  |  1996-03-04  |  16KB  |  482 lines

  1. /*
  2.  * MoveMouse.c
  3.  *
  4.  * Based on code from Jon Wtte, Denis Pelli, Apple, and a timely suggestion
  5.  * from Bo Lindbergh.  This code checks to see if the Cursor Device Manager (CDM)
  6.  * is present.  If it is, it uses the CDM calls; otherwise, it directly jabs low memory,
  7.  * in the traditional manner.
  8.  *
  9.  * Also included is glue for all of the CDM routines.  On the PowerPC, the CDM glue is
  10.  * currently (11/95) missing from InterfaceLib.  Since InterfaceLib is a shared library, you can't
  11.  * assume the glue will be present on a target machine.  So this code includes
  12.  * its own glue, the construction of which is thanks to a helpful suggestion from Bo Lindbergh.
  13.  *
  14.  * For documentation of the CDM, see Apple Tech Note "HW 01 - ADB (The Untold Story: Space Aliens
  15.  * ate my mouse)".
  16.  *
  17. * - Dan Sears (sears@netcom.com)
  18.  
  19.  * From Apple Developer Services:
  20.  *
  21.  * In the past, moving the cursor programatically on the Macintosh has
  22.  * entailed the manipulation of low memory globals. This has worked for
  23.  * all macs for quite some time. But with the advent of the power book
  24.  * series and many 3rd party track balls, it has become apparent that the
  25.  * low memory globals no longer contained adequate information for the
  26.  * system to truly support all types of positioning devices. So, with the
  27.  * new Centris CPU's, and CPU's from all lines after we are implementing a
  28.  * new tool set that provides a much more comprehensive set of utilities
  29.  * for dealing with the cursor location and mouse button state. We call
  30.  * this new manager the Cursor Device Manager, and DTS will be documenting
  31.  * it in a future tech not, but since many machines are now shipping that
  32.  * do not use the traditional low memory globals to get the mouse location
  33.  * and position the mouse, it is important to "leak" a little of the tech
  34.  * note information early.
  35.  *
  36.  * First, the CDM (Cursor device manager) has its own trap ($AADB) and you
  37.  * can determine if a machine supports the CDM by using the standard TrapAvailable
  38.  * routine. (See inside mac for the source code to Trap
  39.  * Available). Once you have determined that the CDM exists, you should
  40.  * try not to use the low memory globals RawMouse and MTemp to get the
  41.  * current cursor location, or set a new cursor location. Instead the CDM
  42.  * provides 3 calls which you can use to get this info, the first is
  43.  * CrsrDevNextDevice which will give you the next cursor device record in
  44.  * the CDM list, if you pass it a NULL, it will give you the head of the
  45.  * list. Once you have the first cursor device you can use it to get the
  46.  * Cursor data record which contains the current cursor location in its
  47.  * where field. You can set the current location with either the
  48.  * CrsrDevMove (which moves relative to the current location) or the
  49.  * CrsrDevMoveTo (which moves to an absolute location) routines.
  50.  *
  51.  * The following is some sample code which implement some generic routines
  52.  * that work on all macintoshes. These routines are written not for speed
  53.  * but for clarity, so if you are writing a device driver or time critical
  54.  * code there are some things that you can do to speed up these routines,
  55.  * like predetermine at the outset if the CDM exists, this way you
  56.  * wouldn't have to check every time you want to use it, and getting the
  57.  * cursor device only once and keeping the pointer to it around between
  58.  * calls.
  59.  *
  60.  * HISTORY:
  61.  * 8/94 dgp Downloaded from ftp://nada.kth.se/pub/hacks/mac-faq/MoveMouse.c
  62.  * 10/94 dgp made minimal changes so that it would compile in CodeWarrior C. Untested.
  63.  * 12/94 dgp updated for compatibility with Universal Header "CursorDevices.h". Untested.
  64.  * 1/5/95 dgp updated for compatiblity with Universal Headers 2, in which 
  65.  * CursorDevices.h was extensively changed. Untested.
  66.  * 6/26/95 dgp cosmetic changes. Still untested.
  67.  * 11/10/95 cbs Added missing InterfaceLib glue
  68. 11/13/95 dgp renamed glue routines from "glueCallCursorDevice..." to "CallCursorDevice..."
  69. 11/13/95 dgp renamed glue routines from "glueCallCursorDevice..." to "CallCursorDevice..."
  70.  */
  71.  
  72. #if UNIVERSAL_HEADERS<2
  73.     #error "Compiling this file requires a reasonably recent (1995 or later) copy of CursorDevices.h"
  74. #endif
  75. #ifndef __CURSORDEVICES__
  76.     #include <CursorDevices.h>
  77. #endif
  78. #ifndef __TRAPS__
  79.     // this is much quicker than looking for and reading the Traps.h header file.
  80.     #define _CursorDeviceDispatch 0xAADB
  81.     #define _Unimplemented 0xA89F
  82. //    #include <Traps.h>
  83. #endif
  84.  
  85. /*
  86.  * Glue routines for the Cursor Device Manager
  87.  */
  88. OSErr    CallCursorDeviceMove(CursorDevicePtr ourDevice, long deltaX, long deltaY);
  89. OSErr    CallCursorDeviceMoveTo(CursorDevicePtr ourDevice, long absX, long absY);
  90. OSErr    CallCursorDeviceFlush(CursorDevicePtr ourDevice);
  91. OSErr    CallCursorDeviceButtons(CursorDevicePtr ourDevice, short buttons);
  92. OSErr    CallCursorDeviceButtonDown(CursorDevicePtr ourDevice);
  93. OSErr    CallCursorDeviceButtonUp(CursorDevicePtr ourDevice);
  94. OSErr    CallCursorDeviceButtonOp(CursorDevicePtr ourDevice, short buttonNumber, ButtonOpcode opcode, long data);
  95. OSErr    CallCursorDeviceSetButtons(CursorDevicePtr ourDevice, short numberOfButtons);
  96. OSErr    CallCursorDeviceSetAcceleration(CursorDevicePtr ourDevice, Fixed acceleration);
  97. OSErr    CallCursorDeviceDoubleTime(CursorDevicePtr ourDevice, long durationTicks);
  98. OSErr    CallCursorDeviceUnitsPerInch(CursorDevicePtr ourDevice, Fixed resolution);
  99. OSErr    CallCursorDeviceNextDevice(CursorDevicePtr *ourDevice);
  100. OSErr    CallCursorDeviceNewDevice(CursorDevicePtr *ourDevice);
  101. OSErr    CallCursorDeviceDisposeDevice(CursorDevicePtr ourDevice);
  102.  
  103. /*
  104.  * Low memory globals for the mouse
  105.  */
  106. #define xRawMouse    0x082C            // low memory global that has current mouse loc
  107. #define xMTemp        0x0828            // low memory global that has current mouse loc
  108. #define xCrsrNew    0x08CE            // set after you change mtemp and rawmouse
  109. #define xCrsrCouple    0x08CF            // true if the cursor is tied to the mouse
  110.  
  111. void        GetMouseDevicePosition(Point *currentPoint);
  112. void        SetMouseDevicePosition(Point newPoint);
  113. void        SetMouseDevicePositionRel(Point newPoint);
  114. Boolean        IsCDMAvailable(void);
  115.  
  116. #if GENERATINGPOWERPC
  117. enum {
  118.     glueUppCursorDeviceMoveProcInfo =
  119.         kD0DispatchedPascalStackBased |
  120.         DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kTwoByteCode) |
  121.         RESULT_SIZE(SIZE_CODE(sizeof (OSErr))) |
  122.         DISPATCHED_STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof (CursorDevicePtr))) |
  123.         DISPATCHED_STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof (long))) |
  124.         DISPATCHED_STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof (long))),
  125.     glueUppCursorDeviceMoveToProcInfo =
  126.         kD0DispatchedPascalStackBased |
  127.         DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kTwoByteCode) |
  128.         RESULT_SIZE(SIZE_CODE(sizeof (OSErr))) |
  129.         DISPATCHED_STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof (CursorDevicePtr))) |
  130.         DISPATCHED_STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof (long))) |
  131.         DISPATCHED_STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof (long))),
  132.     glueUppCursorDeviceFlushProcInfo =
  133.         kD0DispatchedPascalStackBased |
  134.         DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kTwoByteCode) |
  135.         RESULT_SIZE(SIZE_CODE(sizeof (OSErr))) |
  136.         DISPATCHED_STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof (CursorDevicePtr))),
  137.     glueUppCursorDeviceButtonsProcInfo =
  138.         kD0DispatchedPascalStackBased |
  139.         DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kTwoByteCode) |
  140.         RESULT_SIZE(SIZE_CODE(sizeof (OSErr))) |
  141.         DISPATCHED_STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof (CursorDevicePtr))) |
  142.         DISPATCHED_STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof (short))),
  143.     glueUppCursorDeviceButtonDownProcInfo =
  144.         kD0DispatchedPascalStackBased |
  145.         DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kTwoByteCode) |
  146.         RESULT_SIZE(SIZE_CODE(sizeof (OSErr))) |
  147.         DISPATCHED_STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof (CursorDevicePtr))),
  148.     glueUppCursorDeviceButtonUpProcInfo =
  149.         kD0DispatchedPascalStackBased |
  150.         DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kTwoByteCode) |
  151.         RESULT_SIZE(SIZE_CODE(sizeof (OSErr))) |
  152.         DISPATCHED_STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof (CursorDevicePtr))),
  153.     glueUppCursorDeviceButtonOpProcInfo =
  154.         kD0DispatchedPascalStackBased |
  155.         DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kTwoByteCode) |
  156.         RESULT_SIZE(SIZE_CODE(sizeof (OSErr))) |
  157.         DISPATCHED_STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof (CursorDevicePtr))) |
  158.         DISPATCHED_STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof (short))) |
  159.         DISPATCHED_STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof (ButtonOpcode))) |
  160.         DISPATCHED_STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof (long))),
  161.     glueUppCursorDeviceSetButtonsProcInfo =
  162.         kD0DispatchedPascalStackBased |
  163.         DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kTwoByteCode) |
  164.         RESULT_SIZE(SIZE_CODE(sizeof (OSErr))) |
  165.         DISPATCHED_STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof (CursorDevicePtr))) |
  166.         DISPATCHED_STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof (short))),
  167.     glueUppCursorDeviceSetAccelerationProcInfo =
  168.         kD0DispatchedPascalStackBased |
  169.         DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kTwoByteCode) |
  170.         RESULT_SIZE(SIZE_CODE(sizeof (OSErr))) |
  171.         DISPATCHED_STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof (CursorDevicePtr))) |
  172.         DISPATCHED_STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof (Fixed))),
  173.     glueUppCursorDeviceDoubleTimeProcInfo =
  174.         kD0DispatchedPascalStackBased |
  175.         DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kTwoByteCode) |
  176.         RESULT_SIZE(SIZE_CODE(sizeof (OSErr))) |
  177.         DISPATCHED_STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof (CursorDevicePtr))) |
  178.         DISPATCHED_STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof (long))),
  179.     glueUppCursorDeviceUnitsPerInchProcInfo =
  180.         kD0DispatchedPascalStackBased |
  181.         DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kTwoByteCode) |
  182.         RESULT_SIZE(SIZE_CODE(sizeof (OSErr))) |
  183.         DISPATCHED_STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof (CursorDevicePtr))) |
  184.         DISPATCHED_STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof (Fixed))),
  185.     glueUppCursorDeviceNextDeviceProcInfo =
  186.         kD0DispatchedPascalStackBased |
  187.         DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kTwoByteCode) |
  188.         RESULT_SIZE(SIZE_CODE(sizeof (OSErr))) |
  189.         DISPATCHED_STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof (CursorDevicePtr *))),
  190.     glueUppCursorDeviceNewDeviceProcInfo =
  191.         kD0DispatchedPascalStackBased |
  192.         DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kTwoByteCode) |
  193.         RESULT_SIZE(SIZE_CODE(sizeof (OSErr))) |
  194.         DISPATCHED_STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof (CursorDevicePtr *))),
  195.     glueUppCursorDeviceDisposeDeviceProcInfo =
  196.         kD0DispatchedPascalStackBased |
  197.         DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kTwoByteCode) |
  198.         RESULT_SIZE(SIZE_CODE(sizeof (OSErr))) |
  199.         DISPATCHED_STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof (CursorDevicePtr)))
  200. };
  201. #endif
  202.  
  203. #if !GENERATINGPOWERPC
  204.     pascal void CallCursorTask(void)
  205.         = {
  206.             0x2078,0x08EE,            // MOVE.L jCrsrTask,A0
  207.             0x4E90                    // JSR (A0)
  208.         };
  209. #endif
  210.  
  211. void
  212. GetMouseDevicePosition(
  213.     Point *currentPoint)
  214. {
  215.     CursorDevice *firstMouse;
  216.     long delay;
  217.  
  218.     if (IsCDMAvailable()) {
  219.         firstMouse = NULL;                                // start at head of cursor dev list
  220.         CallCursorDeviceNextDevice(&firstMouse);        // get the next cursor device
  221.         Delay(1, &delay);                                // why is this necessary?! cbs
  222.         *currentPoint = firstMouse->whichCursor->where;
  223.     } else
  224.         *currentPoint = *(Point *) xRawMouse;            // use the low memory global
  225. }
  226.  
  227. void
  228. SetMouseDevicePosition(
  229.     Point newPoint)
  230. {
  231.     CursorDevice *firstMouse;
  232.  
  233.     if (IsCDMAvailable()) {
  234.         firstMouse = NULL;
  235.         CallCursorDeviceNextDevice(&firstMouse);
  236.         CallCursorDeviceMoveTo(firstMouse, (long) newPoint.h, (long) newPoint.v);
  237.     } else {
  238.         *(Point *) xRawMouse = newPoint;
  239.         *(Point *) xMTemp = newPoint;
  240.         *(Ptr) xCrsrNew = *(Ptr) xCrsrCouple;            // Set CrsrNew if coupled
  241. #if !GENERATINGPOWERPC
  242.         CallCursorTask();                                // must call jCrsrTask to update system
  243. #endif
  244.     }
  245. }
  246.  
  247. void
  248. SetMouseDevicePositionRel(
  249.     Point newPoint)
  250. {
  251.     CursorDevice *firstMouse;
  252.     Point tempPt;
  253.  
  254.     if (IsCDMAvailable()) {
  255.         firstMouse = NULL;
  256.         CallCursorDeviceNextDevice(&firstMouse);
  257.         CallCursorDeviceMove(firstMouse, (long) newPoint.h,  (long) newPoint.v);
  258.     } else {
  259.         tempPt = *(Point *) xRawMouse;
  260.         tempPt.h += newPoint.h;
  261.         tempPt.v += newPoint.v;
  262.         *(Point *) xRawMouse = tempPt;
  263.         *(Point *) xMTemp = tempPt;
  264.         *(Ptr) xCrsrNew = *(Ptr) xCrsrCouple;
  265. #if !GENERATINGPOWERPC
  266.         CallCursorTask();
  267. #endif
  268.     }
  269. }
  270.  
  271. Boolean IsCDMAvailable(void)
  272. {
  273.     return NGetTrapAddress(_CursorDeviceDispatch, ToolTrap)
  274.         != NGetTrapAddress(_Unimplemented, ToolTrap);
  275. }
  276.  
  277. OSErr CallCursorDeviceMove(
  278.     CursorDevicePtr ourDevice,
  279.     long deltaX,
  280.     long deltaY)
  281. {
  282. #if GENERATINGPOWERPC
  283.     return CallUniversalProc(
  284.         GetToolboxTrapAddress(_CursorDeviceDispatch),
  285.         glueUppCursorDeviceMoveToProcInfo,
  286.         0, ourDevice, deltaX, deltaY);
  287. #else
  288.     return CursorDeviceMove(ourDevice, deltaX, deltaY);
  289. #endif
  290. }
  291.  
  292. OSErr
  293. CallCursorDeviceMoveTo(
  294.     CursorDevicePtr ourDevice,
  295.     long absX,
  296.     long absY)
  297. {
  298. #if GENERATINGPOWERPC
  299.     return CallUniversalProc(
  300.         GetToolboxTrapAddress(_CursorDeviceDispatch),
  301.         glueUppCursorDeviceMoveToProcInfo,
  302.         1, ourDevice, absX, absY);
  303. #else
  304.     return CursorDeviceMoveTo(ourDevice, absX, absY);
  305. #endif
  306. }
  307.  
  308. OSErr
  309. CallCursorDeviceFlush(
  310.     CursorDevicePtr ourDevice)
  311. {
  312. #if GENERATINGPOWERPC
  313.     return CallUniversalProc(
  314.         GetToolboxTrapAddress(_CursorDeviceDispatch),
  315.         glueUppCursorDeviceFlushProcInfo,
  316.         0x2, ourDevice);
  317. #else
  318.     return CursorDeviceFlush(ourDevice);
  319. #endif
  320. }
  321.  
  322. OSErr
  323. CallCursorDeviceButtons(
  324.     CursorDevicePtr ourDevice,
  325.     short buttons)
  326. {
  327. #if GENERATINGPOWERPC
  328.     return CallUniversalProc(
  329.         GetToolboxTrapAddress(_CursorDeviceDispatch),
  330.         glueUppCursorDeviceButtonsProcInfo,
  331.         0x3, ourDevice, buttons);
  332. #else
  333.     return CursorDeviceButtons(ourDevice, buttons);
  334. #endif
  335. }
  336.  
  337. OSErr
  338. CallCursorDeviceButtonDown(
  339.     CursorDevicePtr ourDevice)
  340. {
  341. #if GENERATINGPOWERPC
  342.     return CallUniversalProc(
  343.         GetToolboxTrapAddress(_CursorDeviceDispatch),
  344.         glueUppCursorDeviceButtonDownProcInfo,
  345.         0x4, ourDevice);
  346. #else
  347.     return CursorDeviceButtonDown(ourDevice);
  348. #endif
  349. }
  350.  
  351. OSErr
  352. CallCursorDeviceButtonUp(
  353.     CursorDevicePtr ourDevice)
  354. {
  355. #if GENERATINGPOWERPC
  356.     return CallUniversalProc(
  357.         GetToolboxTrapAddress(_CursorDeviceDispatch),
  358.         glueUppCursorDeviceButtonUpProcInfo,
  359.         0x5, ourDevice);
  360. #else
  361.     return CursorDeviceButtonUp(ourDevice);
  362. #endif
  363. }
  364.  
  365. OSErr
  366. CallCursorDeviceButtonOp(
  367.     CursorDevicePtr ourDevice,
  368.     short buttonNumber,
  369.     ButtonOpcode opcode,
  370.     long data)
  371. {
  372. #if GENERATINGPOWERPC
  373.     return CallUniversalProc(
  374.         GetToolboxTrapAddress(_CursorDeviceDispatch),
  375.         glueUppCursorDeviceButtonOpProcInfo,
  376.         0x6, ourDevice, buttonNumber, opcode, data);
  377. #else
  378.     return CursorDeviceButtonOp(ourDevice, buttonNumber, opcode, data);
  379. #endif
  380. }
  381.  
  382. OSErr
  383. CallCursorDeviceSetButtons(
  384.     CursorDevicePtr ourDevice,
  385.     short numberOfButtons)
  386. {
  387. #if GENERATINGPOWERPC
  388.     return CallUniversalProc(
  389.         GetToolboxTrapAddress(_CursorDeviceDispatch),
  390.         glueUppCursorDeviceSetButtonsProcInfo,
  391.         0x7, ourDevice, numberOfButtons);
  392. #else
  393.     return CursorDeviceSetButtons(ourDevice, numberOfButtons);
  394. #endif
  395. }
  396.  
  397. OSErr
  398. CallCursorDeviceSetAcceleration(
  399.     CursorDevicePtr ourDevice,
  400.     Fixed acceleration)
  401. {
  402. #if GENERATINGPOWERPC
  403.     return CallUniversalProc(
  404.         GetToolboxTrapAddress(_CursorDeviceDispatch),
  405.         glueUppCursorDeviceSetAccelerationProcInfo,
  406.         0x8, ourDevice, acceleration);
  407. #else
  408.     return CursorDeviceSetAcceleration(ourDevice, acceleration);
  409. #endif
  410. }
  411.  
  412. OSErr
  413. CallCursorDeviceDoubleTime(
  414.     CursorDevicePtr ourDevice,
  415.     long durationTicks)
  416. {
  417. #if GENERATINGPOWERPC
  418.     return CallUniversalProc(
  419.         GetToolboxTrapAddress(_CursorDeviceDispatch),
  420.         glueUppCursorDeviceDoubleTimeProcInfo,
  421.         0x9, ourDevice, durationTicks);
  422. #else
  423.     return CursorDeviceDoubleTime(ourDevice, durationTicks);
  424. #endif
  425. }
  426.  
  427. OSErr
  428. CallCursorDeviceUnitsPerInch(
  429.     CursorDevicePtr ourDevice,
  430.     Fixed resolution)
  431. {
  432. #if GENERATINGPOWERPC
  433.     return CallUniversalProc(
  434.         GetToolboxTrapAddress(_CursorDeviceDispatch),
  435.         glueUppCursorDeviceUnitsPerInchProcInfo,
  436.         0xA, ourDevice, resolution);
  437. #else
  438.     return CursorDeviceUnitsPerInch(ourDevice, resolution);
  439. #endif
  440. }
  441.  
  442. OSErr
  443. CallCursorDeviceNextDevice(
  444.     CursorDevicePtr *ourDevice)
  445. {
  446. #if GENERATINGPOWERPC
  447.     return CallUniversalProc(
  448.         GetToolboxTrapAddress(_CursorDeviceDispatch),
  449.         glueUppCursorDeviceNextDeviceProcInfo,
  450.         0xB, ourDevice);
  451. #else
  452.     return CursorDeviceNextDevice(ourDevice);
  453. #endif
  454. }
  455.  
  456. OSErr
  457. CallCursorDeviceNewDevice(
  458.     CursorDevicePtr *ourDevice)
  459. {
  460. #if GENERATINGPOWERPC
  461.     return CallUniversalProc(
  462.         GetToolboxTrapAddress(_CursorDeviceDispatch),
  463.         glueUppCursorDeviceNewDeviceProcInfo,
  464.         0xC, ourDevice);
  465. #else
  466.     return CursorDeviceNewDevice(ourDevice);
  467. #endif
  468. }
  469.  
  470. OSErr
  471. CallCursorDeviceDisposeDevice(
  472.     CursorDevicePtr ourDevice)
  473. {
  474. #if GENERATINGPOWERPC
  475.     return CallUniversalProc(
  476.         GetToolboxTrapAddress(_CursorDeviceDispatch),
  477.         glueUppCursorDeviceDisposeDeviceProcInfo,
  478.         0xD, ourDevice);
  479. #else
  480.     return CursorDeviceDisposeDevice(ourDevice);
  481. #endif
  482. }