mirror of
https://github.com/simple64/simple64.git
synced 2026-11-12 06:48:42 +01:00
update input qt
This commit is contained in:
1 parent
8a28b164da
commit
2109986981
4 files changed
+33
-6
No files matched your search
@@ -85,7 +85,8 @@ ControllerTab::ControllerTab(unsigned int controller, QSettings* settings, QSett
|
||||
|
||||
gamepadSelect->insertItem(0, "Auto");
|
||||
gamepadSelect->addItem("Keyboard");
|
||||
gamepadSelect->addItem("Emulate VRU");
|
||||
if (controller == 4)
|
||||
gamepadSelect->addItem("Emulate VRU");
|
||||
gamepadSelect->addItem("None");
|
||||
gamepadSelect->setCurrentText(controllerSettings->value("Controller" + QString::number(controller) + "/Gamepad").toString());
|
||||
connect(gamepadSelect, &QComboBox::currentTextChanged, [=](QString text) {
|
||||
|
||||
@@ -363,7 +363,7 @@ EXPORT void CALL SendVRUWord(uint16_t length, uint16_t *word, uint8_t lang)
|
||||
}
|
||||
else
|
||||
{
|
||||
words.append(encoded_string.toLower().toUtf8().constData());
|
||||
words.append(encoded_string.toLower());
|
||||
word_indexes.append(word_list_count);
|
||||
}
|
||||
}
|
||||
@@ -374,6 +374,7 @@ EXPORT void CALL SendVRUWord(uint16_t length, uint16_t *word, uint8_t lang)
|
||||
{
|
||||
words.append(value_list.at(i).toString().toLower());
|
||||
word_indexes.append(word_list_count);
|
||||
DebugMessage(M64MSG_VERBOSE, "word loaded: %s, index: %d", words.last().toUtf8().constData(), word_indexes.last());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,7 +388,7 @@ EXPORT void CALL SendVRUWord(uint16_t length, uint16_t *word, uint8_t lang)
|
||||
doc.setArray(array);
|
||||
if (recognizer)
|
||||
VoskFreeRecognizer(recognizer);
|
||||
recognizer = VoskNewRecognizer(model, (float)hardware_spec->freq, doc.toJson());
|
||||
recognizer = VoskNewRecognizer(model, (float)hardware_spec->freq, doc.toJson().constData());
|
||||
VoskSetAlternatives(recognizer, 3);
|
||||
}
|
||||
}
|
||||
@@ -426,6 +427,7 @@ EXPORT void CALL ClearVRUWords(uint8_t length)
|
||||
word_indexes.clear();
|
||||
if (recognizer)
|
||||
VoskFreeRecognizer(recognizer);
|
||||
DebugMessage(M64MSG_VERBOSE, "word list cleared");
|
||||
recognizer = nullptr;
|
||||
}
|
||||
|
||||
@@ -481,6 +483,7 @@ EXPORT void CALL ReadVRUResults(uint16_t *error_flags, uint16_t *num_results, ui
|
||||
*error_flags = 0x4000;
|
||||
match[0] = 0; // we match index 0, but mark the error flag saying we are really not sure
|
||||
found.append("0");
|
||||
DebugMessage(M64MSG_INFO, "heard a noise, but no word match");
|
||||
}
|
||||
|
||||
*num_results = found.size();
|
||||
@@ -684,6 +687,27 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
|
||||
if (controller[Control].control->Present == 0)
|
||||
return;
|
||||
|
||||
if (controller[Control].joystick && SDL_JoystickGetAttached(controller[Control].joystick) == SDL_FALSE)
|
||||
{
|
||||
for (int j = 0; j < SDL_NumJoysticks(); ++j)
|
||||
{
|
||||
if (controller[Control].device_path == SDL_JoystickPathForIndex(j))
|
||||
{
|
||||
if (SDL_IsGameController(j))
|
||||
{
|
||||
SDL_GameControllerClose(controller[Control].gamepad);
|
||||
controller[Control].gamepad = SDL_GameControllerOpen(j);
|
||||
controller[Control].joystick = SDL_GameControllerGetJoystick(controller[Control].gamepad);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_JoystickClose(controller[Control].joystick);
|
||||
controller[Control].joystick = SDL_JoystickOpen(j);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
setPak(Control);
|
||||
if (controller[Control].control->Type == CONT_TYPE_VRU)
|
||||
{
|
||||
@@ -738,8 +762,7 @@ static int setupVosk()
|
||||
|
||||
VoskSetLogLevel(-1);
|
||||
|
||||
QByteArray vruword_array(vruwords);
|
||||
QJsonDocument vruwordjson = QJsonDocument::fromJson(vruword_array);
|
||||
QJsonDocument vruwordjson = QJsonDocument::fromJson(vruwords.toUtf8());
|
||||
vruwordsobject = vruwordjson.object();
|
||||
|
||||
l_TalkingState = 0;
|
||||
@@ -867,6 +890,8 @@ EXPORT void CALL InitiateControllers(CONTROL_INFO ControlInfo)
|
||||
|
||||
if (controller[i].gamepad)
|
||||
controller[i].joystick = SDL_GameControllerGetJoystick(controller[i].gamepad);
|
||||
if (controller[i].joystick)
|
||||
controller[i].device_path = SDL_JoystickPath(controller[i].joystick);
|
||||
|
||||
controller[i].profile = gameControllerSettings->value("Controller" + QString::number(i + 1) + "/Profile").toString();
|
||||
if (!gameSettings->childGroups().contains(controller[i].profile))
|
||||
|
||||
@@ -9,6 +9,7 @@ typedef struct
|
||||
CONTROL *control; // pointer to CONTROL struct in Core library
|
||||
SDL_GameController *gamepad;
|
||||
SDL_Joystick *joystick;
|
||||
QString device_path;
|
||||
QString profile;
|
||||
int deadzone;
|
||||
int range;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#ifndef VRUWORDS_H
|
||||
#define VRUWORDS_H
|
||||
|
||||
const char * vruwords = "{\"03A50024000303CF00A80003036000EA\": [\"pikachu\"], \
|
||||
QString vruwords = "{\"03A50024000303CF00A80003036000EA\": [\"pikachu\"], \
|
||||
\"03A50045000303CF00A80003036000EA\": [\"pikachu\"], \
|
||||
\"03A50024000303C900450003036000EA\": [\"pikachu\"], \
|
||||
\"03A8018F000303CF00A80003036000EA\": [\"pikachu\"], \
|
||||
|
||||
Reference in new issue
Block a user