Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37403017
en ru br
Репозитории ALT

Группа :: Система/Настройка/Оборудование
Пакет: evhz

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

pax_global_header00006660000000000000000000000064120653745240014522gustar00rootroot0000000000000052 comment=21e95ccf229f8798213ce7105bbf97557bbe45d7
evhz-2012/000075500000000000000000000000001206537452400124225ustar00rootroot00000000000000evhz-2012/.gear/000075500000000000000000000000001206537452400134165ustar00rootroot00000000000000evhz-2012/.gear/rules000064400000000000000000000000071206537452400144700ustar00rootroot00000000000000tar: .
evhz-2012/evhz.c000064400000000000000000000043121206537452400135420ustar00rootroot00000000000000/*****************************************************
Copyright (c) 2012, Vitaly Lipatov <lav@etersoft.ru>
Public domain
******************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <linux/input.h>
#include <fcntl.h>
#include <signal.h>

#define EVENTS 10
#define HZ_LIST 64

typedef struct event_s {
int fd;
int hz[HZ_LIST];
int count;
double prvtime;
} event_t;

int quit = 0;

void sigint() {
signal(SIGINT, sigint);
quit = 1;
}

void calc_event(event_t *evi, int evnum)
{
int bytes;
struct input_event event;
double time;
int hz;
int j;
int avghz;

bytes = read(evi->fd, &event, sizeof(event));

if(bytes != sizeof(event))
return;

if(event.type != EV_REL)
return;

time = event.time.tv_sec * 1000 + event.time.tv_usec / 1000;
hz = 1000 / (time - evi->prvtime);
evi->prvtime = time;

if(hz <= 0)
return;

evi->count++;
evi->hz[evi->count & (HZ_LIST - 1)] = hz;

avghz = 0;
for(j = 0; j < HZ_LIST; j++) {
avghz += evi->hz[j];
}

avghz /= (evi->count > HZ_LIST) ? HZ_LIST : evi->count;

printf("event%i: latest hz = %i (average hz = %i)\n", evnum, hz, avghz);
}


int main(int argc, char **argv) {
int i;
int has_input = 0;
event_t events[EVENTS];

memset(events, 0, sizeof(events));

for(i = 0; i < EVENTS; i++) {
char device[18];
char name[128];

sprintf(device, "/dev/input/event%i", i);
events[i].fd = open(device, O_RDONLY);

if(events[i].fd == -1)
continue;

ioctl(events[i].fd, EVIOCGNAME(sizeof(name)), name);
printf("event%i: %s\n", i, name);
has_input = 1;
}

if (!has_input) {
printf("There are no accessible /dev/input/event* devices\n");
exit(1);
}

signal(SIGINT, sigint);
printf("Press CTRL-C to exit.\n\n");

while(!quit) {
fd_set set;
FD_ZERO(&set);

for(i = 0; i < EVENTS; i++) {
if(events[i].fd != -1) {
FD_SET(events[i].fd, &set);
}
}

if(select(FD_SETSIZE, &set, NULL, NULL, NULL) <= 0)
continue;

for(i = 0; i < EVENTS; i++) {
if(events[i].fd == -1) {
continue;
}

if(!FD_ISSET(events[i].fd, &set)) {
continue;
}

calc_event(&events[i], i);
}
}

for(i = 0; i < EVENTS; i++) {
if(events[i].fd != -1) {
close(events[i].fd);
}
}
}
evhz-2012/evhz.spec000064400000000000000000000017621206537452400142600ustar00rootroot00000000000000Name: evhz
Version: 2012
Release: alt1

Summary: Measure mouse polling rate

Group: System/Configuration/Hardware
License: Public domain
Url: https://wiki.archlinux.org/index.php/Mouse_Polling_Rate

Packager: Vitaly Lipatov <lav@altlinux.ru>

# http://web.archive.org/web/20060623094750/http://homepages.nildram.co.uk/~kial/evhz.c
# Source-git: https://gist.github.com/993351
Source: %name-%version.tar

%description
A tool named evhz that can display the current mouse refresh rate -- useful
when checking that your customised polling settings have been applied.

You will have root permissions to /dev/input/event*

Inspired by code written by Alan Kivlin.

%prep
%setup

%build
gcc -o %name %name.c

%install
install %name -D %buildroot%_sbindir/%name

%files
%_sbindir/%name

%changelog
* Sat Dec 22 2012 Vitaly Lipatov <lav@altlinux.ru> 2012-alt1
- full rewrite original code and set appropriate license

* Fri Apr 06 2012 Vitaly Lipatov <lav@altlinux.ru> 2006-alt1
- initial build for ALT Linux Sisyphus
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin