Version 1.08 with public source code release.

This commit is contained in:
icex2
2020-10-03 20:56:55 +02:00
parent 656148121d
commit 762bf140c0
555 changed files with 55502 additions and 3 deletions
+105
View File
@@ -0,0 +1,105 @@
/**
* Common API to use for any devices implementing piu (pro) button controls
* (e.g. keyboard emulation, custom IOs)
*/
#ifndef PTAPI_IO_PIUBTN_H
#define PTAPI_IO_PIUBTN_H
#include <stdbool.h>
#include <stdint.h>
/**
* Button inputs of a single player
*/
struct ptapi_io_piubtn_inputs {
bool start;
bool back;
bool left;
bool right;
};
/**
* Button light outputs of a single player
*/
struct ptapi_io_piubtn_outputs {
bool start;
bool back;
bool left;
bool right;
};
typedef const char* (*ptapi_io_piubtn_ident_t)(void);
typedef bool (*ptapi_io_piubtn_open_t)(void);
typedef void (*ptapi_io_piubtn_close_t)(void);
typedef bool (*ptapi_io_piubtn_recv_t)(void);
typedef bool (*ptapi_io_piubtn_send_t)(void);
typedef void (*ptapi_io_piubtn_get_input_t)(uint8_t player, struct ptapi_io_piubtn_inputs* inputs);
typedef void (*ptapi_io_piubtn_set_output_t)(uint8_t player, const struct ptapi_io_piubtn_outputs* outputs);
/**
* API functions in a struct to make them easier to handle and have less boilerplate
*/
struct ptapi_io_piubtn_api {
ptapi_io_piubtn_ident_t ident;
ptapi_io_piubtn_open_t open;
ptapi_io_piubtn_close_t close;
ptapi_io_piubtn_recv_t recv;
ptapi_io_piubtn_send_t send;
ptapi_io_piubtn_get_input_t get_input;
ptapi_io_piubtn_set_output_t set_output;
};
/**
* Return an identifier of the implementation. Used for logging and debugging.
*
* @return Identifier string for your implementation (e.g. "my-custom-btnio")
*/
const char* ptapi_io_piubtn_ident(void);
/**
* Open the piubtn device
*
* Open any file handles, spawn threads and/or initialize your device or emulation code to be ready to accept further
* commands.
*
* @return True if opening/initializing your implementation was sucessful, false on failure
*/
bool ptapi_io_piubtn_open(void);
/**
* Close and cleanup your device, shut down threads, free resources etc
*/
void ptapi_io_piubtn_close(void);
/**
* Get _ALL_ readable data from your device in this single recv call.
*
* @return True on success, false on error
*/
bool ptapi_io_piubtn_recv(void);
/**
* Send any output data (e.g. lights) to your device
*
* @return True on success, false on error
*/
bool ptapi_io_piubtn_send(void);
/**
* Get buffered button input data
*
* @param player Player id (0, 1)
* @param inputs Pointer to buffer to copy inputs to. Every time this is invoked, this buffer is nulled. If you do not
* write any data to this, all inputs remain un-triggered.
*/
void ptapi_io_piubtn_get_input(uint8_t player, struct ptapi_io_piubtn_inputs* inputs);
/**
* Set button light outputs (i.e. buffer them)
*
* @param player Player id (0, 1)
* @param outputs Pointer to output data to copy to your private buffers.
*/
void ptapi_io_piubtn_set_output(uint8_t player, const struct ptapi_io_piubtn_outputs* outputs);
#endif
+163
View File
@@ -0,0 +1,163 @@
/**
* Common API to use for any devices implementing (MK6) piuio controls
* (e.g. keyboard emulation, custom IOs)
*/
#ifndef PTAPI_IO_PIUIO_H
#define PTAPI_IO_PIUIO_H
#include <stdbool.h>
#include <stdint.h>
/**
* Enum for pad input sensor groups (four sensors per button/panel)
*/
enum ptapi_io_piuio_sensor_group {
PTAPI_IO_PIUIO_SENSOR_GROUP_RIGHT = 0,
PTAPI_IO_PIUIO_SENSOR_GROUP_LEFT = 1,
PTAPI_IO_PIUIO_SENSOR_GROUP_DOWN = 2,
PTAPI_IO_PIUIO_SENSOR_GROUP_UP = 3,
PTAPI_IO_PIUIO_SENSOR_GROUP_NUM = 4,
};
/**
* Inputs of all arrows of a single pad (per sensor group)
*/
struct ptapi_io_piuio_pad_inputs {
bool lu;
bool ru;
bool cn;
bool ld;
bool rd;
};
/**
* System/operator inputs
*/
struct ptapi_io_piuio_sys_inputs {
bool test;
bool service;
bool clear;
bool coin;
bool coin2;
};
/**
* Pad light outputs
*/
struct ptapi_io_piuio_pad_outputs {
bool lu;
bool ru;
bool cn;
bool ld;
bool rd;
};
/**
* Cabinet light outputs
*/
struct ptapi_io_piuio_cab_outputs {
bool bass;
bool halo_r2;
bool halo_r1;
bool halo_l2;
bool halo_l1;
};
typedef const char* (*ptapi_io_piuio_ident_t)(void);
typedef bool (*ptapi_io_piuio_open_t)(void);
typedef void (*ptapi_io_piuio_close_t)(void);
typedef bool (*ptapi_io_piuio_recv_t)(void);
typedef bool (*ptapi_io_piuio_send_t)(void);
typedef void (*ptapi_io_piuio_get_input_pad_t)(uint8_t player, enum ptapi_io_piuio_sensor_group sensor_group,
struct ptapi_io_piuio_pad_inputs* inputs);
typedef void (*ptapi_io_piuio_get_input_sys_t)(struct ptapi_io_piuio_sys_inputs* inputs);
typedef void (*ptapi_io_piuio_set_output_pad_t)(uint8_t player, struct ptapi_io_piuio_pad_outputs* outputs);
typedef void (*ptapi_io_piuio_set_output_cab_t)(const struct ptapi_io_piuio_cab_outputs* outputs);
/**
* API functions in a struct to make them easier to handle and have less boilerplate
*/
struct ptapi_io_piuio_api {
ptapi_io_piuio_ident_t ident;
ptapi_io_piuio_open_t open;
ptapi_io_piuio_close_t close;
ptapi_io_piuio_recv_t recv;
ptapi_io_piuio_send_t send;
ptapi_io_piuio_get_input_pad_t get_input_pad;
ptapi_io_piuio_get_input_sys_t get_input_sys;
ptapi_io_piuio_set_output_pad_t set_output_pad;
ptapi_io_piuio_set_output_cab_t set_output_cab;
};
/**
* Return an identifier of the implementation. Used for logging and debugging.
*
* @return Identifier string for your implementation (e.g. "my-custom-io")
*/
const char* ptapi_io_piuio_ident(void);
/**
* Open the piuio device
*
* Open any file handles, spawn threads and/or initialize your device or emulation code to be ready to accept further
* commands.
*
* @return True if opening/initializing your implementation was sucessful, false on failure
*/
bool ptapi_io_piuio_open(void);
/**
* Close and cleanup your device, shut down threads, free resources etc
*/
void ptapi_io_piuio_close(void);
/**
* Get _ALL_ readable data from your device in this single recv call. If you have to address single sensores like the
* real piuio, you have to do this on a single call to this function.
*
* @return True on success, false on error
*/
bool ptapi_io_piuio_recv(void);
/**
* Send any output data (e.g. lights) to your device
*
* @return True on success, false on error
*/
bool ptapi_io_piuio_send(void);
/**
* Get buffered pad input data
*
* @param player Player id (0, 1)
* @param sensor_group Sensor group states to get
* @param inputs Pointer to buffer to copy inputs of the selected sensor group to. Every time this is invoked, this
* buffer is nulled. If you do not write any data to this, all inputs remain un-triggered.
*/
void ptapi_io_piuio_get_input_pad(uint8_t player, enum ptapi_io_piuio_sensor_group sensor_group,
struct ptapi_io_piuio_pad_inputs* inputs);
/**
* Get buffered system (test, service, clear, coin) inputs
*
* @param inputs Pointer to buffer to copy inputs to. Every time this is invoked, this buffer is nulled. If you do not
* write any data to this, all inputs remain un-triggered.
*/
void ptapi_io_piuio_get_input_sys(struct ptapi_io_piuio_sys_inputs* inputs);
/**
* Set pad light outputs (i.e. buffer them)
*
* @param player Player id (0, 1)
* @param outputs Pointer to output data to copy to your private buffers.
*/
void ptapi_io_piuio_set_output_pad(uint8_t player, const struct ptapi_io_piuio_pad_outputs* outputs);
/**
* Set cabinet light outputs (i.e. buffer them)
*
* @param outputs Pointer to output data to copy to your private buffers.
*/
void ptapi_io_piuio_set_output_cab(const struct ptapi_io_piuio_cab_outputs* outputs);
#endif
+39
View File
@@ -0,0 +1,39 @@
/**
* Pumptools hooks into the X11 event dispatch loop to grab different events and exposes
* keyboard input events. This allows external modules to react to these inputs.
*/
#ifndef PTAPI_IO_X11_INPUT_HOOK_H
#define PTAPI_IO_X11_INPUT_HOOK_H
#include <X11/Xutil.h>
/**
* Input hooking structure with dispatch functions.
* Set functions you do not use to NULL.
*/
struct ptapi_io_x11_input_hook_handler {
/**
* Dispatch the key press event
*
* @param key Key pressed
*/
void (*dispatch_key_press)(KeySym key);
/**
* Dispatch the key release event
*
* @param key Key released
*/
void (*dispatch_key_release)(KeySym key);
};
typedef const struct ptapi_io_x11_input_hook_handler* (*ptapi_io_x11_input_handler_hook_t)(void);
/**
* Get an input hook handler to receive keyboard inputs from the X11 event loop.
*
* @return Either a valid handler structure with dispatch functions or NULL if unused.
*/
const struct ptapi_io_x11_input_hook_handler* ptapi_io_x11_input_handler_hook(void);
#endif