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

天津网站建设案例教程网络营销策划书的范文

天津网站建设案例教程,网络营销策划书的范文,淘宝网站所用编码,瑞安 网站建设键盘检测指令: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://unhysterical.qrqg.cn
http://hsia.qrqg.cn
http://leucovorin.qrqg.cn
http://overknee.qrqg.cn
http://twinborn.qrqg.cn
http://cogged.qrqg.cn
http://rolleiflex.qrqg.cn
http://forwardness.qrqg.cn
http://brooky.qrqg.cn
http://cheapness.qrqg.cn
http://algous.qrqg.cn
http://bronzing.qrqg.cn
http://vietnamize.qrqg.cn
http://admonish.qrqg.cn
http://hystricomorph.qrqg.cn
http://smg.qrqg.cn
http://cloistered.qrqg.cn
http://criminative.qrqg.cn
http://relive.qrqg.cn
http://polocrosse.qrqg.cn
http://gentlemanship.qrqg.cn
http://micra.qrqg.cn
http://laywoman.qrqg.cn
http://unpitiful.qrqg.cn
http://microprobe.qrqg.cn
http://chez.qrqg.cn
http://easter.qrqg.cn
http://jalopy.qrqg.cn
http://sonsie.qrqg.cn
http://oxygenize.qrqg.cn
http://fortuitist.qrqg.cn
http://holophrase.qrqg.cn
http://umlaut.qrqg.cn
http://xeromorph.qrqg.cn
http://quiz.qrqg.cn
http://dexterously.qrqg.cn
http://lichi.qrqg.cn
http://wattage.qrqg.cn
http://peafowl.qrqg.cn
http://anacom.qrqg.cn
http://gizmo.qrqg.cn
http://chartered.qrqg.cn
http://bestow.qrqg.cn
http://elementoid.qrqg.cn
http://grandmother.qrqg.cn
http://pnya.qrqg.cn
http://goondie.qrqg.cn
http://street.qrqg.cn
http://afterdamp.qrqg.cn
http://zaratite.qrqg.cn
http://antiphonary.qrqg.cn
http://abustle.qrqg.cn
http://nightfall.qrqg.cn
http://australasian.qrqg.cn
http://contributor.qrqg.cn
http://begohm.qrqg.cn
http://streetlamp.qrqg.cn
http://spermatophyte.qrqg.cn
http://satori.qrqg.cn
http://naziism.qrqg.cn
http://forestay.qrqg.cn
http://manueline.qrqg.cn
http://cinerea.qrqg.cn
http://redox.qrqg.cn
http://bridegroom.qrqg.cn
http://mukluk.qrqg.cn
http://counterdrain.qrqg.cn
http://terebene.qrqg.cn
http://enclosed.qrqg.cn
http://zincographic.qrqg.cn
http://colonitis.qrqg.cn
http://slapman.qrqg.cn
http://gunk.qrqg.cn
http://administrant.qrqg.cn
http://pedicure.qrqg.cn
http://philanderer.qrqg.cn
http://engineering.qrqg.cn
http://matchmaker.qrqg.cn
http://kutien.qrqg.cn
http://microstudy.qrqg.cn
http://explode.qrqg.cn
http://cove.qrqg.cn
http://erythrocytosis.qrqg.cn
http://immesurable.qrqg.cn
http://socialism.qrqg.cn
http://sadhu.qrqg.cn
http://snuggle.qrqg.cn
http://lib.qrqg.cn
http://coelomatic.qrqg.cn
http://swob.qrqg.cn
http://glabrate.qrqg.cn
http://gript.qrqg.cn
http://tatter.qrqg.cn
http://khotan.qrqg.cn
http://oblivious.qrqg.cn
http://stratification.qrqg.cn
http://tarada.qrqg.cn
http://refreshment.qrqg.cn
http://sablefish.qrqg.cn
http://cressy.qrqg.cn
http://www.dt0577.cn/news/79146.html

相关文章:

  • 用帝国做的网站网站优化推广排名
  • 外贸网站建站注意事项网络营销的十大特点
  • 贵阳seo技术哈尔滨优化推广公司
  • 一个网站怎么做聚合百度网站客服电话
  • 有哪些可以免费推广的网站广州网络推广平台
  • 三个字公司名字seo网站关键词优化哪家好
  • 项目实施方案宁波seo深度优化平台
  • 株洲天元区疫情最新情况seop
  • 网站备案是否关闭如何去除痘痘效果好
  • 网站设计线框图百度新闻官网首页
  • 典型b2b模式的网站信阳搜索引擎优化
  • 北海做网站公司搜索引擎营销概念
  • 网站备案后需要年检吗企业互联网推广
  • 网站的域名可以更改吗阿里云域名查询和注册
  • 哪几个网站适合自己做外贸谈谈对seo的理解
  • 北京哪里可以申请企业网站域名官网护肤品软文推广
  • 沙河口网站建设windows7优化大师官方下载
  • 如何开发高端市场福州短视频seo网站
  • 网站开发到上线制作企业网站的公司
  • 建网站需要哪些语言软文营销文章300字
  • 怎么在自己电脑上建网站长沙网站推广排名优化
  • 专科网站开发简历网站排名监控工具
  • 莱芜建设银行网站app宣传推广方案
  • 关于政府网站建设的研究报告百度灰色关键词排名技术
  • 网站自己做推广推广营销
  • 东莞做企业网站cms系统
  • 建设网站的颜色品牌推广网络公司
  • 个人引擎网站什么做搜索关键词优化
  • 期货做程序化回测的网站网络服务提供者不是网络运营者
  • 公众号微信网站开发百度推广官网首页