-
fortissBot authored
refs 7890
fortissBot authoredrefs 7890
Gamepad.h 2.20 KiB
#ifndef __GAMEPAD_H
#define __GAMEPAD_H
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <unistd.h>
#include "inc-gen/data_dictionary.h"
// constants
#define JS_EVENT_BUTTON 0x01
#define JS_EVENT_AXIS 0x02
#define JS_EVENT_INIT 0x80
extern const char* GP_DEVICE_NAME;
// types etc
union input_events {
struct input_btns {
int16_t js1_lr; // LX
int16_t js1_ud; // LY
int16_t js2_lr; // RX
int16_t js2_ud; // RY
int16_t gp_lr; // GPX
int16_t gp_ud; // GPY
int16_t bt_tri; // BTN1
int16_t bt_cir; // BTN2
int16_t bt_x; // BTN3
int16_t bt_sqr; // BTN4
int16_t bt_l1; // L1
int16_t bt_r1; // R1
int16_t bt_l2; // L2
int16_t bt_r2; // R2
int16_t bt_sel; // SELECT
int16_t bt_strt;// START
int16_t js1_bt; // LCLICK
int16_t js2_bt; // RCLICK
} btns;
int16_t inps[18];
};
struct js_event {
uint32_t time; // event time stamp in millisecons
int16_t value; // value
uint8_t type; // event type
uint8_t number; // axis/button number
};
extern volatile union input_events ie;
// worker
void* gp_worker(void* pt_args);
// init, term
void gp_init();
void gp_term();
// readers
GEN_TYPE_boolean gp_btn1_read();
GEN_TYPE_boolean gp_btn2_read();
GEN_TYPE_boolean gp_btn3_read();
GEN_TYPE_boolean gp_btn4_read();
GEN_TYPE_boolean gp_btnL1_read();
GEN_TYPE_boolean gp_btnL2_read();
GEN_TYPE_boolean gp_btnR1_read();
GEN_TYPE_boolean gp_btnR2_read();
GEN_TYPE_double gp_btnLX_read();
GEN_TYPE_double gp_btnLY_read();
GEN_TYPE_double gp_btnRX_read();
GEN_TYPE_double gp_btnRY_read();
// noval
GEN_TYPE_boolean gp_btn1_is_noval();
GEN_TYPE_boolean gp_btn2_is_noval();
GEN_TYPE_boolean gp_btn3_is_noval();
GEN_TYPE_boolean gp_btn4_is_noval();
GEN_TYPE_boolean gp_btnL1_is_noval();
GEN_TYPE_boolean gp_btnL2_is_noval();
GEN_TYPE_boolean gp_btnR1_is_noval();
GEN_TYPE_boolean gp_btnR2_is_noval();
GEN_TYPE_boolean gp_btnLX_is_noval();
GEN_TYPE_boolean gp_btnLY_is_noval();
GEN_TYPE_boolean gp_btnRX_is_noval();
GEN_TYPE_boolean gp_btnRY_is_noval();
#endif // __GAMEPAD_H