1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
<%pre>
#include <setup.h>
#include <time.h>
#include <vdr/remote.h>
using namespace vdrlive;
</%pre>
<%args>
int keycode = kNone;
int repeat = 1;
</%args>
<%session scope="global">
bool logged_in(false);
</%session>
<%cpp>
if (!logged_in && LiveSetup().UseAuth()) {
cToSvConcat targetUrl("/login.html?redirect=");
targetUrl.appendUrlEscaped(request.getQuery());
return reply.redirect(targetUrl.data());
}
reply.setContentType("application/xml");
struct timespec ts_req;
ts_req.tv_sec = 0;
ts_req.tv_nsec = 1000000;
for (int i = 0; i < repeat;) {
if (cRemote::Put( (eKeys)keycode ) ) ++i;
else nanosleep(&ts_req, nullptr); // to switch to the thread processing the keys
}
for (int i = 0; i < 100 && cRemote::HasKeys() ;++i) nanosleep(&ts_req, nullptr); // to allow processing the keys before we return
</%cpp>
<?xml version="1.0"?>
<service>
<request name="keypress">
<param name="keycode"><$ keycode $></param>
<param name="repeat"><$ repeat $></param>
</request>
<response><$ "1" $></response>
</service>
|