- Treballant en el editor de templates

This commit is contained in:
2024-09-19 14:07:57 +02:00
parent ecd4f7d6b4
commit 241ae1bd8e
4 changed files with 144 additions and 42 deletions

View File

@@ -1,7 +1,7 @@
#include "jutil.h"
#include <string.h>
#include <ctype.h>
#include <SDL2/SDL.h>
namespace util
{
int stringToInt(const char *value, std::vector<const char*> strings, std::vector<int> values)
@@ -23,4 +23,14 @@ namespace util
if (a==nullptr || b==nullptr) return false;
return (strcmp(a,b)==0);
}
const uint8_t scancode_to_char(const uint8_t scancode)
{
if (scancode == SDL_SCANCODE_0 || scancode == SDL_SCANCODE_KP_0) return '0';
if (scancode >= SDL_SCANCODE_1 && scancode <= SDL_SCANCODE_9) return scancode+19;
if (scancode >= SDL_SCANCODE_KP_1 && scancode <= SDL_SCANCODE_KP_9) return scancode-40;
if (scancode >= SDL_SCANCODE_A && scancode <= SDL_SCANCODE_Z) return scancode+61;
//if (scancode == SDL_SCANCODE_MINUS) return '-';
return '-';
}
}