Skip to content

Commit

Permalink
Merge branch 'master' of github.com:kmatheussen/radium
Browse files Browse the repository at this point in the history
  • Loading branch information
kmatheussen committed Apr 14, 2016
2 parents c011f04 + 9b7f6f6 commit 29b2326
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 16 deletions.
23 changes: 23 additions & 0 deletions Changelog
@@ -1,3 +1,26 @@
Changes 3.7.4 -> 3.7.5:
* windows: Run low level keyboard hook in separate thread.
Hopefully this will prevent left windows key from suddenly
showing the windows menu on Windows 7.
* osx: Support the 1L1 key on non-iso keyboards.
* playlist move up/down buttons
* Make slider text color configurable
* Don't change play position when play cursor is enabled
* Scroll down when adding note, and playing, and play cursor is enabled
* If trying to scroll past last line, jump to line 1 instead of stopping
at last line.
* Fix not smoothly scrolling the last line (bug introduced in 3.7.3)
* Keep "glide" when pasting pitches.
* Keep "glide" when pasting velocities
* Switch glide mode in text tracks by pressing T
* api: numSignatures/numLPBs/numBPMs
* Possible to hide centtext track if notetext track is not visible
* vst: Don't do debug printing in the callbacks
* Fix vst sliders in radium might not always update if the slider
was updated in the native gui. (The bug is quite unlikely to have
ever happened though)


Changes 3.7.2 -> 3.7.4:
* osx: Fix modifier keys when clicking mouse
* Hack fixes for positioning leftmost track.
Expand Down
2 changes: 1 addition & 1 deletion Makefile.Qt
Expand Up @@ -2,7 +2,7 @@
# Users and packagers: Edit build_*.sh instead.
#

VERSION = 3.7.4
VERSION = 3.7.5

#----------------USER SETTINGS-------------------------------

Expand Down
1 change: 1 addition & 0 deletions macosx/cocoa_Keyboard.m
Expand Up @@ -195,6 +195,7 @@ static void init_keymaps(void){

// row 2
keymap_qwerty[kVK_ISO_Section] = EVENT_1L1;
keymap_qwerty[kVK_ANSI_Grave] = EVENT_1L1;
keymap_qwerty[kVK_ANSI_Minus] = EVENT_0R1;
keymap_qwerty[kVK_ANSI_Equal] = EVENT_0R2;
keymap_qwerty[kVK_Delete] = EVENT_BACKSPACE;
Expand Down
58 changes: 43 additions & 15 deletions windows/W_Keyboard.c
Expand Up @@ -34,8 +34,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */

extern struct TEvent tevent;

static bool left_windows_down = false;
static bool right_windows_down = false;
static DEFINE_ATOMIC(bool, left_windows_down) = false;
static DEFINE_ATOMIC(bool, right_windows_down) = false;

static unsigned int g_last_keyswitch;

Expand Down Expand Up @@ -64,9 +64,9 @@ static uint32_t get_keyswitch(void){
if(GetKeyState(VK_RMENU)&0x8000)
keyswitch |= EVENT_RIGHTALT;

if(left_windows_down)
if(ATOMIC_GET(left_windows_down))
keyswitch |= EVENT_LEFTEXTRA1;
if(right_windows_down)
if(ATOMIC_GET(right_windows_down))
keyswitch |= EVENT_RIGHTEXTRA1;

bool is_right_alt =
Expand Down Expand Up @@ -325,27 +325,27 @@ int OS_SYSTEM_get_keycode(void *void_event) {
return scancode;
}

static bool g_bWindowActive = true;
static DEFINE_ATOMIC(bool, g_bWindowActive) = true;

void OS_SYSTEM_EventPreHandler(void *void_event){
MSG *msg = (MSG*)void_event;

switch(msg->message){

case WM_NCACTIVATE:
g_bWindowActive = msg->wParam ? true : false;
ATOMIC_SET(g_bWindowActive, msg->wParam ? true : false);
//printf("1. Got NC Activate. wParam: %d\n",(int)msg->wParam);
//fflush(stdout);
break;

case WM_ACTIVATE:
g_bWindowActive = msg->wParam ? true : false;
ATOMIC_SET(g_bWindowActive, msg->wParam ? true : false);
//printf("2. Got Activate. wParam: %d\n",(int)msg->wParam);
//fflush(stdout);
break;

case WM_ACTIVATEAPP:
g_bWindowActive = msg->wParam ? true : false;
ATOMIC_SET(g_bWindowActive, msg->wParam ? true : false);
//printf("3. Got Activate app. wParam: %d\n",(int)msg->wParam);
//fflush(stdout);
break;
Expand Down Expand Up @@ -449,34 +449,62 @@ LRESULT CALLBACK LowLevelKeyboardProc( int nCode, WPARAM wParam, LPARAM lParam )
if(p->vkCode==VK_LWIN || p->vkCode==VK_RWIN){

if(p->vkCode==VK_LWIN)
left_windows_down = wParam==WM_KEYDOWN;
ATOMIC_SET(left_windows_down, wParam==WM_KEYDOWN);
else
right_windows_down = wParam==WM_KEYDOWN;
ATOMIC_SET(right_windows_down, wParam==WM_KEYDOWN);

#if 0
// Don't think this is any point.
if (left_windows_down)
tevent.keyswitch |= EVENT_LEFTEXTRA1;
else
tevent.keyswitch &= (~EVENT_LEFTEXTRA1);
#endif

//printf("active: %d, left: %s, right: %s. switch: %x\n",g_bWindowActive, left_windows_down?"down":"up", right_windows_down?"down":"up", );
if(g_bWindowActive)
if(ATOMIC_GET(g_bWindowActive)==true)
return 1; // To avoid having the windows menu pop up when the radium window is active and pressing left windows key.
}
}

return CallNextHookEx( g_hKeyboardHook, nCode, wParam, lParam );
}

// Needs to be run in separate thread on windows 7. See example here: https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/f6032ca1-31b8-4ad5-be39-f78dd29952da/hooking-problem-in-windows-7?forum=windowscompatibility

// Code copied from here: https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/f6032ca1-31b8-4ad5-be39-f78dd29952da/hooking-problem-in-windows-7?forum=windowscompatibility
static DWORD WINAPI mouseLLHookThreadProc(LPVOID lParam)
{
MSG msg;

g_hKeyboardHook = SetWindowsHookEx( WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), 0 );

while(GetMessage(&msg, NULL, 0, 0) != FALSE)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

return 0;
}

void OS_SYSTEM_init_keyboard(void) {
init_keymap();
g_hKeyboardHook = SetWindowsHookEx( WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), 0 );

CreateThread(
NULL, // default security attributes
0, // use default stack size
mouseLLHookThreadProc, // thread function name
NULL, // argument to thread function
0, // use default creation flags
NULL // returns the thread identifier
);

//g_hKeyboardHook = SetWindowsHookEx( WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), 0 );
}

void W_KeyboardHandlerShutDown(void){
if(g_hKeyboardHook!=NULL)
UnhookWindowsHookEx(g_hKeyboardHook);
//if(g_hKeyboardHook!=NULL)
// UnhookWindowsHookEx(g_hKeyboardHook);
}

#ifdef RUN_TEST
Expand Down

0 comments on commit 29b2326

Please sign in to comment.