2021-08-23 10:49:39 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2021 Rémi Bernon for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __WINEBUS_UNIX_PRIVATE_H
|
|
|
|
#define __WINEBUS_UNIX_PRIVATE_H
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include <windef.h>
|
|
|
|
#include <winbase.h>
|
|
|
|
#include <winternl.h>
|
2022-02-22 13:04:29 +01:00
|
|
|
#include <ddk/hidsdi.h>
|
2021-08-23 10:49:39 +02:00
|
|
|
|
|
|
|
#include "unixlib.h"
|
|
|
|
|
2021-08-30 11:22:52 +02:00
|
|
|
#include "wine/list.h"
|
|
|
|
|
2021-10-08 09:50:19 +02:00
|
|
|
struct effect_periodic
|
|
|
|
{
|
2021-11-19 09:39:39 +01:00
|
|
|
UINT16 magnitude;
|
|
|
|
INT16 offset;
|
|
|
|
UINT16 phase;
|
2021-10-08 09:50:19 +02:00
|
|
|
UINT16 period;
|
|
|
|
};
|
|
|
|
|
2021-10-08 09:50:21 +02:00
|
|
|
struct effect_envelope
|
|
|
|
{
|
2021-11-19 09:39:39 +01:00
|
|
|
UINT16 attack_level;
|
|
|
|
UINT16 fade_level;
|
2021-10-08 09:50:21 +02:00
|
|
|
UINT16 attack_time;
|
|
|
|
UINT16 fade_time;
|
|
|
|
};
|
|
|
|
|
2021-10-08 09:50:24 +02:00
|
|
|
struct effect_condition
|
|
|
|
{
|
2021-11-19 09:39:39 +01:00
|
|
|
INT16 center_point_offset;
|
|
|
|
INT16 positive_coefficient;
|
|
|
|
INT16 negative_coefficient;
|
|
|
|
UINT16 positive_saturation;
|
|
|
|
UINT16 negative_saturation;
|
|
|
|
UINT16 dead_band;
|
2021-10-08 09:50:24 +02:00
|
|
|
};
|
|
|
|
|
2021-10-08 09:50:26 +02:00
|
|
|
struct effect_constant_force
|
|
|
|
{
|
2021-11-19 09:39:39 +01:00
|
|
|
INT16 magnitude;
|
2021-10-08 09:50:26 +02:00
|
|
|
};
|
|
|
|
|
2021-10-08 09:50:28 +02:00
|
|
|
struct effect_ramp_force
|
|
|
|
{
|
2021-11-19 09:39:39 +01:00
|
|
|
INT16 ramp_start;
|
|
|
|
INT16 ramp_end;
|
2021-10-08 09:50:28 +02:00
|
|
|
};
|
|
|
|
|
2021-10-05 08:43:22 +02:00
|
|
|
struct effect_params
|
|
|
|
{
|
|
|
|
USAGE effect_type;
|
|
|
|
UINT16 duration;
|
|
|
|
UINT16 trigger_repeat_interval;
|
|
|
|
UINT16 sample_period;
|
|
|
|
UINT16 start_delay;
|
|
|
|
BYTE trigger_button;
|
|
|
|
BOOL axis_enabled[2];
|
|
|
|
BOOL direction_enabled;
|
2021-11-19 09:39:39 +01:00
|
|
|
UINT16 direction[2];
|
2021-10-08 09:50:24 +02:00
|
|
|
BYTE condition_count;
|
2021-10-08 09:50:21 +02:00
|
|
|
/* only for periodic, constant or ramp forces */
|
|
|
|
struct effect_envelope envelope;
|
2021-10-08 09:50:19 +02:00
|
|
|
union
|
|
|
|
{
|
|
|
|
struct effect_periodic periodic;
|
2021-10-08 09:50:24 +02:00
|
|
|
struct effect_condition condition[2];
|
2021-10-08 09:50:26 +02:00
|
|
|
struct effect_constant_force constant_force;
|
2021-10-08 09:50:28 +02:00
|
|
|
struct effect_ramp_force ramp_force;
|
2021-10-08 09:50:19 +02:00
|
|
|
};
|
2021-10-05 08:43:22 +02:00
|
|
|
};
|
|
|
|
|
2021-09-22 10:30:42 +02:00
|
|
|
struct raw_device_vtbl
|
2021-09-03 09:30:49 +02:00
|
|
|
{
|
|
|
|
void (*destroy)(struct unix_device *iface);
|
2021-09-15 09:04:46 +02:00
|
|
|
NTSTATUS (*start)(struct unix_device *iface);
|
2021-09-14 08:58:21 +02:00
|
|
|
void (*stop)(struct unix_device *iface);
|
2022-01-31 10:10:59 +01:00
|
|
|
NTSTATUS (*get_report_descriptor)(struct unix_device *iface, BYTE *buffer, UINT length, UINT *out_length);
|
2021-09-03 09:30:49 +02:00
|
|
|
void (*set_output_report)(struct unix_device *iface, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io);
|
|
|
|
void (*get_feature_report)(struct unix_device *iface, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io);
|
|
|
|
void (*set_feature_report)(struct unix_device *iface, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io);
|
|
|
|
};
|
|
|
|
|
2021-09-22 10:30:42 +02:00
|
|
|
struct hid_device_vtbl
|
|
|
|
{
|
|
|
|
void (*destroy)(struct unix_device *iface);
|
|
|
|
NTSTATUS (*start)(struct unix_device *iface);
|
|
|
|
void (*stop)(struct unix_device *iface);
|
2022-01-31 10:10:59 +01:00
|
|
|
NTSTATUS (*haptics_start)(struct unix_device *iface, UINT duration_ms,
|
2021-09-23 08:55:30 +02:00
|
|
|
USHORT rumble_intensity, USHORT buzz_intensity);
|
2022-02-15 09:03:38 +01:00
|
|
|
NTSTATUS (*haptics_stop)(struct unix_device *iface);
|
2021-10-01 09:31:00 +02:00
|
|
|
NTSTATUS (*physical_device_control)(struct unix_device *iface, USAGE control);
|
2021-11-19 09:39:39 +01:00
|
|
|
NTSTATUS (*physical_device_set_gain)(struct unix_device *iface, BYTE percent);
|
2021-10-04 09:51:31 +02:00
|
|
|
NTSTATUS (*physical_effect_control)(struct unix_device *iface, BYTE index, USAGE control, BYTE iterations);
|
2021-10-05 08:43:22 +02:00
|
|
|
NTSTATUS (*physical_effect_update)(struct unix_device *iface, BYTE index, struct effect_params *params);
|
2021-09-22 10:30:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct hid_report_descriptor
|
|
|
|
{
|
|
|
|
BYTE *data;
|
|
|
|
SIZE_T size;
|
|
|
|
SIZE_T max_size;
|
2021-09-23 08:55:28 +02:00
|
|
|
BYTE next_report_id[3];
|
2021-09-22 10:30:42 +02:00
|
|
|
};
|
|
|
|
|
2022-02-14 17:26:19 +01:00
|
|
|
/* HID spec uses None / Stop names for the first two implicit waveforms,
|
|
|
|
* where Windows SDK headers use STOP / NULL for the corresponding HID
|
|
|
|
* usage constants. We're not actually using the usages anyway are we
|
|
|
|
* stick to the HID spec here.
|
|
|
|
*/
|
|
|
|
enum haptics_waveform_ordinal
|
|
|
|
{
|
|
|
|
HAPTICS_WAVEFORM_NONE_ORDINAL = 1, /* implicit, not included in waveform_list / duration_list */
|
|
|
|
HAPTICS_WAVEFORM_STOP_ORDINAL = 2, /* implicit, not included in waveform_list / duration_list */
|
|
|
|
HAPTICS_WAVEFORM_RUMBLE_ORDINAL = 3,
|
|
|
|
HAPTICS_WAVEFORM_BUZZ_ORDINAL = 4,
|
|
|
|
HAPTICS_WAVEFORM_FIRST_ORDINAL = HAPTICS_WAVEFORM_RUMBLE_ORDINAL,
|
|
|
|
HAPTICS_WAVEFORM_LAST_ORDINAL = HAPTICS_WAVEFORM_BUZZ_ORDINAL,
|
2021-09-24 11:51:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct hid_haptics_features
|
|
|
|
{
|
2022-02-14 17:26:19 +01:00
|
|
|
WORD waveform_list[HAPTICS_WAVEFORM_LAST_ORDINAL - HAPTICS_WAVEFORM_FIRST_ORDINAL + 1];
|
|
|
|
WORD duration_list[HAPTICS_WAVEFORM_LAST_ORDINAL - HAPTICS_WAVEFORM_FIRST_ORDINAL + 1];
|
2022-01-31 10:10:59 +01:00
|
|
|
UINT waveform_cutoff_time_ms;
|
2021-09-24 11:51:54 +02:00
|
|
|
};
|
|
|
|
|
2021-09-23 08:55:30 +02:00
|
|
|
struct hid_haptics
|
|
|
|
{
|
2021-09-24 11:51:54 +02:00
|
|
|
struct hid_haptics_features features;
|
2022-02-15 09:03:39 +01:00
|
|
|
UINT16 waveform_intensity[HAPTICS_WAVEFORM_LAST_ORDINAL + 1];
|
2021-09-24 11:51:54 +02:00
|
|
|
BYTE features_report;
|
|
|
|
BYTE waveform_report;
|
2021-09-23 08:55:30 +02:00
|
|
|
};
|
|
|
|
|
2021-12-02 10:47:45 +01:00
|
|
|
/* must match the order and number of usages in the
|
|
|
|
* PID_USAGE_STATE_REPORT report */
|
|
|
|
enum effect_state_flags
|
|
|
|
{
|
|
|
|
EFFECT_STATE_DEVICE_PAUSED = 0x01,
|
|
|
|
EFFECT_STATE_ACTUATORS_ENABLED = 0x02,
|
|
|
|
EFFECT_STATE_EFFECT_PLAYING = 0x04,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hid_effect_state
|
|
|
|
{
|
|
|
|
USHORT report_len;
|
|
|
|
BYTE *report_buf;
|
|
|
|
BYTE id;
|
|
|
|
};
|
|
|
|
|
2021-10-01 09:31:00 +02:00
|
|
|
struct hid_physical
|
|
|
|
{
|
2021-10-05 08:43:22 +02:00
|
|
|
USAGE effect_types[32];
|
|
|
|
struct effect_params effect_params[256];
|
|
|
|
|
2021-10-01 09:31:00 +02:00
|
|
|
BYTE device_control_report;
|
2021-11-17 11:51:50 +01:00
|
|
|
BYTE device_gain_report;
|
2021-10-04 09:51:31 +02:00
|
|
|
BYTE effect_control_report;
|
2021-10-05 08:43:22 +02:00
|
|
|
BYTE effect_update_report;
|
2021-10-08 09:50:19 +02:00
|
|
|
BYTE set_periodic_report;
|
2021-10-08 09:50:21 +02:00
|
|
|
BYTE set_envelope_report;
|
2021-10-08 09:50:24 +02:00
|
|
|
BYTE set_condition_report;
|
2021-10-08 09:50:26 +02:00
|
|
|
BYTE set_constant_force_report;
|
2021-10-08 09:50:28 +02:00
|
|
|
BYTE set_ramp_force_report;
|
2021-12-02 10:47:45 +01:00
|
|
|
|
|
|
|
struct hid_effect_state effect_state;
|
2021-10-01 09:31:00 +02:00
|
|
|
};
|
|
|
|
|
2021-09-22 10:30:43 +02:00
|
|
|
struct hid_device_state
|
|
|
|
{
|
|
|
|
ULONG bit_size;
|
2022-02-22 13:04:29 +01:00
|
|
|
USAGE_AND_PAGE abs_axis_usages[32];
|
2021-09-22 10:30:43 +02:00
|
|
|
USHORT abs_axis_start;
|
|
|
|
USHORT abs_axis_count;
|
|
|
|
USHORT rel_axis_start;
|
|
|
|
USHORT rel_axis_count;
|
|
|
|
USHORT hatswitch_start;
|
|
|
|
USHORT hatswitch_count;
|
|
|
|
USHORT button_start;
|
|
|
|
USHORT button_count;
|
2021-09-22 10:30:44 +02:00
|
|
|
USHORT report_len;
|
2021-09-23 08:55:26 +02:00
|
|
|
BYTE *report_buf;
|
|
|
|
BYTE *last_report_buf;
|
|
|
|
BOOL dropped;
|
2021-09-23 08:55:28 +02:00
|
|
|
BYTE id;
|
2021-09-22 10:30:43 +02:00
|
|
|
};
|
|
|
|
|
2021-08-23 10:49:41 +02:00
|
|
|
struct unix_device
|
|
|
|
{
|
2021-09-22 10:30:42 +02:00
|
|
|
const struct raw_device_vtbl *vtbl;
|
2021-09-03 09:30:50 +02:00
|
|
|
struct list entry;
|
2021-09-15 09:04:41 +02:00
|
|
|
LONG ref;
|
2021-09-22 10:30:42 +02:00
|
|
|
|
|
|
|
const struct hid_device_vtbl *hid_vtbl;
|
|
|
|
struct hid_report_descriptor hid_report_descriptor;
|
2021-09-22 10:30:43 +02:00
|
|
|
struct hid_device_state hid_device_state;
|
2021-09-23 08:55:30 +02:00
|
|
|
struct hid_haptics hid_haptics;
|
2021-10-01 09:31:00 +02:00
|
|
|
struct hid_physical hid_physical;
|
2021-08-23 10:49:41 +02:00
|
|
|
};
|
|
|
|
|
2021-09-22 10:30:42 +02:00
|
|
|
extern void *raw_device_create(const struct raw_device_vtbl *vtbl, SIZE_T size) DECLSPEC_HIDDEN;
|
|
|
|
extern void *hid_device_create(const struct hid_device_vtbl *vtbl, SIZE_T size) DECLSPEC_HIDDEN;
|
2021-09-14 08:58:22 +02:00
|
|
|
|
2021-09-17 08:50:34 +02:00
|
|
|
extern NTSTATUS sdl_bus_init(void *) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS sdl_bus_wait(void *) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS sdl_bus_stop(void *) DECLSPEC_HIDDEN;
|
2021-08-23 10:49:39 +02:00
|
|
|
|
2021-09-17 08:50:34 +02:00
|
|
|
extern NTSTATUS udev_bus_init(void *) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS udev_bus_wait(void *) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS udev_bus_stop(void *) DECLSPEC_HIDDEN;
|
2021-08-23 10:49:39 +02:00
|
|
|
|
2021-09-17 08:50:34 +02:00
|
|
|
extern NTSTATUS iohid_bus_init(void *) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS iohid_bus_wait(void *) DECLSPEC_HIDDEN;
|
|
|
|
extern NTSTATUS iohid_bus_stop(void *) DECLSPEC_HIDDEN;
|
2021-08-23 10:49:39 +02:00
|
|
|
|
2021-09-15 09:04:41 +02:00
|
|
|
extern void bus_event_cleanup(struct bus_event *event) DECLSPEC_HIDDEN;
|
2021-08-30 11:22:52 +02:00
|
|
|
extern void bus_event_queue_destroy(struct list *queue) DECLSPEC_HIDDEN;
|
2021-09-16 10:17:52 +02:00
|
|
|
extern BOOL bus_event_queue_device_removed(struct list *queue, struct unix_device *device) DECLSPEC_HIDDEN;
|
2021-09-06 09:17:31 +02:00
|
|
|
extern BOOL bus_event_queue_device_created(struct list *queue, struct unix_device *device, struct device_desc *desc) DECLSPEC_HIDDEN;
|
2021-09-15 09:04:41 +02:00
|
|
|
extern BOOL bus_event_queue_input_report(struct list *queue, struct unix_device *device,
|
|
|
|
BYTE *report, USHORT length) DECLSPEC_HIDDEN;
|
2021-08-30 11:22:52 +02:00
|
|
|
extern BOOL bus_event_queue_pop(struct list *queue, struct bus_event *event) DECLSPEC_HIDDEN;
|
|
|
|
|
2021-09-22 10:30:42 +02:00
|
|
|
extern BOOL hid_device_begin_report_descriptor(struct unix_device *iface, USAGE usage_page, USAGE usage) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL hid_device_end_report_descriptor(struct unix_device *iface) DECLSPEC_HIDDEN;
|
2021-08-30 11:22:55 +02:00
|
|
|
|
2021-09-23 08:55:28 +02:00
|
|
|
extern BOOL hid_device_begin_input_report(struct unix_device *iface) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL hid_device_end_input_report(struct unix_device *iface) DECLSPEC_HIDDEN;
|
2021-09-22 10:30:42 +02:00
|
|
|
extern BOOL hid_device_add_buttons(struct unix_device *iface, USAGE usage_page,
|
|
|
|
USAGE usage_min, USAGE usage_max) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL hid_device_add_hatswitch(struct unix_device *iface, INT count) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL hid_device_add_axes(struct unix_device *iface, BYTE count, USAGE usage_page,
|
|
|
|
const USAGE *usages, BOOL rel, LONG min, LONG max) DECLSPEC_HIDDEN;
|
2021-08-30 11:22:55 +02:00
|
|
|
|
2021-09-23 08:55:30 +02:00
|
|
|
extern BOOL hid_device_add_haptics(struct unix_device *iface) DECLSPEC_HIDDEN;
|
2021-10-05 08:43:22 +02:00
|
|
|
extern BOOL hid_device_add_physical(struct unix_device *iface, USAGE *usages, USHORT count) DECLSPEC_HIDDEN;
|
2021-08-30 11:22:55 +02:00
|
|
|
|
2021-09-23 08:55:27 +02:00
|
|
|
extern BOOL hid_device_set_abs_axis(struct unix_device *iface, ULONG index, LONG value) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL hid_device_set_rel_axis(struct unix_device *iface, ULONG index, LONG value) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL hid_device_set_button(struct unix_device *iface, ULONG index, BOOL is_set) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL hid_device_set_hatswitch_x(struct unix_device *iface, ULONG index, LONG new_x) DECLSPEC_HIDDEN;
|
|
|
|
extern BOOL hid_device_set_hatswitch_y(struct unix_device *iface, ULONG index, LONG new_y) DECLSPEC_HIDDEN;
|
|
|
|
|
2021-09-23 08:55:26 +02:00
|
|
|
extern BOOL hid_device_sync_report(struct unix_device *iface) DECLSPEC_HIDDEN;
|
|
|
|
extern void hid_device_drop_report(struct unix_device *iface) DECLSPEC_HIDDEN;
|
|
|
|
|
2021-12-02 10:47:48 +01:00
|
|
|
extern void hid_device_set_effect_state(struct unix_device *iface, BYTE index, BYTE flags) DECLSPEC_HIDDEN;
|
|
|
|
|
2021-09-16 10:17:54 +02:00
|
|
|
BOOL is_xbox_gamepad(WORD vid, WORD pid) DECLSPEC_HIDDEN;
|
2021-10-18 17:16:45 +02:00
|
|
|
BOOL is_dualshock4_gamepad(WORD vid, WORD pid) DECLSPEC_HIDDEN;
|
2022-01-27 18:17:57 +01:00
|
|
|
BOOL is_dualsense_gamepad(WORD vid, WORD pid) DECLSPEC_HIDDEN;
|
2021-09-16 10:17:54 +02:00
|
|
|
|
2021-08-23 10:49:39 +02:00
|
|
|
#endif /* __WINEBUS_UNIX_PRIVATE_H */
|