Apply clang-format code style to all source files
This commit is contained in:
+58
-49
@@ -1,7 +1,7 @@
|
||||
#define LOG_MODULE "mouse"
|
||||
|
||||
#include <windows.h>
|
||||
#include <initguid.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <malloc.h>
|
||||
#include <stddef.h>
|
||||
@@ -40,20 +40,20 @@ struct mouse {
|
||||
|
||||
static const struct hid_control mouse_controls[MOUSE_CTL_COUNT] = {
|
||||
/* Left, right, middle, AUX1, AUX2 buttons */
|
||||
{ 0x00090001, 0x00000000, 0x00000001, 0 },
|
||||
{ 0x00090002, 0x00000000, 0x00000001, 0 },
|
||||
{ 0x00090003, 0x00000000, 0x00000001, 0 },
|
||||
{ 0x00090004, 0x00000000, 0x00000001, 0 },
|
||||
{ 0x00090005, 0x00000000, 0x00000001, 0 },
|
||||
{0x00090001, 0x00000000, 0x00000001, 0},
|
||||
{0x00090002, 0x00000000, 0x00000001, 0},
|
||||
{0x00090003, 0x00000000, 0x00000001, 0},
|
||||
{0x00090004, 0x00000000, 0x00000001, 0},
|
||||
{0x00090005, 0x00000000, 0x00000001, 0},
|
||||
|
||||
/* X axis */
|
||||
{ 0x00010030, 0xC0000000, 0x3FFFFFFF, HID_FLAG_RELATIVE },
|
||||
{0x00010030, 0xC0000000, 0x3FFFFFFF, HID_FLAG_RELATIVE},
|
||||
|
||||
/* Y axis */
|
||||
{ 0x00010031, 0xC0000000, 0x3FFFFFFF, HID_FLAG_RELATIVE },
|
||||
{0x00010031, 0xC0000000, 0x3FFFFFFF, HID_FLAG_RELATIVE},
|
||||
|
||||
/* Mouse wheel */
|
||||
{ 0x00010038, 0xFFFF8000, 0x00007FFF, HID_FLAG_RELATIVE },
|
||||
{0x00010038, 0xFFFF8000, 0x00007FFF, HID_FLAG_RELATIVE},
|
||||
};
|
||||
|
||||
static const uint16_t mouse_down_flg[] = {
|
||||
@@ -72,33 +72,43 @@ static const uint16_t mouse_up_flg[] = {
|
||||
RI_MOUSE_BUTTON_5_UP,
|
||||
};
|
||||
|
||||
DEFINE_GUID(mouse_guid, 0x378DE44C, 0x56EF, 0x11D1, 0xBC, 0x8C, \
|
||||
0x00, 0xA0, 0xC9, 0x14, 0x05, 0xDD);
|
||||
DEFINE_GUID(
|
||||
mouse_guid,
|
||||
0x378DE44C,
|
||||
0x56EF,
|
||||
0x11D1,
|
||||
0xBC,
|
||||
0x8C,
|
||||
0x00,
|
||||
0xA0,
|
||||
0xC9,
|
||||
0x14,
|
||||
0x05,
|
||||
0xDD);
|
||||
|
||||
static bool mouse_get_device_usage(const struct hid *hid, uint32_t *usage);
|
||||
static bool mouse_get_name(const struct hid *hid, wchar_t *chars,
|
||||
size_t *nchars);
|
||||
static bool mouse_get_controls(const struct hid *hid,
|
||||
struct hid_control *controls, size_t *ncontrols);
|
||||
static bool mouse_get_lights(const struct hid *hid, struct hid_light *lights,
|
||||
size_t *nlights);
|
||||
static bool mouse_get_value(struct hid *hid, size_t control_no,
|
||||
int32_t *out_value);
|
||||
static bool mouse_set_light(struct hid *hid, size_t light_no,
|
||||
uint32_t intensity);
|
||||
static bool
|
||||
mouse_get_name(const struct hid *hid, wchar_t *chars, size_t *nchars);
|
||||
static bool mouse_get_controls(
|
||||
const struct hid *hid, struct hid_control *controls, size_t *ncontrols);
|
||||
static bool mouse_get_lights(
|
||||
const struct hid *hid, struct hid_light *lights, size_t *nlights);
|
||||
static bool
|
||||
mouse_get_value(struct hid *hid, size_t control_no, int32_t *out_value);
|
||||
static bool
|
||||
mouse_set_light(struct hid *hid, size_t light_no, uint32_t intensity);
|
||||
static void mouse_handle_event(struct hid_ri *hid_ri, const RAWINPUT *ri);
|
||||
static void mouse_close(struct hid *hid);
|
||||
|
||||
static const struct hid_ri_vtbl mouse_vtbl = {{
|
||||
/* .close = */ mouse_close,
|
||||
/* .get_device_usage = */ mouse_get_device_usage,
|
||||
/* .get_name = */ mouse_get_name,
|
||||
/* .get_controls = */ mouse_get_controls,
|
||||
/* .get_lights = */ mouse_get_lights,
|
||||
/* .get_value = */ mouse_get_value,
|
||||
/* .set_light = */ mouse_set_light },
|
||||
/* .handle_event = */ mouse_handle_event
|
||||
};
|
||||
static const struct hid_ri_vtbl mouse_vtbl = {
|
||||
{/* .close = */ mouse_close,
|
||||
/* .get_device_usage = */ mouse_get_device_usage,
|
||||
/* .get_name = */ mouse_get_name,
|
||||
/* .get_controls = */ mouse_get_controls,
|
||||
/* .get_lights = */ mouse_get_lights,
|
||||
/* .get_value = */ mouse_get_value,
|
||||
/* .set_light = */ mouse_set_light},
|
||||
/* .handle_event = */ mouse_handle_event};
|
||||
|
||||
void mouse_create(struct hid_ri **hid_ri, const char *dev_node)
|
||||
{
|
||||
@@ -128,23 +138,23 @@ static bool mouse_get_device_usage(const struct hid *hid, uint32_t *usage)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool mouse_get_name(const struct hid *hid, wchar_t *chars,
|
||||
size_t *nchars)
|
||||
static bool
|
||||
mouse_get_name(const struct hid *hid, wchar_t *chars, size_t *nchars)
|
||||
{
|
||||
struct mouse *m = containerof(hid, struct mouse, super);
|
||||
|
||||
return hid_ri_get_name(chars, nchars, m->name);
|
||||
}
|
||||
|
||||
static bool mouse_get_controls(const struct hid *hid,
|
||||
struct hid_control *controls, size_t *ncontrols)
|
||||
static bool mouse_get_controls(
|
||||
const struct hid *hid, struct hid_control *controls, size_t *ncontrols)
|
||||
{
|
||||
return hid_ri_get_controls(controls, ncontrols, mouse_controls,
|
||||
MOUSE_CTL_COUNT);
|
||||
return hid_ri_get_controls(
|
||||
controls, ncontrols, mouse_controls, MOUSE_CTL_COUNT);
|
||||
}
|
||||
|
||||
static bool mouse_get_lights(const struct hid *hid,
|
||||
struct hid_light *lights, size_t *nlights)
|
||||
static bool mouse_get_lights(
|
||||
const struct hid *hid, struct hid_light *lights, size_t *nlights)
|
||||
{
|
||||
log_assert(nlights != NULL);
|
||||
|
||||
@@ -155,8 +165,8 @@ static bool mouse_get_lights(const struct hid *hid,
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool mouse_get_value(struct hid *hid, size_t control_no,
|
||||
int32_t *out_value)
|
||||
static bool
|
||||
mouse_get_value(struct hid *hid, size_t control_no, int32_t *out_value)
|
||||
{
|
||||
struct mouse *m = containerof(hid, struct mouse, super);
|
||||
long tmp;
|
||||
@@ -179,7 +189,7 @@ static bool mouse_get_value(struct hid *hid, size_t control_no,
|
||||
do {
|
||||
tmp = m->values[control_no];
|
||||
} while (InterlockedCompareExchange(
|
||||
&m->values[control_no], 0, tmp) != tmp);
|
||||
&m->values[control_no], 0, tmp) != tmp);
|
||||
|
||||
*out_value = tmp;
|
||||
|
||||
@@ -190,8 +200,8 @@ static bool mouse_get_value(struct hid *hid, size_t control_no,
|
||||
}
|
||||
}
|
||||
|
||||
static bool mouse_set_light(struct hid *hid, size_t light_no,
|
||||
uint32_t intensity)
|
||||
static bool
|
||||
mouse_set_light(struct hid *hid, size_t light_no, uint32_t intensity)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -222,12 +232,12 @@ static void mouse_handle_event(struct hid_ri *hid_ri, const RAWINPUT *ri)
|
||||
do {
|
||||
tmp = m->values[MOUSE_CTL_X];
|
||||
} while (InterlockedCompareExchange(
|
||||
&m->values[MOUSE_CTL_X], tmp + dx, tmp) != tmp);
|
||||
&m->values[MOUSE_CTL_X], tmp + dx, tmp) != tmp);
|
||||
|
||||
do {
|
||||
tmp = m->values[MOUSE_CTL_Y];
|
||||
} while (InterlockedCompareExchange(
|
||||
&m->values[MOUSE_CTL_Y], tmp + dy, tmp) != tmp);
|
||||
&m->values[MOUSE_CTL_Y], tmp + dy, tmp) != tmp);
|
||||
|
||||
if (ri->data.mouse.usButtonFlags & RI_MOUSE_WHEEL) {
|
||||
dwheel = ri->data.mouse.usButtonData;
|
||||
@@ -235,10 +245,10 @@ static void mouse_handle_event(struct hid_ri *hid_ri, const RAWINPUT *ri)
|
||||
do {
|
||||
tmp = m->values[MOUSE_CTL_WHEEL];
|
||||
} while (InterlockedCompareExchange(
|
||||
&m->values[MOUSE_CTL_WHEEL], tmp + dwheel, tmp) != tmp);
|
||||
&m->values[MOUSE_CTL_WHEEL], tmp + dwheel, tmp) != tmp);
|
||||
}
|
||||
|
||||
for (i = 0 ; i < 5 ; i++) {
|
||||
for (i = 0; i < 5; i++) {
|
||||
if (ri->data.mouse.usButtonFlags & mouse_down_flg[i]) {
|
||||
m->values[i] = 1;
|
||||
} else if (ri->data.mouse.usButtonFlags & mouse_up_flg[i]) {
|
||||
@@ -254,4 +264,3 @@ static void mouse_close(struct hid *hid)
|
||||
free(m->name);
|
||||
free(m);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user