remove nx5 includes and libs,modify inputdevice

This commit is contained in:
侯歌 2022-01-13 10:41:18 +08:00
parent 5436ead5aa
commit e0e87d2c75
9 changed files with 79 additions and 55 deletions

View File

@ -29,16 +29,26 @@ InputDevice::InputDevice(int fdev):listener(nullptr){
LOGD("device %d source=%x vid/pid=%x/%x name=%s",fdev,info.source,info.vendor,info.product,info.name);
}
int InputDevice::isvalid_event(const INPUTEVENT*e){
return ((1<<e->type)&getSource())==(1<<e->type);
int InputDevice::isValidEvent(int type,int code,int value){
return ((1<<type)&getSource())==(1<<type);
}
int InputDevice::getId()const{return devinfo.getId();}
int InputDevice::getSource()const{return devinfo.getSources();}
int InputDevice::getVendor()const{return devinfo.getIdentifier().vendor;}
int InputDevice::getProduct()const{return devinfo.getIdentifier().product;}
int InputDevice::getId()const{
return devinfo.getId();
}
int InputDevice::getSource()const{
return devinfo.getSources();
}
int InputDevice::getVendor()const{
return devinfo.getIdentifier().vendor;
}
int InputDevice::getProduct()const{
return devinfo.getIdentifier().product;
}
const std::string&InputDevice::getName()const{return devinfo.getIdentifier().name;}
const std::string&InputDevice::getName()const{
return devinfo.getIdentifier().name;
}
KeyDevice::KeyDevice(int fd)
:InputDevice(fd){
@ -49,31 +59,31 @@ KeyDevice::KeyDevice(int fd)
KeyLayoutMap::load(fname,kmap);
}
int KeyDevice::putrawdata(const INPUTEVENT*e){
int flags=0;
int keycode=e->code;
if(!isvalid_event(e)){
LOGD("invalid event type %x source=%x",e->type,devinfo.getSources());
int KeyDevice::putRawEvent(int type,int code,int value){
int flags =0;
int keycode=code;
if(!isValidEvent(type,code,value)){
LOGD("invalid event type %x source=%x",type,devinfo.getSources());
return -1;
}
switch(e->type){
switch(type){
case EV_KEY:
if(kmap)kmap->mapKey(e->code/*scancode*/,0,&keycode/*keycode*/,(uint32_t*)&flags);
lastDownKey=(e->value?keycode:-1);//key down
if(kmap)kmap->mapKey(code/*scancode*/,0,&keycode/*keycode*/,(uint32_t*)&flags);
lastDownKey=(value?keycode:-1);//key down
if(lastDownKey==keycode)
repeatCount+=(e->value==0);
repeatCount+=(value==0);
else
repeatCount=0;
key.initialize(getId(),getSource(),(e->value?KeyEvent::ACTION_DOWN:KeyEvent::ACTION_UP)/*action*/,flags,
keycode,e->code/*scancode*/,0/*metaState*/,repeatCount, downtime,SystemClock::uptimeNanos()/*eventtime*/);
LOGV("fd[%d] keycode:%08x->%04x[%s] action=%d flags=%d",getId(),e->code,keycode, key.getLabel(),e->value,flags);
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);
break;
case EV_SYN:
LOGV("fd[%d].SYN value=%d code=%d",getId(),e->value,e->code);
LOGV("fd[%d].SYN value=%d code=%d",getId(),value,code);
break;
default:LOGD("event type %x source=%x",e->type,getSource());break;
default:LOGD("event type %x source=%x",type,getSource());break;
}
return 0;
}
@ -84,29 +94,43 @@ TouchDevice::TouchDevice(int fd):InputDevice(fd){
memset(buttonstats,0,sizeof(buttonstats));
}
int TouchDevice::putrawdata(const INPUTEVENT*e){
if(!isvalid_event(e))return -1;
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;
case ABS_MT_TRACKING_ID:
case ABS_MT_TOUCH_MAJOR:
case ABS_MT_POSITION_X:
case ABS_MT_POSITION_Y:break;
case ABS_MT_WIDTH_MINOR:
case ABS_MT_PRESSURE:
case ABS_MT_DISTANCE:
case ABS_MT_TOOL_TYPE:
case ABS_MT_ORIENTATION:break;
}
}
return 0;
}
int MouseDevice::putrawdata(const INPUTEVENT*e){
int MouseDevice::putRawEvent(int type,int code,int value){
BYTE btnmap[]={ MotionEvent::BUTTON_PRIMARY ,/*BTN_LEFT*/
MotionEvent::BUTTON_SECONDARY,/*BTN_RIGHT*/
MotionEvent::BUTTON_TERTIARY/*BTN_MIDDLE*/ ,0,0};
int act_btn=e->value-BTN_MOUSE;
if(!isvalid_event(e))return -1;
switch(e->type){
int act_btn=value-BTN_MOUSE;
if(!isValidEvent(type,code,value))return -1;
switch(type){
case EV_KEY:
downtime=SystemClock::uptimeNanos();
buttonstats[act_btn]=e->code;
LOGV("Key %x /%d btn=%d %lld",e->value,e->code,btnmap[act_btn],downtime);
mt.setAction(e->code?MotionEvent::ACTION_DOWN:MotionEvent::ACTION_UP);
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(e->code==0)mt.setActionButton(0);
if(code==0)mt.setActionButton(0);
break;
case EV_ABS:
coords->setAxisValue(e->code,e->value);
coords->setAxisValue(code,value);
mt.setAction(MotionEvent::ACTION_MOVE);
break;
case EV_SYN:

View File

@ -1,6 +1,6 @@
#ifndef __INPUT_DEVICE_H__
#define __INPUT_DEVICE_H__
#include <uievents.h>
#include <core/uievents.h>
#include <functional>
#include <map>
#include <memory>
@ -49,9 +49,8 @@ public:
float resolution;
};
void initialize(int32_t id, int32_t generation, int32_t controllerNumber,
const InputDeviceIdentifier& identifier, const std::string& alias, bool isExternal,
bool hasMic);
void initialize(int32_t id, int32_t generation, int32_t controllerNumber,
const InputDeviceIdentifier& identifier,const std::string& alias, bool isExternal,bool hasMic);
inline int32_t getId() const { return mId; }
inline int32_t getControllerNumber() const { return mControllerNumber; }
@ -130,10 +129,10 @@ protected:
InputDeviceInfo devinfo;
EventListener listener;
class KeyLayoutMap*kmap;
int isvalid_event(const INPUTEVENT*e);
virtual int isValidEvent(int type,int code,int value);
public:
InputDevice(int fdev);
virtual int putrawdata(const INPUTEVENT*){return 0;}//PENDING need more rawevent OK,wecan getevent now
virtual int putRawEvent(int type,int code,int value){return 0;}//PENDING need more rawevent OK,wecan getevent now
void setEventConsumeListener(EventListener ls){listener=ls;}
int getId()const;
int getSource()const;
@ -152,25 +151,26 @@ protected:
nsecs_t downtime;
public:
KeyDevice(int fd);
virtual int putrawdata(const INPUTEVENT*);
virtual int putRawEvent(int type,int code,int value);
};
class TouchDevice:public InputDevice{
protected:
MotionEvent mt;
nsecs_t downtime;
BYTE buttonstats[16];
int mPointId;
uint8_t buttonstats[16];
PointerCoords coords[32];
PointerProperties ptprops[32];
public:
TouchDevice(int fd);
virtual int putrawdata(const INPUTEVENT*);
virtual int putRawEvent(int type,int code,int value);
};
class MouseDevice:public TouchDevice{
public:
MouseDevice(int fd):TouchDevice(fd){}
virtual int putrawdata(const INPUTEVENT*);
virtual int putRawEvent(int type,int code,int value);
};
}//namespace
#endif

View File

@ -107,7 +107,7 @@ int InputEventSource::process(const INPUTEVENT*inevents,int count){
LOGD("%d,%d,%d device=%d ",e->type,e->code,e->value,e->device);
continue;
}
dev->putrawdata(e);
dev->putRawEvent(e->type,e->code,e->value);
}
return 0;
}

View File

@ -4816,7 +4816,7 @@ bool View::performContextClick() {
}
bool View::performButtonActionOnTouchDown(MotionEvent& event) {
if (//event.isFromSource(InputDevice::SOURCE_MOUSE) &&
if (event.isFromSource(InputDevice::SOURCE_MOUSE) &&
(event.getButtonState() & MotionEvent::BUTTON_SECONDARY) != 0) {
//showContextMenu(event.getX(), event.getY());
mPrivateFlags |= PFLAG_CANCEL_NEXT_UP_EVENT;
@ -4896,7 +4896,7 @@ bool View::handleScrollBarDragging(MotionEvent& event) {
int action = event.getAction();
if ((mScrollCache->mScrollBarDraggingState == ScrollabilityCache::NOT_DRAGGING
&& action != MotionEvent::ACTION_DOWN)
//|| !event.isFromSource(InputDevice::SOURCE_MOUSE)
|| !event.isFromSource(InputDevice::SOURCE_MOUSE)
|| !event.isButtonPressed(MotionEvent::BUTTON_PRIMARY)) {
mScrollCache->mScrollBarDraggingState = ScrollabilityCache::NOT_DRAGGING;
return false;

View File

@ -2,6 +2,7 @@
#define __CDROID_VIEW_H__
#include <core/eventcodes.h>
#include <core/uievents.h>
#include <core/inputdevice.h>
#include <core/canvas.h>
#include <core/insets.h>
#include <core/viewconfiguration.h>

View File

@ -2214,7 +2214,7 @@ void ViewGroup::requestDisallowInterceptTouchEvent(bool disallowIntercept){
}
bool ViewGroup::onInterceptTouchEvent(MotionEvent& ev){
if( false//ev.isFromSource(InputDevice::SOURCE_MOUSE)
if( ev.isFromSource(InputDevice::SOURCE_MOUSE)
&& (ev.getAction() == MotionEvent::ACTION_DOWN)
&& ev.isButtonPressed(MotionEvent::BUTTON_PRIMARY)
&& isOnScrollbarThumb(ev.getX(), ev.getY()) )

View File

@ -10,11 +10,10 @@
#include <rfb/keysym.h>
#include <rfb/rfbproto.h>
#define USE_DOUBLE_BUFFER 1
#define USE_DOUBLE_BUFFER 0/*do not open doublebuffer,it is not necessary for the gui core */
#ifdef HAVE_FY_TDE2
#ifdef HAVE_FY_TDE2 /*for small screen ,it is no necessary ,memcpy is faster for smallscreen*/
#include <mpi_tde.h>
//#include <mpi_sys.h>
#include <vd/VDecApi.h>
#include <vd/VoApi.h>
#endif

View File

@ -56,16 +56,16 @@ static int test_bit(int nr, uint32_t * addr){
}
static int getfeatures(int fd){
BYTE bitmask[EV_MAX+1];
BYTE bitmask[EV_CNT];
static char features[256];
const char*evs[]={"SYN ","KEY ","REL ","ABS ","MSC ","SW ","LED ","SND ","REP ","FF ","PWR ","FFS ","MAX"};
int rc;
int source=0;
memset(bitmask,0,EV_MAX+1);
memset(bitmask,0,EV_CNT);
rc=ioctl(fd, EVIOCGBIT(0, EV_MAX),bitmask);
features[0]=0;
LOGD_IF(rc<=0,"EVIOCGBIT %d",rc);
for(int i=0;i<0x17/*EV_MAX*/;i++){
for(int i=0;i<EV_CNT;i++){
if(test_bit(i,(unsigned int*)bitmask)&&(i<=5||i>0x10)){
strcat(features,evs[(i<=5?i:i-10)]);
source|=(1<<i);

View File

@ -56,16 +56,16 @@ static int test_bit(int nr, uint32_t * addr){
}
static int getfeatures(int fd){
BYTE bitmask[EV_MAX+1];
BYTE bitmask[EV_CNT];
static char features[256];
const char*evs[]={"SYN ","KEY ","REL ","ABS ","MSC ","SW ","LED ","SND ","REP ","FF ","PWR ","FFS ","MAX"};
int rc;
int source=0;
memset(bitmask,0,EV_MAX+1);
memset(bitmask,0,EV_CNT);
rc=ioctl(fd, EVIOCGBIT(0, EV_MAX),bitmask);
features[0]=0;
LOGD_IF(rc<=0,"EVIOCGBIT %d",rc);
for(int i=0;i<0x17/*EV_MAX*/;i++){
for(int i=0;i<EV_CNT;i++){
if(test_bit(i,(unsigned int*)bitmask)&&(i<=5||i>0x10)){
strcat(features,evs[(i<=5?i:i-10)]);
source|=(1<<i);