Cocoa OpenEmu Plug-in:

- Change system identifier from openemu.system.nintendods to openemu.system.nds.
- Integrate touch pad support.
This commit is contained in:
rogerman 2012-03-07 08:27:48 +00:00
parent 8839973caa
commit 7ca5067856
4 changed files with 63 additions and 9 deletions

View File

@ -34,7 +34,7 @@
<string>http://desmume.org/</string>
<key>OESystemIdentifiers</key>
<array>
<string>openemu.system.nintendods</string>
<string>openemu.system.nds</string>
</array>
</dict>
</plist>

View File

@ -26,6 +26,8 @@
@interface NDSGameCore : OEGameCore
{
bool *input;
bool isTouchPressed;
OEIntPoint touchLocation;
CocoaDSFirmware *firmware;
CocoaDSMic *microphone;
NSInteger displayMode;

View File

@ -46,6 +46,9 @@
// Set up input handling
input = (bool *)calloc(sizeof(bool), OENDSButtonCount);
isTouchPressed = false;
touchLocation.x = 0;
touchLocation.y = 0;
microphone = [[CocoaDSMic alloc] init];
microphone.mode = MICMODE_INTERNAL_NOISE;
@ -291,6 +294,59 @@
input[button] = false;
}
- (oneway void)didTouchScreenPoint:(OEIntPoint)aPoint
{
bool touchPressed = false;
NSInteger dispMode = [self displayMode];
switch (dispMode)
{
case DS_DISPLAY_TYPE_MAIN:
touchPressed = false; // Reject touch input if showing only the main screen.
break;
case DS_DISPLAY_TYPE_TOUCH:
touchPressed = true;
break;
case DS_DISPLAY_TYPE_COMBO:
touchPressed = true;
aPoint.y -= GPU_DISPLAY_HEIGHT; // Normalize the y-coordinate to the DS.
break;
default:
return;
break;
}
// Constrain the touch point to the DS dimensions.
if (aPoint.x < 0)
{
aPoint.x = 0;
}
else if (aPoint.x > (GPU_DISPLAY_WIDTH - 1))
{
aPoint.x = (GPU_DISPLAY_WIDTH - 1);
}
if (aPoint.y < 0)
{
aPoint.y = 0;
}
else if (aPoint.y > (GPU_DISPLAY_HEIGHT - 1))
{
aPoint.y = (GPU_DISPLAY_HEIGHT - 1);
}
isTouchPressed = touchPressed;
touchLocation = aPoint;
}
- (oneway void)didReleaseTouch
{
isTouchPressed = false;
}
- (void) updateNDSController
{
// Setup the DS pad.
@ -309,22 +365,16 @@
input[OENDSButtonDebug],
input[OENDSButtonLid]);
// TODO: Add touch pad support in OpenEmu.
//
// As of March 3, 2012, reading coordinates from a view is not exposed in OpenEmu.
// When this functionality is exposed, then the DS touch pad will be supported.
/*
// Setup the DS touch pad.
if ([self isInputPressed:@"Touch"])
if (isTouchPressed)
{
NSPoint touchLocation = [self inputLocation:@"Touch"];
NDS_setTouchPos((u16)touchLocation.x, (u16)touchLocation.y);
}
else
{
NDS_releaseTouch();
}
*/
// Setup the DS mic.
NDS_setMic(input[OENDSButtonMicrophone]);

View File

@ -43,5 +43,7 @@ typedef enum _OENDSButton
- (oneway void)didPushNDSButton:(OENDSButton)button forPlayer:(NSUInteger)player;
- (oneway void)didReleaseNDSButton:(OENDSButton)button forPlayer:(NSUInteger)player;
- (oneway void)didTouchScreenPoint:(OEIntPoint)aPoint;
- (oneway void)didReleaseTouch;
@end