Remove OpenRazer/OpenRazer-Win32 support as it is unmaintained and replaced by RazerController

This commit is contained in:
Adam Honse 2023-10-11 22:22:48 -05:00
parent f76e8f65a5
commit 8d19ceff95
23 changed files with 3 additions and 9132 deletions

Binary file not shown.

Binary file not shown.

View file

@ -1,31 +0,0 @@
#ifndef DMI_H_
#define DMI_H_
enum dmi_field {
DMI_NONE,
DMI_BIOS_VENDOR,
DMI_BIOS_VERSION,
DMI_BIOS_DATE,
DMI_SYS_VENDOR,
DMI_PRODUCT_NAME,
DMI_PRODUCT_VERSION,
DMI_PRODUCT_SERIAL,
DMI_PRODUCT_UUID,
DMI_BOARD_VENDOR,
DMI_BOARD_NAME,
DMI_BOARD_VERSION,
DMI_BOARD_SERIAL,
DMI_BOARD_ASSET_TAG,
DMI_CHASSIS_VENDOR,
DMI_CHASSIS_TYPE,
DMI_CHASSIS_VERSION,
DMI_CHASSIS_SERIAL,
DMI_CHASSIS_ASSET_TAG,
DMI_STRING_MAX,
};
static inline char* dmi_get_system_info(int x) {
return "BLADESERIAL";
}
#endif /* DMI_H_ */

View file

@ -1,402 +0,0 @@
#ifndef HID_H_
#define HID_H_
#include <SetupAPI.h>
#include <cfgmgr32.h>
#include <Winusb.h>
#pragma comment(lib, "setupapi.lib")
#pragma comment(lib, "Winusb.lib")
#define HID_STAT_ADDED 1
#define HID_STAT_PARSED 2
#define HID_CONNECT_HIDINPUT 0x01
#define HID_CONNECT_HIDRAW 0x04
#define HID_CONNECT_HIDDEV 0x08
#define HID_CONNECT_FF 0x20
#define HID_CONNECT_DEFAULT (HID_CONNECT_HIDINPUT|HID_CONNECT_HIDRAW| HID_CONNECT_HIDDEV|HID_CONNECT_FF)
#define HID_GD_WHEEL 0x00010038
#define HID_REQ_GET_REPORT 0x01
#define HID_REQ_SET_REPORT 0x09
//#define USB_INTERFACE_PROTOCOL_KEYBOARD 1
//#define USB_INTERFACE_PROTOCOL_MOUSE 2
//Hack to make detection work without having to install WinUSB on the correct interface
#define USB_INTERFACE_PROTOCOL_KEYBOARD 0
#define USB_INTERFACE_PROTOCOL_MOUSE 0
static const GUID GUID_DEVINTERFACE = { 0xDEE824EF, 0x729B, 0x4A0E, 0x9C, 0x14, 0xB7, 0x11, 0x7D, 0x33, 0xA8, 0x17 };
typedef enum
{
HID_TYPE_OTHER,
HID_TYPE_USBMOUSE,
HID_TYPE_USBNONE
} hid_type;
struct hid_input {
struct input_dev *input;
};
struct hid_field {
struct hid_input *hidinput; /* associated input structure */
};
struct hid_usage {
unsigned hid;
__u16 code; /* input driver code */
__u8 type; /* input driver type */
};
struct hid_driver {
char *name;
const struct hid_device_id *id_table;
int (*probe)(struct hid_device *dev, const struct hid_device_id *id);
void (*remove)(struct hid_device *dev);
int (*raw_event)(struct hid_device *hdev, struct hid_report *report, u8 *data, int size);
int (*event)(struct hid_device *hdev, struct hid_field *field, struct hid_usage *usage, __s32 value);
int (*input_configured)(struct hid_device *hdev,
struct hid_input *hidinput);
int (*input_mapping)(struct hid_device *hdev,
struct hid_input *hidinput, struct hid_field *field,
struct hid_usage *usage, unsigned long **bit, int *max);
};
struct hid_device_id {
__u16 bus;
__u32 vendor;
__u32 product;
};
struct hid_device {
__u16 product;
enum hid_type type;
struct device dev;
struct hid_ll_driver *ll_driver;
unsigned int status;
struct hid_driver *driver;
};
struct hid_ll_driver {
int (*start)(struct hid_device *hdev);
void (*stop)(struct hid_device *hdev);
int (*parse)(struct hid_device *hdev);
};
inline int ll_start(struct hid_device *hdev) {
printf("ll_start\n");
return 0;
}
inline void ll_stop(struct hid_device *hdev) {
printf("ll_stop\n");
}
inline int ll_parse(struct hid_device *hdev) {
printf("ll_parse\n");
return 0;
}
inline void dev_err(struct device** dev, const char* msg) {
printf("dev_err device=%s msg=%s", (*dev)->init_name, msg);
}
inline void dev_info(struct device** dev, const char* msg) {
printf("dev_err device=%s msg=%s", (*dev)->init_name, msg);
}
inline void *dev_get_drvdata(const struct device *dev) {
return dev->driver_data;
}
inline void dev_set_drvdata(struct device *dev, void *data) {
dev->driver_data = data;
}
inline int hid_connect(struct hid_device *hdev, unsigned int connect_mask) {
printf("hid_connect\n");
return 0;
}
inline int hid_parse(struct hid_device *hdev) {
int ret;
if (hdev->status & HID_STAT_PARSED)
return 0;
ret = hdev->ll_driver->parse(hdev);
if (!ret)
hdev->status |= HID_STAT_PARSED;
return ret;
}
inline void *hid_get_drvdata(struct hid_device *hdev) {
return dev_get_drvdata(&hdev->dev);
}
inline void hid_set_drvdata(struct hid_device *hdev, void *data) {
dev_set_drvdata(&hdev->dev, data);
}
inline int hid_hw_start(struct hid_device *hdev, unsigned int connect_mask) {
int ret = hdev->ll_driver->start(hdev);
if (ret || !connect_mask)
return ret;
ret = hid_connect(hdev, connect_mask);
if (ret)
hdev->ll_driver->stop(hdev);
return ret;
}
inline void hid_hw_stop(struct hid_device *hdev) {
hdev->ll_driver->stop(hdev);
}
inline void hid_err(struct hid_device *hdev, const char* msg, ...) {
va_list args;
va_start(args, msg);
printf("hid_err device=%s", hdev->dev.init_name);
printf(msg, args);
va_end(args);
}
inline void hid_map_usage(struct hid_input* hidinput,
struct hid_usage* usage, unsigned long** bit, int* max,
__u8 type, __u16 c)
{
};
#define container_of(ptr, type, member) (type*)((char*)(ptr)-(char*)&((type *)0)->member)
inline void close(struct device* dev) {
printf("close %04X\n", (to_usb_device(dev))->descriptor.idProduct);
struct usb_interface *intf = to_usb_interface(dev->parent);
struct usb_device *usb_dev = interface_to_usbdev(intf);
struct hid_device *hdev = container_of(dev, struct hid_device, dev);
free(hdev->ll_driver);
free(usb_dev);
free(intf->cur_altsetting);
free(intf);
free(hdev);
//TODO:cleanup malloc memory, move this function into DLL
}
inline void openChromaDevice(struct hid_device** hdev, unsigned int* numHdev, struct hid_driver hdr) {
/*-----------------------------------------------------------------*\
| Loop through all vendor IDs in ID table of header |
\*-----------------------------------------------------------------*/
for (unsigned int i = 0; hdr.id_table[i].vendor != 0; i++)
{
/*-------------------------------------------------------------*\
| Get device information set |
\*-------------------------------------------------------------*/
HDEVINFO hDevInfo = SetupDiGetClassDevs(&GUID_DEVINTERFACE, 0, 0, DIGCF_DEVICEINTERFACE);
if (hDevInfo == INVALID_HANDLE_VALUE)
{
printf("SetupDiGetClassDevs failed\n");
return;
}
SP_DEVINFO_DATA deviceData = { 0 };
deviceData.cbSize = sizeof(SP_DEVINFO_DATA);
/*-------------------------------------------------------------*\
| Loop through all device information entries in set |
\*-------------------------------------------------------------*/
for (unsigned int j = 0; SetupDiEnumDeviceInfo(hDevInfo, j, &deviceData); ++j)
{
/*---------------------------------------------------------*\
| Get device ID string from device information |
\*---------------------------------------------------------*/
char deviceID[MAX_DEVICE_ID_LEN];
if (CM_Get_Device_ID(deviceData.DevInst, deviceID, MAX_DEVICE_ID_LEN, 0))
{
continue;
}
/*---------------------------------------------------------*\
| Parse USB VID out of device ID string |
| Move on to the next device if the VID does not match |
\*---------------------------------------------------------*/
char* vid = strstr(deviceID, "VID_");
if (!vid || hdr.id_table[i].vendor != strtoul(vid + 4, NULL, 16))
{
continue;
}
/*---------------------------------------------------------*\
| Parse USB PID out of device ID string |
| Move on to the next device if the PID does not match |
\*---------------------------------------------------------*/
char* pid = strstr(deviceID, "PID_");
if (!pid || hdr.id_table[i].product != strtoul(pid + 4, NULL, 16))
{
continue;
}
/*---------------------------------------------------------*\
| Enumerate device interface data for this device |
\*---------------------------------------------------------*/
SP_INTERFACE_DEVICE_DATA interfaceData = { 0 };
interfaceData.cbSize = sizeof(SP_INTERFACE_DEVICE_DATA);
if (!SetupDiEnumDeviceInterfaces(hDevInfo, &deviceData, &GUID_DEVINTERFACE, 0, &interfaceData))
{
continue;
}
/*---------------------------------------------------------*\
| Get device interface detail size |
\*---------------------------------------------------------*/
DWORD dwRequiredSize = 0;
SetupDiGetDeviceInterfaceDetail(hDevInfo, &interfaceData, 0, 0, &dwRequiredSize, 0);
/*---------------------------------------------------------*\
| Create a buffer of required size and load the device |
| interface detail information into the buffer |
\*---------------------------------------------------------*/
SP_INTERFACE_DEVICE_DETAIL_DATA* pData = (SP_INTERFACE_DEVICE_DETAIL_DATA*)malloc(dwRequiredSize);
pData->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
if (!SetupDiGetDeviceInterfaceDetail(hDevInfo, &interfaceData, pData, dwRequiredSize, 0, 0))
{
free(pData);
continue;
}
/*---------------------------------------------------------*\
| Open a handle to the device |
\*---------------------------------------------------------*/
HANDLE hDevice = CreateFile(pData->DevicePath
, GENERIC_READ | GENERIC_WRITE
, FILE_SHARE_READ | FILE_SHARE_WRITE
, 0
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED
, 0);
if (hDevice == INVALID_HANDLE_VALUE)
{
free(pData);
continue;
}
/*---------------------------------------------------------*\
| Open a WinUSB handle from the device handle |
\*---------------------------------------------------------*/
WINUSB_INTERFACE_HANDLE hWinUSBHandle;
if (!WinUsb_Initialize(hDevice, &hWinUSBHandle))
{
continue;
}
/*---------------------------------------------------------*\
| Delete the device information set |
\*---------------------------------------------------------*/
SetupDiDestroyDeviceInfoList(hDevInfo);
/*---------------------------------------------------------*\
| Print debug message indicating device is opened |
\*---------------------------------------------------------*/
printf("CM_Get_Device_ID (%s)\n", deviceID);
printf("device %04X:%04X opened!\n", hdr.id_table[i].vendor, hdr.id_table[i].product);
/*---------------------------------------------------------*\
| Create or resize HID device struct buffer |
\*---------------------------------------------------------*/
*hdev = (struct hid_device*)realloc(*hdev, (*numHdev+1) * sizeof(struct hid_device));
if (!*hdev)
{
printf("out of memory\n");
continue;
}
/*---------------------------------------------------------*\
| If there are hdev entries from previous loop iterations, |
| copy the data from the previous location to the new. |
\*---------------------------------------------------------*/
if (*numHdev > 0)
{
for (int old_dev = 0; old_dev < *numHdev; old_dev++)
{
(*hdev)[old_dev].dev.parent = &((*hdev)[old_dev].dev);
(*hdev)[old_dev].dev.parent_usb_interface->dev = &((*hdev)[old_dev].dev);
(*hdev)[old_dev].dev.parent_usb_interface->parent_usb_device->dev = &((*hdev)[old_dev].dev);
}
}
/*---------------------------------------------------------*\
| Allocate buffer for USB interface and USB host interface |
| structures |
\*---------------------------------------------------------*/
struct usb_interface* intf = (struct usb_interface*)malloc(sizeof(struct usb_interface));
intf->cur_altsetting = (struct usb_host_interface*)malloc(sizeof(struct usb_host_interface));
/*---------------------------------------------------------*\
| Set the interface protocol for this device |
| Get this information from the interface descriptor |
\*---------------------------------------------------------*/
//USB_INTERFACE_DESCRIPTOR interface_descriptor;
//WinUsb_QueryInterfaceSettings(hWinUSBHandle, 0, &interface_descriptor);
intf->cur_altsetting->desc.bInterfaceProtocol = 0;// interface_descriptor.bInterfaceProtocol;
/*---------------------------------------------------------*\
| Allocate buffer for USB device structure |
\*---------------------------------------------------------*/
struct usb_device *usbdevice = (struct usb_device*)malloc(sizeof(struct usb_device));
/*---------------------------------------------------------*\
| Set up USB device and interface structures |
\*---------------------------------------------------------*/
usbdevice->descriptor.idVendor = hdr.id_table[i].vendor;
usbdevice->descriptor.idProduct = hdr.id_table[i].product;
intf->parent_usb_device = usbdevice;
(*hdev)[*numHdev].product = hdr.id_table[i].product;
(*hdev)[*numHdev].dev.parent = &((*hdev)[*numHdev].dev);
(*hdev)[*numHdev].dev.driver_data;
(*hdev)[*numHdev].dev.p = hWinUSBHandle;
(*hdev)[*numHdev].dev.parent_usb_interface = intf;
(*hdev)[*numHdev].dev.init_name = hdr.name;
(*hdev)[*numHdev].dev.attr_count = 0;
usbdevice->dev = &((*hdev)[*numHdev].dev);
intf->dev = &((*hdev)[*numHdev].dev);
(*hdev)[*numHdev].status = 2;
(*hdev)[*numHdev].driver = &hdr;
(*hdev)[*numHdev].ll_driver = (struct hid_ll_driver*)malloc(sizeof(struct hid_ll_driver));
(*hdev)[*numHdev].ll_driver->parse = ll_parse;
(*hdev)[*numHdev].ll_driver->start = ll_start;
(*hdev)[*numHdev].ll_driver->stop = ll_stop;
/*---------------------------------------------------------*\
| Call the OpenRazer driver probe function |
\*---------------------------------------------------------*/
(*hdev)[*numHdev].driver->probe(&((*hdev)[*numHdev]), &(hdr.id_table[i]));
(*numHdev)++;
}
if (!numHdev)
{
printf("device %04X:%04X NOT opened!\n", hdr.id_table[i].vendor, hdr.id_table[i].product);
}
}
}
#endif /* HID_H_ */

View file

@ -1,38 +0,0 @@
#ifndef INIT_H_
#define INIT_H_
#define KERN_WARNING
#define KERN_ALERT
#define KERN_CRIT
#define printk printf
inline unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base) {
return strtoul(cp, endp, base);
}
inline void usleep(__int64 usec) {
HANDLE timer;
LARGE_INTEGER ft;
ft.QuadPart = -(10 * usec); // Convert to 100 nanosecond interval, negative value indicates relative time
timer = CreateWaitableTimer(NULL, TRUE, NULL);
SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0);
WaitForSingleObject(timer, INFINITE);
CloseHandle(timer);
}
inline void msleep(__int64 msec) {
usleep(1000 * msec);
}
inline void usleep_range(__int64 usec1, __int64 usec2) {
usleep((usec1 + usec2) / 2);
}
inline unsigned short eflip(unsigned short val) {
return (val & 0xff) * 0xFF + (val >> 8);
}
#endif /* INIT_H_ */

View file

@ -1,98 +0,0 @@
#ifndef KERNEL_H_
#define KERNEL_H_
#include <windows.h>
#define DLL_INTERNAL __declspec( dllexport )
#define u8 unsigned char
#define u16 unsigned short
#define u32 unsigned int
#define u64 unsigned long
#define __u8 unsigned char
#define __u16 unsigned short
#define __u32 unsigned int
#define __u64 unsigned long
#define uint8_t unsigned char
#define uint16_t unsigned short
#define uint32_t unsigned int
#define uint64_t unsigned long
#define __le8 unsigned char
#define __le16 unsigned short
#define __le32 unsigned int
#define __le64 unsigned long
#define __s8 signed char
#define __s16 signed short
#define __s32 signed int
#define __s64 signed long
#define uint unsigned int
#define ulong unsigned long
#define socklen_t int
#define bool int
#define true 1
#define false 0
#define size_t SIZE_T
#define ssize_t SSIZE_T
struct mutex {
CRITICAL_SECTION lock;
};
inline void mutex_init(struct mutex* mutex) {
InitializeCriticalSection(&mutex->lock);
}
inline void mutex_lock(struct mutex* mutex) {
EnterCriticalSection(&mutex->lock);
}
inline void mutex_unlock(struct mutex* mutex) {
LeaveCriticalSection(&mutex->lock);
}
inline int mutex_trylock(struct mutex* mutex) {
return TryEnterCriticalSection(&mutex->lock);
}
inline int mutex_is_locked(struct mutex* mutex) {
if (mutex_trylock(mutex)) {
mutex_unlock(mutex);
return 0;
}
else
return 1;
}
inline void set_bit(int nr, volatile unsigned long *addr) {
int *a = (int *)addr;
int mask;
a += nr >> 5;
mask = 1 << (nr & 0x1f);
*a |= mask;
}
#define __set_bit set_bit
inline void clear_bit(int nr, volatile unsigned long *addr) {
int *a = (int *)addr;
int mask;
a += nr >> 5;
mask = 1 << (nr & 0x1f);
*a &= ~mask;
}
inline int test_bit(int nr, const void *addr) {
int *a = (int *)addr;
int mask;
a += nr >> 5;
mask = 1 << (nr & 0x1f);
return ((mask & *a) != 0);
}
#endif /* KERNEL_H_ */

View file

@ -1,170 +0,0 @@
#ifndef MODULE_H_
#define MODULE_H_
#include <stdio.h>
#include <Winusb.h>
#define MODULE_AUTHOR( __Declaration__ )
#define MODULE_DESCRIPTION( __Declaration__ )
#define MODULE_VERSION( __Declaration__ )
#define MODULE_LICENSE( __Declaration__ )
#define USB_CTRL_SET_TIMEOUT 5000
#define USB_DIR_OUT 0
#define USB_DIR_IN 0x80
#define USB_TYPE_CLASS (0x01 << 5)
#define USB_RECIP_INTERFACE 0x01
#define usb_sndctrlpipe(u,d) 0
#define usb_rcvctrlpipe(u,d) 0
#define PATH_MAX 512
struct usb_interface_descriptor {
unsigned char bInterfaceProtocol;
};
struct usb_host_interface {
struct usb_interface_descriptor desc;
};
struct device {
struct device *parent;
void *p;
const char *init_name;
struct bus_type* bus;
void *driver_data;
unsigned int attr_count;
struct device_attribute * attr_list[64];
struct usb_interface *parent_usb_interface;
};
struct usb_interface {
struct device* dev;
int num_altsetting;
struct usb_host_interface *cur_altsetting;
struct usb_device *parent_usb_device;
};
struct usb_device_descriptor {
unsigned short idVendor;
unsigned short idProduct;
};
struct usb_device {
struct device* dev;
struct usb_device_descriptor descriptor;
};
inline int usb_control_msg(
struct usb_device *usb_dev
, int usb_pipe
, unsigned int request
, unsigned int request_type
, unsigned int value
, unsigned int report_index
, unsigned char* buf, unsigned int size
, unsigned int timeout)
{
/*---------------------------------------------------------*\
| Copy Linux API arguments into WinUSB format message |
\*---------------------------------------------------------*/
WINUSB_SETUP_PACKET packet;
packet.RequestType = request_type;
packet.Request = request;
packet.Value = value;
packet.Index = report_index;
packet.Length = size;
ULONG cbSent = 0;
/*---------------------------------------------------------*\
| Perform WinUSB USB control transfer |
\*---------------------------------------------------------*/
if (!WinUsb_ControlTransfer(usb_dev->dev->p, packet, buf, size, &cbSent, 0))
{
printf("WinUsb_ControlTransfer failed\n");
}
return cbSent;
}
inline struct usb_interface *to_usb_interface(struct device *dev) {
return dev->parent_usb_interface;
}
inline struct usb_device *to_usb_device(struct device *dev) {
return dev->parent_usb_interface->parent_usb_device;
}
inline struct usb_device *interface_to_usbdev(struct usb_interface *intf) {
return to_usb_device(intf->dev->parent);
}
inline void usb_disable_autosuspend(struct usb_device *usb_dev) {
printf("usb_disable_autosuspend\n");
}
struct device_attribute {
const char* name;
ssize_t(*show)(struct device *dev, struct device_attribute *attr, char *buf);
ssize_t(*store)(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);
};
inline int device_create_file(struct device *device, struct device_attribute *entry)
{
if (device->attr_count < 64)
{
printf("device_create_file - Adding %s to list\n", entry->name);
device->attr_list[device->attr_count] = entry;
device->attr_count++;
}
else
{
printf("device_create_file - List is full\n");
}
return 0;
}
inline void device_remove_file(struct device *device, struct device_attribute *entry) {
printf("device_remove_file %s\n", entry->name);
}
#define HID_USB_DEVICE(ven, prod) \
.vendor = (ven) \
, .product = (prod)
#define __stringify(x) #x
// Hack to turn Linux device macros into API calls
#define DEVICE_ATTR1(_device,_name, _mode, _show, _store) \
struct device_attribute dev_attr_##_name = { \
.name = __stringify(_name) \
, .show = _show \
, .store = _store \
}; \
DLL_INTERNAL struct device_attribute dev##_device##_attr_##_name = { \
.name = __stringify(_name) \
, .show = _show \
, .store = _store \
};
#define MODULE_DEVICE_TABLE(type, name)
/*typedef struct hid_device_array_tag {
unsigned int count;
struct hid_device* hdev[];
} hid_device_array;*/
#define module_hid_driver(hdr) \
DLL_INTERNAL unsigned int init_##hdr## (struct hid_device** hdevo) { \
unsigned int numHdevs = 0; \
struct hid_device* hdev = NULL; \
openChromaDevice(&hdev, &numHdevs, hdr); \
*hdevo = hdev; \
return numHdevs; \
}
#endif /* MODULE_H_ */

View file

@ -1,16 +0,0 @@
#ifndef RANDOM_H_
#define RANDOM_H_
static inline void get_random_bytes(void* rand_ptr, unsigned int rand_size) {
char failed = 0;
static HCRYPTPROV prov = 0;
if (prov == 0) {
if (!CryptAcquireContext(&prov, NULL, NULL, PROV_RSA_FULL, 0))
failed = 1;
}
if (!failed && !CryptGenRandom(prov, rand_size, (unsigned char*)rand_ptr))
printf("get_random_bytes failed\n");
}
#endif /* RANDOM_H_ */

View file

@ -1,31 +0,0 @@
#ifndef SLAB_H_
#define SLAB_H_
typedef enum {
GFP_KERNEL,
GFP_ATOMIC,
__GFP_HIGHMEM,
__GFP_HIGH
} gfp_t;
static inline void *kzalloc(size_t s, gfp_t gfp) {
void *p = malloc(s);
memset(p, 0, s);
return p;
}
inline void *kmemdup(const void *src, size_t len, gfp_t gfp) {
void *p;
p = malloc(len);
if (p)
memcpy(p, src, len);
return p;
}
static inline void kfree(const void* p) {
free((void*)p);
}
#endif /* SLAB_H_ */

View file

@ -1,539 +0,0 @@
#ifndef INPUT_H_
#define INPUT_H_
#include <stdio.h>
#include <windows.h>
#define uint unsigned int
#define ulong unsigned long
#define u8 unsigned char
#define u16 unsigned short
#define u32 unsigned int
#define u64 unsigned long
#define ABS_VOLUME 0x20
//input-event-codes.h
#define KEY_RESERVED 0
#define KEY_ESC 1
#define KEY_1 2
#define KEY_2 3
#define KEY_3 4
#define KEY_4 5
#define KEY_5 6
#define KEY_6 7
#define KEY_7 8
#define KEY_8 9
#define KEY_9 10
#define KEY_0 11
#define KEY_MINUS 12
#define KEY_EQUAL 13
#define KEY_BACKSPACE 14
#define KEY_TAB 15
#define KEY_Q 16
#define KEY_W 17
#define KEY_E 18
#define KEY_R 19
#define KEY_T 20
#define KEY_Y 21
#define KEY_U 22
#define KEY_I 23
#define KEY_O 24
#define KEY_P 25
#define KEY_LEFTBRACE 26
#define KEY_RIGHTBRACE 27
#define KEY_ENTER 28
#define KEY_LEFTCTRL 29
#define KEY_A 30
#define KEY_S 31
#define KEY_D 32
#define KEY_F 33
#define KEY_G 34
#define KEY_H 35
#define KEY_J 36
#define KEY_K 37
#define KEY_L 38
#define KEY_SEMICOLON 39
#define KEY_APOSTROPHE 40
#define KEY_GRAVE 41
#define KEY_LEFTSHIFT 42
#define KEY_BACKSLASH 43
#define KEY_Z 44
#define KEY_X 45
#define KEY_C 46
#define KEY_V 47
#define KEY_B 48
#define KEY_N 49
#define KEY_M 50
#define KEY_COMMA 51
#define KEY_DOT 52
#define KEY_SLASH 53
#define KEY_RIGHTSHIFT 54
#define KEY_KPASTERISK 55
#define KEY_LEFTALT 56
#define KEY_SPACE 57
#define KEY_CAPSLOCK 58
#define KEY_F1 59
#define KEY_F2 60
#define KEY_F3 61
#define KEY_F4 62
#define KEY_F5 63
#define KEY_F6 64
#define KEY_F7 65
#define KEY_F8 66
#define KEY_F9 67
#define KEY_F10 68
#define KEY_NUMLOCK 69
#define KEY_SCROLLLOCK 70
#define KEY_KP7 71
#define KEY_KP8 72
#define KEY_KP9 73
#define KEY_KPMINUS 74
#define KEY_KP4 75
#define KEY_KP5 76
#define KEY_KP6 77
#define KEY_KPPLUS 78
#define KEY_KP1 79
#define KEY_KP2 80
#define KEY_KP3 81
#define KEY_KP0 82
#define KEY_KPDOT 83
#define KEY_ZENKAKUHANKAKU 85
#define KEY_102ND 86
#define KEY_F11 87
#define KEY_F12 88
#define KEY_RO 89
#define KEY_KATAKANA 90
#define KEY_HIRAGANA 91
#define KEY_HENKAN 92
#define KEY_KATAKANAHIRAGANA 93
#define KEY_MUHENKAN 94
#define KEY_KPJPCOMMA 95
#define KEY_KPENTER 96
#define KEY_RIGHTCTRL 97
#define KEY_KPSLASH 98
#define KEY_SYSRQ 99
#define KEY_RIGHTALT 100
#define KEY_LINEFEED 101
#define KEY_HOME 102
#define KEY_UP 103
#define KEY_PAGEUP 104
#define KEY_LEFT 105
#define KEY_RIGHT 106
#define KEY_END 107
#define KEY_DOWN 108
#define KEY_PAGEDOWN 109
#define KEY_INSERT 110
#define KEY_DELETE 111
#define KEY_MACRO 112
#define KEY_MUTE 113
#define KEY_VOLUMEDOWN 114
#define KEY_VOLUMEUP 115
#define KEY_POWER 116 /* SC System Power Down */
#define KEY_KPEQUAL 117
#define KEY_KPPLUSMINUS 118
#define KEY_PAUSE 119
#define KEY_SCALE 120 /* AL Compiz Scale (Expose) */
#define KEY_KPCOMMA 121
#define KEY_HANGEUL 122
#define KEY_HANGUEL KEY_HANGEUL
#define KEY_HANJA 123
#define KEY_YEN 124
#define KEY_LEFTMETA 125
#define KEY_RIGHTMETA 126
#define KEY_COMPOSE 127
#define KEY_STOP 128 /* AC Stop */
#define KEY_AGAIN 129
#define KEY_PROPS 130 /* AC Properties */
#define KEY_UNDO 131 /* AC Undo */
#define KEY_FRONT 132
#define KEY_COPY 133 /* AC Copy */
#define KEY_OPEN 134 /* AC Open */
#define KEY_PASTE 135 /* AC Paste */
#define KEY_FIND 136 /* AC Search */
#define KEY_CUT 137 /* AC Cut */
#define KEY_HELP 138 /* AL Integrated Help Center */
#define KEY_MENU 139 /* Menu (show menu) */
#define KEY_CALC 140 /* AL Calculator */
#define KEY_SETUP 141
#define KEY_SLEEP 142 /* SC System Sleep */
#define KEY_WAKEUP 143 /* System Wake Up */
#define KEY_FILE 144 /* AL Local Machine Browser */
#define KEY_SENDFILE 145
#define KEY_DELETEFILE 146
#define KEY_XFER 147
#define KEY_PROG1 148
#define KEY_PROG2 149
#define KEY_WWW 150 /* AL Internet Browser */
#define KEY_MSDOS 151
#define KEY_COFFEE 152 /* AL Terminal Lock/Screensaver */
#define KEY_SCREENLOCK KEY_COFFEE
#define KEY_DIRECTION 153
#define KEY_CYCLEWINDOWS 154
#define KEY_MAIL 155
#define KEY_BOOKMARKS 156 /* AC Bookmarks */
#define KEY_COMPUTER 157
#define KEY_BACK 158 /* AC Back */
#define KEY_FORWARD 159 /* AC Forward */
#define KEY_CLOSECD 160
#define KEY_EJECTCD 161
#define KEY_EJECTCLOSECD 162
#define KEY_NEXTSONG 163
#define KEY_PLAYPAUSE 164
#define KEY_PREVIOUSSONG 165
#define KEY_STOPCD 166
#define KEY_RECORD 167
#define KEY_REWIND 168
#define KEY_PHONE 169 /* Media Select Telephone */
#define KEY_ISO 170
#define KEY_CONFIG 171 /* AL Consumer Control Configuration */
#define KEY_HOMEPAGE 172 /* AC Home */
#define KEY_REFRESH 173 /* AC Refresh */
#define KEY_EXIT 174 /* AC Exit */
#define KEY_MOVE 175
#define KEY_EDIT 176
#define KEY_SCROLLUP 177
#define KEY_SCROLLDOWN 178
#define KEY_KPLEFTPAREN 179
#define KEY_KPRIGHTPAREN 180
#define KEY_NEW 181 /* AC New */
#define KEY_REDO 182 /* AC Redo/Repeat */
#define KEY_F13 183
#define KEY_F14 184
#define KEY_F15 185
#define KEY_F16 186
#define KEY_F17 187
#define KEY_F18 188
#define KEY_F19 189
#define KEY_F20 190
#define KEY_F21 191
#define KEY_F22 192
#define KEY_F23 193
#define KEY_F24 194
#define KEY_PLAYCD 200
#define KEY_PAUSECD 201
#define KEY_PROG3 202
#define KEY_PROG4 203
#define KEY_DASHBOARD 204 /* AL Dashboard */
#define KEY_SUSPEND 205
#define KEY_CLOSE 206 /* AC Close */
#define KEY_PLAY 207
#define KEY_FASTFORWARD 208
#define KEY_BASSBOOST 209
#define KEY_PRINT 210 /* AC Print */
#define KEY_HP 211
#define KEY_CAMERA 212
#define KEY_SOUND 213
#define KEY_QUESTION 214
#define KEY_EMAIL 215
#define KEY_CHAT 216
#define KEY_SEARCH 217
#define KEY_CONNECT 218
#define KEY_FINANCE 219 /* AL Checkbook/Finance */
#define KEY_SPORT 220
#define KEY_SHOP 221
#define KEY_ALTERASE 222
#define KEY_CANCEL 223 /* AC Cancel */
#define KEY_BRIGHTNESSDOWN 224
#define KEY_BRIGHTNESSUP 225
#define KEY_MEDIA 226
#define KEY_SWITCHVIDEOMODE 227 /* Cycle between available video
outputs (Monitor/LCD/TV-out/etc) */
#define KEY_KBDILLUMTOGGLE 228
#define KEY_KBDILLUMDOWN 229
#define KEY_KBDILLUMUP 230
#define KEY_SEND 231 /* AC Send */
#define KEY_REPLY 232 /* AC Reply */
#define KEY_FORWARDMAIL 233 /* AC Forward Msg */
#define KEY_SAVE 234 /* AC Save */
#define KEY_DOCUMENTS 235
#define KEY_BATTERY 236
#define KEY_BLUETOOTH 237
#define KEY_WLAN 238
#define KEY_UWB 239
#define KEY_UNKNOWN 240
#define KEY_VIDEO_NEXT 241 /* drive next video source */
#define KEY_VIDEO_PREV 242 /* drive previous video source */
#define KEY_BRIGHTNESS_CYCLE 243 /* brightness up, after max is min */
#define KEY_BRIGHTNESS_ZERO 244 /* brightness off, use ambient */
#define KEY_DISPLAY_OFF 245 /* display device to off state */
#define KEY_WIMAX 246
/* Range 248 - 255 is reserved for special needs of AT keyboard driver */
#define BTN_MISC 0x100
#define BTN_0 0x100
#define BTN_1 0x101
#define BTN_2 0x102
#define BTN_3 0x103
#define BTN_4 0x104
#define BTN_5 0x105
#define BTN_6 0x106
#define BTN_7 0x107
#define BTN_8 0x108
#define BTN_9 0x109
#define BTN_MOUSE 0x110
#define BTN_LEFT 0x110
#define BTN_RIGHT 0x111
#define BTN_MIDDLE 0x112
#define BTN_SIDE 0x113
#define BTN_EXTRA 0x114
#define BTN_FORWARD 0x115
#define BTN_BACK 0x116
#define BTN_TASK 0x117
#define BTN_JOYSTICK 0x120
#define BTN_TRIGGER 0x120
#define BTN_THUMB 0x121
#define BTN_THUMB2 0x122
#define BTN_TOP 0x123
#define BTN_TOP2 0x124
#define BTN_PINKIE 0x125
#define BTN_BASE 0x126
#define BTN_BASE2 0x127
#define BTN_BASE3 0x128
#define BTN_BASE4 0x129
#define BTN_BASE5 0x12a
#define BTN_BASE6 0x12b
#define BTN_DEAD 0x12f
#define BTN_GAMEPAD 0x130
#define BTN_A 0x130
#define BTN_B 0x131
#define BTN_C 0x132
#define BTN_X 0x133
#define BTN_Y 0x134
#define BTN_Z 0x135
#define BTN_TL 0x136
#define BTN_TR 0x137
#define BTN_TL2 0x138
#define BTN_TR2 0x139
#define BTN_SELECT 0x13a
#define BTN_START 0x13b
#define BTN_MODE 0x13c
#define BTN_THUMBL 0x13d
#define BTN_THUMBR 0x13e
#define BTN_DIGI 0x140
#define BTN_TOOL_PEN 0x140
#define BTN_TOOL_RUBBER 0x141
#define BTN_TOOL_BRUSH 0x142
#define BTN_TOOL_PENCIL 0x143
#define BTN_TOOL_AIRBRUSH 0x144
#define BTN_TOOL_FINGER 0x145
#define BTN_TOOL_MOUSE 0x146
#define BTN_TOOL_LENS 0x147
#define BTN_TOUCH 0x14a
#define BTN_STYLUS 0x14b
#define BTN_STYLUS2 0x14c
#define BTN_TOOL_DOUBLETAP 0x14d
#define BTN_TOOL_TRIPLETAP 0x14e
#define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */
#define BTN_WHEEL 0x150
#define BTN_GEAR_DOWN 0x150
#define BTN_GEAR_UP 0x151
#define KEY_OK 0x160
#define KEY_SELECT 0x161
#define KEY_GOTO 0x162
#define KEY_CLEAR 0x163
#define KEY_POWER2 0x164
#define KEY_OPTION 0x165
#define KEY_INFO 0x166 /* AL OEM Features/Tips/Tutorial */
#define KEY_TIME 0x167
#define KEY_VENDOR 0x168
#define KEY_ARCHIVE 0x169
#define KEY_PROGRAM 0x16a /* Media Select Program Guide */
#define KEY_CHANNEL 0x16b
#define KEY_FAVORITES 0x16c
#define KEY_EPG 0x16d
#define KEY_PVR 0x16e /* Media Select Home */
#define KEY_MHP 0x16f
#define KEY_LANGUAGE 0x170
#define KEY_TITLE 0x171
#define KEY_SUBTITLE 0x172
#define KEY_ANGLE 0x173
#define KEY_ZOOM 0x174
#define KEY_MODE 0x175
#define KEY_KEYBOARD 0x176
#define KEY_SCREEN 0x177
#define KEY_PC 0x178 /* Media Select Computer */
#define KEY_TV 0x179 /* Media Select TV */
#define KEY_TV2 0x17a /* Media Select Cable */
#define KEY_VCR 0x17b /* Media Select VCR */
#define KEY_VCR2 0x17c /* VCR Plus */
#define KEY_SAT 0x17d /* Media Select Satellite */
#define KEY_SAT2 0x17e
#define KEY_CD 0x17f /* Media Select CD */
#define KEY_TAPE 0x180 /* Media Select Tape */
#define KEY_RADIO 0x181
#define KEY_TUNER 0x182 /* Media Select Tuner */
#define KEY_PLAYER 0x183
#define KEY_TEXT 0x184
#define KEY_DVD 0x185 /* Media Select DVD */
#define KEY_AUX 0x186
#define KEY_MP3 0x187
#define KEY_AUDIO 0x188
#define KEY_VIDEO 0x189
#define KEY_DIRECTORY 0x18a
#define KEY_LIST 0x18b
#define KEY_MEMO 0x18c /* Media Select Messages */
#define KEY_CALENDAR 0x18d
#define KEY_RED 0x18e
#define KEY_GREEN 0x18f
#define KEY_YELLOW 0x190
#define KEY_BLUE 0x191
#define KEY_CHANNELUP 0x192 /* Channel Increment */
#define KEY_CHANNELDOWN 0x193 /* Channel Decrement */
#define KEY_FIRST 0x194
#define KEY_LAST 0x195 /* Recall Last */
#define KEY_AB 0x196
#define KEY_NEXT 0x197
#define KEY_RESTART 0x198
#define KEY_SLOW 0x199
#define KEY_SHUFFLE 0x19a
#define KEY_BREAK 0x19b
#define KEY_PREVIOUS 0x19c
#define KEY_DIGITS 0x19d
#define KEY_TEEN 0x19e
#define KEY_TWEN 0x19f
#define KEY_VIDEOPHONE 0x1a0 /* Media Select Video Phone */
#define KEY_GAMES 0x1a1 /* Media Select Games */
#define KEY_ZOOMIN 0x1a2 /* AC Zoom In */
#define KEY_ZOOMOUT 0x1a3 /* AC Zoom Out */
#define KEY_ZOOMRESET 0x1a4 /* AC Zoom */
#define KEY_WORDPROCESSOR 0x1a5 /* AL Word Processor */
#define KEY_EDITOR 0x1a6 /* AL Text Editor */
#define KEY_SPREADSHEET 0x1a7 /* AL Spreadsheet */
#define KEY_GRAPHICSEDITOR 0x1a8 /* AL Graphics Editor */
#define KEY_PRESENTATION 0x1a9 /* AL Presentation App */
#define KEY_DATABASE 0x1aa /* AL Database App */
#define KEY_NEWS 0x1ab /* AL Newsreader */
#define KEY_VOICEMAIL 0x1ac /* AL Voicemail */
#define KEY_ADDRESSBOOK 0x1ad /* AL Contacts/Address Book */
#define KEY_MESSENGER 0x1ae /* AL Instant Messaging */
#define KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */
#define KEY_SPELLCHECK 0x1b0 /* AL Spell Check */
#define KEY_LOGOFF 0x1b1 /* AL Logoff */
#define KEY_DOLLAR 0x1b2
#define KEY_EURO 0x1b3
#define KEY_FRAMEBACK 0x1b4 /* Consumer - transport controls */
#define KEY_FRAMEFORWARD 0x1b5
#define KEY_CONTEXT_MENU 0x1b6 /* GenDesc - system context menu */
#define KEY_MEDIA_REPEAT 0x1b7 /* Consumer - transport control */
#define KEY_DEL_EOL 0x1c0
#define KEY_DEL_EOS 0x1c1
#define KEY_INS_LINE 0x1c2
#define KEY_DEL_LINE 0x1c3
#define KEY_FN 0x1d0
#define KEY_FN_ESC 0x1d1
#define KEY_FN_F1 0x1d2
#define KEY_FN_F2 0x1d3
#define KEY_FN_F3 0x1d4
#define KEY_FN_F4 0x1d5
#define KEY_FN_F5 0x1d6
#define KEY_FN_F6 0x1d7
#define KEY_FN_F7 0x1d8
#define KEY_FN_F8 0x1d9
#define KEY_FN_F9 0x1da
#define KEY_FN_F10 0x1db
#define KEY_FN_F11 0x1dc
#define KEY_FN_F12 0x1dd
#define KEY_FN_1 0x1de
#define KEY_FN_2 0x1df
#define KEY_FN_D 0x1e0
#define KEY_FN_E 0x1e1
#define KEY_FN_F 0x1e2
#define KEY_FN_S 0x1e3
#define KEY_FN_B 0x1e4
#define KEY_BRL_DOT1 0x1f1
#define KEY_BRL_DOT2 0x1f2
#define KEY_BRL_DOT3 0x1f3
#define KEY_BRL_DOT4 0x1f4
#define KEY_BRL_DOT5 0x1f5
#define KEY_BRL_DOT6 0x1f6
#define KEY_BRL_DOT7 0x1f7
#define KEY_BRL_DOT8 0x1f8
#define KEY_BRL_DOT9 0x1f9
#define KEY_BRL_DOT10 0x1fa
#define KEY_NUMERIC_0 0x200 /* used by phones, remote controls, */
#define KEY_NUMERIC_1 0x201 /* and other keypads */
#define KEY_NUMERIC_2 0x202
#define KEY_NUMERIC_3 0x203
#define KEY_NUMERIC_4 0x204
#define KEY_NUMERIC_5 0x205
#define KEY_NUMERIC_6 0x206
#define KEY_NUMERIC_7 0x207
#define KEY_NUMERIC_8 0x208
#define KEY_NUMERIC_9 0x209
#define KEY_NUMERIC_STAR 0x20a
#define KEY_NUMERIC_POUND 0x20b
/* We avoid low common keys in module aliases so they don't get huge. */
#define KEY_MIN_INTERESTING KEY_MUTE
#define KEY_MAX 0x2ff
#define KEY_CNT (KEY_MAX+1)
#define EV_SYN 0x00
#define EV_KEY 0x01
#define EV_REL 0x02
#define EV_ABS 0x03
#define EV_MSC 0x04
#define EV_SW 0x05
#define EV_LED 0x11
#define EV_SND 0x12
#define EV_REP 0x14
#define EV_FF 0x15
#define EV_PWR 0x16
#define EV_FF_STATUS 0x17
#define EV_MAX 0x1f
#define EV_CNT (EV_MAX+1)
#define SYN_REPORT 0
#define BITS_PER_BYTE 8
#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
#define DECLARE_BITMAP(name,bits) unsigned long name[BITS_TO_LONGS(bits)]
struct input_dev {
const char *name;
const char *phys;
unsigned long evbit[BITS_TO_LONGS(EV_CNT)];
unsigned long keybit[BITS_TO_LONGS(KEY_CNT)];
};
static inline void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) {
printf("input_event\n");
}
static inline void input_report_key(struct input_dev *dev, unsigned int code, int value) {
input_event(dev, EV_KEY, code, value);
}
static inline void input_sync(struct input_dev *dev) {
input_event(dev, EV_SYN, SYN_REPORT, 0);
}
#endif /* INPUT_H_ */