mirror of
https://github.com/86Box/86Box.git
synced 2026-02-24 02:18:20 -07:00
Merge branch 'master' into pc98x1
This commit is contained in:
@@ -55,38 +55,31 @@ const char* mtouch_identity[] = {
|
||||
};
|
||||
|
||||
typedef struct mouse_microtouch_t {
|
||||
double baud_rate;
|
||||
int b;
|
||||
char cmd[256];
|
||||
int cmd_pos;
|
||||
uint8_t format;
|
||||
bool mode_status;
|
||||
uint8_t id, cal_cntr, pen_mode;
|
||||
bool soh;
|
||||
bool in_reset;
|
||||
serial_t *serial;
|
||||
Fifo8 resp;
|
||||
pc_timer_t host_to_serial_timer;
|
||||
pc_timer_t reset_timer;
|
||||
double baud_rate;
|
||||
unsigned int abs_x_int, abs_y_int;
|
||||
int b;
|
||||
char cmd[256];
|
||||
int cmd_pos;
|
||||
uint8_t format;
|
||||
bool mode_status;
|
||||
uint8_t id, cal_cntr, pen_mode;
|
||||
bool soh;
|
||||
bool in_reset;
|
||||
serial_t *serial;
|
||||
Fifo8 resp;
|
||||
pc_timer_t host_to_serial_timer;
|
||||
pc_timer_t reset_timer;
|
||||
} mouse_microtouch_t;
|
||||
|
||||
static mouse_microtouch_t *mtouch_inst = NULL;
|
||||
|
||||
void
|
||||
mt_fifo8_puts(Fifo8 *fifo, const uint8_t *data)
|
||||
{
|
||||
fifo8_push(fifo, 1);
|
||||
fifo8_push_all(fifo, data, strlen(data));
|
||||
fifo8_push(fifo, '\r');
|
||||
}
|
||||
|
||||
void
|
||||
microtouch_reset_complete(void *priv)
|
||||
{
|
||||
mouse_microtouch_t *mtouch = (mouse_microtouch_t *) priv;
|
||||
|
||||
mtouch->in_reset = false;
|
||||
mt_fifo8_puts(&mtouch->resp, "0");
|
||||
fifo8_push_all(&mtouch->resp, (uint8_t *) "\x01\x30\x0D", 3); /* <SOH>0<CR> */
|
||||
}
|
||||
|
||||
void
|
||||
@@ -96,85 +89,55 @@ microtouch_calibrate_timer(void *priv)
|
||||
|
||||
if (!fifo8_num_used(&mtouch->resp)) {
|
||||
mtouch->cal_cntr--;
|
||||
mt_fifo8_puts(&mtouch->resp, "1");
|
||||
fifo8_push_all(&mtouch->resp, (uint8_t *) "\x01\x31\x0D", 3); /* <SOH>1<CR> */
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
microtouch_process_commands(mouse_microtouch_t *mtouch)
|
||||
{
|
||||
int fifo_used = fifo8_num_used(&mtouch->resp);
|
||||
mtouch->cmd[strcspn(mtouch->cmd, "\r")] = '\0';
|
||||
mtouch->cmd_pos = 0;
|
||||
if (mtouch->cmd[0] == 'A' && (mtouch->cmd[1] == 'D' || mtouch->cmd[1] == 'E')) { /* Autobaud Enable/Disable */
|
||||
mt_fifo8_puts(&mtouch->resp, "0");
|
||||
}
|
||||
pclog("MT Command: %s\n", mtouch->cmd);
|
||||
|
||||
if (mtouch->cmd[0] == 'C' && (mtouch->cmd[1] == 'N' || mtouch->cmd[1] == 'X')) { /* Calibrate New/Extended */
|
||||
mt_fifo8_puts(&mtouch->resp, "0");
|
||||
mtouch->cal_cntr = 2;
|
||||
}
|
||||
if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'D') { /* Format Decimal */
|
||||
mouse_set_sample_rate(106);
|
||||
mtouch->format = FORMAT_DEC;
|
||||
mt_fifo8_puts(&mtouch->resp, "0");
|
||||
}
|
||||
if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'N') { /* Filter Number */
|
||||
mt_fifo8_puts(&mtouch->resp, "0");
|
||||
}
|
||||
if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'O') { /* Finger Only */
|
||||
mtouch->pen_mode = 1;
|
||||
mt_fifo8_puts(&mtouch->resp, "0");
|
||||
}
|
||||
if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'H') { /* Format Hexadecimal */
|
||||
mouse_set_sample_rate(106);
|
||||
mtouch->format = FORMAT_HEX;
|
||||
mt_fifo8_puts(&mtouch->resp, "0");
|
||||
}
|
||||
if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'Q') { /* ?? */
|
||||
mt_fifo8_puts(&mtouch->resp, "0");
|
||||
}
|
||||
if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'R') { /* Format Raw */
|
||||
mouse_set_sample_rate(106);
|
||||
mtouch->format = FORMAT_RAW;
|
||||
mtouch->cal_cntr = 0;
|
||||
mt_fifo8_puts(&mtouch->resp, "0");
|
||||
}
|
||||
if (mtouch->cmd[0] == 'F' && mtouch->cmd[1] == 'T') { /* Format Tablet */
|
||||
mouse_set_sample_rate(192);
|
||||
mtouch->format = FORMAT_TABLET;
|
||||
mt_fifo8_puts(&mtouch->resp, "0");
|
||||
}
|
||||
if (mtouch->cmd[0] == 'G' && mtouch->cmd[1] == 'F') { /* ?? */
|
||||
mt_fifo8_puts(&mtouch->resp, "0");
|
||||
}
|
||||
if (mtouch->cmd[0] == 'G' && mtouch->cmd[1] == 'P' && mtouch->cmd[2] == '1') { /* Get Parameter Block 1 */
|
||||
mt_fifo8_puts(&mtouch->resp, "A");
|
||||
fifo8_push_all(&mtouch->resp, (uint8_t *) "0000000000000000000000000\r", sizeof("0000000000000000000000000\r") - 1);
|
||||
mt_fifo8_puts(&mtouch->resp, "0");
|
||||
}
|
||||
if (mtouch->cmd[0] == 'M' && mtouch->cmd[1] == 'P') { /* ?? */
|
||||
mt_fifo8_puts(&mtouch->resp, "0");
|
||||
}
|
||||
if (mtouch->cmd[0] == 'M' && mtouch->cmd[1] == 'S') { /* Mode Stream */
|
||||
mt_fifo8_puts(&mtouch->resp, "0");
|
||||
fifo8_push_all(&mtouch->resp, (uint8_t *) "\x01\x41\x0D", 3); /* <SOH>A<CR> */
|
||||
fifo8_push_all(&mtouch->resp, (uint8_t *) "0000000000000000000000000\r", 26);
|
||||
}
|
||||
if (mtouch->cmd[0] == 'M' && mtouch->cmd[1] == 'T') { /* Mode Status */
|
||||
mtouch->mode_status = true;
|
||||
mt_fifo8_puts(&mtouch->resp, "0");
|
||||
}
|
||||
if (mtouch->cmd[0] == 'N' && mtouch->cmd[1] == 'M') { /* ?? */
|
||||
mt_fifo8_puts(&mtouch->resp, "0");
|
||||
}
|
||||
if (mtouch->cmd[0] == 'O' && mtouch->cmd[1] == 'I') { /* Output Identity */
|
||||
mt_fifo8_puts(&mtouch->resp, mtouch_identity[mtouch->id]);
|
||||
fifo8_push(&mtouch->resp, 0x01);
|
||||
fifo8_push_all(&mtouch->resp, (uint8_t *) mtouch_identity[mtouch->id], 6);
|
||||
fifo8_push(&mtouch->resp, 0x0D);
|
||||
return;
|
||||
}
|
||||
if (mtouch->cmd[0] == 'P') {
|
||||
if (mtouch->cmd[1] == 'F') mtouch->pen_mode = 3; /* Pen or Finger */
|
||||
else if (mtouch->cmd[1] == 'O') mtouch->pen_mode = 2; /* Pen Only */
|
||||
mt_fifo8_puts(&mtouch->resp, "0"); /* Also 'PL' Parameter Lock */
|
||||
}
|
||||
if (mtouch->cmd[0] == 'Q' && mtouch->cmd[1] == 'P') { /* ?? */
|
||||
mt_fifo8_puts(&mtouch->resp, "0");
|
||||
}
|
||||
if (mtouch->cmd[0] == 'R') { /* Reset */
|
||||
mtouch->in_reset = true;
|
||||
@@ -185,28 +148,31 @@ microtouch_process_commands(mouse_microtouch_t *mtouch)
|
||||
if (mtouch->id < 2) {
|
||||
mouse_set_sample_rate(106);
|
||||
mtouch->format = FORMAT_DEC;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mouse_set_sample_rate(192);
|
||||
mtouch->format = FORMAT_TABLET;
|
||||
}
|
||||
|
||||
timer_on_auto(&mtouch->reset_timer, 500. * 1000.);
|
||||
return;
|
||||
}
|
||||
if (mtouch->cmd[0] == 'S' && mtouch->cmd[1] == 'P' && mtouch->cmd[2] == '1') { /* Set Parameter Block 1 */
|
||||
mt_fifo8_puts(&mtouch->resp, "A");
|
||||
fifo8_push_all(&mtouch->resp, (uint8_t *) "\x01\x41\x0D", 3); /* <SOH>A<CR> */
|
||||
return;
|
||||
}
|
||||
if (mtouch->cmd[0] == 'U' && mtouch->cmd[1] == 'T') { /* Unit Type */
|
||||
mt_fifo8_puts(&mtouch->resp, "TP****00");
|
||||
}
|
||||
if (mtouch->cmd[0] == 'Z') { /* Null */
|
||||
mt_fifo8_puts(&mtouch->resp, "0");
|
||||
}
|
||||
if (fifo8_num_used(&mtouch->resp) != fifo_used || mtouch->in_reset) {
|
||||
pclog("Command handled: %s\n", mtouch->cmd);
|
||||
} else {
|
||||
pclog("Command ignored: %s\n", mtouch->cmd);
|
||||
fifo8_push(&mtouch->resp, 0x01);
|
||||
|
||||
if (mtouch->id == 2) {
|
||||
fifo8_push_all(&mtouch->resp, (uint8_t *) "TP****00", 8);
|
||||
} else {
|
||||
fifo8_push_all(&mtouch->resp, (uint8_t *) "QM****00", 8);
|
||||
}
|
||||
fifo8_push(&mtouch->resp, 0x0D);
|
||||
return;
|
||||
}
|
||||
|
||||
fifo8_push_all(&mtouch->resp, (uint8_t *) "\x01\x30\x0D", 3); /* <SOH>0<CR> */
|
||||
}
|
||||
|
||||
void
|
||||
@@ -243,8 +209,14 @@ mtouch_write(serial_t *serial, void *priv, uint8_t data)
|
||||
if (data != '\r') {
|
||||
dev->cmd[dev->cmd_pos++] = data;
|
||||
} else {
|
||||
dev->cmd[dev->cmd_pos++] = data;
|
||||
dev->soh = 0;
|
||||
|
||||
if (!dev->cmd_pos) {
|
||||
return;
|
||||
}
|
||||
|
||||
dev->cmd[dev->cmd_pos++] = data;
|
||||
dev->cmd_pos = 0;
|
||||
microtouch_process_commands(dev);
|
||||
}
|
||||
}
|
||||
@@ -325,7 +297,7 @@ mtouch_poll(void *priv)
|
||||
snprintf(buffer, sizeof(buffer), "\x1c%03d,%03d\r", abs_x_int, abs_y_int);
|
||||
}
|
||||
} else if (dev->b) { /* Liftoff Status */
|
||||
snprintf(buffer, sizeof(buffer), "\x18%03d,%03d\r", abs_x_int, abs_y_int);
|
||||
snprintf(buffer, sizeof(buffer), "\x18%03d,%03d\r", dev->abs_x_int, dev->abs_y_int);
|
||||
}
|
||||
fifo8_push_all(&dev->resp, (uint8_t *)buffer, strlen(buffer));
|
||||
}
|
||||
@@ -349,7 +321,7 @@ mtouch_poll(void *priv)
|
||||
snprintf(buffer, sizeof(buffer), "\x1c%03X,%03X\r", abs_x_int, abs_y_int);
|
||||
}
|
||||
} else if (dev->b) { /* Liftoff Status */
|
||||
snprintf(buffer, sizeof(buffer), "\x18%03X,%03X\r", abs_x_int, abs_y_int);
|
||||
snprintf(buffer, sizeof(buffer), "\x18%03X,%03X\r", dev->abs_x_int, dev->abs_y_int);
|
||||
}
|
||||
fifo8_push_all(&dev->resp, (uint8_t *)buffer, strlen(buffer));
|
||||
}
|
||||
@@ -367,14 +339,17 @@ mtouch_poll(void *priv)
|
||||
fifo8_push(&dev->resp, (abs_y_int >> 7) & 0b1111111);
|
||||
} else if (dev->b) { /* Liftoff */
|
||||
fifo8_push(&dev->resp, 0b10000000 | ((dev->pen_mode == 2) ? ((1 << 5)) : 0));
|
||||
fifo8_push(&dev->resp, abs_x_int & 0b1111111);
|
||||
fifo8_push(&dev->resp, (abs_x_int >> 7) & 0b1111111);
|
||||
fifo8_push(&dev->resp, abs_y_int & 0b1111111);
|
||||
fifo8_push(&dev->resp, (abs_y_int >> 7) & 0b1111111);
|
||||
fifo8_push(&dev->resp, dev->abs_x_int & 0b1111111);
|
||||
fifo8_push(&dev->resp, (dev->abs_x_int >> 7) & 0b1111111);
|
||||
fifo8_push(&dev->resp, dev->abs_y_int & 0b1111111);
|
||||
fifo8_push(&dev->resp, (dev->abs_y_int >> 7) & 0b1111111);
|
||||
}
|
||||
}
|
||||
|
||||
dev->b = b; /* Save buttonpress */
|
||||
/* Save old states*/
|
||||
dev->abs_x_int = abs_x_int;
|
||||
dev->abs_y_int = abs_y_int;
|
||||
dev->b = b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ typedef struct midi_device_t {
|
||||
void (*play_sysex)(uint8_t *sysex, unsigned int len);
|
||||
void (*play_msg)(uint8_t *msg);
|
||||
void (*poll)(void);
|
||||
void (*reset)(void);
|
||||
int (*write)(uint8_t val);
|
||||
} midi_device_t;
|
||||
|
||||
@@ -77,6 +78,7 @@ extern void midi_raw_out_thru_rt_byte(uint8_t val);
|
||||
extern void midi_raw_out_byte(uint8_t val);
|
||||
extern void midi_clear_buffer(void);
|
||||
extern void midi_poll(void);
|
||||
extern void midi_reset(void);
|
||||
|
||||
extern void midi_in_handler(int set, void (*msg)(void *priv, uint8_t *msg, uint32_t len), int (*sysex)(void *priv, uint8_t *buffer, uint32_t len, int abort), void *priv);
|
||||
extern void midi_in_handlers_clear(void);
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
|
||||
#define MPU401_VERSION 0x15
|
||||
#define MPU401_REVISION 0x01
|
||||
#define MPU401_QUEUE 1024
|
||||
#define MPU401_QUEUE 32
|
||||
#define MPU401_INPUT_QUEUE 1024
|
||||
#define MPU401_TIMECONSTANT (60000000 / 1000.0f)
|
||||
#define MPU401_TIMECONSTANT (60000000.0 / 1000.0)
|
||||
#define MPU401_RESETBUSY 27.0f
|
||||
|
||||
/*helpers*/
|
||||
@@ -89,7 +89,7 @@ typedef struct mpu_t {
|
||||
uint32_t ch_toref[16];
|
||||
struct track {
|
||||
int counter;
|
||||
uint8_t value[3];
|
||||
uint8_t value[8];
|
||||
uint8_t sys_val;
|
||||
uint8_t vlength;
|
||||
uint8_t length;
|
||||
@@ -106,7 +106,6 @@ typedef struct mpu_t {
|
||||
int wsm;
|
||||
int wsd_start;
|
||||
int run_irq;
|
||||
int irq_pending;
|
||||
int track_req;
|
||||
int send_now;
|
||||
int eoi_scheduled;
|
||||
@@ -116,9 +115,11 @@ typedef struct mpu_t {
|
||||
int sysex_in_finished;
|
||||
int rec_copy;
|
||||
RecState rec;
|
||||
uint8_t irq_pending;
|
||||
uint8_t tmask;
|
||||
uint8_t cmask;
|
||||
uint8_t amask;
|
||||
uint8_t queued_eois;
|
||||
uint8_t last_rtcmd;
|
||||
uint16_t midi_mask;
|
||||
uint16_t req_mask;
|
||||
|
||||
@@ -1488,8 +1488,8 @@ modem_init(const device_t *info)
|
||||
|
||||
modem->clientsocket = modem->serversocket = modem->waitingclientsocket = -1;
|
||||
|
||||
fifo8_create(&modem->data_pending, 0x10000);
|
||||
fifo8_create(&modem->rx_data, 0x10000);
|
||||
fifo8_create(&modem->data_pending, 0x20000);
|
||||
fifo8_create(&modem->rx_data, 0x20000);
|
||||
|
||||
timer_add(&modem->dtr_timer, modem_dtr_callback_timer, modem, 0);
|
||||
timer_add(&modem->host_to_serial_timer, host_to_modem_cb, modem, 0);
|
||||
|
||||
@@ -341,7 +341,7 @@ midi_raw_out_byte(uint8_t val)
|
||||
else if ((midi_out->midi_sysex_data[5] == 0x10) && (midi_out->midi_sysex_data[6] == 0x00) && (midi_out->midi_sysex_data[7] == 0x01))
|
||||
midi_out->midi_sysex_delay = 30; /* Dark Sun 1 */
|
||||
else
|
||||
midi_out->midi_sysex_delay = (unsigned int) (((float) (midi_out->midi_pos) * 1.25f) * 1000.0f / 3125.0f) + 2;
|
||||
midi_out->midi_sysex_delay = (unsigned int) (((double) (midi_out->midi_pos) * 1.25) / 3.125) + 2;
|
||||
|
||||
midi_out->midi_sysex_start = plat_get_ticks();
|
||||
}
|
||||
@@ -584,3 +584,10 @@ midi_in_sysex(uint8_t *buffer, uint32_t len)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
midi_reset(void)
|
||||
{
|
||||
if (midi_out && midi_out->m_out_device && midi_out->m_out_device->reset)
|
||||
midi_out->m_out_device->reset();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -442,7 +442,7 @@ sb_dsp_set_mpu(sb_dsp_t *dsp, mpu_t *mpu)
|
||||
{
|
||||
dsp->mpu = mpu;
|
||||
|
||||
if (mpu != NULL)
|
||||
if (IS_NOT_ESS(dsp) && (mpu != NULL))
|
||||
mpu401_irq_attach(mpu, sb_dsp_irq_update, sb_dsp_irq_pending, dsp);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user