[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] BUG: virtual input mode seems all broken on my Vista machine on 1.8.0



I haven't tried pygame 1.7 and I haven't tried on other machines yet, but with pygame 1.8.0release on my vista machine, anytime the mouse is in virtual input mode (mouse grabbed and cursor hidden, or fullscreen and cursor hidden) mouse control gets screwy on my Vista machine (seems to get shoved to the screen edges a lot) - oddly enough though, the mouse doesn't get screwy until a key message is processed...

Attached is a test script - with it everything seems fine at first, until a key is pressed, then it goes bad. You can switch fullscreen, mouse grab and mouse visible with the f, g and m keys respectively to see that the screwiness is tied to cases where virtual mouse input is on.

I'm curious if this happens for anybody else, on other OS's, so if you try it out, please let me know if you see the same problems.

import pygame

print pygame.version.ver

grab_mouse = True
mouse_visible = False
full_screen = False

pygame.display.init()
screen = pygame.display.set_mode((640,480))

pygame.event.set_grab(grab_mouse)
pygame.mouse.set_visible(mouse_visible)

pygame.font.init()
def_font = pygame.font.Font(None, 24)

while 1:
    status_text = "grab (g to toggle): "
    if grab_mouse:
        status_text += "ON"
    else:
        status_text += "OFF"
    status_text += "  mouse (m to toggle): "
    if mouse_visible:
        status_text += "Visible"
    else:
        status_text += "Hidden"
    status_text += "  fullscreen (f to toggle): "
    if mouse_visible:
        status_text += "YES"
    else:
        status_text += "NO"
    text_surface = def_font.render(status_text, True, (128,196,255), (0,0,0))
    screen.blit(text_surface, (0,0))
    pygame.draw.circle(screen, (255,255,255), pygame.mouse.get_pos(), 2)
    for event in pygame.event.get():
            if event.type == pygame.KEYDOWN:
                if event.key == 27:
                    raise SystemExit
                if event.key == pygame.K_g:
                    grab_mouse = not grab_mouse
                    pygame.event.set_grab(grab_mouse)
                if event.key == pygame.K_m:
                    mouse_visible = not mouse_visible
                    pygame.mouse.set_visible(mouse_visible)
                if event.key == pygame.K_f:
                    full_screen = not full_screen
                    if full_screen:
                        screen = pygame.display.set_mode((640,480), pygame.FULLSCREEN)
                    else:
                        screen = pygame.display.set_mode((640,480))
                    
    pygame.display.update()