import sys
import pygame

pygame.init()


clk = pygame.time.Clock()


if pygame.joystick.get_count() == 0:
    raise IOError()
joy = pygame.joystick.Joystick(0)
joy.init()


size = width, height = 600, 600
screen = pygame.display.set_mode(size)
pygame.display.set_caption()


frameRect = pygame.Rect((45, 45), (510, 510))


crosshair = pygame.surface.Surface((10, 10))
crosshair.fill(pygame.Color())
pygame.draw.circle(crosshair, pygame.Color(), (5,5), 5, 0)
crosshair.set_colorkey(pygame.Color(), pygame.RLEACCEL)
crosshair = crosshair.convert()


writer = pygame.font.Font(pygame.font.get_default_font(), 15)
buttons = {}
for b in range(joy.get_numbuttons()):
    buttons[b] = [
        writer.render(
            hex(b)[2:].upper(),
            1,
            pygame.Color(),
            pygame.Color()
        ).convert(),
        
        
        ((15*b)+45, 560)
    ]

while True:
    
    pygame.event.pump()
    for events in pygame.event.get():
        if events.type == pygame.QUIT:
            pygame.quit()
            sys.exit()

    
    screen.fill(pygame.Color())

    
    x = joy.get_axis(0)
    y = joy.get_axis(1)

    
    
    screen.blit(crosshair, ((x*250)+300-5, (y*250)+300-5))
    pygame.draw.rect(screen, pygame.Color(), frameRect, 1)

    
    for b in range(joy.get_numbuttons()):
        if joy.get_button(b):
            screen.blit(buttons[b][0], buttons[b][1])

    
    pygame.display.flip()
    clk.tick(40)