More progress towards 2nd gameport support
This commit is contained in:
@@ -1593,8 +1593,9 @@ pc_reset_hard_init(void)
|
|||||||
the chances of the SCSI controller ending up on the bridge. */
|
the chances of the SCSI controller ending up on the bridge. */
|
||||||
video_voodoo_init();
|
video_voodoo_init();
|
||||||
|
|
||||||
if (joystick_type)
|
/* installs first game port if no device provides one, must be late */
|
||||||
gameport_update_joystick_type(); /* installs game port if no device provides one, must be late */
|
if (joystick_type[0])
|
||||||
|
gameport_update_joystick_type(0);
|
||||||
|
|
||||||
ui_sb_update_panes();
|
ui_sb_update_panes();
|
||||||
|
|
||||||
@@ -1802,7 +1803,7 @@ pc_run(void)
|
|||||||
#ifdef USE_GDBSTUB /* avoid a KBC FIFO overflow when CPU emulation is stalled */
|
#ifdef USE_GDBSTUB /* avoid a KBC FIFO overflow when CPU emulation is stalled */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
joystick_process();
|
joystick_process(0); // Gameport 0
|
||||||
endblit();
|
endblit();
|
||||||
|
|
||||||
/* Done with this frame, update statistics. */
|
/* Done with this frame, update statistics. */
|
||||||
|
|||||||
46
src/config.c
46
src/config.c
@@ -529,62 +529,63 @@ load_input_devices(void)
|
|||||||
else
|
else
|
||||||
mouse_type = 0;
|
mouse_type = 0;
|
||||||
|
|
||||||
|
uint8_t joy_insn = 0;
|
||||||
p = ini_section_get_string(cat, "joystick_type", NULL);
|
p = ini_section_get_string(cat, "joystick_type", NULL);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
joystick_type = joystick_get_from_internal_name(p);
|
joystick_type[joy_insn] = joystick_get_from_internal_name(p);
|
||||||
|
|
||||||
if (!joystick_type) {
|
if (!joystick_type[joy_insn]) {
|
||||||
/* Try to read an integer for backwards compatibility with old configs */
|
/* Try to read an integer for backwards compatibility with old configs */
|
||||||
if (!strcmp(p, "0"))
|
if (!strcmp(p, "0"))
|
||||||
/* Workaround for ini_section_get_int returning 0 on non-integer data */
|
/* Workaround for ini_section_get_int returning 0 on non-integer data */
|
||||||
joystick_type = joystick_get_from_internal_name("2axis_2button");
|
joystick_type[joy_insn] = joystick_get_from_internal_name("2axis_2button");
|
||||||
else {
|
else {
|
||||||
int js = ini_section_get_int(cat, "joystick_type", 8);
|
int js = ini_section_get_int(cat, "joystick_type", 8);
|
||||||
switch (js) {
|
switch (js) {
|
||||||
case JS_TYPE_2AXIS_4BUTTON:
|
case JS_TYPE_2AXIS_4BUTTON:
|
||||||
joystick_type = joystick_get_from_internal_name("2axis_4button");
|
joystick_type[joy_insn] = joystick_get_from_internal_name("2axis_4button");
|
||||||
break;
|
break;
|
||||||
case JS_TYPE_2AXIS_6BUTTON:
|
case JS_TYPE_2AXIS_6BUTTON:
|
||||||
joystick_type = joystick_get_from_internal_name("2axis_6button");
|
joystick_type[joy_insn] = joystick_get_from_internal_name("2axis_6button");
|
||||||
break;
|
break;
|
||||||
case JS_TYPE_2AXIS_8BUTTON:
|
case JS_TYPE_2AXIS_8BUTTON:
|
||||||
joystick_type = joystick_get_from_internal_name("2axis_8button");
|
joystick_type[joy_insn] = joystick_get_from_internal_name("2axis_8button");
|
||||||
break;
|
break;
|
||||||
case JS_TYPE_4AXIS_4BUTTON:
|
case JS_TYPE_4AXIS_4BUTTON:
|
||||||
joystick_type = joystick_get_from_internal_name("4axis_4button");
|
joystick_type[joy_insn] = joystick_get_from_internal_name("4axis_4button");
|
||||||
break;
|
break;
|
||||||
case JS_TYPE_CH_FLIGHTSTICK_PRO:
|
case JS_TYPE_CH_FLIGHTSTICK_PRO:
|
||||||
joystick_type = joystick_get_from_internal_name("ch_flightstick_pro");
|
joystick_type[joy_insn] = joystick_get_from_internal_name("ch_flightstick_pro");
|
||||||
break;
|
break;
|
||||||
case JS_TYPE_SIDEWINDER_PAD:
|
case JS_TYPE_SIDEWINDER_PAD:
|
||||||
joystick_type = joystick_get_from_internal_name("sidewinder_pad");
|
joystick_type[joy_insn] = joystick_get_from_internal_name("sidewinder_pad");
|
||||||
break;
|
break;
|
||||||
case JS_TYPE_THRUSTMASTER_FCS:
|
case JS_TYPE_THRUSTMASTER_FCS:
|
||||||
joystick_type = joystick_get_from_internal_name("thrustmaster_fcs");
|
joystick_type[joy_insn] = joystick_get_from_internal_name("thrustmaster_fcs");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
joystick_type = JS_TYPE_NONE;
|
joystick_type[joy_insn] = JS_TYPE_NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
joystick_type = JS_TYPE_NONE;
|
joystick_type[joy_insn] = JS_TYPE_NONE;
|
||||||
|
|
||||||
for (int js = 0; js < joystick_get_max_joysticks(joystick_type); js++) {
|
for (int js = 0; js < joystick_get_max_joysticks(joystick_type[joy_insn]); js++) {
|
||||||
sprintf(temp, "joystick_%i_nr", js);
|
sprintf(temp, "joystick_%i_nr", js);
|
||||||
joystick_state[0][js].plat_joystick_nr = ini_section_get_int(cat, temp, 0);
|
joystick_state[0][js].plat_joystick_nr = ini_section_get_int(cat, temp, 0);
|
||||||
|
|
||||||
if (joystick_state[0][js].plat_joystick_nr) {
|
if (joystick_state[0][js].plat_joystick_nr) {
|
||||||
for (int axis_nr = 0; axis_nr < joystick_get_axis_count(joystick_type); axis_nr++) {
|
for (int axis_nr = 0; axis_nr < joystick_get_axis_count(joystick_type[joy_insn]); axis_nr++) {
|
||||||
sprintf(temp, "joystick_%i_axis_%i", js, axis_nr);
|
sprintf(temp, "joystick_%i_axis_%i", js, axis_nr);
|
||||||
joystick_state[0][js].axis_mapping[axis_nr] = ini_section_get_int(cat, temp, axis_nr);
|
joystick_state[0][js].axis_mapping[axis_nr] = ini_section_get_int(cat, temp, axis_nr);
|
||||||
}
|
}
|
||||||
for (int button_nr = 0; button_nr < joystick_get_button_count(joystick_type); button_nr++) {
|
for (int button_nr = 0; button_nr < joystick_get_button_count(joystick_type[joy_insn]); button_nr++) {
|
||||||
sprintf(temp, "joystick_%i_button_%i", js, button_nr);
|
sprintf(temp, "joystick_%i_button_%i", js, button_nr);
|
||||||
joystick_state[0][js].button_mapping[button_nr] = ini_section_get_int(cat, temp, button_nr);
|
joystick_state[0][js].button_mapping[button_nr] = ini_section_get_int(cat, temp, button_nr);
|
||||||
}
|
}
|
||||||
for (int pov_nr = 0; pov_nr < joystick_get_pov_count(joystick_type); pov_nr++) {
|
for (int pov_nr = 0; pov_nr < joystick_get_pov_count(joystick_type[joy_insn]); pov_nr++) {
|
||||||
sprintf(temp, "joystick_%i_pov_%i", js, pov_nr);
|
sprintf(temp, "joystick_%i_pov_%i", js, pov_nr);
|
||||||
p = ini_section_get_string(cat, temp, "0, 0");
|
p = ini_section_get_string(cat, temp, "0, 0");
|
||||||
joystick_state[0][js].pov_mapping[pov_nr][0] = joystick_state[0][js].pov_mapping[pov_nr][1] = 0;
|
joystick_state[0][js].pov_mapping[pov_nr][0] = joystick_state[0][js].pov_mapping[pov_nr][1] = 0;
|
||||||
@@ -2552,7 +2553,8 @@ save_input_devices(void)
|
|||||||
|
|
||||||
ini_section_set_string(cat, "mouse_type", mouse_get_internal_name(mouse_type));
|
ini_section_set_string(cat, "mouse_type", mouse_get_internal_name(mouse_type));
|
||||||
|
|
||||||
if (!joystick_type) {
|
uint8_t joy_insn = 0;
|
||||||
|
if (!joystick_type[joy_insn]) {
|
||||||
ini_section_delete_var(cat, "joystick_type");
|
ini_section_delete_var(cat, "joystick_type");
|
||||||
|
|
||||||
for (int js = 0; js < MAX_PLAT_JOYSTICKS; js++) {
|
for (int js = 0; js < MAX_PLAT_JOYSTICKS; js++) {
|
||||||
@@ -2573,22 +2575,22 @@ save_input_devices(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ini_section_set_string(cat, "joystick_type", joystick_get_internal_name(joystick_type));
|
ini_section_set_string(cat, "joystick_type", joystick_get_internal_name(joystick_type[joy_insn]));
|
||||||
|
|
||||||
for (int js = 0; js < joystick_get_max_joysticks(joystick_type); js++) {
|
for (int js = 0; js < joystick_get_max_joysticks(joystick_type[joy_insn]); js++) {
|
||||||
sprintf(tmp2, "joystick_%i_nr", js);
|
sprintf(tmp2, "joystick_%i_nr", js);
|
||||||
ini_section_set_int(cat, tmp2, joystick_state[0][js].plat_joystick_nr);
|
ini_section_set_int(cat, tmp2, joystick_state[0][js].plat_joystick_nr);
|
||||||
|
|
||||||
if (joystick_state[0][js].plat_joystick_nr) {
|
if (joystick_state[0][js].plat_joystick_nr) {
|
||||||
for (int axis_nr = 0; axis_nr < joystick_get_axis_count(joystick_type); axis_nr++) {
|
for (int axis_nr = 0; axis_nr < joystick_get_axis_count(joystick_type[joy_insn]); axis_nr++) {
|
||||||
sprintf(tmp2, "joystick_%i_axis_%i", js, axis_nr);
|
sprintf(tmp2, "joystick_%i_axis_%i", js, axis_nr);
|
||||||
ini_section_set_int(cat, tmp2, joystick_state[0][js].axis_mapping[axis_nr]);
|
ini_section_set_int(cat, tmp2, joystick_state[0][js].axis_mapping[axis_nr]);
|
||||||
}
|
}
|
||||||
for (int button_nr = 0; button_nr < joystick_get_button_count(joystick_type); button_nr++) {
|
for (int button_nr = 0; button_nr < joystick_get_button_count(joystick_type[joy_insn]); button_nr++) {
|
||||||
sprintf(tmp2, "joystick_%i_button_%i", js, button_nr);
|
sprintf(tmp2, "joystick_%i_button_%i", js, button_nr);
|
||||||
ini_section_set_int(cat, tmp2, joystick_state[0][js].button_mapping[button_nr]);
|
ini_section_set_int(cat, tmp2, joystick_state[0][js].button_mapping[button_nr]);
|
||||||
}
|
}
|
||||||
for (int pov_nr = 0; pov_nr < joystick_get_pov_count(joystick_type); pov_nr++) {
|
for (int pov_nr = 0; pov_nr < joystick_get_pov_count(joystick_type[joy_insn]); pov_nr++) {
|
||||||
sprintf(tmp2, "joystick_%i_pov_%i", js, pov_nr);
|
sprintf(tmp2, "joystick_%i_pov_%i", js, pov_nr);
|
||||||
sprintf(temp, "%i, %i", joystick_state[0][js].pov_mapping[pov_nr][0],
|
sprintf(temp, "%i, %i", joystick_state[0][js].pov_mapping[pov_nr][0],
|
||||||
joystick_state[0][js].pov_mapping[pov_nr][1]);
|
joystick_state[0][js].pov_mapping[pov_nr][1]);
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ typedef struct _joystick_instance_ {
|
|||||||
void *dat;
|
void *dat;
|
||||||
} joystick_instance_t;
|
} joystick_instance_t;
|
||||||
|
|
||||||
int joystick_type = JS_TYPE_NONE;
|
int joystick_type[GAMEPORT_MAX] = { JS_TYPE_NONE, JS_TYPE_NONE };
|
||||||
|
|
||||||
static const joystick_t joystick_none = {
|
static const joystick_t joystick_none = {
|
||||||
.name = "None",
|
.name = "None",
|
||||||
@@ -299,17 +299,17 @@ timer_over(void *priv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gameport_update_joystick_type(void)
|
gameport_update_joystick_type(uint8_t gp)
|
||||||
{
|
{
|
||||||
/* Add a standalone game port if a joystick is enabled but no other game ports exist. */
|
/* Add a standalone game port if a joystick is enabled but no other game ports exist. */
|
||||||
if (standalone_gameport_type)
|
if (standalone_gameport_type)
|
||||||
gameport_add(standalone_gameport_type);
|
gameport_add(standalone_gameport_type);
|
||||||
|
|
||||||
/* Reset the joystick interface. */
|
/* Reset the joystick interface. */
|
||||||
if (joystick_instance[0]) {
|
if (joystick_instance[gp]) {
|
||||||
joystick_instance[0]->intf->close(joystick_instance[0]->dat);
|
joystick_instance[gp]->intf->close(joystick_instance[gp]->dat);
|
||||||
joystick_instance[0]->intf = joysticks[joystick_type].joystick;
|
joystick_instance[gp]->intf = joysticks[joystick_type[gp]].joystick;
|
||||||
joystick_instance[0]->dat = joystick_instance[0]->intf->init();
|
joystick_instance[gp]->dat = joystick_instance[gp]->intf->init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -393,24 +393,27 @@ gameport_init(const device_t *info)
|
|||||||
{
|
{
|
||||||
gameport_t *dev = calloc(1, sizeof(gameport_t));
|
gameport_t *dev = calloc(1, sizeof(gameport_t));
|
||||||
|
|
||||||
|
// TODO: Later we'll actually support more than one gameport
|
||||||
|
uint8_t joy_insn = 0;
|
||||||
|
|
||||||
/* Allocate global instance. */
|
/* Allocate global instance. */
|
||||||
if (!joystick_instance[0] && joystick_type) {
|
if (!joystick_instance[joy_insn] && joystick_type[joy_insn]) {
|
||||||
joystick_instance[0] = calloc(1, sizeof(joystick_instance_t));
|
joystick_instance[joy_insn] = calloc(1, sizeof(joystick_instance_t));
|
||||||
|
|
||||||
// For each analog joystick axis
|
// For each analog joystick axis
|
||||||
for (uint8_t i = 0; i < 4; i++) {
|
for (uint8_t i = 0; i < 4; i++) {
|
||||||
joystick_instance[0]->axis[i].joystick = joystick_instance[0];
|
joystick_instance[joy_insn]->axis[i].joystick = joystick_instance[joy_insn];
|
||||||
|
|
||||||
joystick_instance[0]->axis[i].axis_nr = i;
|
joystick_instance[joy_insn]->axis[i].axis_nr = i;
|
||||||
|
|
||||||
timer_add(&joystick_instance[0]->axis[i].timer, timer_over, &joystick_instance[0]->axis[i], 0);
|
timer_add(&joystick_instance[joy_insn]->axis[i].timer, timer_over, &joystick_instance[joy_insn]->axis[i], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
joystick_instance[0]->intf = joysticks[joystick_type].joystick;
|
joystick_instance[joy_insn]->intf = joysticks[joystick_type[joy_insn]].joystick;
|
||||||
joystick_instance[0]->dat = joystick_instance[0]->intf->init();
|
joystick_instance[joy_insn]->dat = joystick_instance[joy_insn]->intf->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->joystick = joystick_instance[0];
|
dev->joystick = joystick_instance[joy_insn];
|
||||||
|
|
||||||
/* Map game port to the default address. Not applicable on PnP-only ports. */
|
/* Map game port to the default address. Not applicable on PnP-only ports. */
|
||||||
dev->len = (info->local >> 16) & 0xff;
|
dev->len = (info->local >> 16) & 0xff;
|
||||||
@@ -475,15 +478,18 @@ gameport_close(void *priv)
|
|||||||
{
|
{
|
||||||
gameport_t *dev = (gameport_t *) priv;
|
gameport_t *dev = (gameport_t *) priv;
|
||||||
|
|
||||||
|
// TODO: Later we'll actually support more than one gameport
|
||||||
|
uint8_t joy_insn = 0;
|
||||||
|
|
||||||
/* If this port was active, remove it from the active ports list. */
|
/* If this port was active, remove it from the active ports list. */
|
||||||
gameport_remap(dev, 0);
|
gameport_remap(dev, 0);
|
||||||
|
|
||||||
/* Free the global instance here, if it wasn't already freed. */
|
/* Free the global instance here, if it wasn't already freed. */
|
||||||
if (joystick_instance[0]) {
|
if (joystick_instance[joy_insn]) {
|
||||||
joystick_instance[0]->intf->close(joystick_instance[0]->dat);
|
joystick_instance[joy_insn]->intf->close(joystick_instance[joy_insn]->dat);
|
||||||
|
|
||||||
free(joystick_instance[0]);
|
free(joystick_instance[joy_insn]);
|
||||||
joystick_instance[0] = NULL;
|
joystick_instance[joy_insn] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(dev);
|
free(dev);
|
||||||
@@ -793,7 +799,7 @@ gameport_available(int port)
|
|||||||
|
|
||||||
/* UI */
|
/* UI */
|
||||||
const device_t *
|
const device_t *
|
||||||
gameport_getdevice(int port)
|
gameport_get_device(int port)
|
||||||
{
|
{
|
||||||
return (gameports[port].device);
|
return (gameports[port].device);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ extern "C" {
|
|||||||
|
|
||||||
extern int gameport_available(int port);
|
extern int gameport_available(int port);
|
||||||
#ifdef EMU_DEVICE_H
|
#ifdef EMU_DEVICE_H
|
||||||
extern const device_t *gameport_getdevice(int port);
|
extern const device_t *gameport_get_device(int port);
|
||||||
#endif
|
#endif
|
||||||
extern int gameport_has_config(int port);
|
extern int gameport_has_config(int port);
|
||||||
extern const char *gameport_get_internal_name(int port);
|
extern const char *gameport_get_internal_name(int port);
|
||||||
@@ -151,11 +151,11 @@ extern plat_joystick_state_t plat_joystick_state[MAX_PLAT_JOYSTICKS];
|
|||||||
extern joystick_state_t joystick_state[GAMEPORT_MAX][MAX_JOYSTICKS];
|
extern joystick_state_t joystick_state[GAMEPORT_MAX][MAX_JOYSTICKS];
|
||||||
extern int joysticks_present;
|
extern int joysticks_present;
|
||||||
|
|
||||||
extern int joystick_type;
|
extern int joystick_type[GAMEPORT_MAX];
|
||||||
|
|
||||||
extern void joystick_init(void);
|
extern void joystick_init(void);
|
||||||
extern void joystick_close(void);
|
extern void joystick_close(void);
|
||||||
extern void joystick_process(void);
|
extern void joystick_process(uint8_t gp);
|
||||||
|
|
||||||
extern const char *joystick_get_name(int js);
|
extern const char *joystick_get_name(int js);
|
||||||
extern const char *joystick_get_internal_name(int js);
|
extern const char *joystick_get_internal_name(int js);
|
||||||
@@ -168,7 +168,7 @@ extern const char *joystick_get_axis_name(int js, int id);
|
|||||||
extern const char *joystick_get_button_name(int js, int id);
|
extern const char *joystick_get_button_name(int js, int id);
|
||||||
extern const char *joystick_get_pov_name(int js, int id);
|
extern const char *joystick_get_pov_name(int js, int id);
|
||||||
|
|
||||||
extern void gameport_update_joystick_type(void);
|
extern void gameport_update_joystick_type(uint8_t gp);
|
||||||
extern void gameport_remap(void *priv, uint16_t address);
|
extern void gameport_remap(void *priv, uint16_t address);
|
||||||
extern void *gameport_add(const device_t *gameport_type);
|
extern void *gameport_add(const device_t *gameport_type);
|
||||||
|
|
||||||
|
|||||||
@@ -625,7 +625,7 @@ europc_boot(UNUSED(const device_t *info))
|
|||||||
mouse_bus_set_irq(sys->mouse, 2);
|
mouse_bus_set_irq(sys->mouse, 2);
|
||||||
/* Configure the port for (Bus Mouse Compatible) Mouse. */
|
/* Configure the port for (Bus Mouse Compatible) Mouse. */
|
||||||
b |= 0x01;
|
b |= 0x01;
|
||||||
} else if (joystick_type)
|
} else if (joystick_type[0])
|
||||||
b |= 0x02; /* enable port as joysticks */
|
b |= 0x02; /* enable port as joysticks */
|
||||||
sys->nvr.regs[MRTC_CONF_C] = b;
|
sys->nvr.regs[MRTC_CONF_C] = b;
|
||||||
|
|
||||||
|
|||||||
@@ -2397,7 +2397,7 @@ machine_xt_m240_init(const machine_t *model)
|
|||||||
if (fdc_current[0] == FDC_INTERNAL)
|
if (fdc_current[0] == FDC_INTERNAL)
|
||||||
device_add(&fdc_at_device); /* io.c logs clearly show it using port 3F7 */
|
device_add(&fdc_at_device); /* io.c logs clearly show it using port 3F7 */
|
||||||
|
|
||||||
if (joystick_type)
|
if (joystick_type[0])
|
||||||
device_add(&gameport_200_device);
|
device_add(&gameport_200_device);
|
||||||
|
|
||||||
nmi_init();
|
nmi_init();
|
||||||
|
|||||||
@@ -27,10 +27,11 @@ extern "C" {
|
|||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include "qt_models_common.hpp"
|
#include "qt_models_common.hpp"
|
||||||
|
|
||||||
JoystickConfiguration::JoystickConfiguration(int type, int joystick_nr, QWidget *parent)
|
JoystickConfiguration::JoystickConfiguration(int type, uint8_t gameport_nr, int joystick_nr, QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, ui(new Ui::JoystickConfiguration)
|
, ui(new Ui::JoystickConfiguration)
|
||||||
, type(type)
|
, type(type)
|
||||||
|
, gameport_nr(gameport_nr)
|
||||||
, joystick_nr(joystick_nr)
|
, joystick_nr(joystick_nr)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@@ -41,7 +42,7 @@ JoystickConfiguration::JoystickConfiguration(int type, int joystick_nr, QWidget
|
|||||||
Models::AddEntry(model, plat_joystick_state[c].name, c + 1);
|
Models::AddEntry(model, plat_joystick_state[c].name, c + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->comboBoxDevice->setCurrentIndex(joystick_state[0][joystick_nr].plat_joystick_nr);
|
ui->comboBoxDevice->setCurrentIndex(joystick_state[gameport_nr][joystick_nr].plat_joystick_nr);
|
||||||
layout()->setSizeConstraint(QLayout::SetFixedSize);
|
layout()->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +120,7 @@ JoystickConfiguration::on_comboBoxDevice_currentIndexChanged(int index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int nr_axes = plat_joystick_state[joystick].nr_axes;
|
int nr_axes = plat_joystick_state[joystick].nr_axes;
|
||||||
int mapping = joystick_state[0][joystick_nr].axis_mapping[c];
|
int mapping = joystick_state[gameport_nr][joystick_nr].axis_mapping[c];
|
||||||
if (mapping & POV_X)
|
if (mapping & POV_X)
|
||||||
cbox->setCurrentIndex(nr_axes + (mapping & 3) * 2);
|
cbox->setCurrentIndex(nr_axes + (mapping & 3) * 2);
|
||||||
else if (mapping & POV_Y)
|
else if (mapping & POV_Y)
|
||||||
@@ -147,7 +148,7 @@ JoystickConfiguration::on_comboBoxDevice_currentIndexChanged(int index)
|
|||||||
Models::AddEntry(model, plat_joystick_state[joystick].button[d].name, 0);
|
Models::AddEntry(model, plat_joystick_state[joystick].button[d].name, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbox->setCurrentIndex(joystick_state[0][joystick_nr].button_mapping[c]);
|
cbox->setCurrentIndex(joystick_state[gameport_nr][joystick_nr].button_mapping[c]);
|
||||||
|
|
||||||
ui->ct->addWidget(label, row, 0);
|
ui->ct->addWidget(label, row, 0);
|
||||||
ui->ct->addWidget(cbox, row, 1);
|
ui->ct->addWidget(cbox, row, 1);
|
||||||
@@ -179,7 +180,7 @@ JoystickConfiguration::on_comboBoxDevice_currentIndexChanged(int index)
|
|||||||
Models::AddEntry(model, plat_joystick_state[joystick].axis[d].name, 0);
|
Models::AddEntry(model, plat_joystick_state[joystick].axis[d].name, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int mapping = joystick_state[0][joystick_nr].pov_mapping[c / 2][c & 1];
|
int mapping = joystick_state[gameport_nr][joystick_nr].pov_mapping[c / 2][c & 1];
|
||||||
int nr_povs = plat_joystick_state[joystick].nr_povs;
|
int nr_povs = plat_joystick_state[joystick].nr_povs;
|
||||||
if (mapping & POV_X)
|
if (mapping & POV_X)
|
||||||
cbox->setCurrentIndex((mapping & 3) * 2);
|
cbox->setCurrentIndex((mapping & 3) * 2);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class JoystickConfiguration : public QDialog {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit JoystickConfiguration(int type, int joystick_nr, QWidget *parent = nullptr);
|
explicit JoystickConfiguration(int type, uint8_t gameport_nr, int joystick_nr, QWidget *parent = nullptr);
|
||||||
~JoystickConfiguration();
|
~JoystickConfiguration();
|
||||||
|
|
||||||
int selectedDevice();
|
int selectedDevice();
|
||||||
@@ -25,6 +25,7 @@ private:
|
|||||||
Ui::JoystickConfiguration *ui;
|
Ui::JoystickConfiguration *ui;
|
||||||
QList<QWidget *> widgets;
|
QList<QWidget *> widgets;
|
||||||
int type;
|
int type;
|
||||||
|
int gameport_nr;
|
||||||
int joystick_nr;
|
int joystick_nr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
*
|
*
|
||||||
* Mouse/Joystick configuration UI module.
|
* Mouse/Joystick configuration UI module.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
* Authors: Joakim L. Gilje <jgilje@jgilje.net>
|
* Authors: Joakim L. Gilje <jgilje@jgilje.net>
|
||||||
*
|
*
|
||||||
* Copyright 2021 Joakim L. Gilje
|
* Copyright 2021 Joakim L. Gilje
|
||||||
@@ -95,7 +93,7 @@ SettingsInput::save()
|
|||||||
keyboard_type = ui->comboBoxKeyboard->currentData().toInt();
|
keyboard_type = ui->comboBoxKeyboard->currentData().toInt();
|
||||||
mouse_type = ui->comboBoxMouse->currentData().toInt();
|
mouse_type = ui->comboBoxMouse->currentData().toInt();
|
||||||
|
|
||||||
joystick_type = ui->comboBoxJoystick->currentData().toInt();
|
joystick_type[0] = ui->comboBoxJoystick0->currentData().toInt();
|
||||||
|
|
||||||
// Copy accelerators from working set to global set
|
// Copy accelerators from working set to global set
|
||||||
for(int x = 0; x < NUM_ACCELS; x++) {
|
for(int x = 0; x < NUM_ACCELS; x++) {
|
||||||
@@ -179,21 +177,22 @@ SettingsInput::onCurrentMachineChanged(int machineId)
|
|||||||
ui->comboBoxMouse->setCurrentIndex(-1);
|
ui->comboBoxMouse->setCurrentIndex(-1);
|
||||||
ui->comboBoxMouse->setCurrentIndex(selectedRow);
|
ui->comboBoxMouse->setCurrentIndex(selectedRow);
|
||||||
|
|
||||||
|
// Joysticks
|
||||||
int i = 0;
|
int i = 0;
|
||||||
const char *joyName = joystick_get_name(i);
|
const char *joyName = joystick_get_name(i);
|
||||||
auto *joystickModel = ui->comboBoxJoystick->model();
|
auto *joystickModel = ui->comboBoxJoystick0->model();
|
||||||
removeRows = joystickModel->rowCount();
|
removeRows = joystickModel->rowCount();
|
||||||
selectedRow = 0;
|
selectedRow = 0;
|
||||||
while (joyName) {
|
while (joyName) {
|
||||||
int row = Models::AddEntry(joystickModel, tr(joyName).toUtf8().data(), i);
|
int row = Models::AddEntry(joystickModel, tr(joyName).toUtf8().data(), i);
|
||||||
if (i == joystick_type)
|
if (i == joystick_type[0])
|
||||||
selectedRow = row - removeRows;
|
selectedRow = row - removeRows;
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
joyName = joystick_get_name(i);
|
joyName = joystick_get_name(i);
|
||||||
}
|
}
|
||||||
joystickModel->removeRows(0, removeRows);
|
joystickModel->removeRows(0, removeRows);
|
||||||
ui->comboBoxJoystick->setCurrentIndex(selectedRow);
|
ui->comboBoxJoystick0->setCurrentIndex(selectedRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -309,11 +308,11 @@ SettingsInput::on_comboBoxMouse_currentIndexChanged(int index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsInput::on_comboBoxJoystick_currentIndexChanged(int index)
|
SettingsInput::on_comboBoxJoystick0_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
int joystickId = ui->comboBoxJoystick->currentData().toInt();
|
int joystickId = ui->comboBoxJoystick0->currentData().toInt();
|
||||||
for (int i = 0; i < MAX_JOYSTICKS; ++i) {
|
for (int i = 0; i < MAX_JOYSTICKS; ++i) {
|
||||||
auto *btn = findChild<QPushButton *>(QString("pushButtonJoystick%1").arg(i + 1));
|
auto *btn = findChild<QPushButton *>(QString("pushButtonJoystick0%1").arg(i + 1));
|
||||||
if (btn == nullptr)
|
if (btn == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -336,10 +335,10 @@ SettingsInput::on_pushButtonConfigureMouse_clicked()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get_axis(JoystickConfiguration &jc, int axis, int joystick_nr)
|
get_axis(JoystickConfiguration &jc, int axis, uint8_t gameport_nr, int joystick_nr)
|
||||||
{
|
{
|
||||||
int axis_sel = jc.selectedAxis(axis);
|
int axis_sel = jc.selectedAxis(axis);
|
||||||
int nr_axes = plat_joystick_state[joystick_state[0][joystick_nr].plat_joystick_nr - 1].nr_axes;
|
int nr_axes = plat_joystick_state[joystick_state[gameport_nr][joystick_nr].plat_joystick_nr - 1].nr_axes;
|
||||||
|
|
||||||
if (axis_sel < nr_axes)
|
if (axis_sel < nr_axes)
|
||||||
return axis_sel;
|
return axis_sel;
|
||||||
@@ -352,10 +351,10 @@ get_axis(JoystickConfiguration &jc, int axis, int joystick_nr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
get_pov(JoystickConfiguration &jc, int pov, int joystick_nr)
|
get_pov(JoystickConfiguration &jc, int pov, uint8_t gameport_nr, int joystick_nr)
|
||||||
{
|
{
|
||||||
int pov_sel = jc.selectedPov(pov);
|
int pov_sel = jc.selectedPov(pov);
|
||||||
int nr_povs = plat_joystick_state[joystick_state[0][joystick_nr].plat_joystick_nr - 1].nr_povs * 2;
|
int nr_povs = plat_joystick_state[joystick_state[gameport_nr][joystick_nr].plat_joystick_nr - 1].nr_povs * 2;
|
||||||
|
|
||||||
if (pov_sel < nr_povs) {
|
if (pov_sel < nr_povs) {
|
||||||
if (pov_sel & 1)
|
if (pov_sel & 1)
|
||||||
@@ -368,9 +367,9 @@ get_pov(JoystickConfiguration &jc, int pov, int joystick_nr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
updateJoystickConfig(int type, int joystick_nr, QWidget *parent)
|
updateJoystickConfig(int type, uint8_t gameport_nr, int joystick_nr, QWidget *parent)
|
||||||
{
|
{
|
||||||
JoystickConfiguration jc(type, joystick_nr, parent);
|
JoystickConfiguration jc(type, gameport_nr, joystick_nr, parent);
|
||||||
switch (jc.exec()) {
|
switch (jc.exec()) {
|
||||||
case QDialog::Rejected:
|
case QDialog::Rejected:
|
||||||
return;
|
return;
|
||||||
@@ -378,43 +377,43 @@ updateJoystickConfig(int type, int joystick_nr, QWidget *parent)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
joystick_state[0][joystick_nr].plat_joystick_nr = jc.selectedDevice();
|
joystick_state[gameport_nr][joystick_nr].plat_joystick_nr = jc.selectedDevice();
|
||||||
if (joystick_state[0][joystick_nr].plat_joystick_nr) {
|
if (joystick_state[gameport_nr][joystick_nr].plat_joystick_nr) {
|
||||||
for (int axis_nr = 0; axis_nr < joystick_get_axis_count(type); axis_nr++) {
|
for (int axis_nr = 0; axis_nr < joystick_get_axis_count(type); axis_nr++) {
|
||||||
joystick_state[0][joystick_nr].axis_mapping[axis_nr] = get_axis(jc, axis_nr, joystick_nr);
|
joystick_state[gameport_nr][joystick_nr].axis_mapping[axis_nr] = get_axis(jc, axis_nr, gameport_nr, joystick_nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int button_nr = 0; button_nr < joystick_get_button_count(type); button_nr++) {
|
for (int button_nr = 0; button_nr < joystick_get_button_count(type); button_nr++) {
|
||||||
joystick_state[0][joystick_nr].button_mapping[button_nr] = jc.selectedButton(button_nr);
|
joystick_state[gameport_nr][joystick_nr].button_mapping[button_nr] = jc.selectedButton(button_nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int pov_nr = 0; pov_nr < joystick_get_pov_count(type) * 2; pov_nr += 2) {
|
for (int pov_nr = 0; pov_nr < joystick_get_pov_count(type) * 2; pov_nr += 2) {
|
||||||
joystick_state[0][joystick_nr].pov_mapping[pov_nr][0] = get_pov(jc, pov_nr, joystick_nr);
|
joystick_state[gameport_nr][joystick_nr].pov_mapping[pov_nr][0] = get_pov(jc, pov_nr, gameport_nr, joystick_nr);
|
||||||
joystick_state[0][joystick_nr].pov_mapping[pov_nr][1] = get_pov(jc, pov_nr + 1, joystick_nr);
|
joystick_state[gameport_nr][joystick_nr].pov_mapping[pov_nr][1] = get_pov(jc, pov_nr + 1, gameport_nr, joystick_nr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsInput::on_pushButtonJoystick1_clicked()
|
SettingsInput::on_pushButtonJoystick01_clicked()
|
||||||
{
|
{
|
||||||
updateJoystickConfig(ui->comboBoxJoystick->currentData().toInt(), 0, this);
|
updateJoystickConfig(ui->comboBoxJoystick0->currentData().toInt(), 0, 0, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsInput::on_pushButtonJoystick2_clicked()
|
SettingsInput::on_pushButtonJoystick02_clicked()
|
||||||
{
|
{
|
||||||
updateJoystickConfig(ui->comboBoxJoystick->currentData().toInt(), 1, this);
|
updateJoystickConfig(ui->comboBoxJoystick0->currentData().toInt(), 0, 1, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsInput::on_pushButtonJoystick3_clicked()
|
SettingsInput::on_pushButtonJoystick03_clicked()
|
||||||
{
|
{
|
||||||
updateJoystickConfig(ui->comboBoxJoystick->currentData().toInt(), 2, this);
|
updateJoystickConfig(ui->comboBoxJoystick0->currentData().toInt(), 0, 2, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsInput::on_pushButtonJoystick4_clicked()
|
SettingsInput::on_pushButtonJoystick04_clicked()
|
||||||
{
|
{
|
||||||
updateJoystickConfig(ui->comboBoxJoystick->currentData().toInt(), 3, this);
|
updateJoystickConfig(ui->comboBoxJoystick0->currentData().toInt(), 0, 3, this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ private slots:
|
|||||||
void on_comboBoxMouse_currentIndexChanged(int index);
|
void on_comboBoxMouse_currentIndexChanged(int index);
|
||||||
void on_pushButtonConfigureMouse_clicked();
|
void on_pushButtonConfigureMouse_clicked();
|
||||||
|
|
||||||
void on_comboBoxJoystick_currentIndexChanged(int index);
|
void on_comboBoxJoystick0_currentIndexChanged(int index);
|
||||||
void on_pushButtonJoystick1_clicked();
|
void on_pushButtonJoystick01_clicked();
|
||||||
void on_pushButtonJoystick2_clicked();
|
void on_pushButtonJoystick02_clicked();
|
||||||
void on_pushButtonJoystick3_clicked();
|
void on_pushButtonJoystick03_clicked();
|
||||||
void on_pushButtonJoystick4_clicked();
|
void on_pushButtonJoystick04_clicked();
|
||||||
|
|
||||||
void on_tableKeys_cellDoubleClicked(int row, int col);
|
void on_tableKeys_cellDoubleClicked(int row, int col);
|
||||||
void on_tableKeys_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn);
|
void on_tableKeys_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn);
|
||||||
|
|||||||
@@ -90,42 +90,42 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="labelJoystick">
|
<widget class="QLabel" name="labelJoystick0">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Joystick:</string>
|
<string>Joystick:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1" colspan="2">
|
<item row="2" column="1" colspan="2">
|
||||||
<widget class="QComboBox" name="comboBoxJoystick">
|
<widget class="QComboBox" name="comboBoxJoystick0">
|
||||||
<property name="maxVisibleItems">
|
<property name="maxVisibleItems">
|
||||||
<number>30</number>
|
<number>30</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QPushButton" name="pushButtonJoystick1">
|
<widget class="QPushButton" name="pushButtonJoystick01">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Joystick 1...</string>
|
<string>Joystick 1...</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QPushButton" name="pushButtonJoystick2">
|
<widget class="QPushButton" name="pushButtonJoystick02">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Joystick 2...</string>
|
<string>Joystick 2...</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="2">
|
<item row="3" column="2">
|
||||||
<widget class="QPushButton" name="pushButtonJoystick3">
|
<widget class="QPushButton" name="pushButtonJoystick03">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Joystick 3...</string>
|
<string>Joystick 3...</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="3">
|
<item row="3" column="3">
|
||||||
<widget class="QPushButton" name="pushButtonJoystick4">
|
<widget class="QPushButton" name="pushButtonJoystick04">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Joystick 4...</string>
|
<string>Joystick 4...</string>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ joystick_close(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
joystick_get_axis(int gameport, int joystick_nr, int mapping)
|
joystick_get_axis(int joystick_nr, int mapping)
|
||||||
{
|
{
|
||||||
if (mapping & POV_X) {
|
if (mapping & POV_X) {
|
||||||
switch (plat_joystick_state[joystick_nr].p[mapping & 3]) {
|
switch (plat_joystick_state[joystick_nr].p[mapping & 3]) {
|
||||||
@@ -128,9 +128,9 @@ joystick_get_axis(int gameport, int joystick_nr, int mapping)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
joystick_process(void)
|
joystick_process(uint8_t gp)
|
||||||
{
|
{
|
||||||
if (!joystick_type)
|
if (!joystick_type[gp])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SDL_JoystickUpdate();
|
SDL_JoystickUpdate();
|
||||||
@@ -146,44 +146,44 @@ joystick_process(void)
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
pclog("joystick %i - x=%i y=%i b[0]=%i b[1]=%i %i\n", js,
|
pclog("joystick %i - x=%i y=%i b[0]=%i b[1]=%i %i\n", js,
|
||||||
joystick_state[0][js].x,
|
joystick_state[gp][js].x,
|
||||||
joystick_state[0][js].y,
|
joystick_state[gp][js].y,
|
||||||
joystick_state[0][js].b[0],
|
joystick_state[gp][js].b[0],
|
||||||
joystick_state[0][js].b[1],
|
joystick_state[gp][js].b[1],
|
||||||
joysticks_present);
|
joysticks_present[gp]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int js = 0; js < joystick_get_max_joysticks(joystick_type); js++) {
|
for (int js = 0; js < joystick_get_max_joysticks(joystick_type[gp]); js++) {
|
||||||
if (joystick_state[0][js].plat_joystick_nr) {
|
if (joystick_state[gp][js].plat_joystick_nr) {
|
||||||
int joystick_nr = joystick_state[0][js].plat_joystick_nr - 1;
|
int joystick_nr = joystick_state[gp][js].plat_joystick_nr - 1;
|
||||||
|
|
||||||
for (int axis_nr = 0; axis_nr < joystick_get_axis_count(joystick_type); axis_nr++)
|
for (int axis_nr = 0; axis_nr < joystick_get_axis_count(joystick_type[gp]); axis_nr++)
|
||||||
joystick_state[0][js].axis[axis_nr] = joystick_get_axis(0, joystick_nr, joystick_state[0][js].axis_mapping[axis_nr]);
|
joystick_state[gp][js].axis[axis_nr] = joystick_get_axis(joystick_nr, joystick_state[gp][js].axis_mapping[axis_nr]);
|
||||||
|
|
||||||
for (int button_nr = 0; button_nr < joystick_get_button_count(joystick_type); button_nr++)
|
for (int button_nr = 0; button_nr < joystick_get_button_count(joystick_type[gp]); button_nr++)
|
||||||
joystick_state[0][js].button[button_nr] = plat_joystick_state[joystick_nr].b[joystick_state[0][js].button_mapping[button_nr]];
|
joystick_state[gp][js].button[button_nr] = plat_joystick_state[joystick_nr].b[joystick_state[gp][js].button_mapping[button_nr]];
|
||||||
|
|
||||||
for (int pov_nr = 0; pov_nr < joystick_get_pov_count(joystick_type); pov_nr++) {
|
for (int pov_nr = 0; pov_nr < joystick_get_pov_count(joystick_type[gp]); pov_nr++) {
|
||||||
int x = joystick_get_axis(0, joystick_nr, joystick_state[0][js].pov_mapping[pov_nr][0]);
|
int x = joystick_get_axis(joystick_nr, joystick_state[gp][js].pov_mapping[pov_nr][0]);
|
||||||
int y = joystick_get_axis(0, joystick_nr, joystick_state[0][js].pov_mapping[pov_nr][1]);
|
int y = joystick_get_axis(joystick_nr, joystick_state[gp][js].pov_mapping[pov_nr][1]);
|
||||||
double angle = (atan2((double) y, (double) x) * 360.0) / (2 * M_PI);
|
double angle = (atan2((double) y, (double) x) * 360.0) / (2 * M_PI);
|
||||||
double magnitude = sqrt((double) x * (double) x + (double) y * (double) y);
|
double magnitude = sqrt((double) x * (double) x + (double) y * (double) y);
|
||||||
|
|
||||||
if (magnitude < 16384)
|
if (magnitude < 16384)
|
||||||
joystick_state[0][js].pov[pov_nr] = -1;
|
joystick_state[gp][js].pov[pov_nr] = -1;
|
||||||
else
|
else
|
||||||
joystick_state[0][js].pov[pov_nr] = ((int) angle + 90 + 360) % 360;
|
joystick_state[gp][js].pov[pov_nr] = ((int) angle + 90 + 360) % 360;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int axis_nr = 0; axis_nr < joystick_get_axis_count(joystick_type); axis_nr++)
|
for (int axis_nr = 0; axis_nr < joystick_get_axis_count(joystick_type[gp]); axis_nr++)
|
||||||
joystick_state[0][js].axis[axis_nr] = 0;
|
joystick_state[gp][js].axis[axis_nr] = 0;
|
||||||
|
|
||||||
for (int button_nr = 0; button_nr < joystick_get_button_count(joystick_type); button_nr++)
|
for (int button_nr = 0; button_nr < joystick_get_button_count(joystick_type[gp]); button_nr++)
|
||||||
joystick_state[0][js].button[button_nr] = 0;
|
joystick_state[gp][js].button[button_nr] = 0;
|
||||||
|
|
||||||
for (int pov_nr = 0; pov_nr < joystick_get_pov_count(joystick_type); pov_nr++)
|
for (int pov_nr = 0; pov_nr < joystick_get_pov_count(joystick_type[gp]); pov_nr++)
|
||||||
joystick_state[0][js].pov[pov_nr] = -1;
|
joystick_state[gp][js].pov[pov_nr] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ win_joystick_handle(PRAWINPUT raw)
|
|||||||
|
|
||||||
plat_joystick_state[j].a[axis_nr] = value;
|
plat_joystick_state[j].a[axis_nr] = value;
|
||||||
#if 0
|
#if 0
|
||||||
joystick_log("%s %-06d ", plat_joystick_state[0][j].axis[axis_nr].name, plat_joystick_state[j].a[axis_nr]);
|
joystick_log("%s %-06d ", plat_joystick_state[j].axis[axis_nr].name, plat_joystick_state[j].a[axis_nr]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -476,7 +476,7 @@ win_joystick_handle(PRAWINPUT raw)
|
|||||||
plat_joystick_state[j].p[pov_nr] = value;
|
plat_joystick_state[j].p[pov_nr] = value;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
joystick_log("%s %-3d ", plat_joystick_state[0][j].pov[pov_nr].name, plat_joystick_state[j].p[pov_nr]);
|
joystick_log("%s %-3d ", plat_joystick_state[j].pov[pov_nr].name, plat_joystick_state[j].p[pov_nr]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
@@ -505,41 +505,41 @@ joystick_get_axis(int joystick_nr, int mapping)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
joystick_process(void)
|
joystick_process(uint8_t gp)
|
||||||
{
|
{
|
||||||
if (joystick_type == JS_TYPE_NONE)
|
if (joystick_type[gp] == JS_TYPE_NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int js = 0; js < joystick_get_max_joysticks(joystick_type); js++) {
|
for (int js = 0; js < joystick_get_max_joysticks(joystick_type[gp]); js++) {
|
||||||
if (joystick_state[0][js].plat_joystick_nr) {
|
if (joystick_state[gp][js].plat_joystick_nr) {
|
||||||
int joystick_nr = joystick_state[0][js].plat_joystick_nr - 1;
|
int joystick_nr = joystick_state[gp][js].plat_joystick_nr - 1;
|
||||||
|
|
||||||
for (int axis_nr = 0; axis_nr < joystick_get_axis_count(joystick_type); axis_nr++)
|
for (int axis_nr = 0; axis_nr < joystick_get_axis_count(joystick_type[gp]); axis_nr++)
|
||||||
joystick_state[0][js].axis[axis_nr] = joystick_get_axis(joystick_nr, joystick_state[0][js].axis_mapping[axis_nr]);
|
joystick_state[gp][js].axis[axis_nr] = joystick_get_axis(joystick_nr, joystick_state[gp][js].axis_mapping[axis_nr]);
|
||||||
|
|
||||||
for (int button_nr = 0; button_nr < joystick_get_button_count(joystick_type); button_nr++)
|
for (int button_nr = 0; button_nr < joystick_get_button_count(joystick_type[gp]); button_nr++)
|
||||||
joystick_state[0][js].button[button_nr] = plat_joystick_state[joystick_nr].b[joystick_state[0][js].button_mapping[button_nr]];
|
joystick_state[gp][js].button[button_nr] = plat_joystick_state[joystick_nr].b[joystick_state[gp][js].button_mapping[button_nr]];
|
||||||
|
|
||||||
for (int pov_nr = 0; pov_nr < joystick_get_pov_count(joystick_type); pov_nr++) {
|
for (int pov_nr = 0; pov_nr < joystick_get_pov_count(joystick_type[gp]); pov_nr++) {
|
||||||
int x = joystick_get_axis(joystick_nr, joystick_state[0][js].pov_mapping[pov_nr][0]);
|
int x = joystick_get_axis(joystick_nr, joystick_state[gp][js].pov_mapping[pov_nr][0]);
|
||||||
int y = joystick_get_axis(joystick_nr, joystick_state[0][js].pov_mapping[pov_nr][1]);
|
int y = joystick_get_axis(joystick_nr, joystick_state[gp][js].pov_mapping[pov_nr][1]);
|
||||||
double angle = (atan2((double) y, (double) x) * 360.0) / (2 * M_PI);
|
double angle = (atan2((double) y, (double) x) * 360.0) / (2 * M_PI);
|
||||||
double magnitude = sqrt((double) x * (double) x + (double) y * (double) y);
|
double magnitude = sqrt((double) x * (double) x + (double) y * (double) y);
|
||||||
|
|
||||||
if (magnitude < 16384)
|
if (magnitude < 16384)
|
||||||
joystick_state[0][js].pov[pov_nr] = -1;
|
joystick_state[gp][js].pov[pov_nr] = -1;
|
||||||
else
|
else
|
||||||
joystick_state[0][js].pov[pov_nr] = ((int) angle + 90 + 360) % 360;
|
joystick_state[gp][js].pov[pov_nr] = ((int) angle + 90 + 360) % 360;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int axis_nr = 0; axis_nr < joystick_get_axis_count(joystick_type); axis_nr++)
|
for (int axis_nr = 0; axis_nr < joystick_get_axis_count(joystick_type[gp]); axis_nr++)
|
||||||
joystick_state[0][js].axis[axis_nr] = 0;
|
joystick_state[gp][js].axis[axis_nr] = 0;
|
||||||
|
|
||||||
for (int button_nr = 0; button_nr < joystick_get_button_count(joystick_type); button_nr++)
|
for (int button_nr = 0; button_nr < joystick_get_button_count(joystick_type[gp]); button_nr++)
|
||||||
joystick_state[0][js].button[button_nr] = 0;
|
joystick_state[gp][js].button[button_nr] = 0;
|
||||||
|
|
||||||
for (int pov_nr = 0; pov_nr < joystick_get_pov_count(joystick_type); pov_nr++)
|
for (int pov_nr = 0; pov_nr < joystick_get_pov_count(joystick_type[gp]); pov_nr++)
|
||||||
joystick_state[0][js].pov[pov_nr] = -1;
|
joystick_state[gp][js].pov[pov_nr] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1484,7 +1484,7 @@ joystick_close(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
joystick_process(void)
|
joystick_process(uint8_t gp)
|
||||||
{
|
{
|
||||||
/* No-op. */
|
/* No-op. */
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user