mirror of
https://github.com/holub/mame
synced 2025-06-24 21:34:43 +03:00
added screenshot option and serving it from webserver (nw)
This commit is contained in:
parent
15cc532d49
commit
912a7fde30
@ -102,6 +102,32 @@ int web_engine::begin_request_handler(struct mg_connection *conn)
|
|||||||
return 1;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,11 @@
|
|||||||
document.getElementById('current').innerHTML = message;
|
document.getElementById('current').innerHTML = message;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function takeScreenshot()
|
||||||
|
{
|
||||||
|
document.getElementById('content').innerHTML = '<center><img src="/screenshot.png"/></center>';
|
||||||
|
}
|
||||||
|
|
||||||
function startWebSocket() {
|
function startWebSocket() {
|
||||||
var url = 'ws://localhost:8080/foo';
|
var url = 'ws://localhost:8080/foo';
|
||||||
websocket = new WebSocket(url);
|
websocket = new WebSocket(url);
|
||||||
@ -28,7 +33,7 @@
|
|||||||
writeToScreen('<b style="color: green;">Connected</b>');
|
writeToScreen('<b style="color: green;">Connected</b>');
|
||||||
};
|
};
|
||||||
websocket.onclose = function(ev) {
|
websocket.onclose = function(ev) {
|
||||||
writeToScreen('<b style="color: white;">Disconnected</b>');
|
writeToScreen('<b style="color: red;">Disconnected</b>');
|
||||||
};
|
};
|
||||||
websocket.onmessage = function(ev) {
|
websocket.onmessage = function(ev) {
|
||||||
if (ev.data=='update_machine')
|
if (ev.data=='update_machine')
|
||||||
@ -80,21 +85,33 @@
|
|||||||
<a href="#page1" data-transition="fade" data-icon="grid">Image</a>
|
<a href="#page1" data-transition="fade" data-icon="grid">Image</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="#page1" data-transition="fade" data-icon="info">Info</a>
|
<a href="#page1" data-transition="fade" data-icon="star">Commands</a>
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="#page1" data-transition="fade" data-icon="check">Logs</a>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div data-role="content">
|
<div data-role="content" id ="content">
|
||||||
</div>
|
</div>
|
||||||
<div data-theme="a" data-role="footer" data-position="fixed">
|
<div data-theme="a" data-role="footer" data-position="fixed">
|
||||||
<h3>
|
<div data-role="navbar" data-iconpos="top">
|
||||||
<div id="current"></div>
|
<ul>
|
||||||
</h3>
|
<li>
|
||||||
<a data-role="button" href="javascript:startWebSocket();" data-icon="refresh" data-iconpos="left" class="ui-btn-right">Reconnect</a>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
Reference in New Issue
Block a user