1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2016-2017 - Brad Parker
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <libretro.h>
#include <string/stdstring.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
#include <encodings/utf.h>
#include "menu_osk.h"
#include "../../input/input_driver.h"
static char *osk_grid[45] = {NULL};
static int osk_ptr = 0;
static enum osk_type osk_idx = OSK_LOWERCASE_LATIN;
#ifdef HAVE_LANGEXTRA
/* This file has a UTF8 BOM, we assume HAVE_LANGEXTRA is only enabled for compilers that can support this. */
#include "menu_osk_utf8_pages.h"
#else
/* Otherwise define some ascii-friendly pages. */
static const char *symbols_page1_grid[] = {
"1","2","3","4","5","6","7","8","9","0","Bksp",
"!","\"","#","$","%","&","'","*","(",")","Enter",
"+",",","-","~","/",":",";","=","<",">","Lower",
"?","@","[","\\","]","^","_","|","{","}","Next"};
static const char *uppercase_grid[] = {
"1","2","3","4","5","6","7","8","9","0","Bksp",
"Q","W","E","R","T","Y","U","I","O","P","Enter",
"A","S","D","F","G","H","J","K","L","+","Lower",
"Z","X","C","V","B","N","M"," ","_","/","Next"};
static const char *lowercase_grid[] = {
"1","2","3","4","5","6","7","8","9","0","Bksp",
"q","w","e","r","t","y","u","i","o","p","Enter",
"a","s","d","f","g","h","j","k","l","@","Upper",
"z","x","c","v","b","n","m"," ","-",".","Next"};
#endif
void menu_event_set_osk_idx(enum osk_type idx)
{
osk_idx = idx;
}
enum osk_type menu_event_get_osk_idx(void)
{
return osk_idx;
}
int menu_event_get_osk_ptr(void)
{
return osk_ptr;
}
void menu_event_set_osk_ptr(int i)
{
osk_ptr = i;
}
void menu_event_osk_append(int ptr)
{
if (ptr < 0)
return;
#ifdef HAVE_LANGEXTRA
if (string_is_equal(osk_grid[ptr],"\xe2\x87\xa6")) /* backspace character */
input_keyboard_event(true, '\x7f', '\x7f', 0, RETRO_DEVICE_KEYBOARD);
else if (string_is_equal(osk_grid[ptr],"\xe2\x8f\x8e")) /* return character */
input_keyboard_event(true, '\n', '\n', 0, RETRO_DEVICE_KEYBOARD);
else
if (string_is_equal(osk_grid[ptr],"\xe2\x87\xa7")) /* up arrow */
menu_event_set_osk_idx(OSK_UPPERCASE_LATIN);
else if (string_is_equal(osk_grid[ptr],"\xe2\x87\xa9")) /* down arrow */
menu_event_set_osk_idx(OSK_LOWERCASE_LATIN);
else if (string_is_equal(osk_grid[ptr],"\xe2\x8a\x95")) /* plus sign (next button) */
#else
if (string_is_equal(osk_grid[ptr], "Bksp"))
input_keyboard_event(true, '\x7f', '\x7f', 0, RETRO_DEVICE_KEYBOARD);
else if (string_is_equal(osk_grid[ptr], "Enter"))
input_keyboard_event(true, '\n', '\n', 0, RETRO_DEVICE_KEYBOARD);
else
if (string_is_equal(osk_grid[ptr], "Upper"))
menu_event_set_osk_idx(OSK_UPPERCASE_LATIN);
else if (string_is_equal(osk_grid[ptr], "Lower"))
menu_event_set_osk_idx(OSK_LOWERCASE_LATIN);
else if (string_is_equal(osk_grid[ptr], "Next"))
#endif
if (menu_event_get_osk_idx() < OSK_TYPE_LAST - 1)
menu_event_set_osk_idx((enum osk_type)(menu_event_get_osk_idx() + 1));
else
menu_event_set_osk_idx((enum osk_type)(OSK_TYPE_UNKNOWN + 1));
else
input_keyboard_line_append(osk_grid[ptr]);
}
void menu_event_osk_iterate(void)
{
switch (menu_event_get_osk_idx())
{
#ifdef HAVE_LANGEXTRA
case OSK_HIRAGANA_PAGE1:
memcpy(osk_grid, hiragana_page1_grid, sizeof(hiragana_page1_grid));
break;
case OSK_HIRAGANA_PAGE2:
memcpy(osk_grid, hiragana_page2_grid, sizeof(hiragana_page2_grid));
break;
case OSK_KATAKANA_PAGE1:
memcpy(osk_grid, katakana_page1_grid, sizeof(katakana_page1_grid));
break;
case OSK_KATAKANA_PAGE2:
memcpy(osk_grid, katakana_page2_grid, sizeof(katakana_page2_grid));
break;
#endif
case OSK_SYMBOLS_PAGE1:
memcpy(osk_grid, symbols_page1_grid, sizeof(uppercase_grid));
break;
case OSK_UPPERCASE_LATIN:
memcpy(osk_grid, uppercase_grid, sizeof(uppercase_grid));
break;
case OSK_LOWERCASE_LATIN:
default:
memcpy(osk_grid, lowercase_grid, sizeof(lowercase_grid));
break;
}
}
char** menu_event_get_osk_grid(void)
{
return osk_grid;
}
|