Original author: Pierre Sarrazin. Preserve upstream GPLv3-or-later and file-specific notices. Source: http://sarrazip.com/dev/coco-planes-0.1.0.tar.gz Archive SHA-256: 29191e6ba225965caa637ee726e1189639dc7fcdf2b68310fb93fbffd56c9c52
21 lines
430 B
C
21 lines
430 B
C
#include "KeyState.h"
|
|
|
|
|
|
void
|
|
KeyState_init(KeyState *self, byte probeBit, BOOL testBit)
|
|
{
|
|
self->probeBit = probeBit;
|
|
self->testBit = testBit;
|
|
self->pressedPreviously = FALSE;
|
|
}
|
|
|
|
|
|
BOOL
|
|
KeyState_update(KeyState *self)
|
|
{
|
|
BOOL pressedNow = isKeyPressed(self->probeBit, self->testBit);
|
|
BOOL justPressed = (!self->pressedPreviously && pressedNow);
|
|
self->pressedPreviously = pressedNow;
|
|
return justPressed;
|
|
}
|