mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-17 16:50:31 +00:00
Add RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK
This commit is contained in:
parent
095a0e81cf
commit
93ed9b2f3b
3 changed files with 18 additions and 0 deletions
|
|
@ -337,6 +337,8 @@ func (f *Frontend) Start() {
|
|||
case <-f.done:
|
||||
return
|
||||
default:
|
||||
f.nano.NotifyFrameTime(targetFrameTimeNs / 1000)
|
||||
|
||||
f.Tick()
|
||||
|
||||
now := os.Nanotime()
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ type Nanoarch struct {
|
|||
retropad InputState
|
||||
|
||||
keyboardCb *C.struct_retro_keyboard_callback
|
||||
frameTimeCb *C.struct_retro_frame_time_callback
|
||||
LastFrameTime time.Time
|
||||
LibCo bool
|
||||
meta Metadata
|
||||
|
|
@ -427,6 +428,12 @@ func (n *Nanoarch) Run() {
|
|||
}
|
||||
}
|
||||
|
||||
func (n *Nanoarch) NotifyFrameTime(usec int64) {
|
||||
if n.frameTimeCb != nil {
|
||||
C.call_frame_time_cb(n.frameTimeCb, C.retro_usec_t(usec))
|
||||
}
|
||||
}
|
||||
|
||||
func (n *Nanoarch) IsSupported() error { return graphics.RGFWTryInit() }
|
||||
func (n *Nanoarch) IsGL() bool { return n.Video.gl.enabled }
|
||||
func (n *Nanoarch) IsStopped() bool { return n.Stopped.Load() }
|
||||
|
|
@ -876,6 +883,10 @@ func coreEnvironment(cmd C.unsigned, data unsafe.Pointer) C.bool {
|
|||
latency := *(*C.unsigned)(data)
|
||||
Nan0.log.Info().Uint("latency_ms", uint(latency)).Msg("audio latency requested")
|
||||
return true
|
||||
case C.RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK:
|
||||
Nan0.frameTimeCb = (*C.struct_retro_frame_time_callback)(data)
|
||||
Nan0.log.Info().Msg("Frame time callback registered")
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,4 +41,9 @@ static inline void call_audio_buffer_status(
|
|||
if (cb && cb->callback) cb->callback(active, occupancy, underrun);
|
||||
}
|
||||
|
||||
static inline void call_frame_time_cb(
|
||||
struct retro_frame_time_callback *cb, retro_usec_t usec) {
|
||||
if (cb && cb->callback) cb->callback(usec);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue