This repository was archived by the owner on Jan 30, 2025. It is now read-only.
-
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.
vm_tools: add mapping for dualsense gamepad
Adding an input mapping for the dualsense gamepad to correct it's mapping. BUG=b:277829347 TEST=tested on dut Change-Id: I961b0b546272a83e43164b53f72a3d70566a18a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/4432333 Reviewed-by: Kenneth Albanowski <[email protected]> Reviewed-by: Daniel Ng <[email protected]> Tested-by: Daniel Ng <[email protected]> Reviewed-by: Chloe Pelling <[email protected]> Commit-Queue: Daniel Ng <[email protected]>
- Loading branch information
1 parent
7f5c420
commit f4c9a8d
Showing
13 changed files
with
780 additions
and
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright 2023 The ChromiumOS Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "libevdev-shim.h" // NOLINT(build/include_directory) | ||
|
||
struct libevdev* LibevdevShim::new_evdev(void) { | ||
return libevdev_new(); | ||
} | ||
void LibevdevShim::free(struct libevdev* dev) { | ||
libevdev_free(dev); | ||
} | ||
int LibevdevShim::enable_event_code(struct libevdev* dev, | ||
unsigned int type, | ||
unsigned int code, | ||
const void* data) { | ||
return libevdev_enable_event_code(dev, type, code, data); | ||
} | ||
void LibevdevShim::set_name(struct libevdev* dev, const char* name) { | ||
libevdev_set_name(dev, name); | ||
} | ||
void LibevdevShim::set_id_product(struct libevdev* dev, int product_id) { | ||
libevdev_set_id_product(dev, product_id); | ||
} | ||
void LibevdevShim::set_id_vendor(struct libevdev* dev, int vendor_id) { | ||
libevdev_set_id_vendor(dev, vendor_id); | ||
} | ||
void LibevdevShim::set_id_bustype(struct libevdev* dev, int bustype) { | ||
libevdev_set_id_bustype(dev, bustype); | ||
} | ||
void LibevdevShim::set_id_version(struct libevdev* dev, int version) { | ||
libevdev_set_id_version(dev, version); | ||
} | ||
|
||
int LibevdevShim::uinput_create_from_device( | ||
const struct libevdev* dev, | ||
int uinput_fd, | ||
struct libevdev_uinput** uinput_dev) { | ||
return libevdev_uinput_create_from_device(dev, uinput_fd, uinput_dev); | ||
} | ||
int LibevdevShim::uinput_write_event(const struct libevdev_uinput* uinput_dev, | ||
unsigned int type, | ||
unsigned int code, | ||
int value) { | ||
return libevdev_uinput_write_event(uinput_dev, type, code, value); | ||
} | ||
void LibevdevShim::uinput_destroy(struct libevdev_uinput* uinput_dev) { | ||
libevdev_uinput_destroy(uinput_dev); | ||
} | ||
|
||
LibevdevShim* Libevdev::singleton = nullptr; | ||
|
||
LibevdevShim* Libevdev::Get() { | ||
return singleton; | ||
} | ||
|
||
void Libevdev::Set(LibevdevShim* shim) { | ||
singleton = shim; | ||
} |
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,50 @@ | ||
// Copyright 2023 The ChromiumOS Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef VM_TOOLS_SOMMELIER_LIBEVDEV_LIBEVDEV_SHIM_H_ | ||
#define VM_TOOLS_SOMMELIER_LIBEVDEV_LIBEVDEV_SHIM_H_ | ||
|
||
#include <libevdev/libevdev.h> | ||
#include <libevdev/libevdev-uinput.h> | ||
|
||
class LibevdevShim { | ||
public: | ||
LibevdevShim() = default; | ||
LibevdevShim(LibevdevShim&&) = delete; | ||
LibevdevShim& operator=(LibevdevShim&&) = delete; | ||
|
||
virtual ~LibevdevShim() = default; | ||
|
||
virtual struct libevdev* new_evdev(void); | ||
virtual void free(struct libevdev* dev); | ||
virtual int enable_event_code(struct libevdev* dev, | ||
unsigned int type, | ||
unsigned int code, | ||
const void* data); | ||
virtual void set_name(struct libevdev* dev, const char* name); | ||
virtual void set_id_product(struct libevdev* dev, int product_id); | ||
virtual void set_id_vendor(struct libevdev* dev, int vendor_id); | ||
virtual void set_id_bustype(struct libevdev* dev, int bustype); | ||
virtual void set_id_version(struct libevdev* dev, int version); | ||
|
||
virtual int uinput_create_from_device(const struct libevdev* dev, | ||
int uinput_fd, | ||
struct libevdev_uinput** uinput_dev); | ||
virtual int uinput_write_event(const struct libevdev_uinput* uinput_dev, | ||
unsigned int type, | ||
unsigned int code, | ||
int value); | ||
virtual void uinput_destroy(struct libevdev_uinput* uinput_dev); | ||
}; | ||
|
||
class Libevdev { | ||
public: | ||
static LibevdevShim* Get(); | ||
static void Set(LibevdevShim* shim); | ||
|
||
private: | ||
static LibevdevShim* singleton; | ||
}; | ||
|
||
#endif // VM_TOOLS_SOMMELIER_LIBEVDEV_LIBEVDEV_SHIM_H_ |
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,72 @@ | ||
// Copyright 2023 The ChromiumOS Authors | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef VM_TOOLS_SOMMELIER_LIBEVDEV_MOCK_LIBEVDEV_SHIM_H_ | ||
#define VM_TOOLS_SOMMELIER_LIBEVDEV_MOCK_LIBEVDEV_SHIM_H_ | ||
|
||
#include <gmock/gmock.h> | ||
|
||
#include "libevdev-shim.h" // NOLINT(build/include_directory) | ||
|
||
class MockLibevdevShim : public LibevdevShim { | ||
public: | ||
MOCK_METHOD(struct libevdev*, new_evdev, (), (override)); | ||
|
||
MOCK_METHOD(void, free, (struct libevdev * dev), (override)); | ||
|
||
MOCK_METHOD(int, | ||
enable_event_code, | ||
(struct libevdev * dev, | ||
unsigned int type, | ||
unsigned int code, | ||
const void* data), | ||
(override)); | ||
|
||
MOCK_METHOD(void, | ||
set_name, | ||
(struct libevdev * dev, const char* name), | ||
(override)); | ||
|
||
MOCK_METHOD(void, | ||
set_id_product, | ||
(struct libevdev * dev, int product_id), | ||
(override)); | ||
|
||
MOCK_METHOD(void, | ||
set_id_vendor, | ||
(struct libevdev * dev, int vendor_id), | ||
(override)); | ||
|
||
MOCK_METHOD(void, | ||
set_id_bustype, | ||
(struct libevdev * dev, int bustype_id), | ||
(override)); | ||
|
||
MOCK_METHOD(void, | ||
set_id_version, | ||
(struct libevdev * dev, int version_id), | ||
(override)); | ||
|
||
MOCK_METHOD(int, | ||
uinput_create_from_device, | ||
(const struct libevdev* dev, | ||
int uinput_fd, | ||
struct libevdev_uinput** uinput_dev), | ||
(override)); | ||
|
||
MOCK_METHOD(int, | ||
uinput_write_event, | ||
(const struct libevdev_uinput* uinput_dev, | ||
unsigned int type, | ||
unsigned int code, | ||
int value), | ||
(override)); | ||
|
||
MOCK_METHOD(void, | ||
uinput_destroy, | ||
(struct libevdev_uinput * uinput_dev), | ||
(override)); | ||
}; | ||
|
||
#endif // VM_TOOLS_SOMMELIER_LIBEVDEV_MOCK_LIBEVDEV_SHIM_H_ |
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
Oops, something went wrong.