MAMEWorld >> Programming
View all threads Index   Threaded Mode Threaded  

Pages: 1

Llaffer
MAME Fan
Reged: 05/04/11
Posts: 231
Send PM


Can we get iCade functionality in MAME please? :)
#257785 - 06/18/11 08:03 PM


I picked up the iCade, and it's pretty fun on the Atari games on iPad (I hope other games in the future supports it).

This would be a great controller for MAME.

The problem is, the device doesn't act like a normal joystick, so normal joystick logic won't work. The iCade syncs with a device as a bluetooth keyboard.

When you move the joystick or press a button and hold it, only a single keystroke is sent that the game is expected to detect and then react on, instead of a constant signal with joysticks.

When the joystick or button returns to default, a second keystroke is sent telling the game that the action has ended.

I have the keyboard mappings, but hoping someone who's more knowledable with the MAME code can implement.

Here are the key mappings:


Code:

Action |   key to ... 
| start | to end
========================
Up | w | e
Down | x | z
Left | a | q
Right | d | c
Btn0 | t | y
Btn1 | u | f
Btn2 | i | m
Btn3 | o | g
Btn4 | h | r
Btn5 | j | n
Btn6 | k | p
Btn7 | l | v


The buttons are arranged in 2 rows of 4, with what I call "Btn0" through "Btn3" on the top row, and "Btn4" through "Btn7" on the bottom row. Here's an image that shows what I attempted to explain:


Diagonals are counted by signaling both the UP and the LEFT on, and then both off when centered.

If you rotate the joystick, you get the following signals (I'll start up and go clockwise)

w <-- up on
d <-- right on (diagonal)
e <-- up off (right)
x <-- down on (diagonal)
c <-- right off (down)
a <-- left on (diagonal)
z <-- down off (left)
w <-- up on (diagonal)
q <-- left off (up again)
e <-- up off (joystick centered)

Hope this information helps. I'd love to see iCade functionality added to MAME

Thanks



R. Belmont
Cuckoo for IGAvania
Reged: 09/21/03
Posts: 9711
Loc: ECV-197 The Orville
Send PM


Re: Can we get iCade functionality in MAME please? :) new [Re: Llaffer]
#257873 - 06/20/11 01:45 AM


> I picked up the iCade, and it's pretty fun on the Atari games on iPad (I hope other
> games in the future supports it).
>
> This would be a great controller for MAME.
>
> The problem is, the device doesn't act like a normal joystick, so normal joystick
> logic won't work. The iCade syncs with a device as a bluetooth keyboard.

I guess I don't understand why it doesn't work already - just configure MAME for a keyboard and remap the keys to match what it's sending.



Llaffer
MAME Fan
Reged: 05/04/11
Posts: 231
Send PM


Re: Can we get iCade functionality in MAME please? :) new [Re: R. Belmont]
#257875 - 06/20/11 02:43 AM


I did try it that way first, and it failed.

The problem is that when I press LEFT, the keypress isn't held and consistant. It's just a single keypress showing the start of LEFT until the counterpart single keypress showing that the LEFT switch is off.

If it was a consistant signal, then it would work fine.

As a test (and this is how I determined the grid of keystrokes in the first place), I used it with notepad to see what characters happened in different situations.

If they were "press and hold" like my normal QWERTY keyboard, notepad would have this on it:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

As I pressed and held the key. But instead, only a single keystroke happened.

Hope that helps clear things up.



R. Belmont
Cuckoo for IGAvania
Reged: 09/21/03
Posts: 9711
Loc: ECV-197 The Orville
Send PM


Re: Can we get iCade functionality in MAME please? :) new [Re: Llaffer]
#257930 - 06/20/11 05:25 PM


> I did try it that way first, and it failed.
>
> The problem is that when I press LEFT, the keypress isn't held and consistant. It's
> just a single keypress showing the start of LEFT until the counterpart single
> keypress showing that the LEFT switch is off.
>

Not repeating doesn't necessarily mean it's sending the key-up right away, but I'm not sure how to test that easily in Windows Regardless, assuming it is, that will obviously cause problems mapping the keys in MAME since MAME requires you to hold the key down for several seconds. Can you just map the keys using your regular keyboard and then play using the iCade?



Llaffer
MAME Fan
Reged: 05/04/11
Posts: 231
Send PM


Re: Can we get iCade functionality in MAME please? :) new [Re: R. Belmont]
#257939 - 06/20/11 07:16 PM


> > I did try it that way first, and it failed.
> >
> > The problem is that when I press LEFT, the keypress isn't held and consistant. It's
> > just a single keypress showing the start of LEFT until the counterpart single
> > keypress showing that the LEFT switch is off.
> >
>
> Not repeating doesn't necessarily mean it's sending the key-up right away, but I'm
> not sure how to test that easily in Windows Regardless, assuming it is, that will
> obviously cause problems mapping the keys in MAME since MAME requires you to hold the
> key down for several seconds. Can you just map the keys using your regular keyboard
> and then play using the iCade?

Nope. I tried that too.

The keystroke definately is not being held like it would be if you mapped the "wasd" keys to joystick controls. If you tested pressing and holding LEFT with notepad in focus, you'd see a long string of a's until you let go. iCade in the same case only sends a single byte.



R. Belmont
Cuckoo for IGAvania
Reged: 09/21/03
Posts: 9711
Loc: ECV-197 The Orville
Send PM


Re: Can we get iCade functionality in MAME please? :) new [Re: Llaffer]
#257955 - 06/20/11 09:10 PM


> The keystroke definately is not being held like it would be if you mapped the "wasd"
> keys to joystick controls. If you tested pressing and holding LEFT with notepad in
> focus, you'd see a long string of a's until you let go. iCade in the same case only
> sends a single byte.

So when you do try to use it in MAME with the keys mapped properly, holding the stick left just moves left once and not again? If that's the case, then either iCade needs to change their firmware or they need to provide a specific HID driver that makes it look more like a normal keyboard to applications. From what you're saying, there doesn't seem to be a way for MAME (or any other application) to determine if the stick or buttons are being held.

Is using iCade with a PC actually supported by the manufacturer? I thought it was intended for use with the iPad only, and this may be why, unfortunately.



Llaffer
MAME Fan
Reged: 05/04/11
Posts: 231
Send PM


Re: Can we get iCade functionality in MAME please? :) new [Re: R. Belmont]
#258130 - 06/23/11 01:54 AM


I'm still thinking that as long as the software (no matter what platform it's running on) is expecting keyboard input and knows what to do when specific keys are received, it should work. The game would have to know to use iCade keyboard inputs instead of a QWERTY keyboard input since they are obviously different.



R. Belmont
Cuckoo for IGAvania
Reged: 09/21/03
Posts: 9711
Loc: ECV-197 The Orville
Send PM


Re: Can we get iCade functionality in MAME please? :) new [Re: Llaffer]
#258171 - 06/23/11 10:39 PM


> I'm still thinking that as long as the software (no matter what platform it's running
> on) is expecting keyboard input and knows what to do when specific keys are received,
> it should work. The game would have to know to use iCade keyboard inputs instead of a
> QWERTY keyboard input since they are obviously different.

You're missing my point. If you re-configured MAME to use the iCade's keymaps and the iCade sticks/buttons still did nothing then it is not properly emulating a keyboard, full stop. My guess is it wasn't really intended for use with PCs and so they're doing things in a way that Windows/DirectInput doesn't like.

But mostly I would've liked an answer to "So when you do try to use it in MAME with the keys mapped properly, holding the stick left just moves left once and not again?". The answer to that basically determines if it's even feasible to modify MAME to support the thing.



Firehawke
Manual Meister
Reged: 08/12/06
Posts: 665
Send PM


Not terribly likely as it stands-- read within. new [Re: R. Belmont]
#259596 - 07/11/11 09:48 AM


I read a review of the iCade over at Ars Technica a few days back. It basically presents itself as a bluetooth keyboard, and to preserve battery life as much as possible, they have done some oddities to the buttons and joystick.

Basically, it sends one keystroke when the button goes down, then another when the button goes back up-- state changes, in other words, instead of continuously sending the button when held. Same goes for the joystick directions, with on and off keystrokes for each.

The MAME keyboard interface as it stands is not well-suited for this kind of setup.

I imagine the best solution would be to write a PPJOY module that handles the weirdness and passes "cleaned pure status" to any and all games.

Here's a chunk of the open source API for your perusal, along with a link to reference it:

from https://github.com/scarnie/iCade-iOS/blob/master/iCadeTest/iCade/iCadeReaderView.h

Code:

/*
UP ON,OFF = w,e
RT ON,OFF = d,c
DN ON,OFF = x,z
LT ON,OFF = a,q
A ON,OFF = y,t
B ON,OFF = h,r
C ON,OFF = u,f
D ON,OFF = j,n
E ON,OFF = i,m
F ON,OFF = k,p
G ON,OFF = o,g
H ON,OFF = l,v
*/




---
Try checking the MAME manual at http://docs.mamedev.org



R. Belmont
Cuckoo for IGAvania
Reged: 09/21/03
Posts: 9711
Loc: ECV-197 The Orville
Send PM


Re: Not terribly likely as it stands-- read within. new [Re: Firehawke]
#260011 - 07/15/11 04:21 PM


> Basically, it sends one keystroke when the button goes down, then another when the
> button goes back up-- state changes, in other words, instead of continuously sending
> the button when held. Same goes for the joystick directions, with on and off
> keystrokes for each.

That's odd. My understanding was the keyboards always have worked that way. MAME wants to see key-down and then no key-up until you've actually let go, and that's precisely the interface both DirectInput and the traditional Windows message API present. Games (and MAME) disable key auto-repeat, because the keyboard implements that by sending key-down (wait) key-up/key-down (wait) key-up/key-down (repeat) and that would of course be harmful to games.

I guess I'll read the Ars article in case you aren't quoting it properly



Firehawke
Manual Meister
Reged: 08/12/06
Posts: 665
Send PM


Re: Not terribly likely as it stands-- read within. new [Re: R. Belmont]
#260012 - 07/15/11 05:06 PM


Okay, I see why your confusion. I also think I see how to better explain the oddity of the design.

This thing is for an iPad. There's no joystick APIs-- Apple never wanted us to use anything but the touchscreen. So, an external controller had to shim into SOMETHING already existing. Since the newest models have bluetooth keyboard support, they chose that.

Only thing is, they can't pull raw data off the keyboard state. They get keyboard "pressed this key and released" events, just like the onscreen keyboard provides. So, the only way to actually get the state info they WANTED was to literally do a hack job and use multiple keys to simulate state.



---
Try checking the MAME manual at http://docs.mamedev.org



R. Belmont
Cuckoo for IGAvania
Reged: 09/21/03
Posts: 9711
Loc: ECV-197 The Orville
Send PM


Re: Not terribly likely as it stands-- read within. new [Re: Firehawke]
#260027 - 07/15/11 07:06 PM


> Only thing is, they can't pull raw data off the keyboard state. They get keyboard
> "pressed this key and released" events, just like the onscreen keyboard provides. So,
> the only way to actually get the state info they WANTED was to literally do a hack
> job and use multiple keys to simulate state.

Ok, I get it now.



Llaffer
MAME Fan
Reged: 05/04/11
Posts: 231
Send PM


Re: Not terribly likely as it stands-- read within. new [Re: R. Belmont]
#260087 - 07/16/11 06:15 PM


Right. Which is why I think it's possible, with code, that MAME could have an "iCade" mode, that would then be expecting the inputs from an iCade and know what to do with it.

I've played with GlovePIE and ppjoy to try to write a script to turn iCade inputs into a joystick output, but I've not had much luck in that department.



R. Belmont
Cuckoo for IGAvania
Reged: 09/21/03
Posts: 9711
Loc: ECV-197 The Orville
Send PM


Re: Not terribly likely as it stands-- read within. new [Re: Llaffer]
#260227 - 07/18/11 09:46 PM


> Right. Which is why I think it's possible, with code, that MAME could have an "iCade"
> mode, that would then be expecting the inputs from an iCade and know what to do with
> it.

It's possible, but the whole "key down sends another key up" thing does pretty extreme violence to how pretty much everything expects keyboards to work. It's really unfortunate they didn't include a more standard Bluetooth keyboard emulation in the firmware.



Tingoes
Old game finder!
Reged: 10/03/05
Posts: 113
Send PM


Re: Not terribly likely as it stands-- read within. new [Re: R. Belmont]
#265319 - 09/29/11 04:44 PM


Maybe Apple should include new bluetooth keyboard protocols for remote keyboards in a firmware upgrade for the i Pad.



R. Belmont
Cuckoo for IGAvania
Reged: 09/21/03
Posts: 9711
Loc: ECV-197 The Orville
Send PM


Re: Not terribly likely as it stands-- read within. new [Re: Tingoes]
#265322 - 09/29/11 05:03 PM


> Maybe Apple should include new bluetooth keyboard protocols for remote keyboards in a
> firmware upgrade for the i Pad.

Would be nice



mogli
MAME Fan
Reged: 01/26/08
Posts: 1956
Send PM


Screw Apple new [Re: R. Belmont]
#267827 - 11/02/11 10:55 PM


QED



Consider it high comedy....sincere tragedy....whatever...don't take it personally.

The Culture




krick
Get Fuzzy
Reged: 02/09/04
Posts: 4235
Send PM


Re: Not terribly likely as it stands-- read within. new [Re: R. Belmont]
#267846 - 11/03/11 02:06 AM


> It's possible, but the whole "key down sends another key up" thing does pretty
> extreme violence to how pretty much everything expects keyboards to work. It's really
> unfortunate they didn't include a more standard Bluetooth keyboard emulation in the
> firmware.

There would have to be a "thunking layer" that intercepts the goofiness and translates it to normal key presses. The layer would have to have some sort of state machine design where it toggles between listening for the initial keydown, listening for the keyup, and sending the translated key to MAME. I guess it would have to also emulate holding down the sent key until the next keydown event comes in.



GroovyMAME support forum on BYOAC


Pages: 1

MAMEWorld >> Programming
View all threads Index   Threaded Mode Threaded  

Extra information Permissions
Moderator:  Pi 
0 registered and 3 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 13755