How do I completely skip Mouse Axes events?
AleaInfinitus

I'm making a circuit simulator, but I'm running into an issue with oscillator inconsistency. When the mouse is left alone, the oscillator is fairly stable, but when moving the mouse, Allegro starts pushing a bunch of Mouse Axes events into the event queue and causing the "speed" of the simulation to go way up.

This seems to completely destabilize the sim (for reasons beyond my understanding). Thus I tried skipping mouse axes events via:

#SelectExpand
1skip: 2al_wait_for_event(queue, &event); 3 4if(event.type == ALLEGRO_EVENT_MOUSE_AXES) { 5 goto skip; 6}

Checking for mouse axes events in the while loop did show that none were getting through, but the simulation was still speeding up. Anyone know why?

GullRaDriel

You should get the events as fast as possible and base your logic / drawing loops on timer events, not on mouse events.

Edgar Reynaldo

Here is a basic loop :

   while (!quit) {
      if (redraw) {
         //...
         al_flip_display();
         redraw = false;
      }
      do {
         ALLEGRO_EVENT ev;
         al_wait_for_event(queue , &ev);
         if (ev.type == EAGLE_EVENT_MOUSE_AXES) {continue;}
      } while (!al_is_event_queue_empty(queue));
   }

AleaInfinitus

My current loop layout looks like:

#SelectExpand
1while(1) { 2 al_wait_for_event(queue, &event); 3 4 switch(event.type) { 5 //buttons, clicks, etc. 6 } 7 8 sim_logic(); 9 10 if(redraw) { 11 //rendering 12 }

My sim logic is outside of the event switch, so I don't really know how else to make it rely on the timer exclusively, but I'll try Edgar's design.

Dizzy Egg

Put your sim logic in the switch case, under the timer event case...

RmBeer2

Anyone works, you just take the event and ignore it.

Thread #618330. Printed from Allegro.cc