1 module ds5w.device;
2 
3 import core.stdc.stddef : wchar_t;
4 
5 /*
6 	Device.h is part of DualSenseWindows
7 	https://github.com/Ohjurot/DualSense-Windows
8 
9 	Contributors of this file:
10 	11.2020 Ludwig Füchsl
11 
12 	Licensed under the MIT License (To be found in repository root directory)
13 */
14 
15 enum PSVENDOR = 0x054C;
16 
17 enum DEVICE_VARIANT : uint
18 {
19     DS_REGULAR = 0x0CE6,
20     DS_EDGE = 0x0DF2
21 }
22 
23 /// <summary>
24 /// Enum for device connection type
25 /// </summary>
26 enum DeviceConnection : ubyte
27 {
28     /// <summary>
29     /// Controler is connected via USB
30     /// </summary>
31     USB = 0,
32 
33     /// <summary>
34     /// Controler is connected via bluetooth
35     /// </summary>
36     BT = 1,
37 }
38 
39 /// <summary>
40 /// Struckt for storing device enum info while device discovery
41 /// </summary>
42 struct DeviceEnumInfo
43 {
44     /// <summary>
45     /// Encapsulate data in struct to (at least try) prevent user from modifing the context
46     /// </summary>
47     struct Internal
48     {
49         /// <summary>
50         /// Path to the discovered device
51         /// </summary>
52         wchar_t[260] path;
53 
54         /// <summary>
55         /// Connection type of the discoverd device
56         /// </summary>
57         DeviceConnection connection;
58     }
59 
60     Internal _internal;
61 
62     /// <summary>
63     /// DS_REGULAR or DS_EDGE
64     /// </summary>
65     DEVICE_VARIANT variant;
66 }
67 
68 /// <summary>
69 /// Device context
70 /// </summary>
71 struct DeviceContext
72 {
73     /// <summary>
74     /// Encapsulate data in struct to (at least try) prevent user from modifing the context
75     /// </summary>
76     struct Internal
77     {
78         /// <summary>
79         /// Path to the device
80         /// </summary>
81         wchar_t[260] devicePath;
82 
83         /// <summary>
84         /// Handle to the open device
85         /// </summary>
86         void* deviceHandle;
87 
88         /// <summary>
89         /// Connection of the device
90         /// </summary>
91         DeviceConnection connection;
92 
93         /// <summary>
94         /// Current state of connection
95         /// </summary>
96         bool connected;
97 
98         /// <summary>
99         /// HID Input buffer (will be allocated by the context init function)
100         /// </summary>
101         ubyte[547] hidBuffer;
102     }
103 
104     Internal _internal;
105 
106     /// <summary>
107     /// DS_REGULAR or DS_EDGE
108     /// </summary>
109     DEVICE_VARIANT variant;
110 }