input: implemented B_GET_DEVICE_NAME ioctl on both usb and i2c input devices

Change-Id: Ie1eb0a958b4d60e6fa673cf8fe72bdfe924baf51
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4798
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
Lt-Henry 2021-12-16 00:01:48 +01:00 committed by Adrien Destugues
parent 370623a923
commit 6a9aea9dfd
8 changed files with 45 additions and 1 deletions

View File

@ -267,6 +267,12 @@ JoystickProtocolHandler::Control(uint32 *cookie, uint32 op, void *buffer,
size_t length)
{
switch (op) {
case B_GET_DEVICE_NAME:
{
const char name[] = DEVICE_NAME" Joystick";
return IOGetDeviceName(name, buffer, length);
}
case B_JOYSTICK_SET_DEVICE_MODULE:
{
if (length < sizeof(joystick_module_info))

View File

@ -343,6 +343,12 @@ KeyboardProtocolHandler::Control(uint32 *cookie, uint32 op, void *buffer,
size_t length)
{
switch (op) {
case B_GET_DEVICE_NAME:
{
const char name[] = DEVICE_NAME" Keyboard";
return IOGetDeviceName(name,buffer,length);
}
case KB_READ:
{
if (*cookie == 0) {

View File

@ -131,6 +131,13 @@ MouseProtocolHandler::Control(uint32 *cookie, uint32 op, void *buffer,
size_t length)
{
switch (op) {
case B_GET_DEVICE_NAME:
{
const char name[] = DEVICE_NAME" Mouse";
return IOGetDeviceName(name,buffer,length);
}
case MS_READ:
{
if (length < sizeof(mouse_movement))

View File

@ -6,6 +6,7 @@
#include <stdlib.h>
#include <ring_buffer.h>
#include <kernel.h>
#include "Driver.h"
#include "HIDCollection.h"
@ -187,3 +188,16 @@ ProtocolHandler::SetNextHandler(ProtocolHandler *nextHandler)
{
fNextHandler = nextHandler;
}
status_t
ProtocolHandler::IOGetDeviceName(const char *name, void *buffer, size_t length)
{
if (!IS_USER_ADDRESS(buffer))
return B_BAD_ADDRESS;
if (user_strlcpy((char *)buffer, name, length) > 0)
return B_OK;
return B_ERROR;
}

View File

@ -54,6 +54,9 @@ public:
void SetNextHandler(ProtocolHandler *next);
ProtocolHandler * NextHandler() { return fNextHandler; };
status_t IOGetDeviceName(const char *name, void *buffer,
size_t length);
protected:
status_t fStatus;

View File

@ -182,6 +182,13 @@ TabletProtocolHandler::Control(uint32 *cookie, uint32 op, void *buffer,
size_t length)
{
switch (op) {
case B_GET_DEVICE_NAME:
{
const char name[] = DEVICE_NAME" Tablet";
return IOGetDeviceName(name,buffer,length);
}
case MS_READ:
{
if (length < sizeof(tablet_movement))

View File

@ -15,7 +15,7 @@
#define DRIVER_NAME "i2c_hid"
#define DEVICE_PATH_SUFFIX "i2c"
#define DEVICE_NAME "I2C"
extern DeviceList *gDeviceList;

View File

@ -16,6 +16,7 @@
#define DRIVER_NAME "usb_hid"
#define DEVICE_PATH_SUFFIX "usb"
#define DEVICE_NAME "USB"
#define USB_INTERFACE_CLASS_HID 3
#define USB_INTERFACE_SUBCLASS_HID_BOOT 1