void snes_set_controller_port_device(bool in_port, unsigned device) { int port = in_port == SNES_PORT_1 ? 0 : 1; switch (device) { case SNES_DEVICE_JOYPAD: S9xSetController(port, CTL_JOYPAD, 0, 0, 0, 0); snes_devices[port] = SNES_DEVICE_JOYPAD; break; case SNES_DEVICE_MULTITAP: S9xSetController(port, CTL_MP5, 1, 2, 3, 4); snes_devices[port] = SNES_DEVICE_MULTITAP; break; case SNES_DEVICE_MOUSE: S9xSetController(port, CTL_MOUSE, 0, 0, 0, 0); snes_devices[port] = SNES_DEVICE_MOUSE; /* mapping pointers here */ S9xMapPointer((BTN_POINTER), S9xGetCommandT("Pointer Mouse1+Superscope+Justifier1")); S9xMapPointer((BTN_POINTER2), S9xGetCommandT("Pointer Mouse2")); /* mapping extra buttons here */ MAP_BUTTON(MAKE_BUTTON(PAD_1, BTN_SELECT), "Mouse1 L"); MAP_BUTTON(MAKE_BUTTON(PAD_1, BTN_START), "Mouse1 R"); MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_SELECT), "Mouse2 L"); MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_START), "Mouse2 R"); break; case SNES_DEVICE_SUPER_SCOPE: S9xSetController(port, CTL_SUPERSCOPE, 0, 0, 0, 0); snes_devices[port] = SNES_DEVICE_SUPER_SCOPE; /* mapping pointers here */ S9xMapPointer((BTN_POINTER), S9xGetCommandT("Pointer Mouse1+Superscope+Justifier1")); S9xMapPointer((BTN_POINTER2), S9xGetCommandT("Pointer Mouse2")); /* mapping extra buttons here */ MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_SELECT), "Superscope Fire"); MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_START), "Superscope Cursor"); MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_UP), "Superscope ToggleTurbo"); MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_DOWN), "Superscope Pause"); break; case SNES_DEVICE_JUSTIFIER: S9xSetController(port, CTL_JUSTIFIER, 0, 0, 0, 0); snes_devices[port] = SNES_DEVICE_JUSTIFIER; /* mapping extra buttons here */ MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_SELECT), "Justifier1 Trigger"); MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_START), "Justifier1 Start"); break; case SNES_DEVICE_JUSTIFIERS: S9xSetController(port, CTL_JUSTIFIER, 1, 0, 0, 0); snes_devices[port] = SNES_DEVICE_JUSTIFIERS; break; default: fprintf(stderr, "[libsnes]: Invalid device!\n"); } }
void Snes9xConfig::rebind_keys (void) { s9xcommand_t cmd; char buf[256]; S9xUnmapAllControls (); for (int joypad_i = 0; joypad_i < NUM_JOYPADS; joypad_i++ ) { Binding *bin = (Binding *) &pad[joypad_i]; for (int button_i = 0; button_i < NUM_JOYPAD_LINKS; button_i++) { snprintf (buf, 256, "Joypad%d %s", (joypad_i % 5) + 1, b_links[button_i].snes9x_name); cmd = S9xGetPortCommandT (buf); S9xMapButton (bin[button_i].base_hex (), cmd, FALSE); } } for (int i = NUM_JOYPAD_LINKS; b_links[i].snes9x_name; i++) { snprintf (buf, 256, "%s", b_links[i].snes9x_name); cmd = S9xGetPortCommandT (buf); S9xMapButton (shortcut[i - NUM_JOYPAD_LINKS].base_hex (), cmd, FALSE); } cmd = S9xGetPortCommandT ("Pointer Mouse1+Superscope+Justifier1"); S9xMapPointer (BINDING_MOUSE_POINTER, cmd, TRUE); cmd = S9xGetPortCommandT ("{Mouse1 L,Superscope Fire,Justifier1 Trigger}"); S9xMapButton (BINDING_MOUSE_BUTTON0, cmd, FALSE); cmd = S9xGetPortCommandT ("{Justifier1 AimOffscreen Trigger,Superscope AimOffscreen}"); S9xMapButton (BINDING_MOUSE_BUTTON1, cmd, FALSE); cmd = S9xGetPortCommandT ("{Mouse1 R,Superscope Cursor,Justifier1 Start}"); S9xMapButton (BINDING_MOUSE_BUTTON2, cmd, FALSE); return; }
void retro_set_controller_port_device(unsigned in_port, unsigned device) { int port = in_port; switch (device) { case RETRO_DEVICE_JOYPAD: retro_devices[port] = RETRO_DEVICE_JOYPAD; S9xSetController(port, CTL_JOYPAD, port, 0, 0, 0); break; case RETRO_DEVICE_JOYPAD_MULTITAP: retro_devices[port] = RETRO_DEVICE_JOYPAD_MULTITAP; S9xSetController(port, CTL_MP5, port+0, port+2, port+4, port+6); break; case RETRO_DEVICE_MOUSE: retro_devices[port] = RETRO_DEVICE_MOUSE; S9xSetController(port, CTL_MOUSE, 0, 0, 0, 0); /* mapping pointers here */ S9xMapPointer((BTN_POINTER), S9xGetCommandT("Pointer Mouse1+Superscope+Justifier1")); S9xMapPointer((BTN_POINTER2), S9xGetCommandT("Pointer Mouse2")); /* mapping extra buttons here */ LR_MAP_BUTTON(MAKE_BUTTON(1, RETRO_DEVICE_ID_JOYPAD_SELECT), "Mouse1 L"); LR_MAP_BUTTON(MAKE_BUTTON(1, RETRO_DEVICE_ID_JOYPAD_START), "Mouse1 R"); LR_MAP_BUTTON(MAKE_BUTTON(2, RETRO_DEVICE_ID_JOYPAD_SELECT), "Mouse2 L"); LR_MAP_BUTTON(MAKE_BUTTON(2, RETRO_DEVICE_ID_JOYPAD_START), "Mouse2 R"); break; case RETRO_DEVICE_LIGHTGUN_SUPER_SCOPE: S9xSetController(port, CTL_SUPERSCOPE, 0, 0, 0, 0); retro_devices[port] = RETRO_DEVICE_LIGHTGUN_SUPER_SCOPE; /* mapping pointers here */ S9xMapPointer((BTN_POINTER), S9xGetCommandT("Pointer Mouse1+Superscope+Justifier1")); S9xMapPointer((BTN_POINTER2), S9xGetCommandT("Pointer Mouse2")); /* mapping extra buttons here */ LR_MAP_BUTTON(MAKE_BUTTON(2, RETRO_DEVICE_ID_JOYPAD_SELECT), "Superscope Fire"); LR_MAP_BUTTON(MAKE_BUTTON(2, RETRO_DEVICE_ID_JOYPAD_START), "Superscope Cursor"); LR_MAP_BUTTON(MAKE_BUTTON(2, RETRO_DEVICE_ID_JOYPAD_UP), "Superscope ToggleTurbo"); LR_MAP_BUTTON(MAKE_BUTTON(2, RETRO_DEVICE_ID_JOYPAD_DOWN), "Superscope Pause"); break; case RETRO_DEVICE_LIGHTGUN_JUSTIFIER: S9xSetController(port, CTL_JUSTIFIER, 0, 0, 0, 0); retro_devices[port] = RETRO_DEVICE_LIGHTGUN_JUSTIFIER; /* mapping extra buttons here */ LR_MAP_BUTTON(MAKE_BUTTON(2, RETRO_DEVICE_ID_JOYPAD_SELECT), "Justifier1 Trigger"); LR_MAP_BUTTON(MAKE_BUTTON(2, RETRO_DEVICE_ID_JOYPAD_START), "Justifier1 Start"); break; case RETRO_DEVICE_LIGHTGUN_JUSTIFIERS: S9xSetController(port, CTL_JUSTIFIER, 1, 0, 0, 0); retro_devices[port] = RETRO_DEVICE_LIGHTGUN_JUSTIFIERS; break; default: if (log_cb) log_cb(RETRO_LOG_ERROR, "Invalid device!\n"); } if (((retro_devices[0] == RETRO_DEVICE_JOYPAD) && retro_devices[1] == RETRO_DEVICE_JOYPAD) || ((retro_devices[0] == RETRO_DEVICE_JOYPAD) && retro_devices[1] == RETRO_DEVICE_JOYPAD_MULTITAP) || ((retro_devices[0] == RETRO_DEVICE_JOYPAD_MULTITAP) && retro_devices[1] == RETRO_DEVICE_JOYPAD)) Settings.NormalControls = 1; }
/**************************************************************************** * Set the default mapping for NGC ***************************************************************************/ void SetDefaultButtonMap () { int maxcode = 0x10; s9xcommand_t cmd; /*** Joypad 1 ***/ ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 A"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 B"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 X"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Y"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 L"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 R"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Select"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Start"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Up"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Down"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Left"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad1 Right"); maxcode = 0x20; /*** Joypad 2 ***/ ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 A"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 B"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 X"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Y"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 L"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 R"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Select"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Start"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Up"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Down"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Left"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad2 Right"); maxcode = 0x30; /*** Joypad 3 ***/ ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 A"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 B"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 X"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Y"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 L"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 R"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Select"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Start"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Up"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Down"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Left"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad3 Right"); maxcode = 0x40; /*** Joypad 4 ***/ ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 A"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 B"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 X"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Y"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 L"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 R"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Select"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Start"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Up"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Down"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Left"); ASSIGN_BUTTON_FALSE (maxcode++, "Joypad4 Right"); maxcode = 0x50; /*** Superscope ***/ ASSIGN_BUTTON_FALSE (maxcode++, "Superscope AimOffscreen"); ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Fire"); ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Cursor"); ASSIGN_BUTTON_FALSE (maxcode++, "Superscope ToggleTurbo"); ASSIGN_BUTTON_FALSE (maxcode++, "Superscope Pause"); maxcode = 0x60; /*** Mouse ***/ ASSIGN_BUTTON_FALSE (maxcode++, "Mouse1 L"); ASSIGN_BUTTON_FALSE (maxcode++, "Mouse1 R"); ASSIGN_BUTTON_FALSE (maxcode++, "Mouse2 L"); ASSIGN_BUTTON_FALSE (maxcode++, "Mouse2 R"); maxcode = 0x70; /*** Justifier ***/ ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 AimOffscreen"); ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 Trigger"); ASSIGN_BUTTON_FALSE (maxcode++, "Justifier1 Start"); ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 AimOffscreen"); ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 Trigger"); ASSIGN_BUTTON_FALSE (maxcode++, "Justifier2 Start"); maxcode = 0x80; S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Superscope"), false); S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Mouse1"), false); S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Mouse2"), false); S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Justifier1"), false); S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Justifier2"), false); SetControllers (); }
static void map_buttons() { MAP_BUTTON(MAKE_BUTTON(PAD_1, BTN_A), "Joypad1 A"); MAP_BUTTON(MAKE_BUTTON(PAD_1, BTN_B), "Joypad1 B"); MAP_BUTTON(MAKE_BUTTON(PAD_1, BTN_X), "Joypad1 X"); MAP_BUTTON(MAKE_BUTTON(PAD_1, BTN_Y), "Joypad1 Y"); MAP_BUTTON(MAKE_BUTTON(PAD_1, BTN_SELECT), "{Joypad1 Select,Mouse1 L}"); MAP_BUTTON(MAKE_BUTTON(PAD_1, BTN_START), "{Joypad1 Start,Mouse1 R}"); MAP_BUTTON(MAKE_BUTTON(PAD_1, BTN_L), "Joypad1 L"); MAP_BUTTON(MAKE_BUTTON(PAD_1, BTN_R), "Joypad1 R"); MAP_BUTTON(MAKE_BUTTON(PAD_1, BTN_LEFT), "Joypad1 Left"); MAP_BUTTON(MAKE_BUTTON(PAD_1, BTN_RIGHT), "Joypad1 Right"); MAP_BUTTON(MAKE_BUTTON(PAD_1, BTN_UP), "Joypad1 Up"); MAP_BUTTON(MAKE_BUTTON(PAD_1, BTN_DOWN), "Joypad1 Down"); S9xMapPointer((BTN_POINTER), S9xGetCommandT("Pointer Mouse1+Superscope+Justifier1"), false); S9xMapPointer((BTN_POINTER2), S9xGetCommandT("Pointer Mouse2"), false); MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_A), "Joypad2 A"); MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_B), "Joypad2 B"); MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_X), "Joypad2 X"); MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_Y), "Joypad2 Y"); MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_SELECT), "{Joypad2 Select,Mouse2 L,Superscope Fire,Justifier1 Trigger}"); MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_START), "{Joypad2 Start,Mouse2 R,Superscope Cursor,Justifier1 Start}"); MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_L), "Joypad2 L"); MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_R), "Joypad2 R"); MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_LEFT), "Joypad2 Left"); MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_RIGHT), "Joypad2 Right"); MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_UP), "{Joypad2 Up,Superscope ToggleTurbo}"); MAP_BUTTON(MAKE_BUTTON(PAD_2, BTN_DOWN), "{Joypad2 Down,Superscope Pause}"); MAP_BUTTON(MAKE_BUTTON(PAD_3, BTN_A), "Joypad3 A"); MAP_BUTTON(MAKE_BUTTON(PAD_3, BTN_B), "Joypad3 B"); MAP_BUTTON(MAKE_BUTTON(PAD_3, BTN_X), "Joypad3 X"); MAP_BUTTON(MAKE_BUTTON(PAD_3, BTN_Y), "Joypad3 Y"); MAP_BUTTON(MAKE_BUTTON(PAD_3, BTN_SELECT), "Joypad3 Select"); MAP_BUTTON(MAKE_BUTTON(PAD_3, BTN_START), "Joypad3 Start"); MAP_BUTTON(MAKE_BUTTON(PAD_3, BTN_L), "Joypad3 L"); MAP_BUTTON(MAKE_BUTTON(PAD_3, BTN_R), "Joypad3 R"); MAP_BUTTON(MAKE_BUTTON(PAD_3, BTN_LEFT), "Joypad3 Left"); MAP_BUTTON(MAKE_BUTTON(PAD_3, BTN_RIGHT), "Joypad3 Right"); MAP_BUTTON(MAKE_BUTTON(PAD_3, BTN_UP), "Joypad3 Up"); MAP_BUTTON(MAKE_BUTTON(PAD_3, BTN_DOWN), "Joypad3 Down"); MAP_BUTTON(MAKE_BUTTON(PAD_4, BTN_A), "Joypad4 A"); MAP_BUTTON(MAKE_BUTTON(PAD_4, BTN_B), "Joypad4 B"); MAP_BUTTON(MAKE_BUTTON(PAD_4, BTN_X), "Joypad4 X"); MAP_BUTTON(MAKE_BUTTON(PAD_4, BTN_Y), "Joypad4 Y"); MAP_BUTTON(MAKE_BUTTON(PAD_4, BTN_SELECT), "Joypad4 Select"); MAP_BUTTON(MAKE_BUTTON(PAD_4, BTN_START), "Joypad4 Start"); MAP_BUTTON(MAKE_BUTTON(PAD_4, BTN_L), "Joypad4 L"); MAP_BUTTON(MAKE_BUTTON(PAD_4, BTN_R), "Joypad4 R"); MAP_BUTTON(MAKE_BUTTON(PAD_4, BTN_LEFT), "Joypad4 Left"); MAP_BUTTON(MAKE_BUTTON(PAD_4, BTN_RIGHT), "Joypad4 Right"); MAP_BUTTON(MAKE_BUTTON(PAD_4, BTN_UP), "Joypad4 Up"); MAP_BUTTON(MAKE_BUTTON(PAD_4, BTN_DOWN), "Joypad4 Down"); MAP_BUTTON(MAKE_BUTTON(PAD_5, BTN_A), "Joypad5 A"); MAP_BUTTON(MAKE_BUTTON(PAD_5, BTN_B), "Joypad5 B"); MAP_BUTTON(MAKE_BUTTON(PAD_5, BTN_X), "Joypad5 X"); MAP_BUTTON(MAKE_BUTTON(PAD_5, BTN_Y), "Joypad5 Y"); MAP_BUTTON(MAKE_BUTTON(PAD_5, BTN_SELECT), "Joypad5 Select"); MAP_BUTTON(MAKE_BUTTON(PAD_5, BTN_START), "Joypad5 Start"); MAP_BUTTON(MAKE_BUTTON(PAD_5, BTN_L), "Joypad5 L"); MAP_BUTTON(MAKE_BUTTON(PAD_5, BTN_R), "Joypad5 R"); MAP_BUTTON(MAKE_BUTTON(PAD_5, BTN_LEFT), "Joypad5 Left"); MAP_BUTTON(MAKE_BUTTON(PAD_5, BTN_RIGHT), "Joypad5 Right"); MAP_BUTTON(MAKE_BUTTON(PAD_5, BTN_UP), "Joypad5 Up"); MAP_BUTTON(MAKE_BUTTON(PAD_5, BTN_DOWN), "Joypad5 Down"); }