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>
|
|
|
|
|
|
|
|
#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);
|
2021-09-03 09:30:49 +02:00
|
|
|
NTSTATUS (*get_report_descriptor)(struct unix_device *iface, BYTE *buffer, DWORD length, DWORD *out_length);
|
|
|
|
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);
|
2021-09-23 08:55:30 +02:00
|
|
|
NTSTATUS (*haptics_start)(struct unix_device *iface, DWORD duration_ms,
|
|
|
|
USHORT rumble_intensity, USHORT buzz_intensity);
|
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
|
|
|
};
|
|
|
|
|
2021-09-24 11:51:54 +02:00
|
|
|
enum haptics_waveform_index
|
|
|
|
{
|
|
|
|
HAPTICS_WAVEFORM_STOP_INDEX = 1,
|
|
|
|
HAPTICS_WAVEFORM_NULL_INDEX = 2,
|
|
|
|
HAPTICS_WAVEFORM_RUMBLE_INDEX = 3,
|
|
|
|
HAPTICS_WAVEFORM_BUZZ_INDEX = 4,
|
|
|
|
HAPTICS_WAVEFORM_LAST_INDEX = HAPTICS_WAVEFORM_BUZZ_INDEX,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hid_haptics_features
|
|
|
|
{
|
|
|
|
WORD waveform_list[HAPTICS_WAVEFORM_LAST_INDEX - HAPTICS_WAVEFORM_NULL_INDEX];
|
|
|
|
WORD duration_list[HAPTICS_WAVEFORM_LAST_INDEX - HAPTICS_WAVEFORM_NULL_INDEX];
|
|
|
|
DWORD waveform_cutoff_time_ms;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct hid_haptics_waveform
|
|
|
|
{
|
|
|
|
WORD manual_trigger;
|
|
|
|
WORD intensity;
|
|
|
|
};
|
|
|
|
|
2021-09-23 08:55:30 +02:00
|
|
|
struct hid_haptics
|
|
|
|
{
|
2021-09-24 11:51:54 +02:00
|
|
|
struct hid_haptics_features features;
|
|
|
|
struct hid_haptics_waveform waveforms[HAPTICS_WAVEFORM_LAST_INDEX + 1];
|
|
|
|
BYTE features_report;
|
|
|
|
BYTE waveform_report;
|
2021-09-23 08:55:30 +02:00
|
|
|
};
|
|
|
|
|
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-10-01 09:31:00 +02:00
|
|
|
};
|
|
|
|
|
2021-09-22 10:30:43 +02:00
|
|
|
struct hid_device_state
|
|
|
|
{
|
|
|
|
ULONG bit_size;
|
|
|
|
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-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;
|
2021-09-16 10:17:54 +02:00
|
|
|
|
2021-08-23 10:49:39 +02:00
|
|
|
#endif /* __WINEBUS_UNIX_PRIVATE_H */
|