@CarbonEventHandler(kEventClassTablet, kEventTabletProximity)    
    @CarbonEventHandler(kEventClassTablet, kEventTabletPoint)    
    @CarbonEventHandler(kEventClassMouse, kEventMouseDragged)
    @CarbonEventHandler(kEventClassMouse, kEventMouseDown)
    @CarbonEventHandler(kEventClassMouse, kEventMouseUp)
    @CarbonEventHandler(kEventClassMouse, kEventMouseMoved)
    def _tablet_event(self, next_handler, ev, data):
        '''Process tablet event and return True if some event was processed.
        Return True if no tablet event found.
        '''
        event_type = ctypes.c_uint32()
        r = carbon.GetEventParameter(ev, kEventParamTabletEventType,
            typeUInt32, None,
            ctypes.sizeof(event_type), None,
            ctypes.byref(event_type))
        if r != noErr:
            return False

        if event_type.value == kEventTabletProximity:
            proximity_rec = TabletProximityRec()
            _oscheck(
                carbon.GetEventParameter(ev, kEventParamTabletProximityRec,
                    typeTabletProximityRec, None, 
                    ctypes.sizeof(proximity_rec), None, 
                    ctypes.byref(proximity_rec))
            )
            cursor = self._get_cursor(proximity_rec)
            if proximity_rec.enterProximity:
                self.dispatch_event('on_enter', cursor)
            else:
                self.dispatch_event('on_leave', cursor)
        elif event_type.value == kEventTabletPoint:
            point_rec = TabletPointRec()
            _oscheck(
            carbon.GetEventParameter(ev, kEventParamTabletPointRec,
                typeTabletPointRec, None,
                ctypes.sizeof(point_rec), None,
                ctypes.byref(point_rec))
            )
            #x = point_rec.absX
            #y = point_rec.absY
            x, y = self.window._get_mouse_position(ev)
            pressure = point_rec.pressure / float(0xffff)
            #point_rec.tiltX,
            #point_rec.tiltY,
            #point_rec.rotation,
            #point_rec.tangentialPressure,
            self.dispatch_event('on_motion', self._cursor, x, y, pressure, 
                0., 0.)

        carbon.CallNextEventHandler(next_handler, ev)
        return noErr
dataset/ETHPy150Open ardekantur/pyglet/pyglet/input/carbon_tablet.py/CarbonTabletCanvas._tablet_event/original