mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-02 12:17:46 +08:00
fix allwinner.inputdevice,modify samples app(add command args to app)
This commit is contained in:
parent
e8d5d6f0f0
commit
04409e8b92
@ -28,7 +28,7 @@ public:
|
||||
};
|
||||
|
||||
int main(int argc,const char*argv[]){
|
||||
App app;
|
||||
App app(argc,argv);
|
||||
Window*w=new Window(100,50,1200,620);
|
||||
MyAdapter*adapter=new MyAdapter(0);
|
||||
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
};
|
||||
|
||||
int main(int argc,const char*argv[]){
|
||||
App app;
|
||||
App app(argc,argv);
|
||||
Window*w=new Window(50,50,1200,640);
|
||||
MyAdapter*adapter=new MyAdapter();
|
||||
ListView*lv=(ListView*)&w->addView(new ListView(460,500));
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
};
|
||||
|
||||
int main(int argc,const char*argv[]){
|
||||
App app;
|
||||
App app(argc,argv);
|
||||
Window*w=new Window(50,50,1200,640);
|
||||
MyAdapter*adapter=new MyAdapter();
|
||||
ListView*lv=(ListView*)&w->addView(new ListView(460,500));
|
||||
|
@ -41,7 +41,7 @@ View*createHeader(){
|
||||
return ll;
|
||||
}
|
||||
int main(int argc,const char*argv[]){
|
||||
App app;
|
||||
App app(argc,argv);
|
||||
Window*w=new Window(50,50,1200,640);
|
||||
MyAdapter*adapter=new MyAdapter();
|
||||
ListView*lv=(ListView*)&w->addView(new ListView(460,500));
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <keylayoutmap.h>
|
||||
#include <app.h>
|
||||
#include <core/app.h>
|
||||
|
||||
using namespace std;
|
||||
namespace cdroid{
|
||||
@ -36,7 +36,7 @@ InputDevice::InputDevice(int fdev):listener(nullptr){
|
||||
di.name=info.name;
|
||||
di.product=info.product;
|
||||
di.vendor=info.vendor;
|
||||
devinfo.initialize(fdev,0,0,di,std::string(),0,0);
|
||||
mDeviceInfo.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.
|
||||
@ -152,16 +152,16 @@ int InputDevice::isValidEvent(int type,int code,int value){
|
||||
}
|
||||
|
||||
int InputDevice::getId()const{
|
||||
return devinfo.getId();
|
||||
return mDeviceInfo.getId();
|
||||
}
|
||||
int InputDevice::getSource()const{
|
||||
return devinfo.getSources();
|
||||
return mDeviceInfo.getSources();
|
||||
}
|
||||
int InputDevice::getVendor()const{
|
||||
return devinfo.getIdentifier().vendor;
|
||||
return mDeviceInfo.getIdentifier().vendor;
|
||||
}
|
||||
int InputDevice::getProduct()const{
|
||||
return devinfo.getIdentifier().product;
|
||||
return mDeviceInfo.getIdentifier().product;
|
||||
}
|
||||
|
||||
int InputDevice::getClasses()const{
|
||||
@ -169,7 +169,7 @@ int InputDevice::getClasses()const{
|
||||
}
|
||||
|
||||
const std::string&InputDevice::getName()const{
|
||||
return devinfo.getIdentifier().name;
|
||||
return mDeviceInfo.getIdentifier().name;
|
||||
}
|
||||
|
||||
KeyDevice::KeyDevice(int fd)
|
||||
@ -185,7 +185,7 @@ 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());
|
||||
LOGD("invalid event type %x source=%x",type,mDeviceInfo.getSources());
|
||||
return -1;
|
||||
}
|
||||
switch(type){
|
||||
@ -230,16 +230,25 @@ int TouchDevice::putRawEvent(int type,int code,int value){
|
||||
if(!isValidEvent(type,code,value))return -1;
|
||||
switch(type){
|
||||
case EV_KEY:
|
||||
LOGV("BTN %d %d:%d",BTN_TOUCH,code,value);
|
||||
switch(code){
|
||||
case BTN_TOUCH:
|
||||
case BTN_TOOL_FINGER:
|
||||
mEvent.setActionButton(code);
|
||||
case BTN_STYLUS:
|
||||
LOGV("BTN %d %d:%d====",BTN_TOUCH,code,value);
|
||||
mEvent.setActionButton(MotionEvent::BUTTON_PRIMARY);
|
||||
if(value)
|
||||
mEvent.setButtonState(MotionEvent::BUTTON_PRIMARY);
|
||||
else
|
||||
mEvent.setButtonState(mEvent.getButtonState()&(~MotionEvent::BUTTON_PRIMARY));
|
||||
break;
|
||||
case BTN_0:
|
||||
case BTN_STYLUS2:
|
||||
mEvent.setActionButton(MotionEvent::BUTTON_SECONDARY);
|
||||
if(value)
|
||||
mEvent.setButtonState(MotionEvent::BUTTON_SECONDARY);
|
||||
else
|
||||
mEvent.setButtonState(mEvent.getButtonState()&(~MotionEvent::BUTTON_SECONDARY));
|
||||
break;
|
||||
case BTN_TOOL_FINGER:break;
|
||||
}break;
|
||||
case EV_ABS:
|
||||
switch(code){
|
||||
@ -267,7 +276,7 @@ int TouchDevice::putRawEvent(int type,int code,int value){
|
||||
if(mLastButtonStates==0){
|
||||
action=mEvent.getButtonState()?MotionEvent::ACTION_DOWN:MotionEvent::ACTION_MOVE;
|
||||
}else{
|
||||
action=mLastButtonStates&&mEvent.getButtonState()==0?MotionEvent::ACTION_UP:MotionEvent::ACTION_MOVE;
|
||||
action=(mLastButtonStates&&(mEvent.getButtonState()==0))?MotionEvent::ACTION_UP:MotionEvent::ACTION_MOVE;
|
||||
}
|
||||
LOGV("action :%d buttonstate:%d/%d",action,mEvent.getActionButton(),mEvent.getButtonState());
|
||||
mEvent.initialize(getId(),getSource(),action,mEvent.getActionButton(),
|
||||
|
@ -176,7 +176,7 @@ public:
|
||||
typedef std::function<void(const InputEvent&)>EventListener;
|
||||
protected:
|
||||
int mDeviceClasses;
|
||||
InputDeviceInfo devinfo;
|
||||
InputDeviceInfo mDeviceInfo;
|
||||
EventListener listener;
|
||||
class KeyLayoutMap*kmap;
|
||||
virtual int isValidEvent(int type,int code,int value);
|
||||
|
@ -301,6 +301,13 @@ public:
|
||||
ACTION_BUTTON_PRESS = 11,
|
||||
ACTION_BUTTON_RELEASE = 12
|
||||
};
|
||||
/*Flag indicating the motion event intersected the top edge of the screen.*/
|
||||
enum{
|
||||
EDGE_TOP = 0x0001,
|
||||
EDGE_BOTTOM= 0x0002,
|
||||
EDGE_LEFT = 0x0004,
|
||||
EDGE_RIGHT = 0x0008
|
||||
};
|
||||
enum{
|
||||
AXIS_X = 0,
|
||||
AXIS_Y = 1,
|
||||
|
@ -69,7 +69,7 @@ INT InputInit(){
|
||||
dev.fds[dev.nfd++]=fd;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
return fd>0;
|
||||
},nullptr);
|
||||
free(namelist);
|
||||
LOGD(".....end nglInputInit maxfd=%d numfd=%d\r\n",dev.maxfd,nf);
|
||||
|
Loading…
Reference in New Issue
Block a user