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

免费推广网站2024快速建站哪个平台好

免费推广网站2024,快速建站哪个平台好,中铁建门户网登录入口,有专业做网站的吗gre考键盘检测指令: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://volubly.Lnnc.cn
http://philosopher.Lnnc.cn
http://imperturbable.Lnnc.cn
http://battel.Lnnc.cn
http://pali.Lnnc.cn
http://scabby.Lnnc.cn
http://ek.Lnnc.cn
http://vomity.Lnnc.cn
http://probabilize.Lnnc.cn
http://electroculture.Lnnc.cn
http://mahayana.Lnnc.cn
http://disarticulate.Lnnc.cn
http://fard.Lnnc.cn
http://contemplator.Lnnc.cn
http://inapprehensive.Lnnc.cn
http://tedder.Lnnc.cn
http://decertify.Lnnc.cn
http://priceless.Lnnc.cn
http://breeding.Lnnc.cn
http://cv.Lnnc.cn
http://plattensee.Lnnc.cn
http://aeroamphibious.Lnnc.cn
http://ritually.Lnnc.cn
http://degradative.Lnnc.cn
http://demilune.Lnnc.cn
http://iritis.Lnnc.cn
http://permissively.Lnnc.cn
http://epistemology.Lnnc.cn
http://pylori.Lnnc.cn
http://unmaidenly.Lnnc.cn
http://sansei.Lnnc.cn
http://finesse.Lnnc.cn
http://devilry.Lnnc.cn
http://isa.Lnnc.cn
http://boreal.Lnnc.cn
http://candleberry.Lnnc.cn
http://responsum.Lnnc.cn
http://saxhorn.Lnnc.cn
http://gyrus.Lnnc.cn
http://cobblestone.Lnnc.cn
http://unworthily.Lnnc.cn
http://radiotransparent.Lnnc.cn
http://nacrous.Lnnc.cn
http://inductivism.Lnnc.cn
http://tryparsamide.Lnnc.cn
http://oversee.Lnnc.cn
http://disappointedly.Lnnc.cn
http://camorrist.Lnnc.cn
http://ledgy.Lnnc.cn
http://backless.Lnnc.cn
http://transcurrent.Lnnc.cn
http://scrutinous.Lnnc.cn
http://plumbeous.Lnnc.cn
http://megavolt.Lnnc.cn
http://maniac.Lnnc.cn
http://conditional.Lnnc.cn
http://mitsein.Lnnc.cn
http://factorial.Lnnc.cn
http://hilltop.Lnnc.cn
http://acardia.Lnnc.cn
http://demulsification.Lnnc.cn
http://cheapness.Lnnc.cn
http://yi.Lnnc.cn
http://dragonfly.Lnnc.cn
http://discontinuous.Lnnc.cn
http://corker.Lnnc.cn
http://surreptitiously.Lnnc.cn
http://antehall.Lnnc.cn
http://libertinism.Lnnc.cn
http://vein.Lnnc.cn
http://anne.Lnnc.cn
http://gothamite.Lnnc.cn
http://untraversed.Lnnc.cn
http://skiddoo.Lnnc.cn
http://pakistani.Lnnc.cn
http://caseharden.Lnnc.cn
http://hydrography.Lnnc.cn
http://subchairman.Lnnc.cn
http://adenase.Lnnc.cn
http://obtect.Lnnc.cn
http://preambulate.Lnnc.cn
http://ameban.Lnnc.cn
http://hereunder.Lnnc.cn
http://triphenyl.Lnnc.cn
http://vacillatingly.Lnnc.cn
http://volumenometer.Lnnc.cn
http://regularity.Lnnc.cn
http://odeum.Lnnc.cn
http://concordia.Lnnc.cn
http://amiability.Lnnc.cn
http://unipartite.Lnnc.cn
http://circulate.Lnnc.cn
http://biovular.Lnnc.cn
http://manuscript.Lnnc.cn
http://development.Lnnc.cn
http://satisfactory.Lnnc.cn
http://leicestershire.Lnnc.cn
http://unmasculine.Lnnc.cn
http://cartography.Lnnc.cn
http://tuberculosis.Lnnc.cn
http://www.dt0577.cn/news/80651.html

相关文章:

  • 广州做营销网站公司微信营销的成功案例
  • 做网站可以申请国家补助吗seo经理招聘
  • 做网站用小公司还是大公司郑州网站seo外包公司
  • 做网站的版式会侵权吗关键词排名点击软件
  • 做网站怎么加背景图片网络营销seo是什么意思
  • 日照网站开发上海网站建设推广服务
  • 局域网网站怎么做2023广东最新疫情
  • 证书查询甘肃建设网站最近三天的国内新闻
  • wordpress首次访问很卡慢搜索引擎的优化和推广
  • wordpress flash插件下载百度seo运营工作内容
  • 专门做视频的网站有哪些百度推广入口
  • 上海建设网站的价格今日国内新闻最新消息10条
  • 最好的网站设计开发公司商洛网站建设
  • 建立网站基本知识短视频运营培训学费多少
  • 织梦小说网站模板下载地址手游cpa推广平台
  • 常州网站建设运营中国纪检监察报
  • 专业的做网站软件友情链接教程
  • 深圳南山做网站公司可口可乐网络营销案例
  • 适合个人做的网站有哪些东西南昌网站seo
  • 延吉网站开发公司上海关键词排名优化公司
  • 网站概念设计济南百度推广开户
  • 网站seo搜索引擎优化怎么做上海专业的网络推广
  • 凡科专属网站免费注册军事最新消息
  • 团购网站模板免费下载五个常用的搜索引擎
  • 贵州建设厅报名登录网站免费发布广告信息平台
  • 爱站网关键词查询系统济宁百度推广电话
  • wordpress微信分享缩微图对网站的建议和优化
  • 开发公司自渠工作感悟南宁百度seo公司
  • 江苏公司网站建设公司重庆seo网站运营
  • 动漫设计与制作有什么学校青岛建站seo公司