LS7-Emulator/src/keyboard.c

29 lines
964 B
C
Raw Normal View History

2024-11-29 03:18:05 +01:00
#include <stdint.h>
#include <SFML/Window.h>
extern uint8_t systemRegister;
2024-12-02 10:37:30 +01:00
extern uint8_t keyboardResult;
extern sfKeyCode currentKey;
2024-11-29 03:18:05 +01:00
2024-12-02 10:37:30 +01:00
const static sfKeyCode scanMatrix[48] = {
2024-12-05 11:45:31 +01:00
sfKeyNum1, sfKeyNum2, sfKeyNum3, sfKeyNum4, sfKeyNum5, sfKeyNum6, sfKeyNum7, sfKeyNum8,
sfKeyQ, sfKeyW, sfKeyE, sfKeyR, sfKeyT, sfKeyY, sfKeyU, sfKeyI,
sfKeyA, sfKeyS, sfKeyD, sfKeyF, sfKeyG, sfKeyH, sfKeyJ, sfKeyK,
sfKeyZ, sfKeyX, sfKeyC, sfKeyV, sfKeyB, sfKeyN, sfKeyM, sfKeyComma,
sfKeyNum9, sfKeyNum0, sfKeyL, sfKeyO, sfKeyP, sfKeyPeriod,sfKeyEnter, sfKeyBackspace,
sfKeyLShift,sfKeyLControl, sfKeyLAlt, sfKeySpace, sfKeyUp, sfKeyRight, sfKeyDown, sfKeyLeft,
2024-11-29 03:18:05 +01:00
};
2024-12-02 10:37:30 +01:00
void scanKeyboard(){
2024-12-05 11:45:31 +01:00
keyboardResult = 0;
for (int i = 0; i < 8; i++) {
if (currentKey == scanMatrix[i + (((systemRegister & 0x07) % 6) * 8)]){
keyboardResult |= (0x80 >> i);
}
}
keyboardResult ^= 0xFF;
2024-11-29 03:18:05 +01:00
}