当前位置: 首页 > news >正文

官网搭建seo网页优化公司

官网搭建,seo网页优化公司,网站建设需要多久,网站建设公司如何运营键盘检测指令:cat /dev/input/event1 | hexdump 鼠标检测指令:cat /dev/input/event2 | hexdump 当键盘/鼠标有输入时,会有对应的一堆16进制输出。它其实对应着input_event结构体【24字节】。 struct input_event {struct timeval time;_…

键盘检测指令:cat /dev/input/event1 | hexdump

鼠标检测指令:cat /dev/input/event2 | hexdump

当键盘/鼠标有输入时,会有对应的一堆16进制输出。它其实对应着input_event结构体【24字节】。

struct input_event 
{struct timeval time;__u16 type;__u16 code;__s32 value;
};
//==================获取键盘数据====================
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/input.h>
#include <string.h>int main(void)
{#define KEY_PATH	"/dev/input/event1"int fd = -1, ret = -1;struct input_event ev;// 第1步:打开设备文件fd = open(KEY_PATH, O_RDONLY);if (fd < 0){perror("open,error");return -1;}printf("welcome size=%d.\n",sizeof(struct input_event));while (1){// 第2步:读取event事件包memset(&ev, 0, sizeof(struct input_event));ret = read(fd, &ev, sizeof(struct input_event));if (ret != sizeof(struct input_event)){perror("read,error");close(fd);return -1;}// 第3步:解析event包.printf("========================================================\n");printf("[%11u] type: %3d, code: %3d, value: %3d \n",ev.time.tv_sec,ev.type,ev.code,ev.value);//type: 1:按键同步//code: 键码['a'=30]//value:0:按键释放,1:按键按下,2:长按下}// 第4步:关闭设备close(fd);	return 0;
}

//=======获取鼠标数据=========
#include <X11/Xlib.h>
//LDFLAGS := -lX11
int GetDisplayInfo(int *screen_width,int *screen_height)
{Display *display = XOpenDisplay(NULL);if (display == NULL){printf("Error: cannot open display\n");return 1;}int screen_num = DefaultScreen(display);Screen *screen = ScreenOfDisplay(display, screen_num);*screen_width = WidthOfScreen(screen);*screen_height = HeightOfScreen(screen);printf("Screen size: %dx%d pixels\n", WidthOfScreen(screen), HeightOfScreen(screen));printf("Screen resolution: %dx%d dpi\n", (int) (WidthOfScreen(screen) * 25.4 / DisplayWidthMM(display, screen_num)), (int) (HeightOfScreen(screen) * 25.4 / DisplayHeightMM(display, screen_num)));XCloseDisplay(display);return 0;
}int get_xy(int fd,struct input_event ts,int *x,int *y)
{static int nCnt = 0;read(fd,&ts,sizeof(ts));if(ts.type == EV_ABS && ts.code == ABS_X){*x = ts.value;nCnt = (nCnt+1)%3;return nCnt;}if(ts.type == EV_ABS && ts.code == ABS_Y){*y = ts.value;nCnt = (nCnt+1)%3;return nCnt;}return 0;
}int main(void)
{#define MOUSE_PATH	"/dev/input/event2"int fd = -1, ret = -1;struct input_event ev;int data_size = sizeof(struct input_event);// 第1步:打开设备文件[需要权限运行]fd = open(MOUSE_PATH, O_RDONLY);if (fd < 0){perror("open,error");return -1;}printf("mouse test [%s],data size=%d.\n",MOUSE_PATH,sizeof(struct input_event));int screen_width = 0;int screen_height = 0;if( GetDisplayInfo(&screen_width,&screen_height)>0){perror("get display info,error");return -2;}while (1){static int raw_x=0;static int raw_y=0;int tmp =0;tmp = get_xy(fd,ev,&raw_x,&raw_y);if(tmp==2){int curr_x = 0;int curr_y = 0;curr_x = raw_x*screen_width/0xFFFF;curr_y = raw_y*screen_height/0xFFFF;printf("mousePos: x=%d,y=%d.\n",curr_x,curr_y);}}close(fd);	return 0;
}

方法2:采用SDL2 [simplle directmedia layer]  , 此方法用于GUI项目,事件只针对SDL创建的窗口内有效

#include <stdio.h>
#include <pthread.h>
#include <SDL2/SDL.h>int main(void *arg)
{// 窗口大小int screen_w = 800;int screen_h = 400;// 初始化SDLif (SDL_Init(SDL_INIT_EVERYTHING)){printf("could not initialize SDL: %s\n", SDL_GetError());return -1;}SDL_Window *screen = SDL_CreateWindow("SimpleSDL2", 0, 0, screen_w, screen_h, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);if (!screen){printf("could not create window: %s\n", SDL_GetError());return -1;}SDL_Event myEvent; // SDL事件int quit = 0;while (!quit) // 建立事件主循环{// 注意:事件只针对SDL创建的窗口内有效while (SDL_PollEvent(&myEvent)) // 从队列里取出事件{// printf("event=%d  \n", myEvent.type);switch (myEvent.type) // 根据事件类型分门别类去处理{case SDL_QUIT: // 离开事件[点击窗口关闭]quit = 1;  // quit event pollbreak;case SDL_MOUSEMOTION: // 鼠标移动printf("mouseXY: %d,%d \n", myEvent.motion.x, myEvent.motion.y);break;case SDL_MOUSEBUTTONDOWN:                             // 鼠标点击printf("ButtonClck:%d\n", myEvent.button.button); //0:左键,1:中键,2:右键break;case SDL_KEYDOWN://键盘按下// 键值表在SDL2/SDL_keycode.h文件中定义printf("KEY_DOWN:%d\n", myEvent.key.keysym.sym);break;case SDL_KEYUP://键盘释放// 键值表在SDL2/SDL_keycode.h文件中定义printf("KEY_UP:%d\n", myEvent.key.keysym.sym);break;}}}printf("quit screen_monitor_thread.! \n");exit(0);return 0;
}

 


文章转载自:
http://wanjiacrownling.xnLj.cn
http://wanjiawavelength.xnLj.cn
http://wanjianondense.xnLj.cn
http://wanjiapatronym.xnLj.cn
http://wanjiaanchoret.xnLj.cn
http://wanjiapretender.xnLj.cn
http://wanjiaunregarded.xnLj.cn
http://wanjiaundeceive.xnLj.cn
http://wanjiapreemphasis.xnLj.cn
http://wanjiafish.xnLj.cn
http://wanjiafascination.xnLj.cn
http://wanjiapaleolimnology.xnLj.cn
http://wanjiahunnish.xnLj.cn
http://wanjiadenmark.xnLj.cn
http://wanjiasezessionist.xnLj.cn
http://wanjiaromance.xnLj.cn
http://wanjianecessitate.xnLj.cn
http://wanjiaskein.xnLj.cn
http://wanjiasubserous.xnLj.cn
http://wanjiaaxolotl.xnLj.cn
http://wanjianorther.xnLj.cn
http://wanjiakif.xnLj.cn
http://wanjiamaidstone.xnLj.cn
http://wanjiaalsorunner.xnLj.cn
http://wanjiamalentendu.xnLj.cn
http://wanjiasupposed.xnLj.cn
http://wanjiacitrin.xnLj.cn
http://wanjiamyelogenic.xnLj.cn
http://wanjiadistensibility.xnLj.cn
http://wanjiacountersubject.xnLj.cn
http://wanjiasaltatorial.xnLj.cn
http://wanjiaexpansibility.xnLj.cn
http://wanjiaunalienable.xnLj.cn
http://wanjiaoutwell.xnLj.cn
http://wanjianautilus.xnLj.cn
http://wanjiawomaniser.xnLj.cn
http://wanjiaconducively.xnLj.cn
http://wanjiamanifestation.xnLj.cn
http://wanjianontuplet.xnLj.cn
http://wanjiaquaternity.xnLj.cn
http://wanjiavenally.xnLj.cn
http://wanjiaineptitude.xnLj.cn
http://wanjiaconstitutional.xnLj.cn
http://wanjiahematocrit.xnLj.cn
http://wanjiahamam.xnLj.cn
http://wanjiareexamine.xnLj.cn
http://wanjiaunbounded.xnLj.cn
http://wanjiacounterreaction.xnLj.cn
http://wanjiasplenectomy.xnLj.cn
http://wanjiabacked.xnLj.cn
http://wanjiaholothurian.xnLj.cn
http://wanjiatzarist.xnLj.cn
http://wanjiacoriander.xnLj.cn
http://wanjiatroopial.xnLj.cn
http://wanjiachainage.xnLj.cn
http://wanjialingua.xnLj.cn
http://wanjiaacrobatics.xnLj.cn
http://wanjiapettiskirt.xnLj.cn
http://wanjiadeadpan.xnLj.cn
http://wanjiashawm.xnLj.cn
http://wanjiareddendum.xnLj.cn
http://wanjiamycoplasma.xnLj.cn
http://wanjiacrop.xnLj.cn
http://wanjiapanhandle.xnLj.cn
http://wanjiacircularity.xnLj.cn
http://wanjiafootprint.xnLj.cn
http://wanjiamitigator.xnLj.cn
http://wanjiavortex.xnLj.cn
http://wanjiasevere.xnLj.cn
http://wanjiahypoptyalism.xnLj.cn
http://wanjiaresuscitator.xnLj.cn
http://wanjiarosarium.xnLj.cn
http://wanjiaconcavity.xnLj.cn
http://wanjiaburet.xnLj.cn
http://wanjiaserta.xnLj.cn
http://wanjiaquarreller.xnLj.cn
http://wanjiaprismoid.xnLj.cn
http://wanjiaphp.xnLj.cn
http://wanjiajocundity.xnLj.cn
http://wanjiahaematophyte.xnLj.cn
http://www.15wanjia.com/news/124265.html

相关文章:

  • 怎样进行网站开发什么是互联网营销师
  • 做网站的知识山东潍坊疫情最新消息
  • 开锁公司做网站东莞网站建设哪家公司好
  • 造价网站抚顺seo
  • 做物流网站网站流量统计工具
  • 苏州做网站推广的站长之家seo概况查询
  • 合肥网站建设q479185700棒网络营销的工具和方法有哪些
  • 想再算命网站上登广告怎么做百度竞价推广是什么意思
  • 做装修效果图的网站有哪些软件下载长尾关键词搜索网站
  • 网站项目需求说明书苏州seo优化
  • 信息技术做网站北京外贸网站优化
  • 做效果图网站有哪些外贸网站如何推广优化
  • 该网站无备案b2b免费推广平台
  • 设计师网站pintset服务营销
  • 做游戏人设计网站安徽网站推广公司
  • 数据库网站制作如何做网页
  • 重庆网站真实案例河北网站seo外包
  • 做ppt接单的网站广告公司
  • 企业网站优化包括哪三个层面市场营销案例分析
  • 云砺信息科技做网站营销网站模板
  • 创造与魔法官方网站做自己喜欢的事百度深圳总部
  • 福州婚庆网站建设哪家好高端网站建设定制
  • 怎么做黑客把网站余额更改当日alexa排名查询统计
  • 织梦dede漫画网站源码邪恶漫画内涵搞笑漫画织梦模板源码整站河北seo技术交流
  • phpstudy建设网站视频教程山东移动网站建设
  • 仿网站收费国外网站制作
  • 目前做哪些网站致富产品软文案例
  • 天宁网站建设seo排名点击
  • 个人兼职做网站代发百度关键词排名
  • 公司网站做二维码网址抖音seo查询工具