mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 07:59:42 +00:00
Remove unfinished translation files
This commit is contained in:
parent
561a4cd4bf
commit
85f46b9899
@ -57,7 +57,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TRANSLATE
|
||||
#include "../translation/translation_driver.h"
|
||||
#include "../translation_defines.h"
|
||||
#endif
|
||||
|
||||
#include "../frontend/frontend_driver.h"
|
||||
|
@ -148,7 +148,7 @@
|
||||
#ifdef HAVE_TRANSLATE
|
||||
#include <encodings/base64.h>
|
||||
#include <formats/rbmp.h>
|
||||
#include "translation/translation_driver.h"
|
||||
#include "translation_defines.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DISCORD
|
||||
|
@ -1,28 +0,0 @@
|
||||
#include "../translation_driver.h"
|
||||
|
||||
static void* translation_cached_google_init(const struct translation_driver_info *params)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void translation_cached_google_free(void* data)
|
||||
{
|
||||
}
|
||||
|
||||
static char* translation_cached_google_translate_text(void* data, const char* game_text)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
static char* translation_cached_google_translate_image(void* data, struct ocr_image_info image)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
const translation_driver_t translation_cached_google = {
|
||||
translation_cached_google_init,
|
||||
translation_cached_google_free,
|
||||
translation_cached_google_translate_text,
|
||||
translation_cached_google_translate_image,
|
||||
"cached_google"
|
||||
};
|
@ -1,23 +0,0 @@
|
||||
#include "../translation_driver.h"
|
||||
|
||||
static void* translation_null_init(const struct translation_driver_info *params)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void translation_null_free(void* data)
|
||||
{
|
||||
}
|
||||
|
||||
static char* translation_null_translate_text(const char* game_text)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
const translation_driver_t translation_null = {
|
||||
translation_null_init,
|
||||
translation_null_free,
|
||||
translation_null_translate_text,
|
||||
NULL,
|
||||
"null"
|
||||
};
|
@ -1,22 +0,0 @@
|
||||
#include "../ocr_driver.h"
|
||||
|
||||
static void* ocr_null_init(int game_character_set)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void ocr_null_free(void* data)
|
||||
{
|
||||
}
|
||||
|
||||
char* ocr_null_get_text(void* data, struct ocr_image_info image)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
const ocr_driver_t ocr_null = {
|
||||
ocr_null_init,
|
||||
ocr_null_free,
|
||||
ocr_null_get_text,
|
||||
"null"
|
||||
};
|
@ -1,76 +0,0 @@
|
||||
#include <libretro.h>
|
||||
|
||||
#include "../ocr_driver.h"
|
||||
#include "tesseract/wrapper/tess_get_text.h"
|
||||
|
||||
static void* ocr_tesseract_init(int game_character_set)
|
||||
{
|
||||
bool pass = false;
|
||||
char* lang_data_dir = NULL;
|
||||
const char* tess_char_set = NULL;
|
||||
|
||||
switch (game_character_set)
|
||||
{
|
||||
case RETRO_LANGUAGE_JAPANESE:
|
||||
tess_char_set = "jpn";
|
||||
break;
|
||||
|
||||
case RETRO_LANGUAGE_ENGLISH:
|
||||
tess_char_set = "eng";
|
||||
break;
|
||||
|
||||
case RETRO_LANGUAGE_SPANISH:
|
||||
tess_char_set = "spa";
|
||||
break;
|
||||
}
|
||||
|
||||
if (!tess_char_set)
|
||||
return NULL;
|
||||
|
||||
/* TODO: get lang data from system dir */
|
||||
pass = tess_init(lang_data_dir, tess_char_set);
|
||||
|
||||
/* data is unused by tesseract */
|
||||
if (pass)
|
||||
return (void*)32;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void ocr_tesseract_free(void* data)
|
||||
{
|
||||
}
|
||||
|
||||
char* ocr_tesseract_get_text(void* data, struct ocr_image_info image)
|
||||
{
|
||||
tess_image temp_image;
|
||||
|
||||
temp_image.width = image.width;
|
||||
temp_image.height = image.height;
|
||||
temp_image.data = image.data;
|
||||
|
||||
switch (image.pixel_format)
|
||||
{
|
||||
case RETRO_PIXEL_FORMAT_0RGB1555:
|
||||
case RETRO_PIXEL_FORMAT_RGB565:
|
||||
temp_image.bytes_per_pixel = 2;
|
||||
break
|
||||
|
||||
case RETRO_PIXEL_FORMAT_XRGB8888:
|
||||
temp_image.bytes_per_pixel = 4;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* unsupported format */
|
||||
return "";
|
||||
}
|
||||
|
||||
return tess_get_text(temp_image);
|
||||
}
|
||||
|
||||
const ocr_driver_t ocr_tesseract = {
|
||||
ocr_tesseract_init,
|
||||
ocr_tesseract_free,
|
||||
ocr_tesseract_get_text,
|
||||
"tesseract"
|
||||
};
|
@ -1,46 +0,0 @@
|
||||
#include <boolean.h>
|
||||
#include <tesseract/baseapi.h>
|
||||
#include "tess_get_text.h"
|
||||
|
||||
#define ERROR_BUFFER_LENGTH 1000
|
||||
|
||||
static tesseract::TessBaseAPI *api;
|
||||
static char* one_time_return_pointer = NULL;
|
||||
|
||||
char tess_last_error[ERROR_BUFFER_LENGTH];
|
||||
|
||||
bool tess_init(const char* lang_data_dir, const char* language)
|
||||
{
|
||||
api = new tesseract::TessBaseAPI();
|
||||
|
||||
snprintf(tess_last_error, ERROR_BUFFER_LENGTH, "No errors!\n");
|
||||
|
||||
if (api->Init(lang_data_dir, language))
|
||||
{
|
||||
snprintf(tess_last_error, ERROR_BUFFER_LENGTH,
|
||||
"Could not initialize tesseract.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void tess_deinit(void)
|
||||
{
|
||||
if (one_time_return_pointer)
|
||||
delete [] one_time_return_pointer;
|
||||
|
||||
if (api)
|
||||
api->End();
|
||||
}
|
||||
|
||||
char* tess_get_text(tess_image image)
|
||||
{
|
||||
if (one_time_return_pointer)
|
||||
delete [] one_time_return_pointer;
|
||||
|
||||
api->SetImage(image.data, image.width, image.height,
|
||||
image.bytes_per_pixel, image.width * image.bytes_per_pixel);
|
||||
one_time_return_pointer = api->GetUTF8Text();
|
||||
return one_time_return_pointer;
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
#ifndef TESS_GET_TEXT
|
||||
#define TESS_GET_TEXT
|
||||
|
||||
#include <boolean.h>
|
||||
#include <retro_common_api.h>
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
unsigned bytes_per_pixel;
|
||||
void* data;
|
||||
} tess_image;
|
||||
|
||||
/* if running in RetroArch language should be "eng" or "jpn" */
|
||||
bool tess_init(const char* lang_data_dir, const char* language);
|
||||
void tess_deinit(void);
|
||||
char* tess_get_text(tess_image image);
|
||||
|
||||
extern char tess_last_error[];
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
@ -1,57 +0,0 @@
|
||||
#include <string/stdstring.h>
|
||||
#include <libretro.h>
|
||||
|
||||
#include "ocr_driver.h"
|
||||
#include "../configuration.h"
|
||||
|
||||
static const ocr_driver_t *ocr_backends[] = {
|
||||
#ifdef HAVE_TESSERACT
|
||||
&ocr_tesseract,
|
||||
#endif
|
||||
&ocr_null,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const ocr_driver_t *current_ocr_backend = NULL;
|
||||
static void *ocr_data = NULL;
|
||||
|
||||
static const ocr_driver_t *ocr_find_backend(const char* ident)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; ocr_backends[i]; i++)
|
||||
{
|
||||
if (string_is_equal(ocr_backends[i]->ident, ident))
|
||||
return ocr_backends[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool ocr_driver_init(void)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
int game_char_set = RETRO_LANGUAGE_DUMMY;
|
||||
current_ocr_backend = ocr_find_backend(settings->arrays.ocr_driver);
|
||||
ocr_data = NULL;
|
||||
|
||||
/* TODO: get game language */
|
||||
|
||||
if (current_ocr_backend)
|
||||
ocr_data = (*current_ocr_backend->init)(game_char_set);
|
||||
return ocr_data != NULL;
|
||||
}
|
||||
|
||||
void ocr_driver_free(void)
|
||||
{
|
||||
if (current_ocr_backend && ocr_data)
|
||||
(*current_ocr_backend->free)(ocr_data);
|
||||
}
|
||||
|
||||
char* ocr_driver_get_text(struct ocr_image_info image)
|
||||
{
|
||||
char* image_string = NULL;
|
||||
if (current_ocr_backend && ocr_data)
|
||||
image_string = (*current_ocr_backend->get_text)(ocr_data, image);
|
||||
return image_string;
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
#ifndef __OCR_DRIVER__H
|
||||
#define __OCR_DRIVER__H
|
||||
|
||||
#include <boolean.h>
|
||||
#include <retro_common_api.h>
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
struct ocr_image_info
|
||||
{
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
unsigned pixel_format;
|
||||
void* data;
|
||||
};
|
||||
|
||||
typedef struct ocr_driver
|
||||
{
|
||||
void* (*init)(int game_character_set);
|
||||
void (*free)(void* data);
|
||||
|
||||
/* returned char pointers do not need to be freed but are 1 time use, they may be destroyed on the next call to get_text */
|
||||
char* (*get_text)(void* data, struct ocr_image_info image);
|
||||
|
||||
const char *ident;
|
||||
} ocr_driver_t;
|
||||
|
||||
#ifdef HAVE_TESSERACT
|
||||
extern const ocr_driver_t ocr_tesseract;
|
||||
#endif
|
||||
extern const ocr_driver_t ocr_null;
|
||||
|
||||
bool ocr_driver_init(void);
|
||||
void ocr_driver_free(void);
|
||||
|
||||
/* returned char pointers do not need to be freed but are 1 time use, they may be destroyed on the next call to ocr_driver_get_text */
|
||||
char* ocr_driver_get_text(struct ocr_image_info image);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
@ -1,67 +0,0 @@
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#include "translation_driver.h"
|
||||
#include "ocr_driver.h"
|
||||
#include "../configuration.h"
|
||||
|
||||
static const translation_driver_t *translation_backends[] = {
|
||||
&translation_cached_google,
|
||||
&ocr_null,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const translation_driver_t *current_translation_backend = NULL;
|
||||
static void *translation_data = NULL;
|
||||
|
||||
static const translation_driver_t *translation_find_backend(
|
||||
const char* ident)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; translation_backends[i]; i++)
|
||||
{
|
||||
if (string_is_equal(translation_backends[i]->ident, ident))
|
||||
return translation_backends[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool translation_driver_init(void)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (!settings)
|
||||
return false;
|
||||
|
||||
current_translation_backend = translation_find_backend(
|
||||
settings->arrays.translation_driver);
|
||||
translation_data = NULL;
|
||||
|
||||
if (current_translation_backend)
|
||||
translation_data = (*current_translation_backend->init)();
|
||||
return translation_data != NULL;
|
||||
}
|
||||
|
||||
void translation_driver_free(void)
|
||||
{
|
||||
if (current_translation_backend && translation_data)
|
||||
(*current_translation_backend->free)(translation_data);
|
||||
}
|
||||
|
||||
char* translation_driver_translate_image(struct ocr_image_info image)
|
||||
{
|
||||
char* translated_text = NULL;
|
||||
|
||||
if (current_translation_backend && translation_data)
|
||||
{
|
||||
if (current_translation_backend->translate_image)
|
||||
translated_text = (*current_translation_backend->translate_image)
|
||||
(translation_data, image);
|
||||
else
|
||||
translated_text = (*current_translation_backend->translate_text)
|
||||
(translation_data, ocr_driver_get_text(image));
|
||||
}
|
||||
|
||||
return translated_text;
|
||||
}
|
@ -1,21 +1,5 @@
|
||||
#ifndef __TRANSLATION_DRIVER__H
|
||||
#define __TRANSLATION_DRIVER__H
|
||||
|
||||
#include <boolean.h>
|
||||
#include <retro_common_api.h>
|
||||
|
||||
#include "ocr_driver.h"
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
enum translation_init_errors
|
||||
{
|
||||
TRANSLATION_INIT_SUCCESS = 0,
|
||||
TRANSLATION_INIT_UNSUPPORTED_DEVICE_LANGUAGE,
|
||||
TRANSLATION_INIT_UNSUPPORTED_GAME_LANGUAGE,
|
||||
TRANSLATION_INIT_UNKNOWN_DEVICE_LANGUAGE,
|
||||
TRANSLATION_INIT_UNKNOWN_GAME_LANGUAGE
|
||||
};
|
||||
#ifndef __TRANSLATION_DEFINES__H
|
||||
#define __TRANSLATION_DEFINES__H
|
||||
|
||||
enum translation_lang
|
||||
{
|
||||
@ -86,35 +70,4 @@ enum translation_lang
|
||||
TRANSLATION_LANG_LAST
|
||||
};
|
||||
|
||||
struct translation_driver_info
|
||||
{
|
||||
int device_language;
|
||||
int game_language;
|
||||
};
|
||||
|
||||
typedef struct translation_driver
|
||||
{
|
||||
void* (*init)(const struct translation_driver_info *params);
|
||||
void (*free)(void* data);
|
||||
|
||||
/* use translate_image if non NULL else run image through ocr driver then run translate_text */
|
||||
/* returned char pointers do not need to be freed but are 1 time use, they may be destroyed on the next call to translate_image/text */
|
||||
/* NOTE: translate_image is allowed to call the ocr driver itself if it wants */
|
||||
char* (*translate_text)(void* data, const char* game_text);
|
||||
char* (*translate_image)(void* data, struct ocr_image_info image);
|
||||
|
||||
const char *ident;
|
||||
} translation_driver_t;
|
||||
|
||||
extern const translation_driver_t translation_cached_google;
|
||||
extern const translation_driver_t translation_null;
|
||||
|
||||
bool translation_driver_init(void);
|
||||
void translation_driver_free(void);
|
||||
|
||||
/* returned char pointers do not need to be freed but are 1 time use, they may be destroyed on the next call to translation_driver_translate_image */
|
||||
char* translation_driver_translate_image(struct ocr_image_info image);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user