Commit b78eee31 authored by Ken Thomases's avatar Ken Thomases Committed by Alexandre Julliard

winemac: Build a map from Mac virtual key codes to Win32 vkeys and scan codes…

winemac: Build a map from Mac virtual key codes to Win32 vkeys and scan codes based on Mac keyboard layout.
parent 8a0c8d92
MODULE = winemac.drv
IMPORTS = user32 gdi32 advapi32
EXTRALIBS = -framework AppKit
EXTRALIBS = -framework AppKit -framework Carbon
C_SRCS = \
display.c \
event.c \
gdi.c \
keyboard.c \
macdrv_main.c \
mouse.c \
scroll.c \
......
......@@ -40,8 +40,12 @@
NSMutableArray* keyWindows;
NSMutableSet* triedWindows;
unsigned long windowFocusSerial;
CGEventSourceKeyboardType keyboardType;
}
@property (nonatomic) CGEventSourceKeyboardType keyboardType;
- (void) transformProcessToForeground;
- (BOOL) registerEventQueue:(WineEventQueue*)queue;
......
......@@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#import <Carbon/Carbon.h>
#import "cocoa_app.h"
#import "cocoa_event.h"
#import "cocoa_window.h"
......@@ -28,6 +30,8 @@ int macdrv_err_on;
@implementation WineApplication
@synthesize keyboardType;
- (id) init
{
self = [super init];
......@@ -213,6 +217,8 @@ int macdrv_err_on;
NSWindow* window = [note object];
[keyWindows removeObjectIdenticalTo:window];
}];
self.keyboardType = LMGetKbdType();
}
@end
......@@ -270,3 +276,31 @@ void macdrv_window_rejected_focus(const macdrv_event *event)
[NSApp windowRejectedFocusEvent:event];
});
}
/***********************************************************************
* macdrv_get_keyboard_layout
*
* Returns the keyboard layout uchr data.
*/
CFDataRef macdrv_copy_keyboard_layout(CGEventSourceKeyboardType* keyboard_type, int* is_iso)
{
__block CFDataRef result = NULL;
OnMainThread(^{
TISInputSourceRef inputSource;
inputSource = TISCopyCurrentKeyboardLayoutInputSource();
if (inputSource)
{
CFDataRef uchr = TISGetInputSourceProperty(inputSource,
kTISPropertyUnicodeKeyLayoutData);
result = CFDataCreateCopy(NULL, uchr);
CFRelease(inputSource);
*keyboard_type = ((WineApplication*)NSApp).keyboardType;
*is_iso = (KBGetLayoutType(*keyboard_type) == kKeyboardISO);
}
});
return result;
}
......@@ -84,6 +84,11 @@ struct macdrv_thread_data
{
macdrv_event_queue queue;
const macdrv_event *current_event;
CFDataRef keyboard_layout_uchr;
CGEventSourceKeyboardType keyboard_type;
int iso_keyboard;
WORD keyc2vkey[128];
WORD keyc2scan[128];
};
extern DWORD thread_data_tls_index DECLSPEC_HIDDEN;
......@@ -128,4 +133,6 @@ extern void macdrv_window_did_unminimize(HWND hwnd) DECLSPEC_HIDDEN;
extern void macdrv_mouse_button(HWND hwnd, const macdrv_event *event) DECLSPEC_HIDDEN;
extern void macdrv_compute_keyboard_layout(struct macdrv_thread_data *thread_data) DECLSPEC_HIDDEN;
#endif /* __WINE_MACDRV_H */
......@@ -219,4 +219,8 @@ extern void macdrv_clear_window_color_key(macdrv_window w) DECLSPEC_HIDDEN;
extern void macdrv_window_use_per_pixel_alpha(macdrv_window w, int use_per_pixel_alpha) DECLSPEC_HIDDEN;
extern void macdrv_give_cocoa_window_focus(macdrv_window w) DECLSPEC_HIDDEN;
/* keyboard */
extern CFDataRef macdrv_copy_keyboard_layout(CGEventSourceKeyboardType* keyboard_type, int* is_iso) DECLSPEC_HIDDEN;
#endif /* __WINE_MACDRV_COCOA_H */
......@@ -60,6 +60,8 @@ static void thread_detach(void)
if (data)
{
macdrv_destroy_event_queue(data->queue);
if (data->keyboard_layout_uchr)
CFRelease(data->keyboard_layout_uchr);
HeapFree(GetProcessHeap(), 0, data);
}
}
......@@ -116,6 +118,9 @@ struct macdrv_thread_data *macdrv_init_thread_data(void)
ExitProcess(1);
}
data->keyboard_layout_uchr = macdrv_copy_keyboard_layout(&data->keyboard_type, &data->iso_keyboard);
macdrv_compute_keyboard_layout(data);
set_queue_display_fd(macdrv_get_event_queue_fd(data->queue));
TlsSetValue(thread_data_tls_index, data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment