Fixed OS X client.

This commit is contained in:
Armin Novak 2016-08-03 15:29:24 +02:00 committed by Armin Novak
parent 896f500e7e
commit 376f6a47e1
5 changed files with 328 additions and 394 deletions

View File

@ -32,7 +32,7 @@ typedef struct _APPLE_KEYBOARD_DESC APPLE_KEYBOARD_DESC;
/* VendorID: 0x05AC (Apple, Inc.) */
APPLE_KEYBOARD_DESC APPLE_KEYBOARDS[] =
static const APPLE_KEYBOARD_DESC APPLE_KEYBOARDS[] =
{
{ 0x200, APPLE_KEYBOARD_TYPE_ANSI },
{ 0x201, APPLE_KEYBOARD_TYPE_ANSI }, /* USB Keyboard [Alps or Logitech, M2452] */
@ -143,18 +143,18 @@ APPLE_KEYBOARD_DESC APPLE_KEYBOARDS[] =
{ 0x26A, APPLE_KEYBOARD_TYPE_ANSI }
};
enum APPLE_KEYBOARD_TYPE mac_identify_keyboard_type(uint32_t vendorID, uint32_t productID)
static enum APPLE_KEYBOARD_TYPE mac_identify_keyboard_type(uint32_t vendorID,
uint32_t productID)
{
enum APPLE_KEYBOARD_TYPE type = APPLE_KEYBOARD_TYPE_ANSI;
if (vendorID != 0x05AC) /* Apple, Inc. */
return type;
if ((productID < 0x200) || (productID > 0x26A))
return type;
type = APPLE_KEYBOARDS[productID - 0x200].Type;
return type;
}
@ -165,35 +165,33 @@ enum APPLE_KEYBOARD_TYPE mac_detect_keyboard_type()
IOHIDManagerRef tIOHIDManagerRef = NULL;
IOHIDDeviceRef* tIOHIDDeviceRefs = nil;
enum APPLE_KEYBOARD_TYPE type = APPLE_KEYBOARD_TYPE_ANSI;
tIOHIDManagerRef = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
tIOHIDManagerRef = IOHIDManagerCreate(kCFAllocatorDefault,
kIOHIDOptionsTypeNone);
if (!tIOHIDManagerRef)
return type;
IOHIDManagerSetDeviceMatching(tIOHIDManagerRef, NULL);
IOReturn tIOReturn = IOHIDManagerOpen(tIOHIDManagerRef, kIOHIDOptionsTypeNone);
if (noErr != tIOReturn)
return type;
deviceCFSetRef = IOHIDManagerCopyDevices(tIOHIDManagerRef);
if (!deviceCFSetRef)
return type;
CFIndex deviceIndex, deviceCount = CFSetGetCount(deviceCFSetRef);
tIOHIDDeviceRefs = malloc(sizeof(IOHIDDeviceRef) * deviceCount);
if (!tIOHIDDeviceRefs)
return type;
CFSetGetValues(deviceCFSetRef, (const void**) tIOHIDDeviceRefs);
CFRelease(deviceCFSetRef);
deviceCFSetRef = NULL;
for (deviceIndex = 0; deviceIndex < deviceCount; deviceIndex++)
{
CFTypeRef tCFTypeRef;
@ -201,29 +199,30 @@ enum APPLE_KEYBOARD_TYPE mac_detect_keyboard_type()
uint32_t productID = 0;
uint32_t countryCode = 0;
enum APPLE_KEYBOARD_TYPE ltype;
if (!tIOHIDDeviceRefs[deviceIndex])
continue;
inIOHIDDeviceRef = tIOHIDDeviceRefs[deviceIndex];
tCFTypeRef = IOHIDDeviceGetProperty(inIOHIDDeviceRef, CFSTR(kIOHIDVendorIDKey));
if (tCFTypeRef)
CFNumberGetValue((CFNumberRef) tCFTypeRef, kCFNumberSInt32Type, &vendorID);
tCFTypeRef = IOHIDDeviceGetProperty(inIOHIDDeviceRef, CFSTR(kIOHIDProductIDKey));
tCFTypeRef = IOHIDDeviceGetProperty(inIOHIDDeviceRef,
CFSTR(kIOHIDProductIDKey));
if (tCFTypeRef)
CFNumberGetValue((CFNumberRef) tCFTypeRef, kCFNumberSInt32Type, &productID);
tCFTypeRef = IOHIDDeviceGetProperty(inIOHIDDeviceRef, CFSTR(kIOHIDCountryCodeKey));
tCFTypeRef = IOHIDDeviceGetProperty(inIOHIDDeviceRef,
CFSTR(kIOHIDCountryCodeKey));
if (tCFTypeRef)
CFNumberGetValue((CFNumberRef) tCFTypeRef, kCFNumberSInt32Type, &countryCode);
ltype = mac_identify_keyboard_type(vendorID, productID);
if (ltype != APPLE_KEYBOARD_TYPE_ANSI)
{
type = ltype;
@ -238,9 +237,9 @@ enum APPLE_KEYBOARD_TYPE mac_detect_keyboard_type()
CFRelease(deviceCFSetRef);
deviceCFSetRef = NULL;
}
if (tIOHIDManagerRef)
CFRelease(tIOHIDManagerRef);
return type;
}

View File

@ -49,7 +49,6 @@
BOOL skipResizeOnce;
BOOL saveInitialDragLoc;
BOOL skipMoveWindowOnce;
@public
NSPasteboard* pasteboard_rd;
NSPasteboard* pasteboard_wr;
@ -62,12 +61,12 @@
- (void) setCursor: (NSCursor*) cursor;
- (void) setScrollOffset:(int)xOffset y:(int)yOffset w:(int)width h:(int)height;
- (void) onPasteboardTimerFired :(NSTimer *) timer;
- (void) onPasteboardTimerFired :(NSTimer*) timer;
- (void) pause;
- (void) resume;
- (void) releaseResources;
@property (assign) int is_connected;
@property(assign) int is_connected;
@end
@ -83,8 +82,7 @@
BOOL mac_pre_connect(freerdp* instance);
BOOL mac_post_connect(freerdp* instance);
BOOL mac_authenticate(freerdp* instance, char** username, char** password, char** domain);
DWORD mac_client_thread(void* param);
BOOL mac_authenticate(freerdp* instance, char** username, char** password,
char** domain);
#endif // MRDPVIEW_H

File diff suppressed because it is too large Load Diff

View File

@ -30,18 +30,17 @@
* Client Interface
*/
BOOL mfreerdp_client_global_init()
static BOOL mfreerdp_client_global_init()
{
freerdp_handle_signals();
return TRUE;
}
void mfreerdp_client_global_uninit()
static void mfreerdp_client_global_uninit()
{
}
int mfreerdp_client_start(rdpContext* context)
static int mfreerdp_client_start(rdpContext* context)
{
MRDPView* view;
mfContext* mfc = (mfContext*) context;
@ -49,7 +48,8 @@ int mfreerdp_client_start(rdpContext* context)
if (mfc->view == NULL)
{
// view not specified beforehand. Create view dynamically
mfc->view = [[MRDPView alloc] initWithFrame : NSMakeRect(0, 0, context->settings->DesktopWidth, context->settings->DesktopHeight)];
mfc->view = [[MRDPView alloc] initWithFrame : NSMakeRect(0, 0,
context->settings->DesktopWidth, context->settings->DesktopHeight)];
mfc->view_ownership = TRUE;
}
@ -57,10 +57,10 @@ int mfreerdp_client_start(rdpContext* context)
return [view rdpStart:context];
}
int mfreerdp_client_stop(rdpContext* context)
static int mfreerdp_client_stop(rdpContext* context)
{
mfContext* mfc = (mfContext*) context;
if (mfc->thread)
{
SetEvent(mfc->stopEvent);
@ -68,7 +68,7 @@ int mfreerdp_client_stop(rdpContext* context)
CloseHandle(mfc->thread);
mfc->thread = NULL;
}
if (mfc->view_ownership)
{
MRDPView* view = (MRDPView*) mfc->view;
@ -80,41 +80,41 @@ int mfreerdp_client_stop(rdpContext* context)
return 0;
}
BOOL mfreerdp_client_new(freerdp* instance, rdpContext* context)
static BOOL mfreerdp_client_new(freerdp* instance, rdpContext* context)
{
mfContext* mfc;
rdpSettings* settings;
mfc = (mfContext*) instance->context;
mfc->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
context->instance->PreConnect = mac_pre_connect;
context->instance->PostConnect = mac_post_connect;
context->instance->Authenticate = mac_authenticate;
context->channels = freerdp_channels_new();
settings = instance->settings;
settings->AsyncTransport = TRUE;
settings->AsyncUpdate = TRUE;
settings->AsyncInput = TRUE;
return TRUE;
}
static void mfreerdp_client_free(freerdp* instance, rdpContext* context)
{
mfContext* mfc;
rdpSettings* settings;
if (!instance || !context)
return;
mfc = (mfContext*) instance->context;
mfc->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
context->instance->PreConnect = mac_pre_connect;
context->instance->PostConnect = mac_post_connect;
context->instance->Authenticate = mac_authenticate;
context->channels = freerdp_channels_new();
settings = instance->settings;
settings->AsyncTransport = TRUE;
settings->AsyncUpdate = TRUE;
settings->AsyncInput = TRUE;
return TRUE;
CloseHandle(mfc->stopEvent);
}
void mfreerdp_client_free(freerdp* instance, rdpContext* context)
{
}
void freerdp_client_mouse_event(rdpContext* cfc, DWORD flags, int x, int y)
static void freerdp_client_mouse_event(rdpContext* cfc, DWORD flags, int x,
int y)
{
int width, height;
rdpInput* input = cfc->instance->input;
rdpSettings* settings = cfc->instance->settings;
width = settings->DesktopWidth;
height = settings->DesktopHeight;
@ -132,30 +132,28 @@ void freerdp_client_mouse_event(rdpContext* cfc, DWORD flags, int x, int y)
input->MouseEvent(input, flags, x, y);
}
void mf_scale_mouse_event(void* context, rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
void mf_scale_mouse_event(void* context, rdpInput* input, UINT16 flags,
UINT16 x, UINT16 y)
{
mfContext* mfc = (mfContext*) context;
MRDPView* view = (MRDPView*) mfc->view;
int ww, wh, dw, dh;
ww = mfc->client_width;
wh = mfc->client_height;
dw = mfc->context.settings->DesktopWidth;
dh = mfc->context.settings->DesktopHeight;
// Convert to windows coordinates
y = [view frame].size.height - y;
if (!mfc->context.settings->SmartSizing || ((ww == dw) && (wh == dh)))
{
y = y + mfc->yCurrentScroll;
if (wh != dh)
{
y -= (dh - wh);
}
input->MouseEvent(input, flags, x + mfc->xCurrentScroll, y);
}
else
@ -169,16 +167,12 @@ int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
{
pEntryPoints->Version = 1;
pEntryPoints->Size = sizeof(RDP_CLIENT_ENTRY_POINTS_V1);
pEntryPoints->GlobalInit = mfreerdp_client_global_init;
pEntryPoints->GlobalUninit = mfreerdp_client_global_uninit;
pEntryPoints->ContextSize = sizeof(mfContext);
pEntryPoints->ClientNew = mfreerdp_client_new;
pEntryPoints->ClientFree = mfreerdp_client_free;
pEntryPoints->ClientStart = mfreerdp_client_start;
pEntryPoints->ClientStop = mfreerdp_client_stop;
return 0;
}

View File

@ -54,16 +54,9 @@ struct mf_context
HANDLE stopEvent;
HANDLE keyboardThread;
enum APPLE_KEYBOARD_TYPE appleKeyboardType;
HGDI_DC hdc;
UINT16 srcBpp;
UINT16 dstBpp;
freerdp* instance;
DWORD mainThreadId;
DWORD keyboardThreadId;
BOOL disconnect;
BOOL sw_gdi;
DWORD keyboardThreadId;
BOOL clipboardSync;
wClipboard* clipboard;