FabGL
ESP32 Display Controller and Graphics Library
codepages.h
Go to the documentation of this file.
1 /*
2  Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - <http://www.fabgl.com>
3  Copyright (c) 2019-2021 Fabrizio Di Vittorio.
4  All rights reserved.
5 
6 
7 * Please contact fdivitto2013@gmail.com if you need a commercial license.
8 
9 
10 * This library and related software is available under GPL v3. Feel free to use FabGL in free software and hardware:
11 
12  FabGL is free software: you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  FabGL is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with FabGL. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 
27 
28 #pragma once
29 
30 
39 #include "fabutils.h"
40 
41 
42 namespace fabgl {
43 
44 
45 
46 // associates virtual key to ASCII code
47 struct VirtualKeyToASCII {
48  VirtualKey vk;
49  uint8_t ASCII;
50 };
51 
52 
53 struct CodePage {
54  uint16_t codepage;
55  const VirtualKeyToASCII * convTable; // last item has vk = VK_NONE (ending marker)
56 };
57 
58 
59 extern const CodePage CodePage437;
60 extern const CodePage CodePage1252;
61 
62 
63 struct CodePages {
64  static int count() { return 2; }
65  static CodePage const * get(uint16_t codepage, CodePage const * defaultValue = &CodePage437) {
66  static const CodePage * codepages[] = { &CodePage437, &CodePage1252 };
67  for (int i = 0; i < sizeof(CodePage) / sizeof(CodePage*); ++i)
68  if (codepages[i]->codepage == codepage)
69  return codepages[i];
70  return defaultValue;
71  }
72 };
73 
74 
75 
90 int virtualKeyToASCII(VirtualKeyItem const & item, CodePage const * codepage);
91 
92 
93 
94 } // fabgl namespace
95 
VirtualKey
Represents each possible real or derived (SHIFT + real) key.
Definition: fabutils.h:1016
This file contains some utility classes and functions.
Definition: canvas.cpp:36