@@ -173,6 +173,40 @@ bool Game_Ineluki::Execute(StringView ini_file) {
173173 // no-op
174174 } else if (cmd.name == " registercheatevent" ) {
175175 cheatlist.emplace_back (Utils::LowerCase (cmd.arg ), atoi (cmd.arg2 .c_str ()));
176+ } else if (cmd.name == " setmouseasreturn" ) {
177+ // This command is only found in a few uncommon versions of the patch
178+ if (!mouse_support) {
179+ return true ;
180+ }
181+ std::string arg_lower = Utils::LowerCase (cmd.arg );
182+ if (arg_lower == " left" ) {
183+ mouse_decision_binding = MouseReturnMode::Left;
184+ } else if (arg_lower == " right" ) {
185+ mouse_decision_binding = MouseReturnMode::Right;
186+ } else if (arg_lower == " both" ) {
187+ mouse_decision_binding = MouseReturnMode::Both;
188+ } else if (arg_lower == " none" ) {
189+ mouse_decision_binding = MouseReturnMode::None;
190+ } else {
191+ Output::Warning (" Ineluki: Invalid value for setMouseAsReturn" );
192+ mouse_decision_binding = MouseReturnMode::None;
193+ }
194+ } else if (cmd.name == " setmousewheelaskeys" ) {
195+ // This command is only found in a few uncommon versions of the patch
196+ if (!mouse_support) {
197+ return true ;
198+ }
199+ std::string arg_lower = Utils::LowerCase (cmd.arg );
200+ if (arg_lower == " updown" ) {
201+ mouse_wheel_binding = MouseWheelMode::UpDown;
202+ } else if (arg_lower == " leftright" ) {
203+ mouse_wheel_binding = MouseWheelMode::LeftRight;
204+ } else if (arg_lower == " none" ) {
205+ mouse_wheel_binding = MouseWheelMode::None;
206+ } else {
207+ Output::Warning (" Ineluki: Invalid value for setMouseWheelAsKeys" );
208+ mouse_wheel_binding = MouseWheelMode::None;
209+ }
176210 }
177211 }
178212
@@ -263,6 +297,10 @@ bool Game_Ineluki::Parse(StringView ini_file) {
263297 } else if (cmd.name == " registercheatevent" ) {
264298 cmd.arg = ini.Get (section, " cheat" , std::string ());
265299 cmd.arg2 = ini.Get (section, " value" , std::string ());
300+ } else if (cmd.name == " setmouseasreturn" ) {
301+ cmd.arg = ini.Get (section, " value" , std::string ());
302+ } else if (cmd.name == " setmousewheelaskeys" ) {
303+ cmd.arg = ini.Get (section, " value" , std::string ());
266304 } else {
267305 Output::Debug (" Ineluki: Unknown command {}" , cmd.name );
268306 valid = false ;
@@ -294,10 +332,15 @@ int Game_Ineluki::GetMidiTicks() {
294332}
295333
296334void Game_Ineluki::Update () {
297- if (!key_support) {
298- return ;
335+ if (key_support) {
336+ UpdateKeys ();
337+ }
338+ if (mouse_support) {
339+ UpdateMouse ();
299340 }
341+ }
300342
343+ void Game_Ineluki::UpdateKeys () {
301344 for (const auto & key : keylist_down) {
302345 if (Input::IsRawKeyTriggered (key.key )) {
303346 output_list.push_back (key.value );
@@ -332,6 +375,34 @@ void Game_Ineluki::Update() {
332375 }
333376}
334377
378+ void Game_Ineluki::UpdateMouse () {
379+ #if defined(USE_MOUSE) && defined(SUPPORT_MOUSE)
380+ if (Input::IsRawKeyTriggered (Input::Keys::MOUSE_LEFT)) {
381+ if ((mouse_decision_binding == MouseReturnMode::Left || mouse_decision_binding == MouseReturnMode::Both)) {
382+ Input::SimulateButtonPress (Input::DECISION);
383+ }
384+ } else if (Input::IsRawKeyTriggered (Input::Keys::MOUSE_RIGHT)) {
385+ if ((mouse_decision_binding == MouseReturnMode::Right || mouse_decision_binding == MouseReturnMode::Both)) {
386+ Input::SimulateButtonPress (Input::DECISION);
387+ }
388+ }
389+
390+ if (Input::IsRawKeyTriggered (Input::Keys::MOUSE_SCROLLUP)) {
391+ if (mouse_wheel_binding == MouseWheelMode::UpDown) {
392+ Input::SimulateButtonPress (Input::UP);
393+ } else if (mouse_wheel_binding == MouseWheelMode::LeftRight) {
394+ Input::SimulateButtonPress (Input::LEFT);
395+ }
396+ } else if (Input::IsRawKeyTriggered (Input::Keys::MOUSE_SCROLLDOWN)) {
397+ if (mouse_wheel_binding == MouseWheelMode::UpDown) {
398+ Input::SimulateButtonPress (Input::DOWN);
399+ } else if (mouse_wheel_binding == MouseWheelMode::LeftRight) {
400+ Input::SimulateButtonPress (Input::RIGHT);
401+ }
402+ }
403+ #endif
404+ }
405+
335406void Game_Ineluki::OnScriptFileReady (FileRequestResult* result) {
336407 auto it = std::find_if (async_scripts.begin (), async_scripts.end (), [&](const auto & a) {
337408 return a.script_name == result->file ;
0 commit comments