2

I have a (very) small Pygame demo that behaves differently under Linux and OS X. The demo creates a 500x500 window then goes into a loop where it collects events. The "frame rate" is regulated at 5 fps using the Pygame Clock. When executed under OS X, event.get() never returns more than two queued mouse events per frame. When executed under Linux, event.get() returns many more events and is able to accurately track the mouse motion between frames.

EDIT: I have found some comments that suggest there may be issues with mouse events in SDL (which underlies Pygame) under OS X. This Pygame installation is using 1.2.14.

Does anyone know what I am doing wrong, or how I can get OS X to capture a similar richness of events between frames?

Here is the code:

import pygame
from pygame.locals import QUIT

pygame.init()
pygame.display.init()

display = pygame.display.set_mode((500,500))
clock = pygame.time.Clock()

done = False
while not done:
    clock.tick(5)
    events = pygame.event.get()
    if len(events) > 1:
        print len(events)
    for event in events:
        if event.type == pygame.locals.QUIT:
            done = True

Example outputs follow. These were captured on the same (dual-booted) machine.

OS X output (while moving the mouse around the window):

$ python pygameevent.py
2
2
2
2
2
2
2
3
2
2

Linux output (while moving the mouse around the window):

$ python pygameevent.py
18
14
21
15
12
15
19
24
23
21
18
3
10
cweb
  • 382
  • 2
  • 11
EricD
  • 171
  • 1
  • 6
  • Do you know what the extra events are? It could be that the only difference between the two is that your Linux OS is more perceive with mouse movements. See if this affects how a simple application works. – cweb Mar 17 '15 at 02:13

0 Answers0