comparison src/main.rs @ 14:adab13145994

Add support for remote clients.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 02 Nov 2020 00:06:09 +0100
parents 97e543f50f62
children 478cf2a7d577
comparison
equal deleted inserted replaced
13:97e543f50f62 14:adab13145994
12 // GNU Affero General Public License for more details. 12 // GNU Affero General Public License for more details.
13 // 13 //
14 // You should have received a copy of the GNU Affero General Public License 14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <https://www.gnu.org/licenses/>. 15 // along with this program. If not, see <https://www.gnu.org/licenses/>.
16 16
17 #[cfg(feature = "gui")]
17 mod gtk; 18 mod gtk;
19 mod server;
18 mod uinput; 20 mod uinput;
19 mod state; 21 mod state;
22
23 use std::env::args;
20 24
21 const MAX_X: i32 = 69920; 25 const MAX_X: i32 = 69920;
22 const MAX_Y: i32 = 39980; 26 const MAX_Y: i32 = 39980;
23 27
24 const DEFAULT_WIDTH: i32 = 320; 28 const DEFAULT_WIDTH: i32 = 320;
25 const DEFAULT_HEIGHT: i32 = 180; 29 const DEFAULT_HEIGHT: i32 = 180;
26 30
31 #[derive(Debug)]
32 enum Ui {
33 Gtk,
34 Server,
35 }
36
27 fn main() { 37 fn main() {
28 gtk::main(); 38 let mut args: Vec<_> = args().collect();
39 let ui = match if args.len() > 1 {
40 args.remove(1)
41 } else {
42 String::from("gui")
43 }.as_str() {
44 "gui" => Ui::Gtk,
45 "server" => Ui::Server,
46 name => {
47 eprintln!("Wrong UI “{}”, expected gui or server.", name);
48 std::process::exit(2);
49 }
50 };
51
52 match ui {
53 #[cfg(feature = "gui")]
54 Ui::Gtk => gtk::main(&args),
55
56 #[cfg(not(feature = "gui"))]
57 Ui::Gtk => panic!("tablet-emu has been compiled without GUI support."),
58
59 Ui::Server => server::main(&args),
60 }
29 } 61 }