mirror of
https://github.com/mamedev/mame.git
synced 2024-11-16 07:48:32 +01:00
added screenshot option and serving it from webserver (nw)
This commit is contained in:
parent
15cc532d49
commit
912a7fde30
2 changed files with 53 additions and 10 deletions
|
@ -102,6 +102,32 @@ int web_engine::begin_request_handler(struct mg_connection *conn)
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
if (!strncmp(request_info->uri, "/screenshot.png",15))
|
||||
{
|
||||
screen_device_iterator iter(m_machine->root_device());
|
||||
screen_device *screen = iter.first();
|
||||
|
||||
if (screen == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
astring fname("screenshot.png");
|
||||
emu_file file(m_machine->options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||
file_error filerr = file.open(fname);
|
||||
|
||||
if (filerr != FILERR_NONE)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_machine->video().save_snapshot(screen, file);
|
||||
astring fullpath(file.fullpath());
|
||||
file.close();
|
||||
|
||||
mg_send_file(conn,fullpath);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,11 @@
|
|||
document.getElementById('current').innerHTML = message;
|
||||
};
|
||||
|
||||
function takeScreenshot()
|
||||
{
|
||||
document.getElementById('content').innerHTML = '<center><img src="/screenshot.png"/></center>';
|
||||
}
|
||||
|
||||
function startWebSocket() {
|
||||
var url = 'ws://localhost:8080/foo';
|
||||
websocket = new WebSocket(url);
|
||||
|
@ -28,7 +33,7 @@
|
|||
writeToScreen('<b style="color: green;">Connected</b>');
|
||||
};
|
||||
websocket.onclose = function(ev) {
|
||||
writeToScreen('<b style="color: white;">Disconnected</b>');
|
||||
writeToScreen('<b style="color: red;">Disconnected</b>');
|
||||
};
|
||||
websocket.onmessage = function(ev) {
|
||||
if (ev.data=='update_machine')
|
||||
|
@ -80,21 +85,33 @@
|
|||
<a href="#page1" data-transition="fade" data-icon="grid">Image</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#page1" data-transition="fade" data-icon="info">Info</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#page1" data-transition="fade" data-icon="check">Logs</a>
|
||||
<a href="#page1" data-transition="fade" data-icon="star">Commands</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div data-role="content">
|
||||
<div data-role="content" id ="content">
|
||||
</div>
|
||||
<div data-theme="a" data-role="footer" data-position="fixed">
|
||||
<h3>
|
||||
<div id="current"></div>
|
||||
</h3>
|
||||
<a data-role="button" href="javascript:startWebSocket();" data-icon="refresh" data-iconpos="left" class="ui-btn-right">Reconnect</a>
|
||||
<div data-role="navbar" data-iconpos="top">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="#page1" data-transition="fade" data-icon="info">Info</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#page1" data-transition="fade" data-icon="check">Logs</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="javascript:takeScreenshot();" data-transition="fade" data-icon="search">Screenshot</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="javascript:startWebSocket();" data-transition="fade" data-icon="refresh">Reconnect</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<h3>
|
||||
<div id="current"></div>
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
|
Loading…
Reference in a new issue