Skip to content

Commit

Permalink
Simulator: use SDL_GetTicks64()
Browse files Browse the repository at this point in the history
  • Loading branch information
KlausMu committed Dec 13, 2024
1 parent 3213cba commit 86feb77
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
7 changes: 3 additions & 4 deletions Platformio/hardware/windows_linux/keypad_gui/keypad_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include "../util_hal_windows_linux.h"

#include "key_map.h"

Expand All @@ -19,7 +18,7 @@ uint32_t KEY_HOLD_TIME = 500; // Keys are considered held after 500 ms
// The state to track a single key since the GUI is mouse based
ActiveKey activeKey = {' ', 0, GUI_KEY_IDLE};
guiKeyStates lastGUIKeyState = GUI_KEY_IDLE;
long long holdTimer;
Uint64 holdTimer;

// https://wrfranklin.org/Research/Short_Notes/pnpoly.html
int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy)
Expand Down Expand Up @@ -81,7 +80,7 @@ int event_filter(void *userdata, SDL_Event * event) {
activeKey.key = key.key;
activeKey.state = event->type == SDL_MOUSEBUTTONDOWN ? GUI_KEY_PRESSED : GUI_KEY_RELEASED;
activeKey.keyCode = key.id;
holdTimer = SDL_MOUSEBUTTONDOWN ? current_timestamp_hal_windowsLinux() : 0;
holdTimer = SDL_MOUSEBUTTONDOWN ? SDL_GetTicks64() : 0;
break;
}
}
Expand Down Expand Up @@ -168,7 +167,7 @@ KeyState pumpKeys() {
lastGUIKeyState = activeKey.state;

// If the key has been pressed long enough to be considered held, change the state
if (activeKey.state == GUI_KEY_PRESSED && (current_timestamp_hal_windowsLinux() - holdTimer) > KEY_HOLD_TIME) {
if (activeKey.state == GUI_KEY_PRESSED && (SDL_GetTicks64() - holdTimer) > KEY_HOLD_TIME) {
activeKey.state = GUI_KEY_HOLD;
}

Expand Down
10 changes: 0 additions & 10 deletions Platformio/hardware/windows_linux/util_hal_windows_linux.cpp

This file was deleted.

1 change: 0 additions & 1 deletion Platformio/hardware/windows_linux/util_hal_windows_linux.h

This file was deleted.

0 comments on commit 86feb77

Please sign in to comment.