annotate src/protocol.rs @ 20:f81d56c5da76 default tip

Use features to condition building binaries.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 26 Aug 2021 23:49:52 +0200
parents ba09079686a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 // Tablet emulator, for people who don’t own one
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2 // Copyright © 2020 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 //
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
4 // This program is free software: you can redistribute it and/or modify
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5 // it under the terms of the GNU Affero General Public License as published by
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6 // the Free Software Foundation, either version 3 of the License, or
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7 // (at your option) any later version.
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 //
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9 // This program is distributed in the hope that it will be useful,
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12 // GNU Affero General Public License for more details.
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 //
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14 // You should have received a copy of the GNU Affero General Public License
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
15 // along with this program. If not, see <https://www.gnu.org/licenses/>.
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16
19
ba09079686a0 Add support for different endianness between client and server.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 18
diff changeset
17 use serde::{Serialize, Deserialize};
18
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
18 use bitflags::bitflags;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
19
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
20 bitflags! {
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
21 /// This is the memory layout of the buttons on the 3DS.
19
ba09079686a0 Add support for different endianness between client and server.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 18
diff changeset
22 #[derive(Serialize, Deserialize, Default)]
18
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
23 pub struct Buttons: u32 {
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
24 const A = 0x00000001;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
25 const B = 0x00000002;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
26 const SELECT = 0x00000004;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
27 const START = 0x00000008;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
28 const RIGHT = 0x00000010;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
29 const LEFT = 0x00000020;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30 const UP = 0x00000040;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
31 const DOWN = 0x00000080;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
32 const R = 0x00000100;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
33 const L = 0x00000200;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
34 const X = 0x00000400;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
35 const Y = 0x00000800;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36 // Nothing
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 // Nothing
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38 const ZL = 0x00004000;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39 const ZR = 0x00008000;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
40 const RESIZE = 0x00010000; // Not an actual 3DS button!
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
41 // Nothing
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
42 // Nothing
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
43 // Nothing
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
44 const TOUCH = 0x00100000;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
45 // Nothing
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
46 // Nothing
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
47 // Nothing
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
48 const C_RIGHT = 0x01000000;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
49 const C_LEFT = 0x02000000;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50 const C_UP = 0x04000000;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
51 const C_DOWN = 0x08000000;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
52 const CIRCLE_RIGHT = 0x10000000;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
53 const CIRCLE_LEFT = 0x20000000;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
54 const CIRCLE_UP = 0x40000000;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
55 const CIRCLE_DOWN = 0x80000000;
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
56 }
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
57 }
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
58
19
ba09079686a0 Add support for different endianness between client and server.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 18
diff changeset
59 #[derive(Serialize, Deserialize, Debug, Default)]
18
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
60 pub struct Event {
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
61 pub buttons: Buttons,
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
62 pad: (i16, i16),
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
63 c_pad: (i16, i16),
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
64 pub touch: (u16, u16),
3f7b7a3ad8fe Build three binaries instead of using arguments.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
65 }