mirror of
https://github.com/stupidcomputer/jsfw.git
synced 2024-12-26 21:42:23 -06:00
never gonna let you down
This commit is contained in:
parent
063c69303b
commit
141a8db388
9
client.c
9
client.c
@ -4,13 +4,11 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <linux/uinput.h>
|
#include <linux/uinput.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <pthread.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -20,6 +18,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int fd;
|
int fd;
|
||||||
@ -158,7 +157,7 @@ void device_handle_report(MessageDeviceReport *report) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < report->key_count; i++) {
|
for (int i = 0; i < report->key_count; i++) {
|
||||||
if (device_emit(EV_KEY, device.info.key_id[i], (uint32_t)(!report->key[i]) - 1 ) != 0)
|
if (device_emit(EV_KEY, device.info.key_id[i], (uint32_t)(!report->key[i]) - 1) != 0)
|
||||||
printf("CLIENT: Error writing key event to uinput\n");
|
printf("CLIENT: Error writing key event to uinput\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,10 +290,10 @@ void client_run(char *address, uint16_t port) {
|
|||||||
if (msg_deserialize(buf, len, &message) != 0) {
|
if (msg_deserialize(buf, len, &message) != 0) {
|
||||||
printf("CLIENT: Couldn't parse message (code: %d, len: %d)\n", buf[0], len);
|
printf("CLIENT: Couldn't parse message (code: %d, len: %d)\n", buf[0], len);
|
||||||
int l = len > 100 ? 100 : len;
|
int l = len > 100 ? 100 : len;
|
||||||
for(int i = 0; i < l; i++) {
|
for (int i = 0; i < l; i++) {
|
||||||
printf("%02x", buf[i]);
|
printf("%02x", buf[i]);
|
||||||
}
|
}
|
||||||
if(len > 100) {
|
if (len > 100) {
|
||||||
printf(" ... %d more bytes", len - 100);
|
printf(" ... %d more bytes", len - 100);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
6
hid.c
6
hid.c
@ -75,7 +75,7 @@ void setup_device(PhysicalDevice *dev) {
|
|||||||
if (i == EV_ABS) {
|
if (i == EV_ABS) {
|
||||||
struct input_absinfo abs;
|
struct input_absinfo abs;
|
||||||
ioctl(dev->event, EVIOCGABS(j), &abs);
|
ioctl(dev->event, EVIOCGABS(j), &abs);
|
||||||
uint16_t index = dev->device_info.abs_count++;
|
uint16_t index = dev->device_info.abs_count++;
|
||||||
dev->device_info.abs_id[index] = j;
|
dev->device_info.abs_id[index] = j;
|
||||||
dev->device_info.abs_min[index] = abs.minimum;
|
dev->device_info.abs_min[index] = abs.minimum;
|
||||||
dev->device_info.abs_max[index] = abs.maximum;
|
dev->device_info.abs_max[index] = abs.maximum;
|
||||||
@ -84,11 +84,11 @@ void setup_device(PhysicalDevice *dev) {
|
|||||||
dev->device_info.abs_res[index] = abs.resolution;
|
dev->device_info.abs_res[index] = abs.resolution;
|
||||||
dev->mapping.abs_indices[j] = index;
|
dev->mapping.abs_indices[j] = index;
|
||||||
} else if (i == EV_REL) {
|
} else if (i == EV_REL) {
|
||||||
uint16_t index = dev->device_info.rel_count++;
|
uint16_t index = dev->device_info.rel_count++;
|
||||||
dev->device_info.rel_id[index] = j;
|
dev->device_info.rel_id[index] = j;
|
||||||
dev->mapping.rel_indices[j] = index;
|
dev->mapping.rel_indices[j] = index;
|
||||||
} else if (i == EV_KEY) {
|
} else if (i == EV_KEY) {
|
||||||
uint16_t index = dev->device_info.key_count++;
|
uint16_t index = dev->device_info.key_count++;
|
||||||
dev->device_info.key_id[index] = j;
|
dev->device_info.key_id[index] = j;
|
||||||
dev->mapping.key_indices[j] = index;
|
dev->mapping.key_indices[j] = index;
|
||||||
}
|
}
|
||||||
|
1
hid.h
1
hid.h
@ -2,6 +2,7 @@
|
|||||||
#ifndef HID_H
|
#ifndef HID_H
|
||||||
#define HID_H
|
#define HID_H
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
2
net.h
2
net.h
@ -19,7 +19,7 @@ typedef struct {
|
|||||||
uint16_t rel_count;
|
uint16_t rel_count;
|
||||||
uint16_t key_count;
|
uint16_t key_count;
|
||||||
|
|
||||||
uint16_t abs_id[ABS_CNT];
|
uint16_t abs_id[ABS_CNT];
|
||||||
uint32_t abs_min[ABS_CNT];
|
uint32_t abs_min[ABS_CNT];
|
||||||
uint32_t abs_max[ABS_CNT];
|
uint32_t abs_max[ABS_CNT];
|
||||||
uint32_t abs_fuzz[ABS_CNT];
|
uint32_t abs_fuzz[ABS_CNT];
|
||||||
|
Loading…
Reference in New Issue
Block a user