mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2025-07-01 23:35:47 +00:00
Remove map creation support
This commit is contained in:
parent
415c2efe87
commit
0a5b4ec5cc
@ -11,10 +11,6 @@ Usage: I<moonlight> E<lt>actionE<gt> [options] [host]
|
||||
|
||||
=over 4
|
||||
|
||||
=item B<map>
|
||||
|
||||
Create a mapping file for a gamepad.
|
||||
|
||||
=item B<pair>
|
||||
|
||||
Pair this computer with the host.
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of Moonlight Embedded.
|
||||
*
|
||||
* Copyright (C) 2015 Iwan Timmer
|
||||
* Copyright (C) 2015-2017 Iwan Timmer
|
||||
*
|
||||
* Moonlight is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -429,85 +429,6 @@ void evdev_create(const char* device, char* mapFile) {
|
||||
loop_add_fd(devices[dev].fd, &evdev_handle, POLLIN);
|
||||
}
|
||||
|
||||
static void evdev_map_key(char* keyName, short* key) {
|
||||
printf("Press %s\n", keyName);
|
||||
currentKey = key;
|
||||
currentAbs = NULL;
|
||||
*key = -1;
|
||||
loop_main();
|
||||
|
||||
usleep(250000);
|
||||
evdev_drain();
|
||||
}
|
||||
|
||||
static void evdev_map_abs(char* keyName, short* abs, bool* reverse) {
|
||||
printf("Move %s\n", keyName);
|
||||
currentKey = NULL;
|
||||
currentAbs = abs;
|
||||
currentReverse = reverse;
|
||||
*abs = -1;
|
||||
loop_main();
|
||||
|
||||
usleep(250000);
|
||||
evdev_drain();
|
||||
}
|
||||
|
||||
static void evdev_map_abskey(char* keyName, short* key, short* abs, bool* reverse) {
|
||||
printf("Press %s\n", keyName);
|
||||
currentKey = key;
|
||||
currentAbs = abs;
|
||||
currentReverse = reverse;
|
||||
*key = -1;
|
||||
*abs = -1;
|
||||
*currentReverse = false;
|
||||
loop_main();
|
||||
|
||||
usleep(250000);
|
||||
evdev_drain();
|
||||
}
|
||||
|
||||
void evdev_map(char* fileName) {
|
||||
struct mapping map;
|
||||
|
||||
handler = evdev_handle_mapping_event;
|
||||
|
||||
evdev_map_abs("Left Stick Right", &(map.abs_x), &(map.reverse_x));
|
||||
evdev_map_abs("Left Stick Up", &(map.abs_y), &(map.reverse_y));
|
||||
evdev_map_key("Left Stick Button", &(map.btn_thumbl));
|
||||
|
||||
evdev_map_abs("Right Stick Right", &(map.abs_rx), &(map.reverse_rx));
|
||||
evdev_map_abs("Right Stick Up", &(map.abs_ry), &(map.reverse_ry));
|
||||
evdev_map_key("Right Stick Button", &(map.btn_thumbr));
|
||||
|
||||
evdev_map_abskey("D-Pad Right", &(map.btn_dpad_right), &(map.abs_dpad_x), &(map.reverse_dpad_x));
|
||||
if (map.btn_dpad_right >= 0)
|
||||
evdev_map_key("D-Pad Left", &(map.btn_dpad_left));
|
||||
else
|
||||
map.btn_dpad_left = -1;
|
||||
|
||||
evdev_map_abskey("D-Pad Down", &(map.btn_dpad_down), &(map.abs_dpad_y), &(map.reverse_dpad_y));
|
||||
if (map.btn_dpad_down >= 0)
|
||||
evdev_map_key("D-Pad Up", &(map.btn_dpad_up));
|
||||
else
|
||||
map.btn_dpad_up = -1;
|
||||
|
||||
evdev_map_key("Button X (1)", &(map.btn_west));
|
||||
evdev_map_key("Button A (2)", &(map.btn_south));
|
||||
evdev_map_key("Button B (3)", &(map.btn_east));
|
||||
evdev_map_key("Button Y (4)", &(map.btn_north));
|
||||
evdev_map_key("Back Button", &(map.btn_select));
|
||||
evdev_map_key("Start Button", &(map.btn_start));
|
||||
evdev_map_key("Special Button", &(map.btn_mode));
|
||||
|
||||
bool ignored;
|
||||
evdev_map_abskey("Left Trigger", &(map.btn_tl2), &(map.abs_z), &ignored);
|
||||
evdev_map_abskey("Right Trigger", &(map.btn_tr2), &(map.abs_rz), &ignored);
|
||||
|
||||
evdev_map_key("Left Bumper", &(map.btn_tl));
|
||||
evdev_map_key("Right Bumper", &(map.btn_tr));
|
||||
mapping_save(fileName, &map);
|
||||
}
|
||||
|
||||
void evdev_start() {
|
||||
// After grabbing, the only way to quit via the keyboard
|
||||
// is via the special key combo that the input handling
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of Moonlight Embedded.
|
||||
*
|
||||
* Copyright (C) 2015 Iwan Timmer
|
||||
* Copyright (C) 2015-2017 Iwan Timmer
|
||||
*
|
||||
* Moonlight is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -19,7 +19,6 @@
|
||||
|
||||
void evdev_create(const char* device, char* mapFile);
|
||||
void evdev_loop();
|
||||
void evdev_map(char* fileName);
|
||||
|
||||
void evdev_init();
|
||||
void evdev_start();
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of Moonlight Embedded.
|
||||
*
|
||||
* Copyright (C) 2015 Iwan Timmer
|
||||
* Copyright (C) 2015-2017 Iwan Timmer
|
||||
*
|
||||
* Moonlight is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -23,9 +23,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define write_config(fd, key, value) fprintf(fd, "%s = %hd\n", key, value)
|
||||
#define write_config_bool(fd, key, value) fprintf(fd, "%s = %s\n", key, value?"true":"false");
|
||||
|
||||
void mapping_load(char* fileName, struct mapping* map) {
|
||||
FILE* fd = fopen(fileName, "r");
|
||||
if (fd == NULL) {
|
||||
@ -53,10 +50,22 @@ void mapping_load(char* fileName, struct mapping* map) {
|
||||
map->abs_rz = int_value;
|
||||
else if (strcmp("abs_deadzone", key) == 0)
|
||||
map->abs_deadzone = int_value;
|
||||
else if (strcmp("abs_dpad_x", key) == 0)
|
||||
map->abs_dpad_x = int_value;
|
||||
else if (strcmp("abs_dpad_y", key) == 0)
|
||||
map->abs_dpad_y = int_value;
|
||||
else if (strcmp("hat_dpad_right", key) == 0)
|
||||
map->hat_dpad_right = int_value;
|
||||
else if (strcmp("hat_dpad_left", key) == 0)
|
||||
map->hat_dpad_left = int_value;
|
||||
else if (strcmp("hat_dpad_up", key) == 0)
|
||||
map->hat_dpad_up = int_value;
|
||||
else if (strcmp("hat_dpad_down", key) == 0)
|
||||
map->hat_dpad_down = int_value;
|
||||
else if (strcmp("hat_dpad_dir_right", key) == 0)
|
||||
map->hat_dpad_dir_right = int_value;
|
||||
else if (strcmp("hat_dpad_dir_left", key) == 0)
|
||||
map->hat_dpad_dir_left = int_value;
|
||||
else if (strcmp("hat_dpad_dir_up", key) == 0)
|
||||
map->hat_dpad_dir_up = int_value;
|
||||
else if (strcmp("hat_dpad_dir_down", key) == 0)
|
||||
map->hat_dpad_dir_down = int_value;
|
||||
else if (strcmp("btn_south", key) == 0)
|
||||
map->btn_south = int_value;
|
||||
else if (strcmp("btn_north", key) == 0)
|
||||
@ -99,10 +108,6 @@ void mapping_load(char* fileName, struct mapping* map) {
|
||||
map->reverse_rx = strcmp("true", value) == 0;
|
||||
else if (strcmp("reverse_ry", key) == 0)
|
||||
map->reverse_ry = strcmp("true", value) == 0;
|
||||
else if (strcmp("reverse_dpad_x", key) == 0)
|
||||
map->reverse_dpad_x = strcmp("true", value) == 0;
|
||||
else if (strcmp("reverse_dpad_y", key) == 0)
|
||||
map->reverse_dpad_y = strcmp("true", value) == 0;
|
||||
else
|
||||
fprintf(stderr, "Can't map (%s)\n", key);
|
||||
}
|
||||
@ -114,57 +119,3 @@ void mapping_load(char* fileName, struct mapping* map) {
|
||||
}
|
||||
free(line);
|
||||
}
|
||||
|
||||
void mapping_save(char* fileName, struct mapping* map) {
|
||||
FILE* fd = fopen(fileName, "w");
|
||||
if (fd == NULL) {
|
||||
fprintf(stderr, "Can't open mapping file: %s\n", fileName);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
write_config(fd, "abs_x", map->abs_x);
|
||||
write_config(fd, "abs_y", map->abs_y);
|
||||
write_config(fd, "abs_z", map->abs_z);
|
||||
|
||||
write_config_bool(fd, "reverse_x", map->reverse_x);
|
||||
write_config_bool(fd, "reverse_y", map->reverse_y);
|
||||
|
||||
write_config(fd, "abs_rx", map->abs_rx);
|
||||
write_config(fd, "abs_ry", map->abs_ry);
|
||||
write_config(fd, "abs_rz", map->abs_rz);
|
||||
|
||||
write_config_bool(fd, "reverse_rx", map->reverse_rx);
|
||||
write_config_bool(fd, "reverse_ry", map->reverse_ry);
|
||||
|
||||
write_config(fd, "abs_deadzone", map->abs_deadzone);
|
||||
|
||||
write_config(fd, "abs_dpad_x", map->abs_dpad_x);
|
||||
write_config(fd, "abs_dpad_y", map->abs_dpad_y);
|
||||
|
||||
write_config_bool(fd, "reverse_dpad_x", map->reverse_dpad_x);
|
||||
write_config_bool(fd, "reverse_dpad_y", map->reverse_dpad_y);
|
||||
|
||||
write_config(fd, "btn_north", map->btn_north);
|
||||
write_config(fd, "btn_east", map->btn_east);
|
||||
write_config(fd, "btn_south", map->btn_south);
|
||||
write_config(fd, "btn_west", map->btn_west);
|
||||
|
||||
write_config(fd, "btn_select", map->btn_select);
|
||||
write_config(fd, "btn_start", map->btn_start);
|
||||
write_config(fd, "btn_mode", map->btn_mode);
|
||||
|
||||
write_config(fd, "btn_thumbl", map->btn_thumbl);
|
||||
write_config(fd, "btn_thumbr", map->btn_thumbr);
|
||||
|
||||
write_config(fd, "btn_tl", map->btn_tl);
|
||||
write_config(fd, "btn_tr", map->btn_tr);
|
||||
write_config(fd, "btn_tl2", map->btn_tl2);
|
||||
write_config(fd, "btn_tr2", map->btn_tr2);
|
||||
|
||||
write_config(fd, "btn_dpad_up", map->btn_dpad_up);
|
||||
write_config(fd, "btn_dpad_down", map->btn_dpad_down);
|
||||
write_config(fd, "btn_dpad_left", map->btn_dpad_left);
|
||||
write_config(fd, "btn_dpad_right", map->btn_dpad_right);
|
||||
|
||||
fclose(fd);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of Moonlight Embedded.
|
||||
*
|
||||
* Copyright (C) 2015 Iwan Timmer
|
||||
* Copyright (C) 2015-2017 Iwan Timmer
|
||||
*
|
||||
* Moonlight is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -40,4 +40,3 @@ struct mapping {
|
||||
};
|
||||
|
||||
void mapping_load(char* fileName, struct mapping* map);
|
||||
void mapping_save(char* fileName, struct mapping* map);
|
||||
|
16
src/main.c
16
src/main.c
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This file is part of Moonlight Embedded.
|
||||
*
|
||||
* Copyright (C) 2015, 2016 Iwan Timmer
|
||||
* Copyright (C) 2015-2017 Iwan Timmer
|
||||
*
|
||||
* Moonlight is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -119,7 +119,6 @@ static void help() {
|
||||
printf("Usage: moonlight [action] (options) [host]\n");
|
||||
printf(" moonlight [configfile]\n");
|
||||
printf("\n Actions\n\n");
|
||||
printf("\tmap\t\t\tCreate mapping file for gamepad\n");
|
||||
printf("\tpair\t\t\tPair device with computer\n");
|
||||
printf("\tunpair\t\t\tUnpair device with computer\n");
|
||||
printf("\tstream\t\t\tStream computer to device\n");
|
||||
@ -183,19 +182,6 @@ int main(int argc, char* argv[]) {
|
||||
exit(-1);
|
||||
}
|
||||
config.stream.supportsHevc = config.codec != CODEC_H264 && (config.codec == CODEC_HEVC || platform_supports_hevc(system));
|
||||
|
||||
if (strcmp("map", config.action) == 0) {
|
||||
if (config.address == NULL) {
|
||||
perror("No filename for mapping");
|
||||
exit(-1);
|
||||
}
|
||||
udev_init(!inputAdded, config.mapping);
|
||||
for (int i=0;i<config.inputsCount;i++)
|
||||
evdev_create(config.inputs[i].path, config.inputs[i].mapping);
|
||||
|
||||
evdev_map(config.address);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (config.address == NULL) {
|
||||
config.address = malloc(MAX_ADDRESS_SIZE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user