mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-20 21:43:12 -07:00
Add Rumble to GUI
This commit is contained in:
parent
3c2e9a0418
commit
042e02eb3e
5 changed files with 21 additions and 9 deletions
|
@ -73,6 +73,7 @@ class Controller : public QObject
|
|||
int GetDeviceID();
|
||||
QString GetName();
|
||||
ChiakiControllerState GetState();
|
||||
void SetRumble(uint8_t left, uint8_t right);
|
||||
|
||||
signals:
|
||||
void StateChanged();
|
||||
|
|
|
@ -92,13 +92,13 @@ class StreamSession : public QObject
|
|||
QMap<Qt::Key, int> key_map;
|
||||
|
||||
void PushAudioFrame(int16_t *buf, size_t samples_count);
|
||||
void Event(ChiakiEvent *event);
|
||||
#if CHIAKI_GUI_ENABLE_SETSU
|
||||
void HandleSetsuEvent(SetsuEvent *event);
|
||||
#endif
|
||||
|
||||
private slots:
|
||||
void InitAudio(unsigned int channels, unsigned int rate);
|
||||
void Event(ChiakiEvent *event);
|
||||
|
||||
public:
|
||||
explicit StreamSession(const StreamSessionConnectInfo &connect_info, QObject *parent = nullptr);
|
||||
|
|
|
@ -291,3 +291,12 @@ ChiakiControllerState Controller::GetState()
|
|||
#endif
|
||||
return state;
|
||||
}
|
||||
|
||||
void Controller::SetRumble(uint8_t left, uint8_t right)
|
||||
{
|
||||
#ifdef CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER
|
||||
if(!controller)
|
||||
return;
|
||||
SDL_GameControllerRumble(controller, (uint16_t)left << 8, (uint16_t)right << 8, 5000);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -313,13 +313,11 @@ void StreamSession::SendFeedbackState()
|
|||
ChiakiControllerState state;
|
||||
chiaki_controller_state_set_idle(&state);
|
||||
|
||||
#if CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER
|
||||
for(auto controller : controllers)
|
||||
{
|
||||
auto controller_state = controller->GetState();
|
||||
chiaki_controller_state_or(&state, &state, &controller_state);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CHIAKI_GUI_ENABLE_SETSU
|
||||
chiaki_controller_state_or(&state, &state, &setsu_state);
|
||||
|
@ -381,11 +379,15 @@ void StreamSession::Event(ChiakiEvent *event)
|
|||
case CHIAKI_EVENT_LOGIN_PIN_REQUEST:
|
||||
emit LoginPINRequested(event->login_pin_request.pin_incorrect);
|
||||
break;
|
||||
case CHIAKI_EVENT_RUMBLE:
|
||||
// TODO
|
||||
//CHIAKI_LOGD(GetChiakiLog(), "Rumble %#02x, %#02x, %#02x",
|
||||
// event->rumble.unknown, event->rumble.left, event->rumble.right);
|
||||
case CHIAKI_EVENT_RUMBLE: {
|
||||
uint8_t left = event->rumble.left;
|
||||
uint8_t right = event->rumble.right;
|
||||
QMetaObject::invokeMethod(this, [this, left, right]() {
|
||||
for(auto controller : controllers)
|
||||
controller->SetRumble(left, right);
|
||||
});
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -117,8 +117,8 @@ typedef struct chiaki_audio_stream_info_event_t
|
|||
typedef struct chiaki_rumble_event_t
|
||||
{
|
||||
uint8_t unknown;
|
||||
uint8_t left;
|
||||
uint8_t right;
|
||||
uint8_t left; // low-frequency
|
||||
uint8_t right; // high-frequency
|
||||
} ChiakiRumbleEvent;
|
||||
|
||||
typedef enum {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue