mirror of https://github.com/stella-emu/stella.git
added light gun position scaling (now it works with a mouse)
This commit is contained in:
parent
d43227444a
commit
6e896f1228
|
@ -60,7 +60,7 @@ class StellaLIBRETRO
|
|||
|
||||
void* getROM() const { return rom_image.get(); }
|
||||
uInt32 getROMSize() const { return rom_size; }
|
||||
constexpr uInt32 getROMMax() const { return Cartridge::maxSize(); }
|
||||
constexpr uInt32 getROMMax() const { return uInt32(Cartridge::maxSize()); }
|
||||
|
||||
uInt8* getRAM() { return system_ram; }
|
||||
constexpr uInt32 getRAMSize() const { return 128; }
|
||||
|
@ -100,6 +100,10 @@ class StellaLIBRETRO
|
|||
return myOSystem->console().tia().height() * getVideoZoom();
|
||||
}
|
||||
|
||||
const Common::Rect& getImageRect() const {
|
||||
return myOSystem->frameBuffer().imageRect();
|
||||
}
|
||||
|
||||
float getAudioRate() const {
|
||||
return getConsoleNTSC() ? (262 * 76 * 60) / 38.0 : (312 * 76 * 50) / 38.0;
|
||||
}
|
||||
|
|
|
@ -129,11 +129,18 @@ static void update_input()
|
|||
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));
|
||||
{
|
||||
// scale from -0x8000..0x7fff to image rect
|
||||
const Common::Rect& rect = stella.getImageRect();
|
||||
const Int32 x = (input_state_cb(pad, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X) + 0x8000) * rect.w() / 0xffff;
|
||||
const Int32 y = (input_state_cb(pad, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y) + 0x8000) * rect.h() / 0xffff;
|
||||
|
||||
EVENT(Event::MouseAxisXValue, x);
|
||||
EVENT(Event::MouseAxisYValue, 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:
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue