2 * Copyright 2021 RĂ©mi Bernon for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef __WINEBUS_UNIX_PRIVATE_H
20 #define __WINEBUS_UNIX_PRIVATE_H
27 #include <ddk/hidsdi.h>
31 #include "wine/list.h"
33 struct effect_periodic
41 struct effect_envelope
49 struct effect_condition
51 INT16 center_point_offset
;
52 INT16 positive_coefficient
;
53 INT16 negative_coefficient
;
54 UINT16 positive_saturation
;
55 UINT16 negative_saturation
;
59 struct effect_constant_force
64 struct effect_ramp_force
74 UINT16 trigger_repeat_interval
;
79 BOOL direction_enabled
;
83 /* only for periodic, constant or ramp forces */
84 struct effect_envelope envelope
;
87 struct effect_periodic periodic
;
88 struct effect_condition condition
[2];
89 struct effect_constant_force constant_force
;
90 struct effect_ramp_force ramp_force
;
96 struct raw_device_vtbl
98 void (*destroy
)(struct unix_device
*iface
);
99 NTSTATUS (*start
)(struct unix_device
*iface
);
100 void (*stop
)(struct unix_device
*iface
);
101 NTSTATUS (*get_report_descriptor
)(struct unix_device
*iface
, BYTE
*buffer
, UINT length
, UINT
*out_length
);
102 void (*set_output_report
)(struct unix_device
*iface
, HID_XFER_PACKET
*packet
, IO_STATUS_BLOCK
*io
);
103 void (*get_feature_report
)(struct unix_device
*iface
, HID_XFER_PACKET
*packet
, IO_STATUS_BLOCK
*io
);
104 void (*set_feature_report
)(struct unix_device
*iface
, HID_XFER_PACKET
*packet
, IO_STATUS_BLOCK
*io
);
107 struct hid_device_vtbl
109 void (*destroy
)(struct unix_device
*iface
);
110 NTSTATUS (*start
)(struct unix_device
*iface
);
111 void (*stop
)(struct unix_device
*iface
);
112 NTSTATUS (*haptics_start
)(struct unix_device
*iface
, UINT duration_ms
,
113 USHORT rumble_intensity
, USHORT buzz_intensity
,
114 USHORT left_intensity
, USHORT right_intensity
);
115 NTSTATUS (*haptics_stop
)(struct unix_device
*iface
);
116 NTSTATUS (*physical_device_control
)(struct unix_device
*iface
, USAGE control
);
117 NTSTATUS (*physical_device_set_gain
)(struct unix_device
*iface
, BYTE percent
);
118 NTSTATUS (*physical_effect_control
)(struct unix_device
*iface
, BYTE index
, USAGE control
, BYTE iterations
);
119 NTSTATUS (*physical_effect_update
)(struct unix_device
*iface
, BYTE index
, struct effect_params
*params
);
122 struct hid_report_descriptor
127 BYTE next_report_id
[3];
130 #include "pshpack1.h"
131 struct hid_haptics_feature
138 struct hid_haptics_features
140 struct hid_haptics_feature rumble
;
141 struct hid_haptics_feature buzz
;
142 struct hid_haptics_feature left
;
143 struct hid_haptics_feature right
;
149 struct hid_haptics_features features
;
150 BYTE features_report
;
151 BYTE intensity_report
;
154 /* must match the order and number of usages in the
155 * PID_USAGE_STATE_REPORT report */
156 enum effect_state_flags
158 EFFECT_STATE_DEVICE_PAUSED
= 0x01,
159 EFFECT_STATE_ACTUATORS_ENABLED
= 0x02,
160 EFFECT_STATE_EFFECT_PLAYING
= 0x04,
163 struct hid_effect_state
172 USAGE effect_types
[32];
173 struct effect_params effect_params
[256];
175 BYTE device_control_report
;
176 BYTE device_gain_report
;
177 BYTE effect_control_report
;
178 BYTE effect_update_report
;
179 BYTE set_periodic_report
;
180 BYTE set_envelope_report
;
181 BYTE set_condition_report
;
182 BYTE set_constant_force_report
;
183 BYTE set_ramp_force_report
;
185 struct hid_effect_state effect_state
;
188 struct hid_device_state
191 USAGE_AND_PAGE abs_axis_usages
[32];
192 USHORT abs_axis_start
;
193 USHORT abs_axis_count
;
194 USHORT rel_axis_start
;
195 USHORT rel_axis_count
;
196 USHORT hatswitch_start
;
197 USHORT hatswitch_count
;
202 BYTE
*last_report_buf
;
209 const struct raw_device_vtbl
*vtbl
;
213 const struct hid_device_vtbl
*hid_vtbl
;
214 struct hid_report_descriptor hid_report_descriptor
;
215 struct hid_device_state hid_device_state
;
216 struct hid_haptics hid_haptics
;
217 struct hid_physical hid_physical
;
220 extern void *raw_device_create(const struct raw_device_vtbl
*vtbl
, SIZE_T size
) DECLSPEC_HIDDEN
;
221 extern void *hid_device_create(const struct hid_device_vtbl
*vtbl
, SIZE_T size
) DECLSPEC_HIDDEN
;
223 extern NTSTATUS
sdl_bus_init(void *) DECLSPEC_HIDDEN
;
224 extern NTSTATUS
sdl_bus_wait(void *) DECLSPEC_HIDDEN
;
225 extern NTSTATUS
sdl_bus_stop(void *) DECLSPEC_HIDDEN
;
227 extern NTSTATUS
udev_bus_init(void *) DECLSPEC_HIDDEN
;
228 extern NTSTATUS
udev_bus_wait(void *) DECLSPEC_HIDDEN
;
229 extern NTSTATUS
udev_bus_stop(void *) DECLSPEC_HIDDEN
;
231 extern NTSTATUS
iohid_bus_init(void *) DECLSPEC_HIDDEN
;
232 extern NTSTATUS
iohid_bus_wait(void *) DECLSPEC_HIDDEN
;
233 extern NTSTATUS
iohid_bus_stop(void *) DECLSPEC_HIDDEN
;
235 extern void bus_event_cleanup(struct bus_event
*event
) DECLSPEC_HIDDEN
;
236 extern void bus_event_queue_destroy(struct list
*queue
) DECLSPEC_HIDDEN
;
237 extern BOOL
bus_event_queue_device_removed(struct list
*queue
, struct unix_device
*device
) DECLSPEC_HIDDEN
;
238 extern BOOL
bus_event_queue_device_created(struct list
*queue
, struct unix_device
*device
, struct device_desc
*desc
) DECLSPEC_HIDDEN
;
239 extern BOOL
bus_event_queue_input_report(struct list
*queue
, struct unix_device
*device
,
240 BYTE
*report
, USHORT length
) DECLSPEC_HIDDEN
;
241 extern BOOL
bus_event_queue_pop(struct list
*queue
, struct bus_event
*event
) DECLSPEC_HIDDEN
;
243 extern BOOL
hid_device_begin_report_descriptor(struct unix_device
*iface
, const USAGE_AND_PAGE
*device_usage
) DECLSPEC_HIDDEN
;
244 extern BOOL
hid_device_end_report_descriptor(struct unix_device
*iface
) DECLSPEC_HIDDEN
;
246 extern BOOL
hid_device_begin_input_report(struct unix_device
*iface
, const USAGE_AND_PAGE
*physical_usage
) DECLSPEC_HIDDEN
;
247 extern BOOL
hid_device_end_input_report(struct unix_device
*iface
) DECLSPEC_HIDDEN
;
248 extern BOOL
hid_device_add_buttons(struct unix_device
*iface
, USAGE usage_page
,
249 USAGE usage_min
, USAGE usage_max
) DECLSPEC_HIDDEN
;
250 extern BOOL
hid_device_add_hatswitch(struct unix_device
*iface
, INT count
) DECLSPEC_HIDDEN
;
251 extern BOOL
hid_device_add_axes(struct unix_device
*iface
, BYTE count
, USAGE usage_page
,
252 const USAGE
*usages
, BOOL rel
, LONG min
, LONG max
) DECLSPEC_HIDDEN
;
254 extern BOOL
hid_device_add_haptics(struct unix_device
*iface
) DECLSPEC_HIDDEN
;
255 extern BOOL
hid_device_add_physical(struct unix_device
*iface
, USAGE
*usages
, USHORT count
) DECLSPEC_HIDDEN
;
257 extern BOOL
hid_device_set_abs_axis(struct unix_device
*iface
, ULONG index
, LONG value
) DECLSPEC_HIDDEN
;
258 extern BOOL
hid_device_set_rel_axis(struct unix_device
*iface
, ULONG index
, LONG value
) DECLSPEC_HIDDEN
;
259 extern BOOL
hid_device_set_button(struct unix_device
*iface
, ULONG index
, BOOL is_set
) DECLSPEC_HIDDEN
;
260 extern BOOL
hid_device_set_hatswitch_x(struct unix_device
*iface
, ULONG index
, LONG new_x
) DECLSPEC_HIDDEN
;
261 extern BOOL
hid_device_set_hatswitch_y(struct unix_device
*iface
, ULONG index
, LONG new_y
) DECLSPEC_HIDDEN
;
262 extern BOOL
hid_device_move_hatswitch(struct unix_device
*iface
, ULONG index
, LONG x
, LONG y
) DECLSPEC_HIDDEN
;
264 extern BOOL
hid_device_sync_report(struct unix_device
*iface
) DECLSPEC_HIDDEN
;
265 extern void hid_device_drop_report(struct unix_device
*iface
) DECLSPEC_HIDDEN
;
267 extern void hid_device_set_effect_state(struct unix_device
*iface
, BYTE index
, BYTE flags
) DECLSPEC_HIDDEN
;
269 BOOL
is_xbox_gamepad(WORD vid
, WORD pid
) DECLSPEC_HIDDEN
;
270 BOOL
is_dualshock4_gamepad(WORD vid
, WORD pid
) DECLSPEC_HIDDEN
;
271 BOOL
is_dualsense_gamepad(WORD vid
, WORD pid
) DECLSPEC_HIDDEN
;
273 #endif /* __WINEBUS_UNIX_PRIVATE_H */