VCMI Android and Mouse Buttons

Hello~

Some time ago I got Android tablet and got idea to use mouse with it for VCMI purposes… which I have recently purchased even. The trick is that while LMB and movement works very nice, the problem arises when I want to check detailed info on artifacts for example. Normally one would just click RMB right? But not here, here Android answers for RMB with “Back” I believe and makes the VCMI jump through the window and exit somewhat. From what I gathered it is possible to somehow override the buttons and probably even on non-rooted devices. Could it be done for VCMI somehow? I’m willing to be alpha/beta/whatever tester for that purpose, my mouse has few extra buttons which I can customize to almost anything on PC (the config persists in the mouse memory). It may be even a keyboard button as a workaround, for example dunno, SHIFT?

Thank you for advance and have a nice day~

Kiiro Yakumo

I will take a quick look. Probably it is too hard to implement so. Anyway quick look should not take too much time. Btw you might want to bind esc to one of your buttons

Checked and failed to implement it quickly. It should not be hard for experienced Android developer so. The problem is that we have no active Android supporters so far.

ESC does the same as RMB currently, it closes the app (sure with prompt but it just assumes I agree for it :P).
Hmm maybe I will ask then from other side. How VCMI and/or the game itself interprets touching with two fingers? Just as normal RMB (like in the original) or something else?
Ah yes I forgot to mention I use the latest build from 19.03.2020.

There is a hack in touch handler to treat second touch as RMB. All the rest of game thinks it is RMB.

Hmm… Would it be in theory possible to assign additionally that second touch to a keyboard key (code) ? For example something unused in the original game like Shift (probably) or some other key? That way maybe the problem of redirecting RMB could be avoided.

A bit offtopic - eh back in the day we had controller with just few buttons and everything worked :stuck_out_tongue:

Should be possible. I broke my android emulator trying to build x86 build and no it does not work at all so can not test until I fix it

There is no rush of course :stuck_out_tongue:
Another option - yeah I’m “helping” :stuck_out_tongue: - would be RMB in DeX mode.
From what I gathered for example Google Docs / Calc recognize LMB and RMB as separate entities. RMB doesn’t do “back” in DeX mode either as global stuff in the first place, so possibly at least DeX mode would be semi-easy to fix as there would be no need for “tricking” anything onboard into thinking “hey we pressed RMB, uuu”.
Nevertheless no rush, try to fix sometime your Android Environment if possible :slight_smile:
If you will need testing area I can offer currently:

  1. Android 6.0 Smartphone (no DeX available, I believe I can connect BT Mouse to it)
  2. Android 10 (10.0?) Smartphone (DeX mode possible)
  3. Android 9 (9.0?) Tablet (DeX mode possible) (mostly playing here because big screen of course)

Have a good and sunny day :slight_smile:

Kiiro Yakumo

Looks like android emulator does not recognize RMB as back. And I do not have real bluetooth mouse so can not move forward there

Probably it is possible to bind to the middle mouse button so.

Ok. Lets check what this apk will say when you click middle mouse button. Rename it to apk, install and check if it reacts on middle button press and does not react on left one
app-debug.apk.zip (2.0 MB)

Tried in both normal mode and DeX mode on Android 9 tablet:

  1. DeX Mode - refuses to work saying it’s designed for start screen(?)
  2. Normal Mode - Tried every button on the mouse, including starting your app temporarely as that start screen(?) but it only says “TextView” on grayish background, nothing new appears from mouse buttons pressing with exception of MMB asking me to select start screen(?) between what I have and your app.

P.S. - not sure if “start screen” is proper wording here :thinking:

That is sad. It means it was not able to catch the middle button. Otherwise it will write some event information. But i am not sure I fully understand this

exception of MMB asking me to select start screen(?) between what I have and your app

Is this behavior different from what other apps do?

Ah sorry, I found the wording I needed, “Home Screen”. Sometimes my english is a suckage :stuck_out_tongue: It’s normal behavior from Android’s point of view, LMB for “touch”, RMB for “back”, MMB for “home”. Even holding MMB works the same way… From what I gathered it’s true at least since Android 4.4 and stays as that to this day. I forgot to mention, that Android 6 smartphone has root access so I will try some tinkering from this angle as well in the meantime.
If there is anything else I can do, just say a word :fox_face:

P.S. - Hmm I will try to gather info how the “official” so called Heroes of Might and Magic 3 “HD” did that

EDIT - ahahaha they didn’t… the RMB is also “back” in “HD” edition… BUT, they did it other way, if you press LMB and hold it, it reads it as “PC RMB” ™ after 2 or so seconds. It would be another workaround I guess, depending if “LMB Hold” in VCMI has some function already or not…

Looks like I finally found some solution. Tested it with emulated bluetooth mouse. Lets wait if it gets merged. https://github.com/vcmi/vcmi-android/pull/12/commits/925567bce62cd7b0854c73c851d59fcd82fc2607

I take it that today’s build includes your changes. Downloaded and checked it. I think it’s on good track. Sure now the RMB does a complete nothing but that also means that you have succeeded at telling Android to “hands off!” from taking control of the button :slight_smile:
It’s a great progress.

No it is not merged yet. Only approved.

Now it was merged so you are welcome to try it. Lets wait for the next daily build

My bad~!
Installed new build and WOW! It works, just like that :slight_smile:
Checked quickly RMB on

  1. Hero on the map
  2. Hero on the heroes list
  3. Hero on the Tavern screen
  4. Town on the towns list
  5. Few objects on the map including mines, portals, artifacts.
  6. Buildings in the town view
  7. Buildings in the building screen
  8. Artifacts in the Artifacts Merchant building
  9. Artifacts equipped on character
  10. Artifacts in the backpack
  11. Basic statistics and advanced skills on character’s screen
  12. Units in character’s army including their morale/luck details

Everything works perfectly fine :slight_smile:
That is in normal mode, on DeX mode ironically it registers RMB as LMB (which is still better than pressing it by habbit and getting back-instant-close)

Unless I missed something I can openly say it’s well playable in normal mode now :slight_smile:
Thank you very very very much <bows!>

EDIT #1 - If you don’t have enough of me (:stuck_out_tongue_winking_eye:) I can try searching through the net if there will be some info as to make RMB work properly in DeX Mode

EDIT #2 - Actually I found something but not sure if that’s exactly the needed part here :thinking:

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
layout_main = (RelativeLayout) findViewById(R.id.layout_main);
registerForContextMenu(layout_main);
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
if (v.getId() == R.id.layout_main) {
menu.setHeaderTitle(“Context Menu Test”);
menu.add(Menu.NONE, ONE, Menu.NONE, “Menu 1”);
}
super.onCreateContextMenu(menu, v, menuInfo);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN && event.getButtonState() == MotionEvent.BUTTON_SECONDARY) {
layout_main.showContextMenu(event.getX(), event.getY());
}
return super.onTouchEvent(event);
}

It is definitely enough. I hoped to do it in a few hours and spent a few days because standard emulator can not emulate mouse correctly. I am glad it works for you. Switching back to my branch now. You can create a bug in mantis and describe about DeX mode issue but do not expect any actions regarding it until we get active Android developer.