mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
Visual keyboard only change state on keydown
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user