Visual keyboard only change state on keydown

This commit is contained in:
Joachim LF
2020-07-09 19:17:36 +02:00
parent ef8a4f9e7b
commit 4a5681576c

View File

@@ -50,6 +50,8 @@ constexpr static KeySDLKeyPair sKeyPairs[] = {
constexpr int sNumberOfKeyPairs = sizeof(sKeyPairs)/sizeof(KeySDLKeyPair);
static bool previousState = false;
State scan() {
// We need to tell SDL to get new state from the host OS
SDL_PumpEvents();
@@ -69,9 +71,13 @@ State scan() {
// Register a key for the mouse, if any
SDL_Point p;
Uint32 mouseState = SDL_GetMouseState(&p.x, &p.y);
if (mouseState & SDL_BUTTON(SDL_BUTTON_LEFT)) {
if (!(previousState) && mouseState & SDL_BUTTON(SDL_BUTTON_LEFT)){
Key k = Simulator::Layout::keyAt(&p);
state.setKey(k);
previousState = true;
}
if (!(mouseState & SDL_BUTTON(SDL_BUTTON_LEFT))) {
previousState = false;
}
#endif