first attempt of implementing light gun support for Libretro

This commit is contained in:
Thomas Jentzsch 2022-01-29 11:37:00 +01:00
parent 096f2434c0
commit ce3fdec7c1
3 changed files with 64 additions and 53 deletions

View File

@ -55,7 +55,7 @@ Lightgun::Lightgun(Jack jack, const Event& event, const System& system,
else if (romMd5 == "2559948f39b91682934ea99d90ede631" || else if (romMd5 == "2559948f39b91682934ea99d90ede631" ||
romMd5 == "e75ab446017448045b152eea78bf7910") romMd5 == "e75ab446017448045b152eea78bf7910")
{ {
// Booby is Hungry // Bobby is Hungry
myOfsX = -21; myOfsX = -21;
myOfsY = 5; myOfsY = 5;
} }

View File

@ -126,6 +126,13 @@ int32_t input_bitmask[4];
EVENT(Event::LeftJoystickFire9, pad, RETRO_DEVICE_ID_JOYPAD_Y); EVENT(Event::LeftJoystickFire9, pad, RETRO_DEVICE_ID_JOYPAD_Y);
break; break;
case Controller::Type::Lightgun:
EVENT(Event::MouseAxisXValue, input_state_cb(pad, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X));
EVENT(Event::MouseAxisYValue, input_state_cb(pad, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y));
EVENT(Event::MouseButtonLeftValue, input_state_cb(pad, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_TRIGGER));
EVENT(Event::MouseButtonRightValue, input_state_cb(pad, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_TRIGGER));
break;
default: default:
break; break;
} }
@ -574,6 +581,10 @@ bool retro_load_game(const struct retro_game_info *info)
{ 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "Right" }, { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "Right" },
{ 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Fire" }, { 3, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B, "Fire" },
{ 0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X, "Pointer X" },
{ 0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y, "Pointer Y" },
{ 0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_PRESSED, "Pointer Button" },
{ 0, 0, 0, 0, NULL }, { 0, 0, 0, 0, NULL },
}; };

View File

@ -199,7 +199,7 @@ extern "C" {
#define RETRO_DEVICE_ID_JOYPAD_R2 13 #define RETRO_DEVICE_ID_JOYPAD_R2 13
#define RETRO_DEVICE_ID_JOYPAD_L3 14 #define RETRO_DEVICE_ID_JOYPAD_L3 14
#define RETRO_DEVICE_ID_JOYPAD_R3 15 #define RETRO_DEVICE_ID_JOYPAD_R3 15
#define RETRO_DEVICE_ID_JOYPAD_MASK 256 #define RETRO_DEVICE_ID_JOYPAD_MASK 256
/* Index / Id values for ANALOG device. */ /* Index / Id values for ANALOG device. */
#define RETRO_DEVICE_INDEX_ANALOG_LEFT 0 #define RETRO_DEVICE_INDEX_ANALOG_LEFT 0
@ -969,46 +969,46 @@ enum retro_mod
* It is recomended to do so in retro_set_environment */ * It is recomended to do so in retro_set_environment */
#define RETRO_ENVIRONMENT_GET_AUDIO_VIDEO_ENABLE (47 | RETRO_ENVIRONMENT_EXPERIMENTAL) #define RETRO_ENVIRONMENT_GET_AUDIO_VIDEO_ENABLE (47 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* int * -- /* int * --
* Tells the core if the frontend wants audio or video. * Tells the core if the frontend wants audio or video.
* If disabled, the frontend will discard the audio or video, * If disabled, the frontend will discard the audio or video,
* so the core may decide to skip generating a frame or generating audio. * so the core may decide to skip generating a frame or generating audio.
* This is mainly used for increasing performance. * This is mainly used for increasing performance.
* Bit 0 (value 1): Enable Video * Bit 0 (value 1): Enable Video
* Bit 1 (value 2): Enable Audio * Bit 1 (value 2): Enable Audio
* Bit 2 (value 4): Use Fast Savestates. * Bit 2 (value 4): Use Fast Savestates.
* Bit 3 (value 8): Hard Disable Audio * Bit 3 (value 8): Hard Disable Audio
* Other bits are reserved for future use and will default to zero. * Other bits are reserved for future use and will default to zero.
* If video is disabled: * If video is disabled:
* * The frontend wants the core to not generate any video, * * The frontend wants the core to not generate any video,
* including presenting frames via hardware acceleration. * including presenting frames via hardware acceleration.
* * The frontend's video frame callback will do nothing. * * The frontend's video frame callback will do nothing.
* * After running the frame, the video output of the next frame should be * * After running the frame, the video output of the next frame should be
* no different than if video was enabled, and saving and loading state * no different than if video was enabled, and saving and loading state
* should have no issues. * should have no issues.
* If audio is disabled: * If audio is disabled:
* * The frontend wants the core to not generate any audio. * * The frontend wants the core to not generate any audio.
* * The frontend's audio callbacks will do nothing. * * The frontend's audio callbacks will do nothing.
* * After running the frame, the audio output of the next frame should be * * After running the frame, the audio output of the next frame should be
* no different than if audio was enabled, and saving and loading state * no different than if audio was enabled, and saving and loading state
* should have no issues. * should have no issues.
* Fast Savestates: * Fast Savestates:
* * Guaranteed to be created by the same binary that will load them. * * Guaranteed to be created by the same binary that will load them.
* * Will not be written to or read from the disk. * * Will not be written to or read from the disk.
* * Suggest that the core assumes loading state will succeed. * * Suggest that the core assumes loading state will succeed.
* * Suggest that the core updates its memory buffers in-place if possible. * * Suggest that the core updates its memory buffers in-place if possible.
* * Suggest that the core skips clearing memory. * * Suggest that the core skips clearing memory.
* * Suggest that the core skips resetting the system. * * Suggest that the core skips resetting the system.
* * Suggest that the core may skip validation steps. * * Suggest that the core may skip validation steps.
* Hard Disable Audio: * Hard Disable Audio:
* * Used for a secondary core when running ahead. * * Used for a secondary core when running ahead.
* * Indicates that the frontend will never need audio from the core. * * Indicates that the frontend will never need audio from the core.
* * Suggests that the core may stop synthesizing audio, but this should not * * Suggests that the core may stop synthesizing audio, but this should not
* compromise emulation accuracy. * compromise emulation accuracy.
* * Audio output for the next frame does not matter, and the frontend will * * Audio output for the next frame does not matter, and the frontend will
* never need an accurate audio state in the future. * never need an accurate audio state in the future.
* * State will never be saved when using Hard Disable Audio. * * State will never be saved when using Hard Disable Audio.
*/ */
#define RETRO_ENVIRONMENT_GET_INPUT_BITMASKS 51 #define RETRO_ENVIRONMENT_GET_INPUT_BITMASKS 51
/* VFS functionality */ /* VFS functionality */
@ -1099,17 +1099,17 @@ typedef int (RETRO_CALLCONV *retro_vfs_rename_t)(const char *old_path, const cha
struct retro_vfs_interface struct retro_vfs_interface
{ {
retro_vfs_get_path_t get_path; retro_vfs_get_path_t get_path;
retro_vfs_open_t open; retro_vfs_open_t open;
retro_vfs_close_t close; retro_vfs_close_t close;
retro_vfs_size_t size; retro_vfs_size_t size;
retro_vfs_tell_t tell; retro_vfs_tell_t tell;
retro_vfs_seek_t seek; retro_vfs_seek_t seek;
retro_vfs_read_t read; retro_vfs_read_t read;
retro_vfs_write_t write; retro_vfs_write_t write;
retro_vfs_flush_t flush; retro_vfs_flush_t flush;
retro_vfs_remove_t remove; retro_vfs_remove_t remove;
retro_vfs_rename_t rename; retro_vfs_rename_t rename;
}; };
struct retro_vfs_interface_info struct retro_vfs_interface_info