CursorDevices.Glue.c

/*
    File:       CursorDevices.Glue.c
    
    Description:
 
    Author:     
 
    Copyright:  Copyright: © 1984-1999 by Apple Computer, Inc.
                all rights reserved.
    
    Disclaimer: You may incorporate this sample code into your applications without
                restriction, though the sample code has been provided "AS IS" and the
                responsibility for its operation is 100% yours.  However, what you are
                not permitted to do is to redistribute the source as "DSC Sample Code"
                after having made changes. If you're going to re-distribute the source,
                we require that you make it clear in the source that the code was
                descended from Apple Sample Code, but that you've made changes.
    
    Change History (most recent first):
 
*/
#include <MixedMode.h>
#include <CursorDevices.h>
#include <Patches.h>
 
#define RESULT_OFFSET(type) ((sizeof(type) == 1) ? 3 : ((sizeof(type) == 2) ? 1 : 0))
 
 
pascal OSErr CursorDeviceMove(CursorDevicePtr ourDevice, long deltaX, long deltaY)
{
    #ifdef applec
        #if sizeof(OSErr) > 4
            #error "Result types larger than 4 bytes are not supported."
        #endif
    #endif
    long    private_result;
 
    private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
        kD0DispatchedPascalStackBased
         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
         | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
         | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice)))
         | DISPATCHED_STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(deltaX)))
         | DISPATCHED_STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(deltaY))),
        0x00000000,
        ourDevice,
        deltaX,
        deltaY);
    return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
}
 
pascal OSErr CursorDeviceMoveTo(CursorDevicePtr ourDevice, long absX, long absY)
{
    #ifdef applec
        #if sizeof(OSErr) > 4
            #error "Result types larger than 4 bytes are not supported."
        #endif
    #endif
    long    private_result;
 
    private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
        kD0DispatchedPascalStackBased
         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
         | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
         | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice)))
         | DISPATCHED_STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(absX)))
         | DISPATCHED_STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(absY))),
        0x00000001,
        ourDevice,
        absX,
        absY);
    return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
}
 
pascal OSErr CursorDeviceFlush(CursorDevicePtr ourDevice)
{
    #ifdef applec
        #if sizeof(OSErr) > 4
            #error "Result types larger than 4 bytes are not supported."
        #endif
    #endif
    long    private_result;
 
    private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
        kD0DispatchedPascalStackBased
         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
         | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
         | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice))),
        0x00000002,
        ourDevice);
    return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
}
 
pascal OSErr CursorDeviceButtons(CursorDevicePtr ourDevice, short buttons)
{
    #ifdef applec
        #if sizeof(OSErr) > 4
            #error "Result types larger than 4 bytes are not supported."
        #endif
    #endif
    long    private_result;
 
    private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
        kD0DispatchedPascalStackBased
         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
         | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
         | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice)))
         | DISPATCHED_STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(buttons))),
        0x00000003,
        ourDevice,
        buttons);
    return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
}
 
pascal OSErr CursorDeviceButtonDown(CursorDevicePtr ourDevice)
{
    #ifdef applec
        #if sizeof(OSErr) > 4
            #error "Result types larger than 4 bytes are not supported."
        #endif
    #endif
    long    private_result;
 
    private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
        kD0DispatchedPascalStackBased
         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
         | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
         | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice))),
        0x00000004,
        ourDevice);
    return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
}
 
pascal OSErr CursorDeviceButtonUp(CursorDevicePtr ourDevice)
{
    #ifdef applec
        #if sizeof(OSErr) > 4
            #error "Result types larger than 4 bytes are not supported."
        #endif
    #endif
    long    private_result;
 
    private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
        kD0DispatchedPascalStackBased
         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
         | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
         | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice))),
        0x00000005,
        ourDevice);
    return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
}
 
pascal OSErr CursorDeviceButtonOp(CursorDevicePtr ourDevice, short buttonNumber, ButtonOpcode opcode, long data)
{
    #ifdef applec
        #if sizeof(OSErr) > 4
            #error "Result types larger than 4 bytes are not supported."
        #endif
    #endif
    long    private_result;
 
    private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
        kD0DispatchedPascalStackBased
         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
         | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
         | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice)))
         | DISPATCHED_STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(buttonNumber)))
         | DISPATCHED_STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(opcode)))
         | DISPATCHED_STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(data))),
        0x00000006,
        ourDevice,
        buttonNumber,
        opcode,
        data);
    return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
}
 
pascal OSErr CursorDeviceSetButtons(CursorDevicePtr ourDevice, short numberOfButtons)
{
    #ifdef applec
        #if sizeof(OSErr) > 4
            #error "Result types larger than 4 bytes are not supported."
        #endif
    #endif
    long    private_result;
 
    private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
        kD0DispatchedPascalStackBased
         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
         | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
         | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice)))
         | DISPATCHED_STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(numberOfButtons))),
        0x00000007,
        ourDevice,
        numberOfButtons);
    return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
}
 
pascal OSErr CursorDeviceSetAcceleration(CursorDevicePtr ourDevice, Fixed acceleration)
{
    #ifdef applec
        #if sizeof(OSErr) > 4
            #error "Result types larger than 4 bytes are not supported."
        #endif
    #endif
    long    private_result;
 
    private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
        kD0DispatchedPascalStackBased
         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
         | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
         | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice)))
         | DISPATCHED_STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(acceleration))),
        0x00000008,
        ourDevice,
        acceleration);
    return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
}
 
pascal OSErr CursorDeviceDoubleTime(CursorDevicePtr ourDevice, long durationTicks)
{
    #ifdef applec
        #if sizeof(OSErr) > 4
            #error "Result types larger than 4 bytes are not supported."
        #endif
    #endif
    long    private_result;
 
    private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
        kD0DispatchedPascalStackBased
         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
         | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
         | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice)))
         | DISPATCHED_STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(durationTicks))),
        0x00000009,
        ourDevice,
        durationTicks);
    return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
}
 
pascal OSErr CursorDeviceUnitsPerInch(CursorDevicePtr ourDevice, Fixed resolution)
{
    #ifdef applec
        #if sizeof(OSErr) > 4
            #error "Result types larger than 4 bytes are not supported."
        #endif
    #endif
    long    private_result;
 
    private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
        kD0DispatchedPascalStackBased
         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
         | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
         | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice)))
         | DISPATCHED_STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(resolution))),
        0x0000000A,
        ourDevice,
        resolution);
    return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
}
 
pascal OSErr CursorDeviceNextDevice(CursorDevicePtr *ourDevice)
{
    #ifdef applec
        #if sizeof(OSErr) > 4
            #error "Result types larger than 4 bytes are not supported."
        #endif
    #endif
    long    private_result;
 
    private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
        kD0DispatchedPascalStackBased
         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
         | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
         | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice))),
        0x0000000B,
        ourDevice);
    return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
}
 
pascal OSErr CursorDeviceNewDevice(CursorDevicePtr *ourDevice)
{
    #ifdef applec
        #if sizeof(OSErr) > 4
            #error "Result types larger than 4 bytes are not supported."
        #endif
    #endif
    long    private_result;
 
    private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
        kD0DispatchedPascalStackBased
         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
         | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
         | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice))),
        0x0000000C,
        ourDevice);
    return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
}
 
pascal OSErr CursorDeviceDisposeDevice(CursorDevicePtr ourDevice)
{
    #ifdef applec
        #if sizeof(OSErr) > 4
            #error "Result types larger than 4 bytes are not supported."
        #endif
    #endif
    long    private_result;
 
    private_result = CallUniversalProc((UniversalProcPtr)NGetTrapAddress(0xAADB, 1),
        kD0DispatchedPascalStackBased
         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
         | DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
         | DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ourDevice))),
        0x0000000D,
        ourDevice);
    return *(((OSErr*)&private_result) + RESULT_OFFSET(OSErr));
}