mirror of
https://github.com/albfan/miraclecast.git
synced 2025-02-12 16:11:54 +00:00
parent
42820c00ba
commit
3f2266e254
2 changed files with 24 additions and 13 deletions
|
@ -1,8 +1,19 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
function kill_child() {
|
||||||
|
CHILDREN="$(ps -o pid= --ppid $$)"
|
||||||
|
echo killing $CHILDREN
|
||||||
|
kill $CHILDREN
|
||||||
|
}
|
||||||
|
|
||||||
IP=$1
|
IP=$1
|
||||||
shift
|
shift
|
||||||
UIBC_PORT=$1
|
UIBC_PORT=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
gstplayer $@ | miracle-uibcctl $IP $UIBC_PORT --daemon
|
echo $$
|
||||||
|
|
||||||
|
trap 'kill_child' SIGTERM
|
||||||
|
|
||||||
|
gstplayer $@ | miracle-uibcctl $IP $UIBC_PORT --daemon &
|
||||||
|
wait
|
||||||
|
|
|
@ -56,20 +56,22 @@ int main(int argc, char *argv[]) {
|
||||||
bzero(buffer, 256);
|
bzero(buffer, 256);
|
||||||
fgets(buffer, 255, stdin);
|
fgets(buffer, 255, stdin);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (daemon) {
|
if (!daemon) {
|
||||||
printf("input: %s", buffer);
|
printf("input: %s", buffer);
|
||||||
}
|
}
|
||||||
char type = buffer[0];
|
char type = buffer[0];
|
||||||
UibcMessage uibcmessage;
|
UibcMessage uibcmessage;
|
||||||
if (type == '0' || type == '1') {
|
if (type == '0' || type == '1') {
|
||||||
uibcmessage = buildUibcMessage(GENERIC_TOUCH_DOWN, buffer, 1, 1);
|
uibcmessage = buildUibcMessage(GENERIC_TOUCH_DOWN, buffer, 1, 1);
|
||||||
} else if (type == '3' || type == '4') {
|
} else if (type == '3' || type == '4') {
|
||||||
uibcmessage = buildUibcMessage(GENERIC_KEY_DOWN, buffer, 1, 1);
|
uibcmessage = buildUibcMessage(GENERIC_KEY_DOWN, buffer, 1, 1);
|
||||||
} else {
|
} else {
|
||||||
|
if (!daemon) {
|
||||||
printf("unknow event type: %s", buffer);
|
printf("unknow event type: %s", buffer);
|
||||||
continue;
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = sendUibcMessage(&uibcmessage, sockfd);
|
r = sendUibcMessage(&uibcmessage, sockfd);
|
||||||
|
@ -86,8 +88,7 @@ const char *int2binary(int x, int padding)
|
||||||
{
|
{
|
||||||
char *b;
|
char *b;
|
||||||
int min_padding = x > 0 ? floor(log2(x)) : 0;
|
int min_padding = x > 0 ? floor(log2(x)) : 0;
|
||||||
if (padding < min_padding)
|
if (padding < min_padding) {
|
||||||
{
|
|
||||||
padding = min_padding;
|
padding = min_padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,8 +96,7 @@ const char *int2binary(int x, int padding)
|
||||||
strcpy(b, "");
|
strcpy(b, "");
|
||||||
|
|
||||||
int z;
|
int z;
|
||||||
for (z = pow(2,padding); z > 0; z >>= 1)
|
for (z = pow(2,padding); z > 0; z >>= 1) {
|
||||||
{
|
|
||||||
strcat(b, ((x & z) == z) ? "1" : "0");
|
strcat(b, ((x & z) == z) ? "1" : "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,8 +176,8 @@ void getUIBCGenericTouchPacket(const char *inEventDesc,
|
||||||
char** splitedStr = str_split((char*)inEventDesc, ",", &size);
|
char** splitedStr = str_split((char*)inEventDesc, ",", &size);
|
||||||
|
|
||||||
if ((int)size - 5 < 0 || ((int)size - 5) % 3 != 0) {
|
if ((int)size - 5 < 0 || ((int)size - 5) % 3 != 0) {
|
||||||
log_error("getUIBCGenericTouchPacket (%s)", "bad input event");
|
log_error("getUIBCGenericTouchPacket (%s)", "bad input event");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int offset_split = 0;
|
int offset_split = 0;
|
||||||
typeId = atoi(*(splitedStr + offset_split++));
|
typeId = atoi(*(splitedStr + offset_split++));
|
||||||
|
|
Loading…
Reference in a new issue