static void select_port_0_device(int data) { printf("--> device index %d\n", data); int port = 0; if (data == 9) { // 9 is currently a hack to indicate the local mouse g_fs_uae_input_ports[port].mode = AMIGA_JOYPORT_MOUSE; g_fs_uae_input_ports[port].new_mode = AMIGA_JOYPORT_MOUSE; strcpy(g_fs_uae_input_ports[port].device, "MOUSE"); amiga_set_joystick_port_mode(port, AMIGA_JOYPORT_MOUSE); // FIXME: not a warning, rather a notification fs_emu_warning(_("Port 0: %s"), _("Mouse")); } else { int count = 0; int new_mode = AMIGA_JOYPORT_DJOY; if (g_fs_uae_amiga_model == MODEL_CD32) { new_mode = AMIGA_JOYPORT_CD32JOY; } fs_emu_input_device *devices = fs_emu_get_input_devices(&count); if (data < count) { g_fs_uae_input_ports[port].mode = new_mode; g_fs_uae_input_ports[port].new_mode = new_mode; uae_strlcpy(g_fs_uae_input_ports[port].device, devices[data].name, sizeof(g_fs_uae_input_ports[port].device)); amiga_set_joystick_port_mode(port, new_mode); // FIXME: not a warning, rather a notification fs_emu_warning(_("Port 0: %s"), devices[data].name); } } fs_uae_reconfigure_input_ports_host(); fs_emu_menu_update_current(); //fs_emu_get_input_devices() //g_fs_uae_input_ports[port].mode = mode; //amiga_set_joystick_port_mode(port, mode); //g_fs_uae_input_ports[port].new_mode = mode; //fs_uae_reconfigure_input_ports_host(); //fs_emu_menu_update_current(); }
void fs_uae_reconfigure_input_ports_host() { fs_emu_log("fs_uae_reconfigure_input_ports_host\n"); fs_emu_reset_input_mapping(); fs_uae_map_keyboard(); int mouse_mapped_to_port = -1; for (int i = 0; i < FS_UAE_NUM_INPUT_PORTS; i++) { fs_uae_input_port *port = g_fs_uae_input_ports + i; fs_log("configuring joystick port %d\n", i); if (port->mode == AMIGA_JOYPORT_NONE) { fs_log("* nothing in port\n"); fs_log("* FIXME\n"); } else if (port->mode == AMIGA_JOYPORT_MOUSE) { fs_log("* amiga mouse\n"); // if (strcmp(port->device, "MOUSE") == 0) { // fs_log("* using host mouse\n"); fs_log("* using device %s\n", port->device); map_mouse(port->device, i); mouse_mapped_to_port = i; // } // else { // fs_log("* not mapping host device to amiga mouse\n"); // } } else if (port->mode == AMIGA_JOYPORT_DJOY) { fs_log("* amiga joystick\n"); if (strcmp(port->device, "MOUSE") == 0) { fs_log("* cannot map mouse to joystick\n"); } else { fs_log("* using device %s\n", port->device); fs_emu_configure_joystick(port->device, "amiga", g_joystick_mappings[i], 1, NULL, 0, true); } } else if (port->mode == AMIGA_JOYPORT_CD32JOY) { fs_log("* amiga cd32 gamepad\n"); if (strcmp(port->device, "MOUSE") == 0) { fs_log("* cannot map mouse to cd32 gamepad\n"); } else { fs_log("* using device %s\n", port->device); fs_emu_configure_joystick(port->device, "cd32", g_joystick_mappings[i], 1, NULL, 0, true); } } } fs_uae_input_port *port0 = g_fs_uae_input_ports; #if 0 int autoswitch = fs_config_get_boolean("joystick_port_0_autoswitch"); if (autoswitch == FS_CONFIG_NONE) { autoswitch = 0; } if (!autoswitch) { if (mouse_mapped_to_port == -1 && port0->mode != AMIGA_JOYPORT_NONE) { // there is a device in port 0, but mouse is not use in either // port fs_log("additionally mapping mouse buttons to port 0\n"); fs_emu_configure_mouse("MOUSE", 0, 0, INPUTEVENT_JOY1_FIRE_BUTTON, 0, INPUTEVENT_JOY1_2ND_BUTTON, 0); } } #endif if (mouse_mapped_to_port == -1 && port0->mode == AMIGA_JOYPORT_DJOY) { fs_log("additionally mapping mouse to port 0\n"); map_mouse("mouse", 0); } #if 0 if (autoswitch && !fs_emu_netplay_enabled()) { // auto-select for other devices when not in netplay mode if (mouse_mapped_to_port == -1) { // FIXME: device "9" is a bit of a hack here, should promote fs_emu_configure_mouse("MOUSE", 0, 0, INPUTEVENT_AMIGA_JOYPORT_0_DEVICE_9, 0, 0, 0); } int count; fs_emu_input_device *input_device = fs_emu_get_input_devices(&count); for (int i = 0; i < count; i++) { //printf("---- %d %s\n", i, input_device->name); //printf("usage: %d\n", input_device->usage); if (input_device->usage) { // this device is used, so we don't want auto-select for this // device input_device++; continue; } if (strcmp(input_device->name, "KEYBOARD") == 0) { continue; } int input_event = INPUTEVENT_AMIGA_JOYPORT_0_DEVICE_0 + i; fs_emu_input_mapping mapping[] = { { "1", input_event }, { NULL, 0 }, }; fs_emu_configure_joystick(input_device->name, "amiga", mapping, 0, NULL, 0); input_device++; }; } #endif fs_emu_map_custom_actions(); }