dev: utilsconsole: merge c and cpp files

This commit is contained in:
Zy 2024-10-12 15:40:32 +02:00
parent 236cb9a780
commit 3f5e13b2f2
6 changed files with 21 additions and 73 deletions

View file

@ -2,11 +2,10 @@ extern "C" {
#include "mlx.h"
#include "3ds.h"
#include "mlx3ds.h"
#include "utilsconsole.h"
}
#include <iostream>
#include <string.h>
#include "utilsconsole.hpp"
#include "utilsconsole.hpp"
#include "firsk.xpm"
#include <sys/dirent.h>
#include <fcntl.h>

View file

@ -7,9 +7,9 @@
// TODO mlx_internal.cpp: embed uc_pause() and change to .c file
#include "utilsconsole.hpp"
extern "C" {
#include "utilsconsole.h"
#include "mlx_internal.h"
#include "3ds.h"

View file

@ -3,12 +3,15 @@
* by Zy
*/
#include "utilsconsole.hpp"
#include <3ds.h>
#include <iostream>
#include <stdarg.h>
#include <cstring>
extern "C" {
#include "utilsconsole.h"
#include <3ds.h>
#include <stdarg.h>
}
using namespace std;
int uc_menu(vector<s_uc_menu_element> &elements) {
static void *lastElements = NULL;
@ -71,6 +74,8 @@ int uc_menu(vector<s_uc_menu_element> &elements) {
return confirmed ? selected : -1;
}
extern "C" {
int uc_menu_quick(const char *str, ...) {
va_list arguments;
auto elements = vector<s_uc_menu_element>();
@ -106,3 +111,5 @@ char *uc_keyboard(const char *def)
swkbdInputText(&swkbd, buf, 1000);
return (buf);
}
}

View file

@ -1,42 +0,0 @@
/**
* utilsconsole_extern_c.cpp
* by Zy
*/
#include <iostream>
extern "C" {
#include "utilsconsole_extern_c.h"
#include <3ds.h>
#include <stdarg.h>
#include <string.h>
using namespace std;
void uc_pause(void) {
cout << "\e[0;2mPress (A) to continue...\e[0m" << endl;
while (aptMainLoop()) {
hidScanInput();
if (hidKeysDown() & KEY_A)
break;
gfxFlushBuffers();
}
}
char *uc_keyboard(const char *def)
{
char *buf;
SwkbdState swkbd;
buf = new char[1000];
if (!buf)
return (NULL);
swkbdInit(&swkbd, SWKBD_TYPE_NORMAL, 1, -1);
swkbdSetInitialText(&swkbd, def);
swkbdInputText(&swkbd, buf, 1000);
return (buf);
}
}