quick hack to make games that require arrow keys playable

Subforum for discussion and help with ScummVM's iPhone port

Moderator: ScummVM Team

Post Reply
donkthemagicllama
Posts: 5
Joined: Wed Nov 15, 2017 9:13 pm

quick hack to make games that require arrow keys playable

Post by donkthemagicllama »

If you want to play a game like Black Cauldron that absolutely needs arrow keys (e.g. to select inventory items), here's a quick and dirty hack.

I don't have time to submit a PR right now, but maybe this can help someone..

It remaps the following keys to be a set of arrow keys (if you look at the layout of these keys on the iPhone keyboard, you'll see its roughly equivalent to WASD):

] = UP
\ = DOWN
_ = LEFT
| = RIGHT

you can't press and hold, but it's good enough for my situation, hopefully yours too... I left the ascii set to F1 in there, as it doesn't seem to work otherwise... there's probably a good reason for this, and a better way to do it, but I haven't messed with it that much yet.

in the file backends/platform/ios7/ios7_osys_events.cpp
add the following cases to the switch statement at line 388:

Code: Select all

    case 93:
        keyPressed = Common::KEYCODE_UP;
        ascii = Common::ASCII_F1;
        break;
    case 92:
        keyPressed = Common::KEYCODE_DOWN;
        ascii = Common::ASCII_F1;
        break;
    case 95:
        keyPressed = Common::KEYCODE_LEFT;
        ascii = Common::ASCII_F1;
        break;
    case 124:
        keyPressed = Common::KEYCODE_RIGHT;
        ascii = Common::ASCII_F1;
        break;
rcreasi
Posts: 1
Joined: Mon Mar 18, 2019 1:49 am

Re: quick hack to make games that require arrow keys playable

Post by rcreasi »

Thanks! This was super helpful. I was stuck on Space Quest II (at one point you have to crawl across a log with the right arrow and trying to swipe precisely right would invariably make you fall to your death). I recompiled with your key codes and they work wonderfully!

I also tried to add my own key code for TAB (in King's Quest I, that's the only way to see your inventory). For some reason that one didn't work, though. :/
digitall
ScummVM Developer
Posts: 1177
Joined: Thu Aug 02, 2012 1:40 pm

Re: quick hack to make games that require arrow keys playable

Post by digitall »

donkthemagicllama: Have opened this as https://github.com/scummvm/scummvm/pull/1540 ... If there are no major objections, will merge in a week or so.

Thanks for your code contribution.
User avatar
criezy
ScummVM Developer
Posts: 955
Joined: Sat Sep 23, 2006 10:41 am
Location: West Sussex, UK

Re: quick hack to make games that require arrow keys playable

Post by criezy »

I have pushed some changes today that should help with controls on iOS:
  • Add three-fingers wipe gestures for arrow keys.
  • Add a bar above the keyboard with menu, escape, tab, return, functions (1 to 12), and arrow keys. On iPhone you will need to scroll the bar to see the arrow keys as they are on the far right of the bar.
  • Remove all the hardcoded mapping of some keys (for example to function keys) that caused issues with some games (when the original key is needed).
  • You can now use the pinch gesture to show/hide the keyboard (pinch in to show it, and pinch out to hide it).
Since I don't have an iPhone, I only tested this with an iPad and with the iOS simulator (and trying a three fingers swipe gesture on the simulator is kind of difficult). So feedback is welcome.
Post Reply