|
How do I completely skip Mouse Axes events? |
AleaInfinitus
Member #18,873
December 2020
|
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: 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
Member #3,861
September 2003
|
You should get the events as fast as possible and base your logic / drawing loops on timer events, not on mouse events. "Code is like shit - it only smells if it is not yours" |
Edgar Reynaldo
Major Reynaldo
May 2007
|
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)); }
My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
AleaInfinitus
Member #18,873
December 2020
|
My current loop layout looks like: 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
Member #10,824
March 2009
|
Put your sim logic in the switch case, under the timer event case...
---------------------------------------------------- |
RmBeer2
Member #16,660
April 2017
|
Anyone works, you just take the event and ignore it. 🌈🌈🌈 🌟 BlackRook WebSite (Only valid from my installer) 🌟 C/C++ 🌟 GNU/Linux 🌟 IceCream/Cornet 🌟 🌈🌈🌈 Rm Beer for Emperor 2021! Rm Beer for Ruinous Slave Drained 2022! Rm Beer for Traveler From The Future Warning Not To Enter In 2023! Rm Beer are building a travel machine for Go Back from 2023! Rm Beer in an apocalyptic world burning hordes of Zombies in 2024! |
|