Created
September 1, 2011 11:56
-
-
Save johnfredcee/1186023 to your computer and use it in GitHub Desktop.
Patch for glop Win32 keycode scan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 7fc6632ed9c0febc058fee3c40ce47830aa40ed9 Mon Sep 17 00:00:00 2001 | |
From: John Connors <[email protected]> | |
Date: Thu, 1 Sep 2011 12:46:31 +0100 | |
Subject: [PATCH] Fixing keycode scan | |
--- | |
src/win32/win32.lisp | 18 +++++++++++++----- | |
1 files changed, 13 insertions(+), 5 deletions(-) | |
diff --git a/src/win32/win32.lisp b/src/win32/win32.lisp | |
index c8c06b7..c119d2c 100644 | |
--- a/src/win32/win32.lisp | |
+++ b/src/win32/win32.lisp | |
@@ -520,8 +520,15 @@ | |
(defcfun ("GetKeyboardState" get-keyboard-state) bool | |
(state-out :pointer)) | |
+ | |
+ | |
(defcfun ("ToAscii" to-ascii) :int | |
- (vkey :uint) (scan-code :uint) (kbd-state :pointer) (buffer :pointer) (flags :uint)) | |
+ (vkey :uint) | |
+ (scan-code :uint) (kbd-state :pointer) (buffer :pointer) (flags :uint)) | |
+ | |
+(defcfun ("ToUnicode" to-unicode) :int | |
+ (vkey :uint) | |
+ (scan-code :uint) (kbd-state :pointer) (buffer :pointer) (buffer-size :int) (flags :uint)) | |
;; XXX: this is an ugly hack and should probably be changed | |
;; We use the %event% var to allow window-proc callback to generate glop:event objects | |
@@ -555,10 +562,11 @@ | |
(values (foreign-enum-keyword 'vkey-type w-param :errorp nil) | |
(with-foreign-object (kbd-state :char 256) | |
(when (get-keyboard-state kbd-state) | |
- (with-foreign-object (buffer :int16) | |
- (let ((res (to-ascii (ldb (byte 32 0) w-param) | |
- (ldb (byte 32 0) l-param) | |
- kbd-state buffer 0))) | |
+ (with-foreign-object (buffer :int32) | |
+ (setf (mem-ref buffer :int32) 0) | |
+ (let ((res (to-unicode (ldb (byte 32 0) w-param) | |
+ (ldb (byte 32 0) l-param) | |
+ kbd-state buffer 4 0))) | |
(case res | |
(0 nil) | |
(t (foreign-string-to-lisp buffer))))))))) | |
-- | |
1.7.6.msysgit.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment