modify input modules

This commit is contained in:
侯歌 2022-01-13 17:27:57 +08:00
parent 00180630bc
commit 2451020a8a
8 changed files with 295 additions and 90 deletions

View File

@ -15,22 +15,148 @@
using namespace std;
namespace cdroid{
static bool containsNonZeroByte(const uint8_t* array, uint32_t startIndex, uint32_t endIndex) {
const uint8_t* end = array + endIndex;
array += startIndex;
while (array != end) {
if (*(array++) != 0) {
return true;
}
}
return false;
}
#define test_bit(bit, array) ((array)[(bit)/8] & (1<<((bit)%8)))
#define sizeof_bit_array(bits) (((bits) + 7) / 8)
InputDevice::InputDevice(int fdev):listener(nullptr){
INPUTDEVICEINFO info;
InputDeviceIdentifier di;
InputGetDeviceInfo(fdev,&info);
di.name=info.name;
di.product=info.product;
di.vendor=info.vendor;
devinfo.initialize(fdev,0,0,di,std::string(),0,0);
devinfo.addSource(info.source);
kmap=nullptr;
LOGD("device %d source=%x vid/pid=%x/%x name=%s",fdev,info.source,info.vendor,info.product,info.name);
INPUTDEVICEINFO info;
InputDeviceIdentifier di;
mDeviceClasses=0;
InputGetDeviceInfo(fdev,&info);
di.name=info.name;
di.product=info.product;
di.vendor=info.vendor;
devinfo.initialize(fdev,0,0,di,std::string(),0,0);
// See if this is a keyboard. Ignore everything in the button range except for
// joystick and gamepad buttons which are handled like keyboards for the most part.
bool haveKeyboardKeys = containsNonZeroByte(info.keyBitMask, 0, sizeof_bit_array(BTN_MISC))
|| containsNonZeroByte(info.keyBitMask, sizeof_bit_array(KEY_OK),
sizeof_bit_array(KEY_MAX + 1));
bool haveGamepadButtons = containsNonZeroByte(info.keyBitMask, sizeof_bit_array(BTN_MISC),
sizeof_bit_array(BTN_MOUSE))
|| containsNonZeroByte(info.keyBitMask, sizeof_bit_array(BTN_JOYSTICK),
sizeof_bit_array(BTN_DIGI));
if (haveKeyboardKeys || haveGamepadButtons) {
mDeviceClasses |= INPUT_DEVICE_CLASS_KEYBOARD;
}
if(test_bit(BTN_MOUSE,info.keyBitMask)
&&test_bit(REL_X,info.relBitMask)
&&test_bit(REL_Y,info.relBitMask))
mDeviceClasses=INPUT_DEVICE_CLASS_CURSOR;//devinfo.addSource(INPUT_DEVICE_CLASS_CURSOR);
if(test_bit(ABS_MT_POSITION_X, info.absBitMask)
&& test_bit(ABS_MT_POSITION_Y, info.absBitMask)) {
// Some joysticks such as the PS3 controller report axes that conflict
// with the ABS_MT range. Try to confirm that the device really is
// a touch screen.
if (test_bit(BTN_TOUCH, info.keyBitMask) || !haveGamepadButtons) {
mDeviceClasses |= INPUT_DEVICE_CLASS_TOUCH | INPUT_DEVICE_CLASS_TOUCH_MT;
}
// Is this an old style single-touch driver?
} else if (test_bit(BTN_TOUCH, info.keyBitMask)
&& test_bit(ABS_X, info.absBitMask)
&& test_bit(ABS_Y, info.absBitMask)) {
mDeviceClasses |= INPUT_DEVICE_CLASS_TOUCH;
// Is this a BT stylus?
} else if ((test_bit(ABS_PRESSURE, info.absBitMask) || test_bit(BTN_TOUCH, info.keyBitMask))
&& !test_bit(ABS_X, info.absBitMask) && !test_bit(ABS_Y, info.absBitMask)) {
//device->classes |= INPUT_DEVICE_CLASS_EXTERNAL_STYLUS;
// Keyboard will try to claim some of the buttons but we really want to reserve those so we
// can fuse it with the touch screen data, so just take them back. Note this means an
// external stylus cannot also be a keyboard device.
mDeviceClasses &= ~INPUT_DEVICE_CLASS_KEYBOARD;
}
// See if this device is a joystick.
// Assumes that joysticks always have gamepad buttons in order to distinguish them
// from other devices such as accelerometers that also have absolute axes.
if (haveGamepadButtons) {
uint32_t assumedClasses = mDeviceClasses | INPUT_DEVICE_CLASS_JOYSTICK;
for (int i = 0; i <= ABS_MAX; i++) {
if (test_bit(i, info.absBitMask)
&& (getAbsAxisUsage(i, assumedClasses) & INPUT_DEVICE_CLASS_JOYSTICK)) {
mDeviceClasses = assumedClasses;
break;
}
}
}
// Check whether this device has switches.
for (int i = 0; i <= SW_MAX; i++) {
if (test_bit(i, info.swBitMask)) {
mDeviceClasses |= INPUT_DEVICE_CLASS_SWITCH;
break;
}
}
// Check whether this device supports the vibrator.
if (test_bit(FF_RUMBLE, info.ffBitMask)) {
mDeviceClasses |= INPUT_DEVICE_CLASS_VIBRATOR;
}
// Configure virtual keys.
if ((mDeviceClasses & INPUT_DEVICE_CLASS_TOUCH)) {
// Load the virtual keys for the touch screen, if any.
// We do this now so that we can make sure to load the keymap if necessary.
uint32_t status = 0;//loadVirtualKeyMapLocked(device);
if (!status) {
mDeviceClasses |= INPUT_DEVICE_CLASS_KEYBOARD;
}
}
kmap=nullptr;
}
uint32_t getAbsAxisUsage(int32_t axis, uint32_t mDeviceClasses) {
// Touch devices get dibs on touch-related axes.
if (mDeviceClasses & INPUT_DEVICE_CLASS_TOUCH) {
switch (axis) {
case ABS_X:
case ABS_Y:
case ABS_PRESSURE:
case ABS_TOOL_WIDTH:
case ABS_DISTANCE:
case ABS_TILT_X:
case ABS_TILT_Y:
case ABS_MT_SLOT:
case ABS_MT_TOUCH_MAJOR:
case ABS_MT_TOUCH_MINOR:
case ABS_MT_WIDTH_MAJOR:
case ABS_MT_WIDTH_MINOR:
case ABS_MT_ORIENTATION:
case ABS_MT_POSITION_X:
case ABS_MT_POSITION_Y:
case ABS_MT_TOOL_TYPE:
case ABS_MT_BLOB_ID:
case ABS_MT_TRACKING_ID:
case ABS_MT_PRESSURE:
case ABS_MT_DISTANCE:
return INPUT_DEVICE_CLASS_TOUCH;
}
}
// External stylus gets the pressure axis
if (mDeviceClasses & INPUT_DEVICE_CLASS_EXTERNAL_STYLUS) {
if (axis == ABS_PRESSURE) {
return INPUT_DEVICE_CLASS_EXTERNAL_STYLUS;
}
}
// Joystick devices get the rest.
return mDeviceClasses & INPUT_DEVICE_CLASS_JOYSTICK;
}
int InputDevice::isValidEvent(int type,int code,int value){
return ((1<<type)&getSource())==(1<<type);
return true;
}
int InputDevice::getId()const{
@ -46,6 +172,10 @@ int InputDevice::getProduct()const{
return devinfo.getIdentifier().product;
}
int InputDevice::getClasses()const{
return mDeviceClasses;
}
const std::string&InputDevice::getName()const{
return devinfo.getIdentifier().name;
}
@ -53,8 +183,8 @@ const std::string&InputDevice::getName()const{
KeyDevice::KeyDevice(int fd)
:InputDevice(fd){
msckey=0;
lastDownKey=-1;
repeatCount=0;
mLastDownKey=-1;
mRepeatCount=0;
const std::string fname=App::getInstance().getDataPath()+getName()+".kl";
KeyLayoutMap::load(fname,kmap);
}
@ -69,16 +199,16 @@ int KeyDevice::putRawEvent(int type,int code,int value){
switch(type){
case EV_KEY:
if(kmap)kmap->mapKey(code/*scancode*/,0,&keycode/*keycode*/,(uint32_t*)&flags);
lastDownKey=(value?keycode:-1);//key down
if(lastDownKey==keycode)
repeatCount+=(value==0);
mLastDownKey=(value?keycode:-1);//key down
if(mLastDownKey==keycode)
mRepeatCount+=(value==0);
else
repeatCount=0;
mRepeatCount=0;
key.initialize(getId(),getSource(),(value?KeyEvent::ACTION_DOWN:KeyEvent::ACTION_UP)/*action*/,flags,
keycode,code/*scancode*/,0/*metaState*/,repeatCount, downtime,SystemClock::uptimeNanos()/*eventtime*/);
LOGV("fd[%d] keycode:%08x->%04x[%s] action=%d flags=%d",getId(),code,keycode, key.getLabel(),value,flags);
if(listener)listener(key);
mEvent.initialize(getId(),getSource(),(value?KeyEvent::ACTION_DOWN:KeyEvent::ACTION_UP)/*action*/,flags,
keycode,code/*scancode*/,0/*metaState*/,mRepeatCount, mDownTime,SystemClock::uptimeNanos()/*eventtime*/);
LOGV("fd[%d] keycode:%08x->%04x[%s] action=%d flags=%d",getId(),code,keycode, mEvent.getLabel(),value,flags);
if(listener)listener(mEvent);
break;
case EV_SYN:
LOGV("fd[%d].SYN value=%d code=%d",getId(),value,code);
@ -89,30 +219,52 @@ int KeyDevice::putRawEvent(int type,int code,int value){
}
TouchDevice::TouchDevice(int fd):InputDevice(fd){
memset(coords,0,sizeof(coords));
memset(ptprops,0,sizeof(ptprops));
memset(buttonstats,0,sizeof(buttonstats));
mPointSlot = 0;
//memset(coords,0,sizeof(coords));
//memset(ptprops,0,sizeof(ptprops));
}
void TouchDevice::setAxisValue(int index,int axis,int value){
auto it=mPointMAP.find(index);
if(it==mPointMAP.end()){
TouchPoint tp;
tp.coord.clear();
auto it2=mPointMAP.insert(std::pair<int,TouchPoint>(index,tp));
it=it2.first;
}
it->second.coord.setAxisValue(axis,value);
}
int TouchDevice::putRawEvent(int type,int code,int value){
if(!isValidEvent(type,code,value))return -1;
if(type==EV_ABS){
switch(type){
case ABS_MT_SLOT: mPointId=value;break;
switch(type){
case EV_ABS:
switch(code){
case ABS_MT_SLOT: mPointSlot=value;break;
case ABS_MT_TRACKING_ID:
case ABS_MT_TOUCH_MAJOR:
case ABS_MT_POSITION_X:
case ABS_MT_POSITION_Y:break;
case ABS_MT_POSITION_Y:
setAxisValue(mPointSlot,code,value);break;
case ABS_X:
case ABS_Y:
case ABS_Z: setAxisValue(0,code,value);break;
case ABS_MT_WIDTH_MINOR:
case ABS_MT_PRESSURE:
case ABS_MT_DISTANCE:
case ABS_MT_TOOL_TYPE:
case ABS_MT_ORIENTATION:break;
}
}break;
case EV_SYN:break;
}
return 0;
}
MouseDevice::MouseDevice(int fd):TouchDevice(fd){
memset(buttonstats,0,sizeof(buttonstats));
}
int MouseDevice::putRawEvent(int type,int code,int value){
BYTE btnmap[]={ MotionEvent::BUTTON_PRIMARY ,/*BTN_LEFT*/
MotionEvent::BUTTON_SECONDARY,/*BTN_RIGHT*/
@ -121,24 +273,27 @@ int MouseDevice::putRawEvent(int type,int code,int value){
if(!isValidEvent(type,code,value))return -1;
switch(type){
case EV_KEY:
downtime=SystemClock::uptimeNanos();
mDownTime=SystemClock::uptimeNanos();
buttonstats[act_btn]=code;
LOGV("Key %x /%d btn=%d %lld",value,code,btnmap[act_btn],downtime);
mt.setAction(code?MotionEvent::ACTION_DOWN:MotionEvent::ACTION_UP);
mt.setActionButton(btnmap[act_btn]);
if(listener)listener(mt);
if(code==0)mt.setActionButton(0);
LOGV("Key %x /%d btn=%d %lld",value,code,btnmap[act_btn],mDownTime);
mEvent.setAction(code?MotionEvent::ACTION_DOWN:MotionEvent::ACTION_UP);
mEvent.setActionButton(btnmap[act_btn]);
if(listener)listener(mEvent);
if(code==0)mEvent.setActionButton(0);
break;
case EV_ABS:
coords->setAxisValue(code,value);
mt.setAction(MotionEvent::ACTION_MOVE);
TouchDevice::putRawEvent(type,code,value);
mEvent.setAction(MotionEvent::ACTION_MOVE);
break;
case EV_SYN:
mt.initialize(getId(),getSource(),mt.getAction()/*action*/,mt.getActionButton()/*actionbutton*/,
mEvent.initialize(getId(),getSource(),mEvent.getAction()/*action*/,mEvent.getActionButton()/*actionbutton*/,
0/*flags*/, 0/*edgeFlags*/,0/*metaState*/,0/*buttonState*/,
0/*xOffset*/,0/*yOffset*/,0/*xPrecision*/,0/*yPrecision*/,
downtime,SystemClock::uptimeNanos(),1/*pointerCount*/,ptprops,coords);
if(listener)listener(mt);
mDownTime,SystemClock::uptimeNanos(),0,nullptr,nullptr);//1/*pointerCount*/,ptprops,coords);
for(auto p:mPointMAP){
mEvent.addSample(SystemClock::uptimeNanos(),p.second.prop,p.second.coord);
}
if(listener)listener(mEvent);
break;
}
return 0;

View File

@ -99,6 +99,55 @@ private:
std::vector<MotionRange> mMotionRanges;
};
/* Input device classes. */
enum {
/* The input device is a keyboard or has buttons. */
INPUT_DEVICE_CLASS_KEYBOARD = 0x00000001,
/* The input device is an alpha-numeric keyboard (not just a dial pad). */
INPUT_DEVICE_CLASS_ALPHAKEY = 0x00000002,
/* The input device is a touchscreen or a touchpad (either single-touch or multi-touch). */
INPUT_DEVICE_CLASS_TOUCH = 0x00000004,
/* The input device is a cursor device such as a trackball or mouse. */
INPUT_DEVICE_CLASS_CURSOR = 0x00000008,
/* The input device is a multi-touch touchscreen. */
INPUT_DEVICE_CLASS_TOUCH_MT = 0x00000010,
/* The input device is a directional pad (implies keyboard, has DPAD keys). */
INPUT_DEVICE_CLASS_DPAD = 0x00000020,
/* The input device is a gamepad (implies keyboard, has BUTTON keys). */
INPUT_DEVICE_CLASS_GAMEPAD = 0x00000040,
/* The input device has switches. */
INPUT_DEVICE_CLASS_SWITCH = 0x00000080,
/* The input device is a joystick (implies gamepad, has joystick absolute axes). */
INPUT_DEVICE_CLASS_JOYSTICK = 0x00000100,
/* The input device has a vibrator (supports FF_RUMBLE). */
INPUT_DEVICE_CLASS_VIBRATOR = 0x00000200,
/* The input device has a microphone. */
INPUT_DEVICE_CLASS_MIC = 0x00000400,
/* The input device is an external stylus (has data we want to fuse with touch data). */
INPUT_DEVICE_CLASS_EXTERNAL_STYLUS = 0x00000800,
/* The input device has a rotary encoder */
INPUT_DEVICE_CLASS_ROTARY_ENCODER = 0x00001000,
/* The input device is virtual (not a real device, not part of UI configuration). */
INPUT_DEVICE_CLASS_VIRTUAL = 0x40000000,
/* The input device is external (not built-in). */
INPUT_DEVICE_CLASS_EXTERNAL = 0x80000000,
};
extern uint32_t getAbsAxisUsage(int32_t axis, uint32_t deviceClasses);
class InputDevice{
public:
static constexpr int SOURCE_CLASS_MASK = 0x000000ff;
@ -126,6 +175,7 @@ public:
static constexpr int SOURCE_ANY = 0xffffff00;
typedef std::function<void(const InputEvent&)>EventListener;
protected:
int mDeviceClasses;
InputDeviceInfo devinfo;
EventListener listener;
class KeyLayoutMap*kmap;
@ -138,17 +188,18 @@ public:
int getSource()const;
int getVendor()const;
int getProduct()const;
int getClasses()const;
const std::string&getName()const;
};
class KeyDevice:public InputDevice{
private:
int lastDownKey;
int repeatCount;
int mLastDownKey;
int mRepeatCount;
protected:
int msckey;
KeyEvent key;
nsecs_t downtime;
KeyEvent mEvent;
nsecs_t mDownTime;
public:
KeyDevice(int fd);
virtual int putRawEvent(int type,int code,int value);
@ -156,20 +207,27 @@ public:
class TouchDevice:public InputDevice{
protected:
MotionEvent mt;
nsecs_t downtime;
int mPointId;
uint8_t buttonstats[16];
PointerCoords coords[32];
PointerProperties ptprops[32];
MotionEvent mEvent;
nsecs_t mDownTime;
int mPointSlot;
typedef struct{
PointerCoords coord;
PointerProperties prop;
}TouchPoint;
std::map<int, TouchPoint>mPointMAP;
//PointerCoords coords[32];
//PointerProperties ptprops[32];
void setAxisValue(int index,int axis,int value);
public:
TouchDevice(int fd);
virtual int putRawEvent(int type,int code,int value);
};
class MouseDevice:public TouchDevice{
protected:
uint8_t buttonstats[16];
public:
MouseDevice(int fd):TouchDevice(fd){}
MouseDevice(int fd);
virtual int putRawEvent(int type,int code,int value);
};
}//namespace

View File

@ -49,14 +49,14 @@ std::shared_ptr<InputDevice>InputEventSource::getdevice(int fd){
std::shared_ptr<InputDevice>dev;
auto itr=devices.find(fd);
if(itr==devices.end()){
InputDevice tmpdev(fd);
if(tmpdev.getSource()&(1<<EV_ABS)){
InputDevice tmpdev(fd);LOGD("device %d classes=%x",fd,tmpdev.getClasses());
if(tmpdev.getClasses()&(INPUT_DEVICE_CLASS_TOUCH|INPUT_DEVICE_CLASS_TOUCH_MT)){
dev.reset(new MouseDevice(fd));
dev->setEventConsumeListener([&](const InputEvent&e){
MotionEvent*mt=MotionEvent::obtain((MotionEvent&)e);
events.push(mt);
});
}else if(tmpdev.getSource()&(1<<EV_KEY)){
}else if(tmpdev.getClasses()&(INPUT_DEVICE_CLASS_KEYBOARD)){
dev.reset(new KeyDevice(fd));
dev->setEventConsumeListener([&](const InputEvent&e){
KeyEvent*key=KeyEvent::obtain((KeyEvent&)e);

View File

@ -540,11 +540,10 @@ void MotionEvent::initialize(
mDownTime = downTime;
mPointerProperties.clear();
for(int i=0;i<pointerCount;i++)
mPointerProperties.push_back(pointerProperties[i]);
mSampleEventTimes.clear();
mSamplePointerCoords.clear();
addSample(eventTime, pointerCoords);
for(int i=0;i<pointerCount;i++)
addSample(eventTime,pointerProperties[i], pointerCoords[i]);
}
MotionEvent::MotionEvent(const MotionEvent&other){
@ -660,11 +659,10 @@ bool MotionEvent::isButtonPressed(int button)const{
return (button!=0)&&((getButtonState() & button) == button);
}
void MotionEvent::addSample(nsecs_t eventTime, const PointerCoords* pointerCoords) {
void MotionEvent::addSample(nsecs_t eventTime,const PointerProperties&prop, const PointerCoords&coord) {
mSampleEventTimes.push_back(eventTime);
for(int i=0;i<getPointerCount();i++)
mSamplePointerCoords.push_back(pointerCoords[i]);
mPointerProperties.push_back(prop);
mSamplePointerCoords.push_back(coord);
}
const PointerCoords* MotionEvent::getRawPointerCoords(size_t pointerIndex) const {

View File

@ -75,10 +75,7 @@ struct PointerProperties {
void copyFrom(const PointerProperties& other);
};
enum {
INPUTSOURCE_KEY=1,
INPUTSOURCE_TOUCH=2,
};
class InputEvent{
protected:
int mDeviceId;
@ -454,7 +451,7 @@ public:
inline void getPointerProperties(size_t pointerIndex,PointerProperties*out) const {
*out=mPointerProperties[pointerIndex];
}
void addSample(nsecs_t eventTime, const PointerCoords* pointerCoords);
void addSample(nsecs_t eventTime,const PointerProperties&, const PointerCoords&);
void offsetLocation(float xOffset, float yOffset);
void setLocation(float x,float y);
void scale(float scaleFactor);

View File

@ -57,7 +57,7 @@ static void key_callback(aui_key_info*ki,void*d){
}
}
#define set_bit(array,bit) ((array)[(bit)/8] = (1<<((bit)%8)))
#define set_bit(array,bit) ((array)[(bit)/8] |= (1<<((bit)%8)))
INT InputGetDeviceInfo(int device,INPUTDEVICEINFO*devinfo){
switch(device){
case DEVICE_IR:
@ -71,17 +71,16 @@ INT InputGetDeviceInfo(int device,INPUTDEVICEINFO*devinfo){
strcpy(devinfo->name,"Mouse-Inject");
devinfo->vendor=INJECTDEV_PTR>>16;
devinfo->product=INJECTDEV_PTR&0xFF;
set_bit(devinfo->absBitMask,EV_ABS);
set_bit(devinfo->absBitMask,EV_SYN);
set_bit(devinfo->keyBitMask,EV_KEY);
set_bit(devinfo->keyBitMask,EV_SYN);
set_bit(devinfo->absBitMask,ABS_X);
set_bit(devinfo->absBitMask,ABS_Y);
set_bit(devinfo->keyBitMask,BTN_TOUCH);
break;
case INJECTDEV_KEY:
strcpy(devinfo->name,"Keyboard-Inject");
devinfo->vendor=INJECTDEV_KEY>>16;
devinfo->product=INJECTDEV_KEY&0xFF;
set_bit(devinfo->keyBitMask,EV_KEY);
set_bit(devinfo->keyBitMask,EV_SYN);
set_bit(devinfo->keyBitMask,BTN_MISC);
set_bit(devinfo->keyBitMask,KEY_OK);
break;
default:break;
}

View File

@ -76,7 +76,7 @@ INT InputInit(){
return 0;
}
#define set_bit(array,bit) ((array)[(bit)/8] = (1<<((bit)%8)))
#define set_bit(array,bit) ((array)[(bit)/8] |= (1<<((bit)%8)))
INT InputGetDeviceInfo(int device,INPUTDEVICEINFO*devinfo){
int rc1,rc2;
@ -99,18 +99,16 @@ INT InputGetDeviceInfo(int device,INPUTDEVICEINFO*devinfo){
strcpy(devinfo->name,"Mouse-Inject");
devinfo->vendor=INJECTDEV_PTR>>16;
devinfo->product=INJECTDEV_PTR&0xFF;
set_bit(devinfo->absBitMask,EV_ABS);
set_bit(devinfo->absBitMask,EV_SYN);
set_bit(devinfo->keyBitMask,EV_KEY);
set_bit(devinfo->keyBitMask,EV_SYN);
set_bit(devinfo->absBitMask,ABS_X);
set_bit(devinfo->absBitMask,ABS_Y);
set_bit(devinfo->keyBitMask,BTN_TOUCH);
break;
case INJECTDEV_KEY:
strcpy(devinfo->name,"qwerty");
devinfo->vendor=INJECTDEV_KEY>>16;
devinfo->product=INJECTDEV_KEY&0xFF;
set_bit(devinfo->keyBitMask,EV_KEY);
set_bit(devinfo->keyBitMask,EV_SYN);
set_bit(devinfo->keyBitMask,BTN_MISC);
set_bit(devinfo->keyBitMask,KEY_OK);
//devinfo->source=(1<<EV_ABS)|(1<<EV_KEY)|(1<<EV_SYN);
break;
default:break;

View File

@ -76,7 +76,7 @@ INT InputInit(){
return 0;
}
#define set_bit(array,bit) ((array)[(bit)/8] = (1<<((bit)%8)))
#define set_bit(array,bit) ((array)[(bit)/8] |= (1<<((bit)%8)))
INT InputGetDeviceInfo(int device,INPUTDEVICEINFO*devinfo){
int rc1,rc2;
@ -99,18 +99,18 @@ INT InputGetDeviceInfo(int device,INPUTDEVICEINFO*devinfo){
strcpy(devinfo->name,"Mouse-Inject");
devinfo->vendor=INJECTDEV_PTR>>16;
devinfo->product=INJECTDEV_PTR&0xFF;
set_bit(devinfo->absBitMask,EV_ABS);
set_bit(devinfo->absBitMask,EV_SYN);
set_bit(devinfo->keyBitMask,EV_KEY);
set_bit(devinfo->keyBitMask,EV_SYN);
//set_bit(devinfo->absBitMask,EV_ABS);
set_bit(devinfo->absBitMask,ABS_X);
set_bit(devinfo->absBitMask,ABS_Y);
set_bit(devinfo->keyBitMask,BTN_TOUCH);
//set_bit(devinfo->keyBitMask,EV_SYN);
break;
case INJECTDEV_KEY:
strcpy(devinfo->name,"qwerty");
devinfo->vendor=INJECTDEV_KEY>>16;
devinfo->product=INJECTDEV_KEY&0xFF;
set_bit(devinfo->keyBitMask,EV_KEY);
set_bit(devinfo->keyBitMask,EV_SYN);
set_bit(devinfo->keyBitMask,BTN_MISC);
set_bit(devinfo->keyBitMask,KEY_OK);
//devinfo->source=(1<<EV_ABS)|(1<<EV_KEY)|(1<<EV_SYN);
break;
default:break;