2020-05-24 15:30:55 -05:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#ifndef KEYBOARD_H
|
|
|
|
#define KEYBOARD_H
|
2022-02-19 10:17:40 -06:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
*
|
2020-05-24 15:30:55 -05:00
|
|
|
* Provides the keyboard interface. It converts incoming key codes to
|
|
|
|
* ASCII characters.
|
|
|
|
*
|
2022-02-19 13:56:55 -06:00
|
|
|
*//*
|
2022-02-19 10:17:40 -06:00
|
|
|
* Copyright (C) 2020-2022 Martin Whitaker.
|
2020-05-24 15:30:55 -05:00
|
|
|
*/
|
|
|
|
|
2022-02-19 10:17:40 -06:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
/**
|
2020-05-24 15:30:55 -05:00
|
|
|
* The Escape character.
|
|
|
|
*/
|
|
|
|
#define ESC 27
|
|
|
|
|
2022-02-19 10:17:40 -06:00
|
|
|
/**
|
2021-12-22 11:31:06 -06:00
|
|
|
* A set of supported keyboard types.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
KT_NONE = 0,
|
|
|
|
KT_LEGACY = 1,
|
|
|
|
KT_USB = 2
|
|
|
|
} keyboard_types_t;
|
|
|
|
|
2022-02-19 10:17:40 -06:00
|
|
|
/**
|
2021-12-22 11:31:06 -06:00
|
|
|
* The set of enabled keyboard types
|
|
|
|
*/
|
|
|
|
extern keyboard_types_t keyboard_types;
|
|
|
|
|
2022-02-19 10:17:40 -06:00
|
|
|
/**
|
2021-12-22 11:31:06 -06:00
|
|
|
* Initialises the keyboard interface.
|
|
|
|
*/
|
2022-04-17 16:46:17 -05:00
|
|
|
void keyboard_init(void);
|
2021-12-22 11:31:06 -06:00
|
|
|
|
2022-02-19 10:17:40 -06:00
|
|
|
/**
|
2020-05-24 15:30:55 -05:00
|
|
|
* Checks if a key has been pressed and returns the primary ASCII character
|
|
|
|
* corresponding to that key if so, otherwise returns the null character.
|
|
|
|
* F1 to F10 are mapped to the corresponding decimal digit (F10 -> 0). All
|
|
|
|
* other keys that don't have a corresponding ASCII character are ignored.
|
|
|
|
* Characters are only returned for key presses, not key releases. A US
|
|
|
|
* keyboard layout is assumed (because we can't easily do anything else).
|
|
|
|
*/
|
|
|
|
char get_key(void);
|
|
|
|
|
|
|
|
#endif // KEYBOARD_H
|