Merge branch 'misc-fixes' into libretro

This commit is contained in:
刘皓 2025-05-10 10:48:49 -04:00
commit 3bceb56bd3
No known key found for this signature in database
GPG key ID: 7901753DB465B711
2 changed files with 8 additions and 6 deletions

View file

@ -32,6 +32,7 @@
#include <SDL_mouse.h>
#include <SDL_clipboard.h>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
@ -677,6 +678,8 @@ struct InputPrivate
/* Collective binding array */
std::vector<Binding*> bindings;
std::string clipboardText;
ButtonState stateArray[BUTTON_CODE_COUNT*2];
ButtonState *states;
@ -1493,11 +1496,10 @@ void Input::clearText()
const char *Input::getClipboardText()
{
// FIXME: this doesn't appear to be freed anywhere
const char *tx = SDL_GetClipboardText();
if (!tx)
throw Exception(Exception::SDLError, "Failed to get clipboard text: %s", SDL_GetError());
return tx;
p->clipboardText = tx;
SDL_free((void *)tx);
return p->clipboardText.c_str();
}
void Input::setClipboardText(const char *text)

View file

@ -41,7 +41,7 @@ int main(int argc, char **argv) {
return 3;
}
outputf << "#include <stddef.h>\n#include <stdint.h>\nextern const uint8_t " << arrayname << "[] = {";
outputf << "#ifndef MKXPZ_EMBEDTOOL_" << arrayname << "\n#define MKXPZ_EMBEDTOOL_" << arrayname << "\n#include <stddef.h>\n#include <stdint.h>\n#ifdef __cplusplus\nextern\n#endif /* __cplusplus */\nconst uint8_t " << arrayname << "[] = {";
uint64_t len = 0;
for (;;) {
@ -53,7 +53,7 @@ int main(int argc, char **argv) {
++len;
}
outputf << "};\nextern const size_t " << arrayname << "_len = " << len << "ULL;";
outputf << "};\n#ifdef __cplusplus\nextern\n#endif /* __cplusplus */\nconst size_t " << arrayname << "_len = " << len << "ULL;\n#endif /* MKXPZ_EMBEDTOOL_" << arrayname << " */\n";
return 0;
}