forked from atar-axis/xpadneo
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xpadneo, core: Add support for synthetic devices
In preparation for mouse mode and keyboard emulation, we need to be able to create virtual devices associated with the controller. Signed-off-by: Kai Krakow <[email protected]>
- Loading branch information
Showing
4 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* xpadneo driver core | ||
* | ||
* Copyright (c) 2021 Kai Krakow <[email protected]> | ||
*/ | ||
|
||
#include "../xpadneo.h" | ||
|
||
extern int xpadneo_init_synthetic(struct xpadneo_devdata *xdata, char *suffix, | ||
struct input_dev **devp) | ||
{ | ||
struct hid_device *hdev = xdata->hdev; | ||
struct input_dev *input_dev = devm_input_allocate_device(&hdev->dev); | ||
size_t suffix_len, name_len; | ||
|
||
if (!input_dev) | ||
return -ENOMEM; | ||
|
||
name_len = strlen(hdev->name); | ||
suffix_len = strlen(suffix); | ||
if ((name_len < suffix_len) || strcmp(xdata->hdev->name + name_len - suffix_len, suffix)) { | ||
input_dev->name = kasprintf(GFP_KERNEL, "%s %s", hdev->name, suffix); | ||
if (!input_dev->name) | ||
return -ENOMEM; | ||
} | ||
|
||
dev_set_drvdata(&input_dev->dev, xdata); | ||
input_dev->phys = hdev->phys; | ||
input_dev->uniq = hdev->uniq; | ||
input_dev->id.bustype = hdev->bus; | ||
input_dev->id.vendor = hdev->vendor; | ||
input_dev->id.product = hdev->product; | ||
input_dev->id.version = hdev->version; | ||
|
||
*devp = input_dev; | ||
return 0; | ||
} |