So I tried the cgkit\wintab route.  Had some success, but still can't get
the dang pressure.  Below is the code I came up with if anyone wants to poke
at it  When ran, it prints stuff like:

<Packet btns:1 x:10937 y:2140> 0 0

With the last two values representing pressure.  Well, it's a start ;)

# pressure.py
import os
import pygame
from cgkit import wintab

pygame.init()

hwnd = 1024
os.environ["SDL_WINDOWID"] = str(hwnd)

def main():
    screen = pygame.display.set_mode((640, 480))
    background = pygame.surface.Surface(screen.get_size())
    background.fill(pygame.color.Color("Black"))
    screen.blit(background, (0,0))

    #--------------------------------------------
    # Creates a "Context" object:
    tablet = wintab.Context()
    tablet.open(hwnd, True)

    looping = True
    while looping:
        events = pygame.event.get()
        for event in events:
            if event.type == pygame.QUIT:
                # allow for exit:
                looping = False

        #--------------------------------------------
        # Get a tuple of range of packets captured: (first, last)
        packetExtents = tablet.queuePacketsEx()
        if packetExtents[1] is not None:
            # This is a sub-list of Packet objects:
            packets = tablet.packetsGet(packetExtents[1])
            # Get the last Packet object:
            packet = packets[-1]
            # Print packet info, and pressure data:
            print packet, packet.normalpressure, packet.tangentpressure

        pygame.display.flip()
    pygame.quit()

if __name__ == "__main__":
    main()

Reply via email to