Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.
C++
fix(remoteplay): separate UI timers and wire color and DualSense paths
Veyra Goal Agentfbd9feb03e4b
diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.mdindex 59cb52a3..3c300770 100644--- a/THIRD_PARTY_NOTICES.md+++ b/THIRD_PARTY_NOTICES.md@@ -56,3 +56,6 @@ statically built using vcpkg. SDL provides DualSense and other controller devicesupport; Veyra maps its public gamepad API to Chiaki semantic input. No SDL audioor video playback path is used. Retained notices: `licenses/remoteplay/SDL3_NOTICES.txt`.This local integration has not been pushed or released.+# Remote Play controller additions (2026-09-12)++Veyra calls the pinned Chiaki orientation tracker API (AGPL-3.0-only with OpenSSL exception). DualSense SDL report offsets and 3 kHz stereo to four-channel haptic routing were checked against chiaki-ng gui/src/controllermanager.cpp and streamsession.cpp. Existing Chiaki and SDL license notices apply. No third-party binary was added.diff --git a/apps/veyra/ui/AppShell.cpp b/apps/veyra/ui/AppShell.cppindex 16745a8d..fe4a92d9 100644--- a/apps/veyra/ui/AppShell.cpp+++ b/apps/veyra/ui/AppShell.cpp@@ -57,7 +57,11 @@ HWND mainWindow=nullptr,video=nullptr,statusBar=nullptr,seekBar=nullptr,playbackveyra::ui::WorkspaceTransition transition;veyra::ui::GlassBackdrop backdrop;bool fullControls=true,menuOpen=false;ULONGLONG pointerTick=0,dashboardTick=0;void layout();-void endTransition(){transition.finish();KillTimer(mainWindow,2);if(video)RemovePropW(video,L"Veyra.ResizeDeferUntil");}+enum : UINT_PTR { TelemetryTimer=1, TransitionTimer=2, ControllerTimer=3 };+void startShellTimer(HWND window,UINT_PTR id,UINT interval){+ if(!SetTimer(window,id,interval,nullptr))veyra::log::error("ui-timer",std::format("start failed id={} error={}",id,GetLastError()));+}+void endTransition(){transition.finish();KillTimer(mainWindow,TransitionTimer);if(video)RemovePropW(video,L"Veyra.ResizeDeferUntil");}veyra::ui::ChromeLayout chromeLayout(int w,int h){using namespace veyra::ui;ChromeLayout target(w,h,uiState.mode==Mode::Professional,uiState.drawer,uiPreferences.inspectorWidth);if(!transition.running){if(target.pro&&uiState.diagnostics){target.viewHeight-=132;target.bottom-=132;}return target;}@@ -136,7 +140,7 @@ void switchMode(){const auto start=std::chrono::steady_clock::now();const auto before=engine.snapshot();const auto host=video;if(uiState.mode==veyra::ui::Mode::Daily){uiState.mode=veyra::ui::Mode::Professional;compareMode=uiState.preferredComparison;}else{uiState.mode=veyra::ui::Mode::Daily;engine.previewView({});uiState.preferredComparison=compareMode;compareMode=0;holdOriginal=false;if(GetCapture())ReleaseCapture();}- updateComparison();if(auto focused=GetFocus();focused&&IsChild(inspector,focused))SetFocus(GetDlgItem(mainWindow,ModeSwitch));SetWindowTextW(GetDlgItem(mainWindow,ModeSwitch),uiState.mode==veyra::ui::Mode::Daily?L"专业模式":L"返回日常模式");transition.start(uiState.mode==veyra::ui::Mode::Professional,GetTickCount64());if(full)endTransition();else{SetPropW(video,L"Veyra.ResizeDeferUntil",HANDLE(uintptr_t(GetTickCount64()+390)));SetTimer(mainWindow,2,16,nullptr);}layout();veyra::log::info("ui-transition",std::format("started target={} durationMs=240 from={}",uiState.mode==veyra::ui::Mode::Professional,transition.from));+ updateComparison();if(auto focused=GetFocus();focused&&IsChild(inspector,focused))SetFocus(GetDlgItem(mainWindow,ModeSwitch));SetWindowTextW(GetDlgItem(mainWindow,ModeSwitch),uiState.mode==veyra::ui::Mode::Daily?L"专业模式":L"返回日常模式");transition.start(uiState.mode==veyra::ui::Mode::Professional,GetTickCount64());if(full)endTransition();else{SetPropW(video,L"Veyra.ResizeDeferUntil",HANDLE(uintptr_t(GetTickCount64()+390)));startShellTimer(mainWindow,TransitionTimer,16);}layout();veyra::log::info("ui-transition",std::format("started target={} durationMs=240 from={}",uiState.mode==veyra::ui::Mode::Professional,transition.from));const auto after=engine.snapshot();veyra::log::info("ui-mode",std::format("professional={} hostSame={} sessionSame={} revisionSame={} positionBefore={} positionAfter={} commandMs={:.3f}",uiState.mode==veyra::ui::Mode::Professional,host==video,before.sessionId==after.sessionId,before.desired.revision==after.desired.revision,before.position,after.position,std::chrono::duration<double,std::milli>(std::chrono::steady_clock::now()-start).count()));}void layout(){@@ -259,7 +263,7 @@ for(int id:{Open,Capture,Recent,Master,Sr,ModeSwitch,WindowMin,WindowMax,WindowCSetPropW(GetDlgItem(hwnd,Open),L"veyra.tip",HANDLE(L"打开视频 / 图片 · Ctrl+O"));SetPropW(GetDlgItem(hwnd,Capture),L"veyra.tip",HANDLE(L"连接采集卡"));SetPropW(GetDlgItem(hwnd,Sr),L"veyra.tip",HANDLE(L"超分辨率 · 专业面板选择 DLSS / RTX 视频超分"));inspector=veyra::ui::createSettingsPanel(hwnd,engine,applySettings);liveStatusPanel=veyra::ui::createLiveStatusPanel(hwnd,engine);selectInspector(uiPreferences.inspector);refreshDailyPresets();SendDlgItemMessageW(hwnd,Volume,TBM_SETPOS,TRUE,LPARAM(uiPreferences.volume*100));veyra::ui::marked(GetDlgItem(hwnd,Play));SetPropW(video,L"veyra.tip",HANDLE(L"专业模式:滚轮缩放 · 中键拖动画面 · 右键恢复适应窗口。缩放不影响增强或保存尺寸。"));tooltips=CreateWindowExW(WS_EX_TOPMOST,TOOLTIPS_CLASSW,nullptr,WS_POPUP|TTS_ALWAYSTIP|TTS_NOPREFIX,0,0,0,0,hwnd,nullptr,GetModuleHandleW(nullptr),nullptr);SendMessageW(tooltips,TTM_SETMAXTIPWIDTH,0,360);EnumChildWindows(hwnd,[](HWND child,LPARAM context)->BOOL{auto tip=reinterpret_cast<HWND>(context);wchar_t cls[32]{};GetClassNameW(child,cls,32);if(child==video||_wcsicmp(cls,L"BUTTON")==0||_wcsicmp(cls,L"EDIT")==0||_wcsicmp(cls,L"COMBOBOX")==0){TOOLINFOW info{sizeof(info)};info.uFlags=TTF_IDISHWND|TTF_SUBCLASS;info.hwnd=GetAncestor(child,GA_ROOT);info.uId=UINT_PTR(child);info.lpszText=LPSTR_TEXTCALLBACKW;SendMessageW(tip,TTM_ADDTOOLW,0,LPARAM(&info));}return TRUE;},LPARAM(tooltips));-if(smokeSeconds>0)startTick=GetTickCount64();diagnosticPanel=veyra::ui::createTelemetryPanel(hwnd,engine);DragAcceptFiles(hwnd,TRUE);SetTimer(hwnd,1,100,nullptr);layout();return 0;}+if(smokeSeconds>0)startTick=GetTickCount64();diagnosticPanel=veyra::ui::createTelemetryPanel(hwnd,engine);DragAcceptFiles(hwnd,TRUE);startShellTimer(hwnd,TelemetryTimer,100);layout();return 0;}case WM_NCCALCSIZE:if(wp)return 0;break;case WM_NCACTIVATE:return DefWindowProcW(hwnd,msg,wp,-1);case WM_NCPAINT:return 0;@@ -320,7 +324,7 @@ case Split:compareMode=compareMode==2?0:2;updateComparison();break;case Reference:referenceBase=SendDlgItemMessageW(hwnd,Reference,CB_GETCURSEL,0,0)==1;updateComparison();break;case Settings:if(uiState.mode==veyra::ui::Mode::Daily)switchMode();selectInspector(0);break;#ifdef VEYRA_ENABLE_REMOTEPLAY-case RemotePlay:veyra::ui::showRemotePlayPanel(hwnd,[](veyra::source::RemotePlayConnectDesc desc){cancelProtection();if(!remoteController.start())veyra::log::warn("remoteplay-input","SDL gamepad initialization failed");SetTimer(mainWindow,2,8,nullptr);currentFile=L"remoteplay:";subtitles.clear();paused=false;engine.previewView({});engine.openRemotePlay(video,std::move(desc),options());SetWindowTextW(mainWindow,L"Veyra — PS5 Remote Play");layout();},[](std::string pin){engine.remotePlayLoginPin(std::move(pin));},[]{auto s=engine.snapshot();veyra::ui::RemotePlayPanelStatus result;+case RemotePlay:veyra::ui::showRemotePlayPanel(hwnd,[](veyra::source::RemotePlayConnectDesc desc){cancelProtection();if(!desc.request.viewOnly){if(!remoteController.start())veyra::log::warn("remoteplay-input","SDL gamepad initialization failed");startShellTimer(mainWindow,ControllerTimer,8);}else{KillTimer(mainWindow,ControllerTimer);remoteController.stop();}currentFile=L"remoteplay:";subtitles.clear();paused=false;engine.previewView({});engine.openRemotePlay(video,std::move(desc),options());SetWindowTextW(mainWindow,L"Veyra — PS5 Remote Play");layout();},[](std::string pin){engine.remotePlayLoginPin(std::move(pin));},[]{auto s=engine.snapshot();veyra::ui::RemotePlayPanelStatus result;result.active=s.remotePlay&&(s.running||s.transport==veyra::engine::TransportState::Opening||s.transport==veyra::engine::TransportState::Stopping);result.message=s.failed?s.status:s.remotePlay&&s.running?L"PS5 画面已进入播放。点击播放器窗口后手柄生效;关闭此面板不停止串流。":result.active?s.status:L"PS5 串流已停止,可以重新连接。";return result;},[]{engine.stop();});break;@@ -352,11 +356,11 @@ case WM_DPICHANGED:{case WM_TIMER:#ifdef VEYRA_ENABLE_REMOTEPLAY-if(wp==2){const auto state=engine.snapshot();if(state.remotePlay&&(state.running||state.transport==veyra::engine::TransportState::Opening)){engine.remotePlayController(remoteController.poll(GetForegroundWindow()==hwnd));}else{engine.remotePlayController({});remoteController.stop();KillTimer(hwnd,2);}return 0;}+if(wp==ControllerTimer){const auto state=engine.snapshot();if(state.remotePlay&&(state.running||state.transport==veyra::engine::TransportState::Opening)){const bool focused=GetForegroundWindow()==hwnd;engine.remotePlayController(remoteController.poll(focused));remoteController.feedback(engine.remotePlayFeedback(),focused);}else{engine.remotePlayController({});remoteController.stop();KillTimer(hwnd,ControllerTimer);}return 0;}#endif-{if(wp==2){transition.sample(GetTickCount64());if(!transition.running){endTransition();veyra::log::info("ui-transition","completed; final layout and swapchain resize released");}layout();return 0;}+{if(wp==TransitionTimer){transition.sample(GetTickCount64());if(!transition.running){endTransition();veyra::log::info("ui-transition","completed; final layout and swapchain resize released");}layout();return 0;}if(full&&fullControls&&!menuOpen&&!veyra::ui::popupSelectorOpen()&&!GetCapture()&&GetTickCount64()-pointerTick>1600){POINT p{};GetCursorPos(&p);ScreenToClient(hwnd,&p);RECT r{};GetClientRect(hwnd,&r);if(p.y<r.bottom-veyra::ui::dip(hwnd,88)||p.x<0||p.x>=r.right||p.y>=r.bottom){fullControls=false;layout();if(GetForegroundWindow()==hwnd)SetCursor(nullptr);veyra::log::info("ui-fullscreen","controls hidden; video and subtitles only");}}-if(closing){if(engine.idle()&&!exportJob.poll().active()){KillTimer(hwnd,1);DestroyWindow(hwnd);}return 0;}if(!autoInput.empty()){auto file=autoInput;autoInput.clear();openFile(file);startTick=GetTickCount64();}if(smokeControls&&startTick){const auto elapsed=GetTickCount64()-startTick;+if(closing){if(engine.idle()&&!exportJob.poll().active()){KillTimer(hwnd,TelemetryTimer);DestroyWindow(hwnd);}return 0;}if(!autoInput.empty()){auto file=autoInput;autoInput.clear();openFile(file);startTick=GetTickCount64();}if(smokeControls&&startTick){const auto elapsed=GetTickCount64()-startTick;if(smokeStep==0&&elapsed>2200){engine.pause(true);smokeStep=1;}if(smokeStep==1&&elapsed>2600){engine.seek(1.0);smokeStep=2;}if(smokeStep==2&&elapsed>3200){engine.pause(false);smokeStep=3;}@@ -366,7 +370,7 @@ if(smokeStep==4&&elapsed>5200&&GetEnvironmentVariableW(L"VEYRA_TEST_LARGE_IMAGE_const double submittedFps=s.submissionFps.value_or(0.0);const bool xessRate=s.applied.frameGenerationBackend==veyra::engine::FrameGenerationBackend::XeSS&&s.applied.multiplier>1;veyra::ui::setText(GetDlgItem(hwnd,FpsLabel),s.running&&!s.image&&s.transport==veyra::engine::TransportState::Playing&&!s.metrics.flow.rateWindowReady?std::wstring(L"帧率采样中"):std::format(L"{} {:.1f} fps",xessRate?L"SDK提交":L"处理产出",xessRate?s.metrics.flow.xessSdkSubmitFps:s.metrics.flow.outputCompletedFps));-auto text=s.capture?std::format(L"{}\r\n输入 {:.1f} / 已处理 {:.1f} / 显示提交 {:.1f}fps | 回调至Present返回p95 {:.1f}ms(非总延迟)| 丢弃 {} | 有效生成 {}",s.status,s.captureFps,s.fps,submittedFps,s.captureAgeP95Ms,s.captureDropped,s.generated):std::format(L"{}\r\n{:.1f} / {:.1f}秒 已处理 {:.1f}fps 提交迟到 {:+.1f}ms 源帧 {} / 有效生成 {}",s.status,s.position,s.duration,s.fps,s.lateMs,s.frames,s.generated);+auto text=s.remotePlay?std::format(L"{}\r\nPS5 接收 {:.1f} / 解码 {:.1f} / 处理 {:.1f} fps | 解码后跳过 {} | 入队丢弃 {}",s.status,s.remoteReceivedFps,s.remoteDecodedFps,s.fps,s.remotePlaySkipped,s.remoteIngressDropped):s.capture?std::format(L"{}\r\n输入 {:.1f} / 已处理 {:.1f} / 显示提交 {:.1f}fps | 回调至Present返回p95 {:.1f}ms(非总延迟)| 丢弃 {} | 有效生成 {}",s.status,s.captureFps,s.fps,submittedFps,s.captureAgeP95Ms,s.captureDropped,s.generated):std::format(L"{}\r\n{:.1f} / {:.1f}秒 已处理 {:.1f}fps 提交迟到 {:+.1f}ms 源帧 {} / 有效生成 {}",s.status,s.position,s.duration,s.fps,s.lateMs,s.frames,s.generated);if(smokeZoom&&startTick&&s.frames>0){const auto elapsed=GetTickCount64()-startTick;if(zoomStep==0&&elapsed>1300){if(uiState.mode==veyra::ui::Mode::Daily)switchMode();zoomBefore=s;RECT r{};GetWindowRect(video,&r);const LPARAM point=MAKELPARAM(r.left+(r.right-r.left)*7/10,r.top+(r.bottom-r.top)/2);if(smokeHover){SetFocus(GetDlgItem(hwnd,ModeSwitch));PostMessageW(hwnd,WM_MOUSEWHEEL,MAKEWPARAM(0,WHEEL_DELTA*3),point);hoverPostedTick=GetTickCount64();zoomStep=4;}else{SendMessageW(video,WM_MOUSEWHEEL,MAKEWPARAM(0,WHEEL_DELTA*3),point);zoomStep=std::abs(engine.previewView().zoom-1.728f)<.001f?1:-1;}}if(zoomStep==4&&GetTickCount64()-hoverPostedTick>150){zoomStep=std::abs(engine.previewView().zoom-1.728f)<.001f?1:-1;veyra::log::info("preview-hover-test",std::format("root-message routed={} focusIsButton={}",zoomStep==1,GetFocus()==GetDlgItem(hwnd,ModeSwitch)));}@@ -387,7 +391,7 @@ setText(GetDlgItem(hwnd,Mute),!s.audioAvailable?L"无音轨":s.muted?L"静音":LEnableWindow(seekBar,s.running&&!s.capture&&!s.image&&s.duration>0);ShowWindow(seekBar,(!full||fullControls)&&!s.capture&&!s.image&&!(showDiagnostics&&uiState.mode==veyra::ui::Mode::Professional&&!full)?SW_SHOW:SW_HIDE);EnableWindow(GetDlgItem(hwnd,Play),!currentFile.empty()&&!s.capture&&!s.image);EnableWindow(GetDlgItem(hwnd,Stop),s.running);setText(GetDlgItem(hwnd,MediaTitle),currentFile.empty()?L"尚未打开媒体":s.remotePlay?L"PS5 · LIVE":s.capture?L"采集卡 · LIVE":std::filesystem::path(currentFile).filename().wstring());auto stamp=[](double v){int seconds=std::max(0,int(v));return std::format(L"{:02}:{:02}:{:02}",seconds/3600,seconds/60%60,seconds%60);};-setText(GetDlgItem(hwnd,TimeLabel),s.capture?std::format(L"输入 {:.1f} fps{}",s.captureFps,s.captureHalfRate?L" · 60→30":s.applied.content==veyra::engine::ContentRate::Capture60To30?L" · 不适用":L""):s.image?L"静态图片":stamp(s.position)+L" / "+stamp(s.duration)+(s.transport==veyra::engine::TransportState::Opening?L" · 正在打开…":s.failed?L" · 发生错误,详见专业诊断":L""));+setText(GetDlgItem(hwnd,TimeLabel),s.remotePlay?(s.remoteRatesReady?std::format(L"接收 {:.1f} · 解码 {:.1f} fps",s.remoteReceivedFps,s.remoteDecodedFps):std::wstring(L"PS5 帧率采样中")):s.capture?std::format(L"输入 {:.1f} fps{}",s.captureFps,s.captureHalfRate?L" · 60→30":s.applied.content==veyra::engine::ContentRate::Capture60To30?L" · 不适用":L""):s.image?L"静态图片":stamp(s.position)+L" / "+stamp(s.duration)+(s.transport==veyra::engine::TransportState::Opening?L" · 正在打开…":s.failed?L" · 发生错误,详见专业诊断":L""));std::wstring metric=std::format(L"源帧处理 {:.1f} fps · 显示提交 {:.1f} fps · 有效生成 {}\n提交迟到 p95 {:.1f} ms · GPU / CPU 时间分别统计\n{}\n实际扫描率与光子延迟:未测",s.fps,submittedFps,s.generated,s.lateP95Ms,s.status);setText(metricLabel,metric);if(uiState.mode==Mode::Professional&&!full&&!transition.running&&GetTickCount64()-dashboardTick>=250){dashboardTick=GetTickCount64();RECT client{};GetClientRect(hwnd,&client);RECT dashboard{0,client.bottom-dip(hwnd,232),client.right,client.bottom};InvalidateRect(hwnd,&dashboard,FALSE);}exportJob.watching(preferWatching&&s.running&&s.transport==veyra::engine::TransportState::Playing);auto job=exportJob.poll();exportPanelStatus(job,!currentFile.empty()&&!s.capture&&!s.image&&s.frames>0&&!s.applying,s.running&&s.frames>0);setText(GetDlgItem(hwnd,JobProgress),job.message+std::format(L" {}% · 查看",int(job.progress*100)));ShowWindow(GetDlgItem(hwnd,JobProgress),job.state==veyra::engine::ExportState::Idle||full?SW_HIDE:SW_SHOW);@@ -442,7 +446,7 @@ if(smokeSeconds>0&&startTick&&GetTickCount64()-startTick>ULONGLONG(smokeSeconds)case WM_CLOSE:endTransition();if(!closing&&smokeSeconds<=0&&exportJob.poll().active()&&MessageBoxW(hwnd,L"导出尚未完成。取消导出并退出?\n选择“否”返回播放器继续导出。",L"退出 Veyra",MB_YESNO|MB_DEFBUTTON2|MB_ICONQUESTION)!=IDYES)return 0;if(!closing&&smokeSeconds<=0){auto snapshot=engine.snapshot();WINDOWPLACEMENT placement{sizeof(placement)};if(full)placement=windowPlacement;else GetWindowPlacement(hwnd,&placement);auto r=placement.rcNormalPosition;uiPreferences.width=MulDiv(r.right-r.left,96,veyra::ui::layoutDpi(hwnd));uiPreferences.height=MulDiv(r.bottom-r.top,96,veyra::ui::layoutDpi(hwnd));uiPreferences.x=r.left;uiPreferences.y=r.top;uiPreferences.positioned=true;uiPreferences.volume=snapshot.volume;uiPreferences.muted=snapshot.muted;uiPreferences.subtitles=uiState.subtitles;uiPreferences.subtitleSize=subtitlePixels;uiPreferences.inspector=uiState.inspector;const bool confirmed=snapshot.frames>0&&!snapshot.applying&&!snapshot.failed;if(!preferences.save(uiPreferences,haveSuccessful?&lastSuccessful:nullptr))veyra::log::warn("ui-preferences","preferences not saved; corrupt original preserved");}exportJob.cancel();closing=true;engine.stop();SetWindowTextW(statusBar,L"正在释放当前任务资源…");return 0;case WM_DESTROY:#ifdef VEYRA_ENABLE_REMOTEPLAY-remoteController.stop();KillTimer(hwnd,2);+remoteController.stop();KillTimer(hwnd,ControllerTimer);#endifbackdrop.detach();DeleteObject(font);DeleteObject(emptyFont);PostQuitMessage(resultCode);return 0;}return DefWindowProcW(hwnd,msg,wp,lp);}diff --git a/apps/veyra/ui/RemotePlayPanel.cpp b/apps/veyra/ui/RemotePlayPanel.cppindex 7703e492..512a778d 100644--- a/apps/veyra/ui/RemotePlayPanel.cpp+++ b/apps/veyra/ui/RemotePlayPanel.cpp@@ -11,7 +11,7 @@namespace veyra::ui {namespace {HWND window=nullptr;HFONT font=nullptr;-enum {Host=1,Account,PairPin,Quality,CodecChoice,Pair,Connect,Cancel,Scan,Wake,LoginPin,SendPin,StatusText,Help,Bitrate,Forget};+enum {Host=1,Account,PairPin,Quality,CodecChoice,Pair,Connect,Cancel,Scan,Wake,LoginPin,SendPin,StatusText,Help,Bitrate,Forget,ViewOnly};std::function<void(source::RemotePlayConnectDesc)> connect;std::function<void(std::string)> login;std::function<RemotePlayPanelStatus()> connectionStatus;std::function<void()> disconnect;bool watching=false;@@ -77,7 +77,7 @@ void arrange(){move(Quality,160,150,220,150);move(CodecChoice,392,150,160,150);move(Connect,160,199,180,36);move(Wake,352,199,200,36);move(LoginPin,160,250,180,28);move(SendPin,352,250,200,30);- move(Bitrate,160,295,180,180);move(Forget,352,295,80,32);move(Cancel,440,295,112,32);move(StatusText,20,341,530,64);move(Help,20,414,530,116);+ move(Bitrate,160,295,180,180);move(Forget,352,295,80,32);move(Cancel,440,295,112,32);move(StatusText,20,341,530,64);move(ViewOnly,20,408,530,28);move(Help,20,442,530,86);}LRESULT CALLBACK proc(HWND h,UINT msg,WPARAM wp,LPARAM lp){switch(msg){case WM_CREATE:{window=h;closing=false;font=makeFont(h);titleTheme(h);@@ -85,6 +85,7 @@ case WM_CREATE:{window=h;closing=false;font=makeFont(h);titleTheme(h);auto c=CreateWindowExW(0,cls,label,WS_CHILD|WS_VISIBLE|style,dip(h,x),dip(h,y),dip(h,w),dip(h,height),h,HMENU(INT_PTR(id)),GetModuleHandleW(nullptr),nullptr);SendMessageW(c,WM_SETFONT,WPARAM(font),TRUE);themeControl(c);return c;};+ add(L"BUTTON",L"仅观看(手柄连接 PS5;更改后需重新连接)",ViewOnly,BS_AUTOCHECKBOX|WS_TABSTOP);add(L"STATIC",L"PS5 地址",100,0,20,21,130,25);add(L"STATIC",L"PSN Account ID",101,0,20,65,130,25);add(L"STATIC",L"8 位配对码",102,0,20,109,130,25);add(L"STATIC",L"串流格式",103,0,20,153,130,25);add(L"STATIC",L"登录 PIN(可选)",104,0,20,253,135,25);add(L"STATIC",L"码率",105,0,20,298,130,25);add(L"COMBOBOX",L"",Host,CBS_DROPDOWN|CBS_AUTOHSCROLL|WS_TABSTOP);SendDlgItemMessageW(h,Host,CB_LIMITTEXT,253,0);@@ -111,7 +112,7 @@ case WM_COMMAND:switch(LOWORD(wp)){auto result=remoteplay::pairLocalPs5(host,account,pin,stop);SecureZeroMemory(pin.data(),pin.size());Outcome out;if(result.result.ok&&!stop.stop_requested()){remoteplay::NativeConnectRequest request;request.host=host;request.video=format;request.credentials=std::move(result.credentials);if(remoteplay::saveProfile(targetPath,request)){out.savedPath=targetPath;out.message=L"配对成功并已加密保存,可以连接。";}else out.message=L"配对成功,但保存失败。请检查目录权限后重试。";}else out.message=result.canceled||stop.stop_requested()?L"已取消配对":std::format(L"配对失败({}),检查 PS5 配对码、Account ID 与网络。",result.result.code);return out;});break;}- case Connect:{if(busy)break;auto saved=remoteplay::loadProfile(profilePath());auto host=ascii(Host);if(!saved||!remoteplay::validHost(host)){SetDlgItemTextW(h,StatusText,L"请先完成配对,并填写有效主机地址。");break;}saved->host=host;saved->video=video();if(!remoteplay::saveProfile(currentProfile,*saved)){SetDlgItemTextW(h,StatusText,L"保存连接设置失败,请检查目录权限。");break;}source::RemotePlayConnectDesc desc;desc.request=std::move(*saved);connect(std::move(desc));watching=true;EnableWindow(GetDlgItem(h,Cancel),TRUE);SetDlgItemTextW(h,StatusText,L"连接已开始。需要登录 PIN 时在下方提交。关闭面板不停止串流。");break;}+ case Connect:{if(busy)break;auto saved=remoteplay::loadProfile(profilePath());auto host=ascii(Host);if(!saved||!remoteplay::validHost(host)){SetDlgItemTextW(h,StatusText,L"请先完成配对,并填写有效主机地址。");break;}saved->host=host;saved->video=video();if(!remoteplay::saveProfile(currentProfile,*saved)){SetDlgItemTextW(h,StatusText,L"保存连接设置失败,请检查目录权限。");break;}source::RemotePlayConnectDesc desc;saved->viewOnly=IsDlgButtonChecked(h,ViewOnly)==BST_CHECKED;desc.request=std::move(*saved);connect(std::move(desc));watching=true;EnableWindow(GetDlgItem(h,Cancel),TRUE);SetDlgItemTextW(h,StatusText,L"连接已开始。需要登录 PIN 时在下方提交。关闭面板不停止串流。");break;}case Cancel:if(busy&&worker.joinable())worker.request_stop();else if(watching)disconnect();break;case Scan:launch([](std::stop_token stop){Outcome out;auto report=remoteplay::discoverLocalPs5(stop);for(const auto& line:report.diagnostics)veyra::log::info("remoteplay-discovery",line);out.hosts=std::move(report.hosts);out.message=stop.stop_requested()?L"已取消查找":out.hosts.empty()?(report.error?std::format(L"主机搜索发生错误({}),详情见日志;可手填 IP。",report.error):L"搜索完成,未收到 PS5 回应;可手填 IP,检查主机开机和局域网。"):L"已填入发现的 PS5 地址。多台主机可手工输入目标 IP。";return out;});break;case Wake:{if(busy)break;auto saved=remoteplay::loadProfile(profilePath());if(!saved){SetDlgItemTextW(h,StatusText,L"需要先配对才能唤醒。");break;}saved->host=ascii(Host);launch([request=std::move(*saved)](std::stop_token stop){Outcome out;if(stop.stop_requested()){out.message=L"已取消唤醒";return out;}auto r=remoteplay::wakeLocalPs5(request);out.message=r.ok?L"已发送唤醒请求,等待 PS5 启动后点击连接。":std::format(L"唤醒请求失败({})",r.code);return out;});break;}diff --git a/docs/REMOTEPLAY_REPAIR_PROGRESS_2026-09-12.md b/docs/REMOTEPLAY_REPAIR_PROGRESS_2026-09-12.mdnew file mode 100644index 00000000..70d4ccd6--- /dev/null+++ b/docs/REMOTEPLAY_REPAIR_PROGRESS_2026-09-12.md@@ -0,0 +1,32 @@+# PS5 目标模式施工进度++基线计划提交325b9e9,tag checkpoint/ps5-full-repair-2026-09-12。用户指定《羊蹄山之魂》实测。目标仍active,未发布。++## 节点一实现++- AppShell timer独立编号1/2/3:遥测、动画、手柄。endTransition不再关闭手柄;SetTimer失败记录。+- RemotePlaySessionSource真实AU/decoded计数及一秒速率窗口,UI分别显示接收/解码,窗口未满显示采样中。decoded mailbox覆盖与入队丢弃分开。+- SDL gyro(rad/s)/accel(g)、双指ID/位置/抬指;Chiaki orientation tracker用于姿态,finite/时间断点检查。当前仍为8ms状态采样,极短触点边沿、传感器时间序列与校准待继续收口。+- enable_dualsense启用,rumble/trigger/motion-reset/raw haptics回调经有界feedback到输入owner;SDL普通震动、DualSense扳机report和四通道触觉分别输出。3kHz双通道触觉重排为四通道(前两声道静音),SDL转换设备频率;仅唯一手柄和唯一四通道Wireless Controller/DualSense端点自动路由,缓存100ms。多设备映射、中文端点名和蓝牙能力仍待完善。+- PS5面板加入仅观看选项,重连生效;不读取电脑设备,不发有效输入,保留协议。主机账号与本地手柄能否共存仍待实机验证。+- PS5独立displayReferred709意图:保留码流BT709标记,使用理想黑位BT1886 EOTF进linear,再走原sRGB呈现。其他来源默认保持旧行为。依据libplacebo pl_transfer_from_av将BT709映射BT1886,明确EOTF != OETF:https://raw.githubusercontent.com/haasn/libplacebo/master/src/include/libplacebo/utils/libav_internal.h 。GPU数值通过不证明用户发灰已全部解决。++## 实际证据++所有日志在项目logs目录,单次测试不超过300秒。++- build-product.cmd:ps5-ui-input-build.log、ps5-full-input-build.log、ps5-controller-test-build.log通过。feedback首建漏ControllerFeedback前置声明失败;补齐后ps5-feedback-build-retry.log通过。+- scripts/remoteplay/test-ui.ps1:真实20次模式动画完成及20次全屏切换、面板两次开关及本地错误配对拒绝;ps5-controller-final-ui/。没有以空白UI测试冒充真实串流。+- run-short-test.ps1,30秒,boundary --virtual:真实SDL虚拟设备双指生命周期、sensor单位、失焦归零/rumble释放、feedback容量通过;ps5-controller-virtual.stdout.log。没有把虚拟输入发送给PS5。+- boundary默认及H264/H265 source回归通过:ps5-controller-boundary/source.stdout.log。+- native CTest69/69、0.48秒:ps5-controller-ctest.log。+- Yuy2ColorTests --remote-yuv:真实D3D12和Presenter读回,Limited/Full乘BT601/709灰阶/色块,最大误差1个8bit码值,present误差0,4/4通过;ps5-color-gpu2.stdout.log。原YUY2回归通过:ps5-existing-color-gpu.stdout.log。读回只在测试中。+- delivery通过47.45秒:logs/delivery/fb3cd22c85c9418ca7c2a37bb43e8e27/result.json,包含真实NR/NVOF/播放/导出。+- exe SHA256:750548CD479ADD7346E8D4BA683A579F8A843352F0545B48BDE23A618572961E。此后仅颜色测试夹具增加色块,产品exe未变。+- RemotePlay OFF增量23步通过:ps5-controller-off-build.log;命令脚本out/remoteplay/audit-20260911/build-off-check.cmd。++## 当前仍要完成++真实游戏反馈、仅观看主机直连、USB/蓝牙拔插与完整效果路由、gyro静止偏移校准、触摸短边沿与传感器事件采样、设备能力显示、同源视觉对照、暂停与网络恢复。不能声称全部手柄功能实机通过。用户已收到测试请求,需打开新测试版供测试;没有发布。++UI已通过但完整控制器仍需上述收口。后续修改不要基于本页把未验收项误标完成。外部SDK/runtime不入Git。diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex 12335bad..b2bf0056 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -1644,3 +1644,7 @@ FRUC候选bSkipWarp/延后重建/时间归零/首对预热均未通过新增rese## 2026-09-12 PS5颜色/UI/完整手柄排查与计划用户确认基本串流、USB和已测增强组合通过;新增发灰、专业状态/模式重绘及全屏手柄故障,要求完整gyro/触摸板与效果,不急发布。静态检查确认AppShell动画/手柄共用timer2及endTransition误停输入;PS5输入FPS仍读captureStats。颜色日志Limited/BT709显式信令,尚未确定发灰根因;核查BT709逆曲线→sRGB显示及范围/alpha链路。ControllerInput/Backend未接gyro/触点/反馈。详见 docs/REMOTEPLAY_COLOR_UI_CONTROLLER_REPAIR_PLAN_2026-09-12.md。仅文档,无产品修改/新实机测试/发布。++## 2026-09-12 目标模式施工节点一++用户已授权施工。timer/真实FPS、PS5显示曲线、sensor/touch/反馈与仅观看初步实现已构建,ON/OFF、69项native、SDL虚拟输入、20+20实际UI切换、GPU灰阶色块及完整delivery47.45秒通过。命令、真实失败、日志、哈希与剩余问题见 docs/REMOTEPLAY_REPAIR_PROGRESS_2026-09-12.md。完整实机、校准/事件与设备路由仍在继续,目标未完成,无发布。diff --git a/include/veyra/engine/EngineController.h b/include/veyra/engine/EngineController.hindex 4266d189..151f2ab8 100644--- a/include/veyra/engine/EngineController.h+++ b/include/veyra/engine/EngineController.h@@ -11,7 +11,7 @@#include "veyra/engine/PreviewView.h"#include "veyra/sink/CaptureAudioSession.h"namespace veyra::source { struct RemotePlayConnectDesc; class RemotePlaySessionSource; }-namespace veyra::remoteplay { struct ControllerState; }+namespace veyra::remoteplay { struct ControllerState;struct ControllerFeedback; }namespace veyra::sink { struct RgbaImage; }namespace veyra::gfx { class D3D12DeviceContext; class CommandSlotRing; }namespace veyra::engine {@@ -52,6 +52,7 @@ struct PlayerSnapshot {bool fgBudgetLimited=false,xessGenerationSuppressed=false;bool running=false,failed=false,image=false,capture=false,remotePlay=false;int remotePlayState=0; uint64_t remotePlaySkipped=0;+ double remoteReceivedFps=0,remoteDecodedFps=0;bool remoteRatesReady=false;uint64_t remoteReceived=0,remoteDecoded=0,remoteIngressDropped=0;};class EngineController {public:@@ -62,6 +63,7 @@ public:void open(HWND video,const std::wstring& path,PlayerOptions options);#ifdef VEYRA_ENABLE_REMOTEPLAYvoid openRemotePlay(HWND, source::RemotePlayConnectDesc, PlayerOptions);+ remoteplay::ControllerFeedback remotePlayFeedback();void remotePlayController(const remoteplay::ControllerState&);void remotePlayLoginPin(std::string);#endifdiff --git a/include/veyra/pipeline/ColorMetadata.h b/include/veyra/pipeline/ColorMetadata.hindex 1e43c71d..93da1c07 100644--- a/include/veyra/pipeline/ColorMetadata.h+++ b/include/veyra/pipeline/ColorMetadata.h@@ -44,4 +44,6 @@ inline ColorDescription resolveFrameColor(const AVFrame& frame,ColorDescriptionreturn c;}inline uint32_t transferCode(TransferFunction t){return t==TransferFunction::Linear?0u:t==TransferFunction::BT709?2u:1u;}+inline uint32_t workingTransferCode(const ColorDescription& c){return c.displayReferred709&&c.transfer==TransferFunction::BT709?3u:transferCode(c.transfer);}+}diff --git a/include/veyra/pipeline/FramePacket.h b/include/veyra/pipeline/FramePacket.hindex 1082dd00..9cc2f2a9 100644--- a/include/veyra/pipeline/FramePacket.h+++ b/include/veyra/pipeline/FramePacket.h@@ -88,6 +88,9 @@ struct ColorDescription {uint16_t rotationDegrees = 0; // 0 / 90 / 180 / 270SampleAspectRatio sar;+ // Display intent is separate from source VUI. PS5 SDR is displayed with+ // BT.1886 (ideal black), not inverse camera OETF, before sRGB presentation.+ bool displayReferred709 = false;bool rangeAssumed = false;bool matrixAssumed = false;bool transferAssumed = false;diff --git a/include/veyra/remoteplay/ChiakiBackend.h b/include/veyra/remoteplay/ChiakiBackend.hindex 1289cd3a..2ec734bc 100644--- a/include/veyra/remoteplay/ChiakiBackend.h+++ b/include/veyra/remoteplay/ChiakiBackend.h@@ -30,6 +30,7 @@ struct BackendResult {struct NativeConnectRequest {std::string host;VideoProfile video;+ bool viewOnly=false;PairingCredentials credentials;};struct NativeSnapshot {@@ -52,6 +53,7 @@ public:BackendResult submitController(const ControllerState&);BackendResult submitLoginPin(std::string_view);NativeSnapshot snapshot() const;+ ControllerFeedback takeFeedback();private:struct Impl;std::unique_ptr<Impl> p_;diff --git a/include/veyra/remoteplay/ControllerInput.h b/include/veyra/remoteplay/ControllerInput.hindex 227a2f88..1c386440 100644--- a/include/veyra/remoteplay/ControllerInput.h+++ b/include/veyra/remoteplay/ControllerInput.h@@ -1,18 +1,25 @@#pragma once#include "Types.h"struct SDL_Gamepad;+struct SDL_AudioStream;namespace veyra::remoteplay {// SDL calls stay on the Win32 UI owner, independently of GPU processing.class ControllerInput {public:~ControllerInput(){stop();}- bool start();+ bool start(uint32_t preferredDevice=0);void stop();ControllerState poll(bool focused);+ void feedback(ControllerFeedback,bool focused);+ void releaseEffects();bool connected()const{return gamepad_!=nullptr;}private:SDL_Gamepad* gamepad_=nullptr;bool initialized_=false;- HostTime enumerateAt_=0;+ HostTime enumerateAt_=0;uint32_t preferredDevice_=0;+ std::array<int8_t,2> touchIds_{-1,-1};uint8_t nextTouchId_=0;+ bool gyro_=false,accel_=false,effectsActive_=false,audioInitialized_=false,hapticAttempted_=false;+ SDL_AudioStream* hapticStream_=nullptr;+};}diff --git a/include/veyra/remoteplay/Types.h b/include/veyra/remoteplay/Types.hindex a0d4d206..3a03b1ed 100644--- a/include/veyra/remoteplay/Types.h+++ b/include/veyra/remoteplay/Types.h@@ -74,6 +74,20 @@ struct PcmBlock {std::size_t frames() const noexcept { return channels ? samples.size()/channels : 0; }bool valid() const noexcept;};+struct ControllerFeedback {+ bool rumble=false,triggers=false,motionReset=false;+ uint8_t left=0,right=0;+ std::array<uint8_t,11> leftTrigger{},rightTrigger{};+ std::vector<int16_t> haptics; // Stereo PCM 3kHz; hard cap 600 samples (100ms).+ void merge(ControllerFeedback next){+ if(next.rumble){rumble=true;left=next.left;right=next.right;}+ if(next.triggers){triggers=true;leftTrigger=next.leftTrigger;rightTrigger=next.rightTrigger;}+ motionReset|=next.motionReset;+ if(next.haptics.size()>600)next.haptics.resize(600);+ if(haptics.size()+next.haptics.size()>600)haptics.clear();+ haptics.insert(haptics.end(),next.haptics.begin(),next.haptics.end());+ }+};struct ControllerState {// Semantic buttons; translated explicitly to Chiaki in the native bridge.enum Button : std::uint32_t { Cross=1u<<0, Circle=1u<<1, Square=1u<<2, Triangle=1u<<3,@@ -82,6 +96,11 @@ struct ControllerState {std::uint32_t buttons = 0;std::int16_t leftX=0, leftY=0, rightX=0, rightY=0;std::uint8_t l2=0, r2=0;+ struct Touch {int8_t id=-1;uint16_t x=0,y=0;bool operator==(const Touch&)const=default;};+ std::array<Touch,2> touches{};+ // SDL coordinate frame: angular velocity rad/s, acceleration in g.+ std::array<float,3> gyro{},accel{0,1,0};+ uint64_t motionTimestampUs=0;bool motionValid=false;bool operator==(const ControllerState&) const = default;};} // namespace veyra::remoteplaydiff --git a/include/veyra/source/RemotePlaySessionSource.h b/include/veyra/source/RemotePlaySessionSource.hindex dce711ff..336ca640 100644--- a/include/veyra/source/RemotePlaySessionSource.h+++ b/include/veyra/source/RemotePlaySessionSource.h@@ -19,8 +19,11 @@ public:void close() noexcept override;void controller(remoteplay::ControllerState state);void loginPin(std::string pin);+ remoteplay::ControllerFeedback takeFeedback();remoteplay::SessionInbox::Snapshot sessionSnapshot() const;uint64_t skipped() const;+ struct Rates {uint64_t received=0,decoded=0,ingressDropped=0;double receivedFps=0,decodedFps=0;bool ready=false;};+ Rates rates() const;sink::CaptureAudioState audioState() const { return audio_.snapshot(); }void setAudioGain(float value) { audio_.setGain(value); }void setAudioSync(unsigned mode, int offset) { audio_.setSync(mode, offset); }@@ -43,6 +46,8 @@ private:remoteplay::HostTime controllerStamp_=0;std::string pin_;uint64_t skipped_=0;+ Rates rates_;+ remoteplay::ControllerFeedback feedback_;sink::CaptureAudioSession audio_;};}diff --git a/include/veyra/source/RemotePlaySource.h b/include/veyra/source/RemotePlaySource.hindex fb75d1e3..33479f34 100644--- a/include/veyra/source/RemotePlaySource.h+++ b/include/veyra/source/RemotePlaySource.h@@ -40,6 +40,7 @@ public:bool connect(const RemotePlayConnectDesc& desc);remoteplay::BackendResult submitController(const remoteplay::ControllerState& state) { return backend_.submitController(state); }remoteplay::BackendResult submitLoginPin(std::string_view pin) { return backend_.submitLoginPin(pin); }+ remoteplay::ControllerFeedback takeFeedback(){return backend_.takeFeedback();}bool connected() const noexcept { return connected_; }remoteplay::SessionInbox::Snapshot sessionSnapshot() const;diff --git a/scripts/remoteplay/test-ui.ps1 b/scripts/remoteplay/test-ui.ps1index 183d6e3f..cd5c3b3c 100644--- a/scripts/remoteplay/test-ui.ps1+++ b/scripts/remoteplay/test-ui.ps1@@ -29,7 +29,7 @@ $oldLog=$env:VEYRA_LOG_FILE$process=$nulltry {$env:VEYRA_LOG_FILE=Join-Path $OutputDirectory 'ui-app.log'- $process=Start-Process -FilePath $PlayerExe -ArgumentList @('--smoke-empty','--smoke-seconds','20','--no-nr','--no-sr','--no-fg') -PassThru -WindowStyle Hidden+ $process=Start-Process -FilePath $PlayerExe -ArgumentList @('--smoke-empty','--smoke-seconds','45','--no-nr','--no-sr','--no-fg') -PassThru -WindowStyle Hidden$deadline=[DateTime]::UtcNow.AddSeconds(8)do {$main=[RpUi]::Find($process.Id,'VeyraApp');if($main -eq [IntPtr]::Zero){Start-Sleep -Milliseconds 50}}while($main -eq [IntPtr]::Zero -and [DateTime]::UtcNow -lt $deadline)if($main -eq [IntPtr]::Zero){throw 'Veyra main window did not open'}@@ -57,6 +57,21 @@ try {Start-Sleep -Milliseconds 150if([RpUi]::Find($process.Id,'VeyraRemotePlaySetup') -ne [IntPtr]::Zero){throw 'Panel did not close'}}+ # Exercise the real mode animation in the RemotePlay-enabled executable.+ for($cycle=0;$cycle -lt 20;$cycle++){+ [RpUi]::PostMessage($main,0x111,[IntPtr]220,[IntPtr]::Zero)|Out-Null+ Start-Sleep -Milliseconds 310+ }+ $modeLog=Get-Content (Join-Path $OutputDirectory 'ui-app.log') -Raw+ if(([regex]::Matches($modeLog,'completed; final layout')).Count -lt 20){throw 'Mode animation timer did not complete all transitions'}+ for($cycle=0;$cycle -lt 20;$cycle++){+ $fullscreen=[RpUi]::GetDlgCtrlID([RpUi]::Button($main,'全屏 F11'))+ if($fullscreen -eq 0){$fullscreen=[RpUi]::GetDlgCtrlID([RpUi]::Button($main,'全屏'))}+ if($fullscreen -eq 0){$fullscreen=[RpUi]::GetDlgCtrlID([RpUi]::Button($main,'退出全屏'))}+ if($fullscreen -eq 0){throw 'Fullscreen button not found'}+ [RpUi]::PostMessage($main,0x111,[IntPtr]$fullscreen,[IntPtr]::Zero)|Out-Null+ Start-Sleep -Milliseconds 50+ }[RpUi]::PostMessage($main,0x10,[IntPtr]::Zero,[IntPtr]::Zero)|Out-Nullif(-not $process.WaitForExit(5000)){throw 'Owned UI test did not exit'}Write-Output 'REMOTEPLAY_UI_PASS entry=1 panel_open_close=2 invalid_pairing_rejected=1 PS5_CONNECTION_NOT_TESTED=1'diff --git a/shaders/RgbToLinear.hlsl b/shaders/RgbToLinear.hlslindex 8863a75f..e8a39039 100644--- a/shaders/RgbToLinear.hlsl+++ b/shaders/RgbToLinear.hlsl@@ -2,6 +2,7 @@ cbuffer RgbParams : register(b0) { uint width; uint height; uint transfer; uintTexture2D<float4> sourceRgb : register(t0);RWTexture2D<float4> linearRgb : register(u0);float decode(float v) {+ if(transfer==3)return pow(max(v,0),2.4);if (transfer == 2) return v < 0.081 ? v / 4.5 : pow((v + 0.099) / 1.099, 1.0 / 0.45);if (transfer == 0) return v;return v <= 0.04045 ? v / 12.92 : pow((v + 0.055) / 1.055, 2.4);diff --git a/shaders/YuvToLinearRgb.hlsl b/shaders/YuvToLinearRgb.hlslindex e0d53bd8..a2a744d2 100644--- a/shaders/YuvToLinearRgb.hlsl+++ b/shaders/YuvToLinearRgb.hlsl@@ -57,7 +57,9 @@ void main(uint3 dispatchThreadId : SV_DispatchThreadID)const float2 uv = chromaPlane[uint2(dispatchThreadId.x / 2, dispatchThreadId.y / 2)];float3 rgb = YuvToRgb(y, uv);rgb = saturate(rgb);- if (colorParams0.z > 1.5) {+ if (colorParams0.z > 2.5) {+ rgb = pow(rgb, 2.4); // BT.1886 EOTF, ideal black SDR display intent.+ } else if (colorParams0.z > 1.5) {rgb = float3(rgb.r < 0.081 ? rgb.r / 4.5 : pow((rgb.r + 0.099) / 1.099, 1.0/0.45),rgb.g < 0.081 ? rgb.g / 4.5 : pow((rgb.g + 0.099) / 1.099, 1.0/0.45),rgb.b < 0.081 ? rgb.b / 4.5 : pow((rgb.b + 0.099) / 1.099, 1.0/0.45));diff --git a/shaders/Yuy2ToLinear.hlsl b/shaders/Yuy2ToLinear.hlslindex 80c5a68e..89216df7 100644--- a/shaders/Yuy2ToLinear.hlsl+++ b/shaders/Yuy2ToLinear.hlsl@@ -8,6 +8,7 @@ Texture2D<float4> packedYuy2 : register(t0);RWTexture2D<float4> linearRgb : register(u0);float decode(float v) {if(transfer==0)return v;+ if(transfer==3)return pow(max(v,0),2.4);if(transfer==2)return v<0.081?v/4.5:pow((v+0.099)/1.099,1.0/0.45);return v<=0.04045?v/12.92:pow((v+0.055)/1.055,2.4);}diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cppindex 9909a9ab..6fdb96c0 100644--- a/src/engine/EngineController.cpp+++ b/src/engine/EngineController.cpp@@ -70,6 +70,7 @@ void EngineController::openRemotePlay(HWND window,source::RemotePlayConnectDesc{std::lock_guard lock(mutex_);snapshot_={};activeFlow_.reset();previewView_={};snapshot_.sessionId=++sessionId_;snapshot_.transport=TransportState::Opening;snapshot_.remotePlay=true;snapshot_.capture=true;savePath_.clear();desired_=opts.snapshot();desired_.revision=++nextRevision_;snapshot_.desired=desired_;opts=PlayerOptions::from(desired_);}post([this,window,request,opts]{paused_=false;seekSeconds_=-1;run(window,L"remoteplay:",opts,request);});}+remoteplay::ControllerFeedback EngineController::remotePlayFeedback(){std::lock_guard lock(mutex_);return activeRemote_?activeRemote_->takeFeedback():remoteplay::ControllerFeedback{};}void EngineController::remotePlayController(const remoteplay::ControllerState& state){std::lock_guard lock(mutex_);if(activeRemote_)activeRemote_->controller(state);}void EngineController::remotePlayLoginPin(std::string pin){std::lock_guard lock(mutex_);if(activeRemote_)activeRemote_->loginPin(std::move(pin));}#endif@@ -353,8 +354,8 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,sif(physicalCapture){const bool available=captureSource.setAudioGain(gain);const auto audioState=captureSource.audioState();std::lock_guard lock(mutex_);snapshot_.audioAvailable=available;snapshot_.captureAudio=audioState;}#ifdef VEYRA_ENABLE_REMOTEPLAYif(remote){remote->setAudioGain(gain);remote->setAudioSync(unsigned(options.settings.audioSync),options.settings.audioOffsetMs);- const auto state=remote->audioState();const auto session=remote->sessionSnapshot();- std::lock_guard lock(mutex_);snapshot_.audioAvailable=state.available;snapshot_.captureAudio=state;snapshot_.remotePlayState=int(session.state);snapshot_.remotePlaySkipped=remote->skipped();}+ const auto state=remote->audioState();const auto session=remote->sessionSnapshot();const auto rates=remote->rates();+ std::lock_guard lock(mutex_);snapshot_.audioAvailable=state.available;snapshot_.captureAudio=state;snapshot_.remotePlayState=int(session.state);snapshot_.remotePlaySkipped=remote->skipped();snapshot_.remoteReceivedFps=rates.receivedFps;snapshot_.remoteDecodedFps=rates.decodedFps;snapshot_.remoteRatesReady=rates.ready;snapshot_.remoteReceived=rates.received;snapshot_.remoteDecoded=rates.decoded;snapshot_.remoteIngressDropped=rates.ingressDropped;}#endif// Save the latest processed real frame before a settings transaction// invalidates it (live rendering can be one batch behind processing).diff --git a/src/pipeline/EnhanceGraph.cpp b/src/pipeline/EnhanceGraph.cppindex ba210596..aff33c3f 100644--- a/src/pipeline/EnhanceGraph.cpp+++ b/src/pipeline/EnhanceGraph.cpp@@ -662,7 +662,7 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frameif (!frame || !initialized_ || !std::isfinite(ptsMs)) return false;const auto resolved=resolveFrameColor(*frame,color?*color:ColorDescription{});if(resolved.matrix==YuvMatrix::BT2020NCL||resolved.matrix==YuvMatrix::BT2020CL||resolved.transfer==TransferFunction::BT2020_10){veyra::log::error("graph","BT.2020 input is not supported by the BT.601/709 SDR conversion");return false;}- if(reset||!realFrameIndex_)veyra::log::info("color",std::format("range={} assumed={} matrix={} assumed={} transfer={} assumed={}",int(resolved.range),resolved.rangeAssumed,int(resolved.matrix),resolved.matrixAssumed,int(resolved.transfer),resolved.transferAssumed));+ if(reset||!realFrameIndex_)veyra::log::info("color",std::format("range={} assumed={} matrix={} assumed={} transfer={} assumed={} display709={}",int(resolved.range),resolved.rangeAssumed,int(resolved.matrix),resolved.matrixAssumed,int(resolved.transfer),resolved.transferAssumed,resolved.displayReferred709));if (frame->color_trc == AVCOL_TRC_SMPTE2084 || frame->color_trc == AVCOL_TRC_ARIB_STD_B67) {veyra::log::error("graph", "HDR input is unsupported by the V1 SDR pipeline"); return false;}@@ -849,14 +849,14 @@ bool EnhanceGraph::process(const AVFrame* frame, double ptsMs, bool reset, Frame// 2. YUV -> RGBA16F.tracker_.transition(list, srcRgba_.Get(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS);if(desc_.rgbInput||desc_.yuy2Input){- const float c[8]={uintBits(srcW_),uintBits(srcH_),uintBits(transferCode(resolved.transfer)),uintBits(resolved.range==ColorRange::Limited?1u:0u),+ const float c[8]={uintBits(srcW_),uintBits(srcH_),uintBits(workingTransferCode(resolved)),uintBits(resolved.range==ColorRange::Limited?1u:0u),resolved.range==ColorRange::Full?0.0f:1.0f,resolved.matrix==YuvMatrix::BT601?0.0f:1.0f,0,0};rgbPass_.bind(list,c,gpuHandleOf(rgbPass_,0).ptr,gpuHandleOf(rgbPass_,1).ptr);list->Dispatch((srcW_+15)/16,(srcH_+15)/16,1);}else{const float constants[8] = { resolved.range==ColorRange::Full?0.0f:1.0f,resolved.matrix==YuvMatrix::BT601?0.0f:1.0f,- float(transferCode(resolved.transfer)), 0.0f,+ float(workingTransferCode(resolved)), 0.0f,uintBits(srcW_), uintBits(srcH_), 0.0f, 0.0f };yuvPass_.bind(list, constants, gpuHandleOf(yuvPass_, 0).ptr, gpuHandleOf(yuvPass_, 2).ptr);list->Dispatch((srcW_ + 15) / 16, (srcH_ + 15) / 16, 1);diff --git a/src/remoteplay/ChiakiBackend.cpp b/src/remoteplay/ChiakiBackend.cppindex 4a53619b..a984617e 100644--- a/src/remoteplay/ChiakiBackend.cpp+++ b/src/remoteplay/ChiakiBackend.cpp@@ -8,6 +8,8 @@#endif#include <chiaki/opusdecoder.h>#include <chiaki/controller.h>+#include <chiaki/orientation.h>+#include <cmath>#include <chiaki/log.h>#include <algorithm>#include <atomic>@@ -59,6 +61,10 @@ struct ChiakiBackend::Impl {std::uint32_t channels=0,rate=0;std::uint64_t sampleIndex=0;bool audioDiscontinuity=true;+ ChiakiOrientationTracker orientation{};ChiakiAccelNewZero accelZero{};+ uint64_t lastMotion=0;+ std::mutex feedbackMutex;ControllerFeedback feedback;+static void logCallback(ChiakiLogLevel level,const char*,void* user) noexcept {auto& self=*static_cast<Impl*>(user);// Raw upstream log strings/hexdumps may contain keys. Do not forward them.@@ -75,9 +81,21 @@ struct ChiakiBackend::Impl {self.connected=false;self.quitReason=static_cast<int>(event->quit.reason);// A remote termination is not a successful decoded EOF.self.token.failed(2000+static_cast<int>(event->quit.reason));break;- default:break; // No unsolicited mic, standby, haptics or keyboard side effects.+ case CHIAKI_EVENT_RUMBLE:{std::lock_guard lock(self.feedbackMutex);self.feedback.rumble=true;self.feedback.left=event->rumble.left;self.feedback.right=event->rumble.right;break;}+ case CHIAKI_EVENT_TRIGGER_EFFECTS:{std::lock_guard lock(self.feedbackMutex);auto& f=self.feedback;f.triggers=true;f.leftTrigger[0]=event->trigger_effects.type_left;f.rightTrigger[0]=event->trigger_effects.type_right;std::copy_n(event->trigger_effects.left,10,f.leftTrigger.begin()+1);std::copy_n(event->trigger_effects.right,10,f.rightTrigger.begin()+1);break;}+ case CHIAKI_EVENT_MOTION_RESET:{std::lock_guard lock(self.feedbackMutex);self.feedback.motionReset=true;break;}+ default:break; // No mic, standby or keyboard side effects.+}}+ static void hapticsCallback(uint8_t* data,size_t size,void* user)noexcept{+ auto& self=*static_cast<Impl*>(user);+ if(!self.active||!data||!size||size%4||size>1200)return;+ try{std::lock_guard lock(self.feedbackMutex);auto& pcm=self.feedback.haptics;+ if(pcm.size()+size/2>600)pcm.clear();+ const auto at=pcm.size();pcm.resize(at+size/2);std::memcpy(pcm.data()+at,data,size);+ }catch(...){++self.errors;}+ }static bool videoCallback(std::uint8_t* data,std::size_t size,const ChiakiVeyraVideoSampleInfo* info,void* user) noexcept {auto& self=*static_cast<Impl*>(user);@@ -148,7 +166,7 @@ BackendResult ChiakiBackend::start(const NativeConnectRequest& request,SessionInrequest.video.fps==30?CHIAKI_VIDEO_FPS_PRESET_30:CHIAKI_VIDEO_FPS_PRESET_60);info.video_profile.codec=request.video.codec==Codec::H264?CHIAKI_CODEC_H264:CHIAKI_CODEC_H265;info.video_profile.bitrate=request.video.bitrateKbps;- info.video_profile_auto_downgrade=false;info.enable_keyboard=false;info.enable_dualsense=false;+ info.video_profile_auto_downgrade=false;info.enable_keyboard=false;info.enable_dualsense=!request.viewOnly;info.auto_regist=false;info.packet_loss_max=0.05;info.enable_idr_on_fec_failure=true;const auto code=chiaki_session_init(&s.session,&info,&s.log);wipe(info.regist_key,sizeof(info.regist_key));wipe(info.morning,sizeof(info.morning));wipe(info.psn_account_id,sizeof(info.psn_account_id));@@ -157,6 +175,8 @@ BackendResult ChiakiBackend::start(const NativeConnectRequest& request,SessionInchiaki_opus_decoder_init(&s.opus,&s.log);s.opusInitialized=true;chiaki_opus_decoder_set_cb(&s.opus,Impl::opusSettings,Impl::opusFrame,&s);ChiakiAudioSink sink{};chiaki_opus_decoder_get_sink(&s.opus,&sink);chiaki_session_set_audio_sink(&s.session,&sink);+ ChiakiAudioSink hapticSink{};hapticSink.user=&s;hapticSink.frame_cb=Impl::hapticsCallback;+ chiaki_session_set_haptics_sink(&s.session,&hapticSink);chiaki_session_set_event_cb(&s.session,Impl::eventCallback,&s);chiaki_session_set_veyra_video_sample_cb(&s.session,Impl::videoCallback,&s);s.active=true;@@ -209,9 +229,27 @@ BackendResult ChiakiBackend::submitController(const ControllerState& state){{ControllerState::Options,CHIAKI_CONTROLLER_BUTTON_OPTIONS},{ControllerState::Share,CHIAKI_CONTROLLER_BUTTON_SHARE},{ControllerState::Touchpad,CHIAKI_CONTROLLER_BUTTON_TOUCHPAD},{ControllerState::PS,CHIAKI_CONTROLLER_BUTTON_PS}};for(auto b:buttons)if(state.buttons&b.semantic)c.buttons|=static_cast<std::uint32_t>(b.target);+ for(size_t i=0;i<state.touches.size();++i){c.touches[i].id=state.touches[i].id;c.touches[i].x=state.touches[i].x;c.touches[i].y=state.touches[i].y;}+ const bool validMotion=state.motionValid&&std::all_of(state.gyro.begin(),state.gyro.end(),[](float v){return std::isfinite(v);})&&std::all_of(state.accel.begin(),state.accel.end(),[](float v){return std::isfinite(v);});+ if(validMotion){+ if(!p_->lastMotion||state.motionTimestampUs<p_->lastMotion||state.motionTimestampUs-p_->lastMotion>100000){+ chiaki_orientation_tracker_init(&p_->orientation);chiaki_accel_new_zero_set_inactive(&p_->accelZero,false);+ }+ if(state.motionTimestampUs!=p_->lastMotion){+ chiaki_orientation_tracker_update(&p_->orientation,state.gyro[0],state.gyro[1],state.gyro[2],state.accel[0],state.accel[1],state.accel[2],&p_->accelZero,false,uint32_t(state.motionTimestampUs));+ p_->lastMotion=state.motionTimestampUs;+ }+ chiaki_orientation_tracker_apply_to_controller_state(&p_->orientation,&c);+ }else p_->lastMotion=0;c.l2_state=state.l2;c.r2_state=state.r2;c.left_x=state.leftX;c.left_y=state.leftY;c.right_x=state.rightX;c.right_y=state.rightY;return p_->record(chiaki_session_set_controller_state(&p_->session,&c),"chiaki_session_set_controller_state");}+ControllerFeedback ChiakiBackend::takeFeedback(){+ if(!p_||!p_->onOwner())return {};+ std::lock_guard lock(p_->feedbackMutex);auto result=std::move(p_->feedback);p_->feedback={};+ if(result.motionReset)p_->lastMotion=0;+ return result;+}NativeSnapshot ChiakiBackend::snapshot()const{// Like start/stop, pointer ownership requires the owner; the atomic counters// themselves may be updated by callbacks. Do not call concurrently with reset.diff --git a/src/remoteplay/ControllerInput.cpp b/src/remoteplay/ControllerInput.cppindex aed922af..437fbd58 100644--- a/src/remoteplay/ControllerInput.cpp+++ b/src/remoteplay/ControllerInput.cpp@@ -4,14 +4,23 @@#include <SDL3/SDL_init.h>#include <SDL3/SDL_hints.h>#include <algorithm>+#include <cmath>+#include <SDL3/SDL_sensor.h>+#include <SDL3/SDL_timer.h>+#include <SDL3/SDL_audio.h>+#include <cstring>+#include "veyra/Log.h"namespace veyra::remoteplay {-bool ControllerInput::start(){+bool ControllerInput::start(uint32_t preferredDevice){+ preferredDevice_=preferredDevice;if(initialized_)return true;// No SDL window is created. Our explicit foreground gate is authoritative.SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS,"1");initialized_=SDL_InitSubSystem(SDL_INIT_GAMEPAD);return initialized_;}void ControllerInput::stop(){+ releaseEffects();if(hapticStream_){SDL_DestroyAudioStream(hapticStream_);hapticStream_=nullptr;}+ if(audioInitialized_){SDL_QuitSubSystem(SDL_INIT_AUDIO);audioInitialized_=false;}hapticAttempted_=false;if(gamepad_){SDL_CloseGamepad(gamepad_);gamepad_=nullptr;}if(initialized_){SDL_QuitSubSystem(SDL_INIT_GAMEPAD);initialized_=false;}}@@ -20,15 +29,20 @@ ControllerState ControllerInput::poll(bool focused){SDL_PumpEvents();SDL_UpdateGamepads();// Only this module initializes SDL; drain its input events rather than// accumulating an unconsumed second application event queue.- SDL_FlushEvents(SDL_EVENT_FIRST,SDL_EVENT_LAST);- if(gamepad_&&!SDL_GamepadConnected(gamepad_)){SDL_CloseGamepad(gamepad_);gamepad_=nullptr;enumerateAt_=0;}+ SDL_Event event;while(SDL_PollEvent(&event)){} // state queries below consume current sensor/touch state+ if(gamepad_&&!SDL_GamepadConnected(gamepad_)){releaseEffects();if(hapticStream_){SDL_DestroyAudioStream(hapticStream_);hapticStream_=nullptr;}hapticAttempted_=false;SDL_CloseGamepad(gamepad_);gamepad_=nullptr;enumerateAt_=0;}const auto now=monotonic100ns();if(!gamepad_&&now>=enumerateAt_){int count=0;auto* ids=SDL_GetGamepads(&count);- for(int i=0;i<count&&!gamepad_;++i)gamepad_=SDL_OpenGamepad(ids[i]);+ for(int i=0;i<count&&!gamepad_;++i)if(!preferredDevice_||ids[i]==preferredDevice_)gamepad_=SDL_OpenGamepad(ids[i]);+ if(gamepad_){+ touchIds_={-1,-1};gyro_=SDL_GamepadHasSensor(gamepad_,SDL_SENSOR_GYRO)&&SDL_SetGamepadSensorEnabled(gamepad_,SDL_SENSOR_GYRO,true);+ accel_=SDL_GamepadHasSensor(gamepad_,SDL_SENSOR_ACCEL)&&SDL_SetGamepadSensorEnabled(gamepad_,SDL_SENSOR_ACCEL,true);+ veyra::log::info("remoteplay-input",std::string("device opened gyro=")+(gyro_?"1":"0")+" accel="+(accel_?"1":"0")+" touchpads="+std::to_string(SDL_GetNumGamepadTouchpads(gamepad_)));+ }SDL_free(ids);enumerateAt_=now+10000000;}- if(!focused||!gamepad_)return state;+ if(!focused||!gamepad_){touchIds_={-1,-1};releaseEffects();return state;}struct Button{SDL_GamepadButton input;ControllerState::Button output;};constexpr Button buttons[]={{SDL_GAMEPAD_BUTTON_SOUTH,ControllerState::Cross},{SDL_GAMEPAD_BUTTON_EAST,ControllerState::Circle},@@ -44,6 +58,67 @@ ControllerState ControllerInput::poll(bool focused){state.rightX=SDL_GetGamepadAxis(gamepad_,SDL_GAMEPAD_AXIS_RIGHTX);state.rightY=SDL_GetGamepadAxis(gamepad_,SDL_GAMEPAD_AXIS_RIGHTY);state.l2=uint8_t(std::max(0,int(SDL_GetGamepadAxis(gamepad_,SDL_GAMEPAD_AXIS_LEFT_TRIGGER)))*255/32767);state.r2=uint8_t(std::max(0,int(SDL_GetGamepadAxis(gamepad_,SDL_GAMEPAD_AXIS_RIGHT_TRIGGER)))*255/32767);+ for(int finger=0;finger<2;++finger){+ bool down=false;float x=0,y=0,pressure=0;+ if(SDL_GetNumGamepadTouchpads(gamepad_)>0&&SDL_GetGamepadTouchpadFinger(gamepad_,0,finger,&down,&x,&y,&pressure)&&down&&std::isfinite(x)&&std::isfinite(y)){+ if(touchIds_[finger]<0)touchIds_[finger]=int8_t(nextTouchId_++&0x7f);+ state.touches[finger]={touchIds_[finger],uint16_t(std::clamp(x,0.f,1.f)*1919),uint16_t(std::clamp(y,0.f,1.f)*1079)};+ }else touchIds_[finger]=-1;+ }+ if(gyro_&&accel_&&SDL_GetGamepadSensorData(gamepad_,SDL_SENSOR_GYRO,state.gyro.data(),3)&&SDL_GetGamepadSensorData(gamepad_,SDL_SENSOR_ACCEL,state.accel.data(),3)){+ for(auto& value:state.accel)value/=SDL_STANDARD_GRAVITY;+ state.motionValid=std::all_of(state.gyro.begin(),state.gyro.end(),[](float v){return std::isfinite(v);})&&std::all_of(state.accel.begin(),state.accel.end(),[](float v){return std::isfinite(v);});+ state.motionTimestampUs=SDL_GetTicksNS()/1000;+ }return state;}+void ControllerInput::releaseEffects(){+ if(!effectsActive_)return;+ if(gamepad_){+ if(!SDL_RumbleGamepad(gamepad_,0,0,0))veyra::log::warn("remoteplay-feedback",SDL_GetError());+ if(SDL_GetGamepadType(gamepad_)==SDL_GAMEPAD_TYPE_PS5){+ std::array<uint8_t,47> effect{};effect[0]=0x0c;effect[10]=5;effect[21]=5;+ if(!SDL_SendGamepadEffect(gamepad_,effect.data(),int(effect.size())))veyra::log::warn("remoteplay-feedback",SDL_GetError());+ }+ }+ if(hapticStream_)SDL_ClearAudioStream(hapticStream_);+ effectsActive_=false;+}+void ControllerInput::feedback(ControllerFeedback f,bool focused){+ if(!focused||!gamepad_){releaseEffects();return;}+ if(f.rumble){effectsActive_=true;if(!SDL_RumbleGamepad(gamepad_,uint16_t(f.left)*257,uint16_t(f.right)*257,5000))veyra::log::warn("remoteplay-feedback",SDL_GetError());}+ if(f.triggers&&SDL_GetGamepadType(gamepad_)==SDL_GAMEPAD_TYPE_PS5){+ // SDL DualSense effects report payload (47 bytes): right at10, left at21.+ std::array<uint8_t,47> effect{};effect[0]=0x0c;+ std::copy(f.rightTrigger.begin(),f.rightTrigger.end(),effect.begin()+10);+ std::copy(f.leftTrigger.begin(),f.leftTrigger.end(),effect.begin()+21);+ effectsActive_=true;+ if(!SDL_SendGamepadEffect(gamepad_,effect.data(),int(effect.size())))veyra::log::warn("remoteplay-feedback",SDL_GetError());+ }+ if(f.haptics.empty()||SDL_GetGamepadType(gamepad_)!=SDL_GAMEPAD_TYPE_PS5)return;+ if(!hapticAttempted_){+ hapticAttempted_=true;+ audioInitialized_=SDL_InitSubSystem(SDL_INIT_AUDIO);+ if(!audioInitialized_){veyra::log::error("remoteplay-haptics",SDL_GetError());return;}+ // Never use the default speakers or a stereo endpoint. Ambiguity fails closed.+ int count=0;auto* devices=SDL_GetAudioPlaybackDevices(&count);SDL_AudioDeviceID selected=0;int matches=0;+ for(int i=0;i<count;++i){const auto* name=SDL_GetAudioDeviceName(devices[i]);SDL_AudioSpec spec{};+ if(name&&(std::strstr(name,"Wireless Controller")||std::strstr(name,"DualSense"))&&SDL_GetAudioDeviceFormat(devices[i],&spec,nullptr)&&spec.channels==4){selected=devices[i];++matches;}+ }+ SDL_free(devices);+ int gamepadCount=0;auto* gamepads=SDL_GetGamepads(&gamepadCount);SDL_free(gamepads);+ if(matches!=1||gamepadCount!=1){veyra::log::warn("remoteplay-haptics","No unique four-channel DualSense endpoint/controller pair; haptics not routed");return;}+ SDL_AudioSpec input{SDL_AUDIO_S16,4,3000};+ hapticStream_=SDL_OpenAudioDeviceStream(selected,&input,nullptr,nullptr);+ if(!hapticStream_||!SDL_ResumeAudioStreamDevice(hapticStream_)){veyra::log::error("remoteplay-haptics",SDL_GetError());if(hapticStream_)SDL_DestroyAudioStream(hapticStream_);hapticStream_=nullptr;return;}+ veyra::log::info("remoteplay-haptics","Dedicated four-channel endpoint opened; speaker channels silent");+ }+ if(!hapticStream_)return;+ std::vector<int16_t> quad;quad.reserve(f.haptics.size()*2);+ for(size_t i=0;i+1<f.haptics.size();i+=2){quad.push_back(0);quad.push_back(0);quad.push_back(f.haptics[i]);quad.push_back(f.haptics[i+1]);}+ if(SDL_GetAudioStreamQueued(hapticStream_)>2400)SDL_ClearAudioStream(hapticStream_);+ effectsActive_=true;+ if(!SDL_PutAudioStreamData(hapticStream_,quad.data(),int(quad.size()*sizeof(int16_t))))veyra::log::warn("remoteplay-haptics",SDL_GetError());+}+}diff --git a/src/source/RemotePlaySessionSource.cpp b/src/source/RemotePlaySessionSource.cppindex ced02468..e524a103 100644--- a/src/source/RemotePlaySessionSource.cpp+++ b/src/source/RemotePlaySessionSource.cpp@@ -8,7 +8,7 @@ extern "C" {namespace veyra::source {bool RemotePlaySessionSource::connect(RemotePlayConnectDesc desc) {close();- { std::lock_guard lock(mutex_); initialized_=started_=failed_=false; skipped_=0; controller_={}; snapshot_={}; }+ { std::lock_guard lock(mutex_); initialized_=started_=failed_=false; skipped_=0; rates_={}; feedback_={}; controller_={}; snapshot_={}; }owner_=std::jthread([this, request=std::move(desc)](std::stop_token stop) mutable { run(stop,std::move(request)); });std::unique_lock lock(mutex_);ready_.wait(lock,[&]{return initialized_;});@@ -46,6 +46,7 @@ void RemotePlaySessionSource::run(std::stop_token stop, RemotePlayConnectDesc de} else log::error("remoteplay-audio","output initialization failed; video remains available");auto lastFrame=std::chrono::steady_clock::now();auto nextController=lastFrame;+ auto rateStart=lastFrame;uint64_t previousReceived=0,previousDecoded=0;while(!stop.stop_requested()) {std::string pin; remoteplay::ControllerState controller;{std::lock_guard lock(mutex_);pin.swap(pin_);controller=remoteplay::monotonic100ns()-controllerStamp_<=1000000?controller_:remoteplay::ControllerState{};}@@ -54,15 +55,22 @@ void RemotePlaySessionSource::run(std::stop_token stop, RemotePlayConnectDesc deif(!r.ok)log::warn("remoteplay",std::format("{} code={}",r.operation,r.code));}const auto now=std::chrono::steady_clock::now();- if(now>=nextController) {+ if(!desc.request.viewOnly&&now>=nextController) {const auto r=source.submitController(controller);if(!r.ok)log::warn("remoteplay",std::format("{} code={}",r.operation,r.code));nextController=now+std::chrono::milliseconds(4);}pipeline::FramePacket packet; const AVFrame* frame=nullptr;const auto result=source.read(packet,&frame);+ auto feedback=source.takeFeedback();const auto snapshot=source.sessionSnapshot();- {std::lock_guard lock(mutex_);snapshot_=snapshot;}+ {std::lock_guard lock(mutex_);snapshot_=snapshot;feedback_.merge(std::move(feedback));+ rates_.received=snapshot.video.accessUnits;rates_.ingressDropped=snapshot.video.dropped;+ const double elapsed=std::chrono::duration<double>(now-rateStart).count();+ if(elapsed>=1){rates_.receivedFps=double(rates_.received-previousReceived)/elapsed;+ rates_.decodedFps=double(rates_.decoded-previousDecoded)/elapsed;rates_.ready=true;+ previousReceived=rates_.received;previousDecoded=rates_.decoded;rateStart=now;}+ }if(result==SourceReadStatus::Error) {std::lock_guard lock(mutex_);failed_=true;break;}if(result==SourceReadStatus::Frame && frame) {publishDecoded(frame,packet,source.info());@@ -92,6 +100,7 @@ void RemotePlaySessionSource::publishDecoded(const AVFrame* frame,pipeline::Framauto* cloned=av_frame_clone(frame);if(!cloned)throw std::bad_alloc();Frame item{std::shared_ptr<AVFrame>(cloned,[](AVFrame* p){av_frame_free(&p);}),packet,info};std::lock_guard lock(mutex_);+ ++rates_.decoded;if(latest_){++skipped_;item.packet.flags|=latest_->packet.flags;item.packet.flags|=static_cast<pipeline::FrameFlags>(pipeline::FrameFlagBits::Discontinuity);}latest_=std::move(item);@@ -112,5 +121,7 @@ void RemotePlaySessionSource::close() noexcept {void RemotePlaySessionSource::controller(remoteplay::ControllerState state){std::lock_guard lock(mutex_);controller_=state;controllerStamp_=remoteplay::monotonic100ns();}void RemotePlaySessionSource::loginPin(std::string pin){std::lock_guard lock(mutex_);SecureZeroMemory(pin_.data(),pin_.size());pin_=std::move(pin);}remoteplay::SessionInbox::Snapshot RemotePlaySessionSource::sessionSnapshot()const{std::lock_guard lock(mutex_);return snapshot_;}+RemotePlaySessionSource::Rates RemotePlaySessionSource::rates()const{std::lock_guard lock(mutex_);return rates_;}+remoteplay::ControllerFeedback RemotePlaySessionSource::takeFeedback(){std::lock_guard lock(mutex_);auto result=std::move(feedback_);feedback_={};return result;}uint64_t RemotePlaySessionSource::skipped()const{std::lock_guard lock(mutex_);return skipped_;}}diff --git a/src/source/RemotePlaySource.cpp b/src/source/RemotePlaySource.cppindex 5513a9ff..8e12eea7 100644--- a/src/source/RemotePlaySource.cpp+++ b/src/source/RemotePlaySource.cpp@@ -76,6 +76,7 @@ bool RemotePlaySource::connect(const RemotePlayConnectDesc& desc)request_ = remoteplay::NativeConnectRequest{};request_.host = desc.request.host;request_.video = desc.request.video;+ request_.viewOnly = desc.request.viewOnly;request_.credentials.accountId = desc.request.credentials.accountId;request_.credentials.registrationKey = desc.request.credentials.registrationKey;request_.credentials.sessionKey = desc.request.credentials.sessionKey;@@ -112,6 +113,7 @@ bool RemotePlaySource::connect(const RemotePlayConnectDesc& desc)info_.color.rangeAssumed = true;info_.color.matrix = pipeline::YuvMatrix::BT709;info_.color.matrixAssumed = true;+ info_.color.displayReferred709 = true;info_.color.transfer = pipeline::TransferFunction::BT709;info_.color.transferAssumed = true;info_.color.primaries = pipeline::ColorPrimaries::BT709;diff --git a/tests/integration/Yuy2ColorTests.cpp b/tests/integration/Yuy2ColorTests.cppindex 72b2113b..59e745e4 100644--- a/tests/integration/Yuy2ColorTests.cpp+++ b/tests/integration/Yuy2ColorTests.cpp@@ -12,8 +12,8 @@ extern "C" {}using namespace veyra;int wmain(int argc,wchar_t**argv){- bool nr=false,rgb=false,native4k=false,temporal=false,realtime=false;- for(int i=1;i<argc;++i){nr|=wcscmp(argv[i],L"--nr")==0;rgb|=wcscmp(argv[i],L"--rgb")==0;native4k|=wcscmp(argv[i],L"--4k")==0;temporal|=wcscmp(argv[i],L"--temporal")==0;realtime|=wcscmp(argv[i],L"--realtime")==0;}+ bool remoteYuv=false,nr=false,rgb=false,native4k=false,temporal=false,realtime=false;+ for(int i=1;i<argc;++i){remoteYuv|=wcscmp(argv[i],L"--remote-yuv")==0;nr|=wcscmp(argv[i],L"--nr")==0;rgb|=wcscmp(argv[i],L"--rgb")==0;native4k|=wcscmp(argv[i],L"--4k")==0;temporal|=wcscmp(argv[i],L"--temporal")==0;realtime|=wcscmp(argv[i],L"--realtime")==0;}nr|=temporal;CoInitializeEx(nullptr,COINIT_MULTITHREADED);gfx::D3D12DeviceContext ctx;gfx::CommandSlotRing ring;Status st;gfx::DeviceContextDesc dd;@@ -21,7 +21,7 @@ int wmain(int argc,wchar_t**argv){const unsigned w=native4k?3840:nr?1920:256,h=native4k?2160:nr?1080:64;HWND window=CreateWindowExW(0,L"STATIC",L"YUY2 contract",WS_POPUP,0,0,w,h,nullptr,nullptr,GetModuleHandleW(nullptr),nullptr);pipeline::EnhanceGraph graph(ctx,ring);engine::VideoPresenter presenter;pipeline::EnhanceGraphDesc gd;- gd.sourceWidth=gd.workWidth=w;gd.sourceHeight=gd.workHeight=h;gd.yuy2Input=!rgb;gd.rgbInput=rgb;gd.enableFg=false;gd.enableNr=nr;gd.enableNvofStandalone=nr;gd.noFeatures=!nr;gd.runtimeAbsPath=runtime::localRuntimeDirectory().wstring();+ gd.sourceWidth=gd.workWidth=w;gd.sourceHeight=gd.workHeight=h;gd.yuy2Input=!rgb&&!remoteYuv;gd.rgbInput=rgb;gd.enableFg=false;gd.enableNr=nr;gd.enableNvofStandalone=nr;gd.noFeatures=!nr;gd.runtimeAbsPath=runtime::localRuntimeDirectory().wstring();if(realtime){if(!native4k||!nr)return 4;gd.nrWidth=gd.flowWidth=1920;gd.nrHeight=gd.flowHeight=1080;@@ -29,26 +29,35 @@ int wmain(int argc,wchar_t**argv){if(!window||!graph.initialize(gd)||!presenter.open(ctx,window,graph)||!graph.createViews())return 2;const unsigned expectedInternalWidth=realtime?1920:w,expectedInternalHeight=realtime?1080:h;if(graph.nrWidth()!=expectedInternalWidth||graph.nrHeight()!=expectedInternalHeight||graph.flowWidth()!=expectedInternalWidth||graph.flowHeight()!=expectedInternalHeight)return 4;- AVFrame* f=av_frame_alloc();f->format=rgb?AV_PIX_FMT_BGRA:AV_PIX_FMT_YUYV422;f->width=w;f->height=h;if(av_frame_get_buffer(f,32)<0)return 3;+ AVFrame* f=av_frame_alloc();f->format=remoteYuv?AV_PIX_FMT_YUV420P:rgb?AV_PIX_FMT_BGRA:AV_PIX_FMT_YUYV422;f->width=w;f->height=h;if(av_frame_get_buffer(f,32)<0)return 3;int failures=0;unsigned frameId=0;for(unsigned index=0;index<(temporal?8u:nr?2u:4u);++index){const bool full=!temporal&&(nr?index>0:index>=2),hd=temporal||(!nr&&(index%2));- for(unsigned y=0;y<h;++y)for(unsigned x=0;x<w;x+=2){auto* p=f->data[0]+ptrdiff_t(y)*f->linesize[0]+x*2;p[0]=uint8_t((x+(temporal?index*2:0))%256);p[2]=uint8_t((x+1+(temporal?index*2:0))%256);p[1]=y%4==0?128:y%4==1?16:y%4==2?240:90;p[3]=y%4==0?128:y%4==1?240:y%4==2?16:180;}+ if(!remoteYuv)for(unsigned y=0;y<h;++y)for(unsigned x=0;x<w;x+=2){auto* p=f->data[0]+ptrdiff_t(y)*f->linesize[0]+x*2;p[0]=uint8_t((x+(temporal?index*2:0))%256);p[2]=uint8_t((x+1+(temporal?index*2:0))%256);p[1]=y%4==0?128:y%4==1?16:y%4==2?240:90;p[3]=y%4==0?128:y%4==1?240:y%4==2?16:180;}+ if(remoteYuv){+ for(unsigned y=0;y<h;++y)for(unsigned x=0;x<w;++x)f->data[0][ptrdiff_t(y)*f->linesize[0]+x]=uint8_t(x%256);+ for(unsigned y=0;y<h/2;++y)for(unsigned x=0;x<w/2;++x){f->data[1][ptrdiff_t(y)*f->linesize[1]+x]=y%4==0?128:y%4==1?16:y%4==2?240:90;f->data[2][ptrdiff_t(y)*f->linesize[2]+x]=y%4==0?128:y%4==1?240:y%4==2?16:180;}+ }if(rgb)for(unsigned y=0;y<h;++y)for(unsigned x=0;x<w;++x){auto* p=f->data[0]+ptrdiff_t(y)*f->linesize[0]+x*4;p[0]=uint8_t(x%256);p[1]=uint8_t((x+37)%256);p[2]=uint8_t((x+129)%256);p[3]=255;}pipeline::ColorDescription color;color.pixelFormat=pipeline::SourcePixelFormat::Yuy2;color.range=full?pipeline::ColorRange::Full:pipeline::ColorRange::Limited;color.matrix=hd?pipeline::YuvMatrix::BT709:pipeline::YuvMatrix::BT601;color.transfer=pipeline::TransferFunction::SRGB;+ if(remoteYuv){color.pixelFormat=pipeline::SourcePixelFormat::Yuv420P;color.transfer=pipeline::TransferFunction::BT709;color.displayReferred709=true;}pipeline::EnhanceGraph::FrameOutputs out;sink::RgbaImage image,display;if(rgb)color.pixelFormat=pipeline::SourcePixelFormat::Bgra8;const double ptsMs=frameId*100.0;++frameId;bool ok=graph.process(f,ptsMs,!temporal||index==0,out,frameId,&color)&&sink::readRgba8(ctx,ring,graph.videoFrameResource(out.videoSlot),image);int error=0,displayError=0;uint64_t sum=0;- if(ok){for(unsigned y=0;y<h;++y)for(unsigned x=0;x<w;++x){auto* p=f->data[0]+ptrdiff_t(y)*f->linesize[0]+(x/2)*4;const double Y=(double(p[(x&1)?2:0])-(full?0:16))/(full?255:219);const double U=(double(p[1])-128)/(full?255:224),V=(double(p[3])-128)/(full?255:224);const double kr=hd?.2126:.299,kb=hd?.0722:.114;double expected[3]={Y+2*(1-kr)*V,0,Y+2*(1-kb)*U};expected[1]=(Y-kr*expected[0]-kb*expected[2])/(1-kr-kb);+ if(ok){for(unsigned y=0;y<h;++y)for(unsigned x=0;x<w;++x){uint8_t neutral[4]={0,128,0,128};auto* p=remoteYuv?neutral:f->data[0]+ptrdiff_t(y)*f->linesize[0]+(x/2)*4;const double Y=(double(p[(x&1)?2:0])-(full?0:16))/(full?255:219);const double U=(double(p[1])-128)/(full?255:224),V=(double(p[3])-128)/(full?255:224);const double kr=hd?.2126:.299,kb=hd?.0722:.114;double expected[3]={Y+2*(1-kr)*V,0,Y+2*(1-kb)*U};expected[1]=(Y-kr*expected[0]-kb*expected[2])/(1-kr-kb);+ if(remoteYuv){const double luma=(double(x%256)-(full?0:16))/(full?255:219);+ const double u=(double(f->data[1][ptrdiff_t(y/2)*f->linesize[1]+x/2])-128)/(full?255:224),v=(double(f->data[2][ptrdiff_t(y/2)*f->linesize[2]+x/2])-128)/(full?255:224);+ const double normalized=std::clamp(luma,0.0,1.0);expected[0]=normalized+2*(1-kr)*v;expected[2]=normalized+2*(1-kb)*u;expected[1]=(normalized-kr*expected[0]-kb*expected[2])/(1-kr-kb);+ for(auto& value:expected){const double linear=std::pow(std::clamp(value,0.0,1.0),2.4);value=linear<=0.0031308?12.92*linear:1.055*std::pow(linear,1.0/2.4)-0.055;}}if(rgb){const auto* bgra=f->data[0]+ptrdiff_t(y)*f->linesize[0]+x*4;for(unsigned c=0;c<3;++c)expected[c]=(double(bgra[2-c])-(full?0:16))/(full?255:219);}for(unsigned c=0;c<3;++c){const int actual=image.pixels[(size_t(y)*w+x)*4+c];sum+=actual;error=std::max(error,std::abs(actual-int(std::lround(std::clamp(expected[c],0.0,1.0)*255))));}}ok=sum>0&&(nr?graph.metrics().nrEvaluateCount==frameId:error<=1);}if(ok)ok=presenter.present(ctx,ring,graph,out.videoSlot,false)&&presenter.readPresentedFrameForTest(ctx,ring,display);if(ok){ok=image.pixels.size()==display.pixels.size();if(ok)for(size_t i=0;i<image.pixels.size();++i)displayError=std::max(displayError,std::abs(int(image.pixels[i])-int(display.pixels[i])));ok=ok&&displayError<=1;}- std::cout<<(rgb?"RGB_COLOR":"YUY2_COLOR")<<" extent="<<w<<"x"<<h<<" nrExtent="<<graph.nrWidth()<<"x"<<graph.nrHeight()<<" flowExtent="<<graph.flowWidth()<<"x"<<graph.flowHeight()<<" full="<<full<<" hd="<<hd<<" nr="<<nr<<" sourceError="<<error<<" displayError="<<displayError<<" pass="<<ok<<std::endl;+ std::cout<<(remoteYuv?"REMOTE_YUV_COLOR":rgb?"RGB_COLOR":"YUY2_COLOR")<<" extent="<<w<<"x"<<h<<" nrExtent="<<graph.nrWidth()<<"x"<<graph.nrHeight()<<" flowExtent="<<graph.flowWidth()<<"x"<<graph.flowHeight()<<" full="<<full<<" hd="<<hd<<" nr="<<nr<<" sourceError="<<error<<" displayError="<<displayError<<" pass="<<ok<<std::endl;if(!ok)++failures;out={};}if(temporal){const auto metrics=graph.metrics();const bool ok=metrics.nvofExecuteCount>0&&metrics.nrMotionFrames>0;std::cout<<"YUY2_TEMPORAL nvof="<<metrics.nvofExecuteCount<<" nrMotion="<<metrics.nrMotionFrames<<" pass="<<ok<<std::endl;if(!ok)++failures;}diff --git a/tests/remoteplay/ProductBoundaryTests.cpp b/tests/remoteplay/ProductBoundaryTests.cppindex bd1dc190..38c4b483 100644--- a/tests/remoteplay/ProductBoundaryTests.cpp+++ b/tests/remoteplay/ProductBoundaryTests.cpp@@ -2,6 +2,8 @@#include "veyra/remoteplay/ControllerInput.h"#include "veyra/remoteplay/Discovery.h"#include <string_view>+#include <SDL3/SDL.h>+#include <cmath>#include <iostream>extern "C" {#include <libavutil/frame.h>@@ -24,7 +26,39 @@ static void mailbox(){};}+int virtualInput(){+ using namespace veyra::remoteplay;+ if(!SDL_InitSubSystem(SDL_INIT_GAMEPAD))return 20;+ SDL_VirtualJoystickDesc desc;SDL_INIT_INTERFACE(&desc);desc.type=SDL_JOYSTICK_TYPE_GAMEPAD;+ desc.vendor_id=0x054c;desc.product_id=0x0ce6;desc.name="Veyra isolated input fixture";+ desc.naxes=6;desc.nbuttons=21;desc.button_mask=(1u<<21)-1;desc.axis_mask=63;+ SDL_VirtualJoystickTouchpadDesc touch{};touch.nfingers=2;desc.ntouchpads=1;desc.touchpads=&touch;+ SDL_VirtualJoystickSensorDesc sensors[2]={{SDL_SENSOR_GYRO,120},{SDL_SENSOR_ACCEL,120}};desc.nsensors=2;desc.sensors=sensors;+ desc.SetSensorsEnabled=[](void*,bool){return true;};+ unsigned rumbleCalls=0;desc.userdata=&rumbleCalls;+ desc.Rumble=[](void* p,Uint16,Uint16){++*static_cast<unsigned*>(p);return true;};+ desc.SendEffect=[](void*,const void*,int){return true;};+ const auto id=SDL_AttachVirtualJoystick(&desc);if(!id)return 21;+ auto* joystick=SDL_OpenJoystick(id);ControllerInput input;+ if(!joystick||!input.start(id))return 22;+ input.poll(true);+ float gyro[3]={.1f,.2f,.3f},accel[3]={0,SDL_STANDARD_GRAVITY,0};+ SDL_SendJoystickVirtualSensorData(joystick,SDL_SENSOR_GYRO,10000000,gyro,3);+ SDL_SendJoystickVirtualSensorData(joystick,SDL_SENSOR_ACCEL,10000000,accel,3);+ SDL_SetJoystickVirtualTouchpad(joystick,0,0,true,.25f,.75f,1);+ SDL_SetJoystickVirtualTouchpad(joystick,0,1,true,1,0,1);+ auto first=input.poll(true);bool ok=first.motionValid&&std::abs(first.accel[1]-1)<1e-5&&std::abs(first.gyro[2]-.3f)<1e-5;+ ok&=first.touches[0].id>=0&&first.touches[1].id>=0&&first.touches[0].id!=first.touches[1].id&&first.touches[0].x==479&&first.touches[0].y==809;+ SDL_SetJoystickVirtualTouchpad(joystick,0,0,true,.5f,.5f,1);auto moved=input.poll(true);ok&=moved.touches[0].id==first.touches[0].id&&moved.touches[0].x==959;+ SDL_SetJoystickVirtualTouchpad(joystick,0,0,false,0,0,0);auto up=input.poll(true);ok&=up.touches[0].id==-1;+ ControllerFeedback f;f.rumble=true;f.left=5;input.feedback(f,true);ok&=rumbleCalls>0;+ const auto before=rumbleCalls;ok&=input.poll(false)==ControllerState{};ok&=rumbleCalls>before;+ ControllerFeedback bounded;for(int i=0;i<20;++i){ControllerFeedback packet;packet.haptics.resize(120,1);bounded.merge(std::move(packet));ok&=bounded.haptics.size()<=600;}+ input.stop();SDL_CloseJoystick(joystick);SDL_DetachVirtualJoystick(id);SDL_QuitSubSystem(SDL_INIT_GAMEPAD);+ std::cout<<"VIRTUAL_INPUT motion_touch_lifecycle_focus_feedback_bounded="<<ok<<" REAL_PS5_NOT_TESTED=1\n";return ok?0:23;+}int main(int argc,char** argv){+ if(argc==2&&std::string_view(argv[1])=="--virtual")return virtualInput();if(argc==2&&std::string_view(argv[1])=="--discover"){const auto report=veyra::remoteplay::discoverLocalPs5({});for(const auto& line:report.diagnostics)std::cout<<line<<'\n';