Cocoa Port:

- Allow mouse input for windows in Main display mode.
This commit is contained in:
rogerman 2013-04-23 17:21:46 +00:00
parent df4d72e055
commit 812b637aaa
2 changed files with 18 additions and 12 deletions

View File

@ -1438,27 +1438,30 @@ enum OGLVertexAttributeID
DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate]; DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate];
const NSInteger displayModeID = [windowController displayMode]; const NSInteger displayModeID = [windowController displayMode];
if (displayModeID != DS_DISPLAY_TYPE_TOUCH && displayModeID != DS_DISPLAY_TYPE_COMBO)
{
return isHandled;
}
// Convert the clicked location from window coordinates, to view coordinates, // Convert the clicked location from window coordinates, to view coordinates,
// and finally to DS touchscreen coordinates. // and finally to DS touchscreen coordinates.
NSPoint touchLoc = [self dsPointFromEvent:theEvent]; NSPoint touchLoc = NSMakePoint(-2.0, -2.0);
if (displayModeID == DS_DISPLAY_TYPE_TOUCH || displayModeID == DS_DISPLAY_TYPE_COMBO)
{
touchLoc = [self dsPointFromEvent:theEvent];
}
const InputAttributes inputAttr = InputManagerEncodeMouseButtonInput([theEvent buttonNumber], touchLoc, buttonPressed); const InputAttributes inputAttr = InputManagerEncodeMouseButtonInput([theEvent buttonNumber], touchLoc, buttonPressed);
if (buttonPressed && [theEvent window] != nil) if (buttonPressed && [theEvent window] != nil)
{ {
char inputCoordBuf[256] = {0}; static char inputStr[INPUT_HANDLER_STRING_LENGTH*2] = {0};
snprintf(inputCoordBuf, 256, " X:%i Y:%i", (int)inputAttr.intCoordX, (int)inputAttr.intCoordY);
char inputStr[INPUT_HANDLER_STRING_LENGTH*2];
strlcpy(inputStr, inputAttr.deviceName, INPUT_HANDLER_STRING_LENGTH*2); strlcpy(inputStr, inputAttr.deviceName, INPUT_HANDLER_STRING_LENGTH*2);
strlcat(inputStr, ":", INPUT_HANDLER_STRING_LENGTH*2); strlcat(inputStr, ":", INPUT_HANDLER_STRING_LENGTH*2);
strlcat(inputStr, inputAttr.elementName, INPUT_HANDLER_STRING_LENGTH*2); strlcat(inputStr, inputAttr.elementName, INPUT_HANDLER_STRING_LENGTH*2);
strlcat(inputStr, inputCoordBuf, INPUT_HANDLER_STRING_LENGTH*2);
if (inputAttr.intCoordX >= 0)
{
static char inputCoordBuf[64] = {0};
snprintf(inputCoordBuf, 64, " X:%i Y:%i", (int)inputAttr.intCoordX, (int)inputAttr.intCoordY);
strlcat(inputStr, inputCoordBuf, INPUT_HANDLER_STRING_LENGTH*2);
}
[[windowController emuControl] setStatusText:[NSString stringWithCString:inputStr encoding:NSUTF8StringEncoding]]; [[windowController emuControl] setStatusText:[NSString stringWithCString:inputStr encoding:NSUTF8StringEncoding]];
} }

View File

@ -1075,7 +1075,10 @@
if (controlID == DSControllerState_Touch) if (controlID == DSControllerState_Touch)
{ {
const NSPoint touchLoc = (cmdAttr.useInputForIntCoord) ? NSMakePoint(cmdAttr.input.intCoordX, cmdAttr.input.intCoordY) : NSMakePoint(cmdAttr.intValue[1], cmdAttr.intValue[2]); const NSPoint touchLoc = (cmdAttr.useInputForIntCoord) ? NSMakePoint(cmdAttr.input.intCoordX, cmdAttr.input.intCoordY) : NSMakePoint(cmdAttr.intValue[1], cmdAttr.intValue[2]);
[[cdsCore cdsController] setTouchState:theState location:touchLoc]; if (touchLoc.x >= 0.0 && touchLoc.y >= 0.0)
{
[[cdsCore cdsController] setTouchState:theState location:touchLoc];
}
} }
else if (controlID == DSControllerState_Microphone) else if (controlID == DSControllerState_Microphone)
{ {