mirror of
https://github.com/mamedev/mame.git
synced 2024-11-16 07:48:32 +01:00
some 5 min slider work, to make it affect settings (nw)
This commit is contained in:
parent
eb3686dc33
commit
6c7d00c958
2 changed files with 50 additions and 2 deletions
|
@ -195,6 +195,40 @@ int web_engine::begin_request_handler(struct mg_connection *conn)
|
||||||
// the client, and mongoose should not send client any more data.
|
// the client, and mongoose should not send client any more data.
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
else if (!strncmp(request_info->uri, "/slider",7))
|
||||||
|
{
|
||||||
|
char cmd_id[64];
|
||||||
|
char cmd_val[64];
|
||||||
|
get_qsvar(request_info, "id", cmd_id, sizeof(cmd_id));
|
||||||
|
get_qsvar(request_info, "val", cmd_val, sizeof(cmd_val));
|
||||||
|
int cnt = 0;
|
||||||
|
int id = atoi(cmd_id);
|
||||||
|
const slider_state *curslider;
|
||||||
|
for (curslider = ui_get_slider_list(); curslider != NULL; curslider = curslider->next)
|
||||||
|
{
|
||||||
|
if (cnt==id)
|
||||||
|
(*curslider->update)(machine(), curslider->arg, NULL, atoi(cmd_val));
|
||||||
|
cnt++;
|
||||||
|
}
|
||||||
|
for (curslider = (slider_state*)machine().osd().get_slider_list(); curslider != NULL; curslider = curslider->next)
|
||||||
|
{
|
||||||
|
if (cnt==id)
|
||||||
|
(*curslider->update)(machine(), curslider->arg, NULL, atoi(cmd_val));
|
||||||
|
cnt++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send HTTP reply to the client
|
||||||
|
mg_printf(conn,
|
||||||
|
"HTTP/1.1 200 OK\r\n"
|
||||||
|
"Content-Type: text/plain\r\n"
|
||||||
|
"Content-Length: 2\r\n" // Always set Content-Length
|
||||||
|
"\r\n"
|
||||||
|
"OK");
|
||||||
|
|
||||||
|
// Returning non-zero tells mongoose that our function has replied to
|
||||||
|
// the client, and mongoose should not send client any more data.
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
else if (!strncmp(request_info->uri, "/screenshot.png",15))
|
else if (!strncmp(request_info->uri, "/screenshot.png",15))
|
||||||
{
|
{
|
||||||
screen_device_iterator iter(m_machine->root_device());
|
screen_device_iterator iter(m_machine->root_device());
|
||||||
|
|
|
@ -53,17 +53,31 @@
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
var items = [];
|
var items = [];
|
||||||
for (var i in data) {
|
for (var i in data) {
|
||||||
items.push('<label for="slider-mini">'+data[i].description +':</label>');
|
items.push('<label for="slider-mini-'+i+'">'+data[i].description +':</label>');
|
||||||
items.push('<input type="range" name="slider-mini" id="slider-mini" value="'+data[i].curval+'" min="'+data[i].minval+'" max="'+data[i].maxval+'" step=="'+data[i].incval+'" data-highlight="true" data-mini="true" />');
|
items.push('<input type="range" name="slider-mini-'+i+'" id="slider-mini-'+i+'" value="'+data[i].curval+'" min="'+data[i].minval+'" max="'+data[i].maxval+'" step=="'+data[i].incval+'" data-highlight="true" data-mini="true" />');
|
||||||
}
|
}
|
||||||
$('#main').html('');
|
$('#main').html('');
|
||||||
$('#main').append(items.join('')).trigger('create');
|
$('#main').append(items.join('')).trigger('create');
|
||||||
|
for (var i in data) {
|
||||||
|
$('#slider-mini-' + i).bind( "slidestop", function(event, ui) { setSliderValue($(this).attr('id').replace('slider-mini-',''),$(this).slider().val()); });
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
error: function (request, status, error) { alert(status + ", " + error); }
|
error: function (request, status, error) { alert(status + ", " + error); }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setSliderValue(id,val)
|
||||||
|
{
|
||||||
|
$.ajax({
|
||||||
|
url: "/slider?id="+id+"&val="+val,
|
||||||
|
cache: false,
|
||||||
|
dataType: "text",
|
||||||
|
success: function(data) {
|
||||||
|
},
|
||||||
|
error: function (request, status, error) { alert(status + ", " + error); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function startWebSocket() {
|
function startWebSocket() {
|
||||||
var url = 'ws://localhost:8080/foo';
|
var url = 'ws://localhost:8080/foo';
|
||||||
|
|
Loading…
Reference in a new issue