forked from neo/neo-layout
neovars: initialization cleaned, functions reordered and removed
This commit is contained in:
parent
1812ec7a43
commit
9e5953f5ce
|
@ -1,12 +1,13 @@
|
|||
; -*- encoding: utf-8 -*-
|
||||
|
||||
name=Neo 2.0 r%revision%-r%CompRevision% (%A_ScriptName%)
|
||||
OnExit, exitprogram
|
||||
NEONumLockLEDState := "Off"
|
||||
NEOCapsLockLEDState := "Off"
|
||||
NEOScrollLockLEDState := "Off"
|
||||
;
|
||||
; Initialize neovars driver program
|
||||
;
|
||||
|
||||
; native unicode-AHK required
|
||||
name := Format("Neo 2.0 r{:s}-r{:s} ({:s})", revision, CompRevision, A_ScriptName)
|
||||
OnExit, exitprogram
|
||||
|
||||
; Make sure AHK runs in Unicode version
|
||||
if (not A_IsUnicode) {
|
||||
MsgBox, 52, Fehlende Unicode-Unterstützung!,
|
||||
(LTrim
|
||||
|
@ -20,6 +21,27 @@ if (not A_IsUnicode) {
|
|||
Suspend
|
||||
}
|
||||
|
||||
; Sync lock states
|
||||
NEONumLockLEDState := "Off"
|
||||
NEOCapsLockLEDState := "Off"
|
||||
NEOScrollLockLEDState := "Off"
|
||||
SetNEOLockStates()
|
||||
|
||||
; Reset global mod-key states
|
||||
wasNonShiftKeyPressed := 0
|
||||
isShiftRPressed := 0
|
||||
isShiftLPressed := 0
|
||||
isShiftPressed := 0
|
||||
isMod2Locked := 0
|
||||
isMod3RPressed := 0
|
||||
isMod3LPressed := 0
|
||||
isMod3Pressed := 0
|
||||
isMod4RPressed := 0
|
||||
isMod4LPressed := 0
|
||||
isMod4Pressed := 0
|
||||
isMod4Locked := 0
|
||||
|
||||
; Read program configuration
|
||||
IniRead,zeigeLockBox,%ini%,Global,zeigeLockBox,1
|
||||
IniRead,zeigeModusBox,%ini%,Global,zeigeModusBox,1
|
||||
IniRead,useMod4Light,%ini%,Global,useMod4Light,1
|
||||
|
@ -32,15 +54,14 @@ IniRead,Mod4LockOff,%ini%,Global,Mod4LockOff,1
|
|||
IniRead,customLayout,%ini%,Global,customLayout,%A_Space%
|
||||
IniRead,Mod3RAufAe,%ini%,Global,Mod3RAufAe,0
|
||||
|
||||
SetNEOLockStates()
|
||||
|
||||
; Read input keyboard layout
|
||||
regread,inputlocale,HKEY_CURRENT_USER,Keyboard Layout\Preload,1
|
||||
regread,inputlocalealias,HKEY_CURRENT_USER,Keyboard Layout\Substitutes,%inputlocale%
|
||||
if (inputlocalealias != "")
|
||||
inputlocale := inputlocalealias
|
||||
|
||||
if (inputlocalealias<>"")
|
||||
inputlocale:=inputlocalealias
|
||||
|
||||
if (inputlocale<>"00000407" and inputlocale<>"00000807" and inputlocale<>"00010407") {
|
||||
; Make sure we run a supported layout
|
||||
if (inputlocale != "00000407" and inputlocale != "00000807" and inputlocale != "00010407") {
|
||||
suspend
|
||||
regread,inputlocale,HKEY_LOCAL_MACHINE,SYSTEM\CurrentControlSet\Control\Keyboard Layouts\%inputlocale%,Layout Text
|
||||
msgbox, 52, Warnung!,
|
||||
|
@ -67,38 +88,6 @@ if (inputlocale<>"00000407" and inputlocale<>"00000807" and inputlocale<>"000104
|
|||
InitializeCustomFun := "InitializeCustom1"
|
||||
if (IsFunc(InitializeCustomFun))
|
||||
%InitializeCustomFun%()
|
||||
wasNonShiftKeyPressed := 0
|
||||
isShiftRPressed := 0
|
||||
isShiftLPressed := 0
|
||||
isShiftPressed := 0
|
||||
isMod2Locked := 0
|
||||
isMod3RPressed := 0
|
||||
isMod3LPressed := 0
|
||||
isMod3Pressed := 0
|
||||
isMod4RPressed := 0
|
||||
isMod4LPressed := 0
|
||||
isMod4Pressed := 0
|
||||
isMod4Locked := 0
|
||||
|
||||
SetNEOLockStates() {
|
||||
global
|
||||
SavedNumLockState := GetKeyState("NumLock","T")
|
||||
SavedScrollLockState := GetKeyState("ScrollLock","T")
|
||||
SavedCapsLockState := GetKeyState("CapsLock","T")
|
||||
SwitchIs0 := "Off"
|
||||
SwitchIs1 := "On"
|
||||
SavedNumLockState := SwitchIs%SavedNumLockState%
|
||||
SavedScrollLockState := SwitchIs%SavedScrollLockState%
|
||||
SavedCapsLockState := SwitchIs%SavedCapsLockState%
|
||||
if (NumLockOff == 1)
|
||||
SetNumLockState, Off
|
||||
else
|
||||
SetNumLockState, On
|
||||
SetScrollLockState, Off
|
||||
SetCapsLockState, Off
|
||||
Sleep,1
|
||||
UpdateNEOLEDS()
|
||||
}
|
||||
|
||||
; Load compose-definitions
|
||||
; Later definitions cannot modify prior ones.
|
||||
|
@ -107,14 +96,6 @@ if (dynamischesCompose) ; parse external XCompose
|
|||
LoadCurrentCompose()
|
||||
else
|
||||
LoadDefaultCompose() ; precompiled XCompose
|
||||
SetOldLockStates() {
|
||||
global
|
||||
UpdateOldLEDS()
|
||||
Sleep,1
|
||||
SetNumLockState,% SavedNumLockState
|
||||
SetScrollLockState,% SavedScrollLockState
|
||||
SetCapsLockState,% SavedCapsLockState
|
||||
}
|
||||
|
||||
; Activate driver with default- or custom layout
|
||||
ActivateLayOut(inputlocale)
|
||||
|
|
|
@ -25,39 +25,6 @@ EbeneAktualisieren() {
|
|||
Check_BSTUpdate()
|
||||
}
|
||||
|
||||
IsShiftActive() {
|
||||
global
|
||||
if (isMod2Locked)
|
||||
if (isShiftPressed)
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
else
|
||||
if (isShiftPressed)
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
}
|
||||
|
||||
IsMod3Active() {
|
||||
global
|
||||
return isMod3Pressed
|
||||
}
|
||||
|
||||
IsMod4Active() {
|
||||
global
|
||||
if (isMod4Locked)
|
||||
if (isMod4Pressed)
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
else
|
||||
if (isMod4Pressed)
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
}
|
||||
|
||||
ToggleMod2Lock() {
|
||||
global
|
||||
if (Mod2LockOff)
|
||||
|
@ -99,4 +66,3 @@ ToggleMod4Lock() {
|
|||
if (LEDChange)
|
||||
UpdateNEOLEDS()
|
||||
}
|
||||
|
||||
|
|
|
@ -1128,7 +1128,7 @@ BSTAddSymbols() {
|
|||
; *) has a graphical symbol already
|
||||
}
|
||||
|
||||
BSTRegister() {
|
||||
InitializeBST() {
|
||||
global CP3F1, CP4F1, CP3F2, CP3F3
|
||||
, useBST, useDBST, bstAnimate, bstLayoutIdx, bstBaseScale
|
||||
, BSTcurrScale, BSTcurrLayout, BSTlayouts
|
||||
|
|
|
@ -231,15 +231,70 @@ SendBlindShiftFixed(char, theseq) {
|
|||
send % "{blind}" . theseq
|
||||
}
|
||||
|
||||
CharProc(name) {
|
||||
CharProc%name%()
|
||||
;
|
||||
; Unicode output
|
||||
;
|
||||
|
||||
SendUnicodeChar(charCode){
|
||||
static ki := "#"
|
||||
if (ki =="#") {
|
||||
VarSetCapacity(ki,28*4,0)
|
||||
DllCall("RtlFillMemory","uint",&ki+ 0,"uint",1,"uint",1)
|
||||
DllCall("RtlFillMemory","uint",&ki+ 28+0,"uint",1,"uint",1)
|
||||
DllCall("RtlFillMemory","uint",&ki+2*28+0,"uint",1,"uint",1)
|
||||
DllCall("RtlFillMemory","uint",&ki+3*28+0,"uint",1,"uint",1)
|
||||
}
|
||||
if (charCode < 0x10000) {
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+ 6,"uint",4,"uint",0x40000|charCode) ;KEYEVENTF_UNICODE
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+28+6,"uint",4,"uint",0x60000|charCode) ;KEYEVENTF_KEYUP|KEYEVENTF_UNICODE
|
||||
DllCall("SendInput","UInt",2,"UInt",&ki,"Int",28)
|
||||
} else {
|
||||
hi_surrogate := 0xD800|((charCode-0x10000)/1024)
|
||||
lo_surrogate := 0xDC00|((charCode-0x10000)&0x3FF)
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+ 6,"uint",4,"uint",0x40000|hi_surrogate) ;KEYEVENTF_UNICODE
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+ 28+6,"uint",4,"uint",0x40000|lo_surrogate) ;KEYEVENTF_UNICODE
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+2*28+6,"uint",4,"uint",0x60000|hi_surrogate) ;KEYEVENTF_KEYUP|KEYEVENTF_UNICODE
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+3*28+6,"uint",4,"uint",0x60000|lo_surrogate) ;KEYEVENTF_KEYUP|KEYEVENTF_UNICODE
|
||||
DllCall("SendInput","UInt",4,"UInt",&ki,"Int",28)
|
||||
}
|
||||
}
|
||||
|
||||
CharProc__Rlod() {
|
||||
global
|
||||
; Neustart des AHK-Skripts
|
||||
SetOldLockStates()
|
||||
reload
|
||||
SendUnicodeCharDown(charCode){
|
||||
static ki := "#"
|
||||
if (ki =="#") {
|
||||
VarSetCapacity(ki,28*2,0)
|
||||
DllCall("RtlFillMemory","uint",&ki+ 0,"uint",1,"uint",1)
|
||||
DllCall("RtlFillMemory","uint",&ki+ 28+0,"uint",1,"uint",1)
|
||||
}
|
||||
if (charCode < 0x10000) {
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+ 6,"uint",4,"uint",0x40000|charCode) ;KEYEVENTF_UNICODE
|
||||
DllCall("SendInput","UInt",1,"UInt",&ki,"Int",28)
|
||||
} else {
|
||||
hi_surrogate := 0xD800|((charCode-0x10000)/1024)
|
||||
lo_surrogate := 0xDC00|((charCode-0x10000) & 0x3FF)
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+ 6,"uint",4,"uint",0x40000|hi_surrogate) ;KEYEVENTF_UNICODE
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+ 28+6,"uint",4,"uint",0x40000|lo_surrogate) ;KEYEVENTF_UNICODE
|
||||
DllCall("SendInput","UInt",2,"UInt",&ki,"Int",28)
|
||||
}
|
||||
}
|
||||
|
||||
SendUnicodeCharUp(charCode){
|
||||
static ki := "#"
|
||||
if (ki =="#") {
|
||||
VarSetCapacity(ki,28*2,0)
|
||||
DllCall("RtlFillMemory","uint",&ki+ 0,"uint",1,"uint",1)
|
||||
DllCall("RtlFillMemory","uint",&ki+ 28+0,"uint",1,"uint",1)
|
||||
}
|
||||
if (charCode < 0x10000) {
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+ 6,"uint",4,"uint",0x60000|charCode) ;KEYEVENTF_KEYUP|KEYEVENTF_UNICODE
|
||||
DllCall("SendInput","UInt",1,"UInt",&ki,"Int",28)
|
||||
} else {
|
||||
hi_surrogate := 0xD800|((charCode-0x10000)/1024)
|
||||
lo_surrogate := 0xDC00|((charCode-0x10000)&0x3FF)
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+ 6,"uint",4,"uint",0x60000|hi_surrogate) ;KEYEVENTF_KEYUP|KEYEVENTF_UNICODE
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+ 28+6,"uint",4,"uint",0x60000|lo_surrogate) ;KEYEVENTF_KEYUP|KEYEVENTF_UNICODE
|
||||
DllCall("SendInput","UInt",2,"UInt",&ki,"Int",28)
|
||||
}
|
||||
}
|
||||
|
||||
;
|
||||
|
@ -378,65 +433,48 @@ CharProc__M4RU(keyName) {
|
|||
EbeneAktualisieren()
|
||||
}
|
||||
|
||||
SendUnicodeChar(charCode){
|
||||
static ki := "#"
|
||||
if (ki =="#") {
|
||||
VarSetCapacity(ki,28*4,0)
|
||||
DllCall("RtlFillMemory","uint",&ki+ 0,"uint",1,"uint",1)
|
||||
DllCall("RtlFillMemory","uint",&ki+ 28+0,"uint",1,"uint",1)
|
||||
DllCall("RtlFillMemory","uint",&ki+2*28+0,"uint",1,"uint",1)
|
||||
DllCall("RtlFillMemory","uint",&ki+3*28+0,"uint",1,"uint",1)
|
||||
}
|
||||
if (charCode < 0x10000) {
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+ 6,"uint",4,"uint",0x40000|charCode) ;KEYEVENTF_UNICODE
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+28+6,"uint",4,"uint",0x60000|charCode) ;KEYEVENTF_KEYUP|KEYEVENTF_UNICODE
|
||||
DllCall("SendInput","UInt",2,"UInt",&ki,"Int",28)
|
||||
} else {
|
||||
hi_surrogate := 0xD800|((charCode-0x10000)/1024)
|
||||
lo_surrogate := 0xDC00|((charCode-0x10000)&0x3FF)
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+ 6,"uint",4,"uint",0x40000|hi_surrogate) ;KEYEVENTF_UNICODE
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+ 28+6,"uint",4,"uint",0x40000|lo_surrogate) ;KEYEVENTF_UNICODE
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+2*28+6,"uint",4,"uint",0x60000|hi_surrogate) ;KEYEVENTF_KEYUP|KEYEVENTF_UNICODE
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+3*28+6,"uint",4,"uint",0x60000|lo_surrogate) ;KEYEVENTF_KEYUP|KEYEVENTF_UNICODE
|
||||
DllCall("SendInput","UInt",4,"UInt",&ki,"Int",28)
|
||||
}
|
||||
;
|
||||
; Other character procedures
|
||||
;
|
||||
; See also keyhooks.ahk
|
||||
|
||||
; Neustart des AHK-Skripts
|
||||
CharProc__Rlod(keyName) {
|
||||
global
|
||||
SetOldLockStates()
|
||||
reload
|
||||
}
|
||||
|
||||
SendUnicodeCharDown(charCode){
|
||||
static ki := "#"
|
||||
if (ki =="#") {
|
||||
VarSetCapacity(ki,28*2,0)
|
||||
DllCall("RtlFillMemory","uint",&ki+ 0,"uint",1,"uint",1)
|
||||
DllCall("RtlFillMemory","uint",&ki+ 28+0,"uint",1,"uint",1)
|
||||
}
|
||||
if (charCode < 0x10000) {
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+ 6,"uint",4,"uint",0x40000|charCode) ;KEYEVENTF_UNICODE
|
||||
DllCall("SendInput","UInt",1,"UInt",&ki,"Int",28)
|
||||
} else {
|
||||
hi_surrogate := 0xD800|((charCode-0x10000)/1024)
|
||||
lo_surrogate := 0xDC00|((charCode-0x10000) & 0x3FF)
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+ 6,"uint",4,"uint",0x40000|hi_surrogate) ;KEYEVENTF_UNICODE
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+ 28+6,"uint",4,"uint",0x40000|lo_surrogate) ;KEYEVENTF_UNICODE
|
||||
DllCall("SendInput","UInt",2,"UInt",&ki,"Int",28)
|
||||
}
|
||||
;
|
||||
; Lock states
|
||||
;
|
||||
|
||||
SetNEOLockStates() {
|
||||
global
|
||||
SavedNumLockState := GetKeyState("NumLock","T")
|
||||
SavedScrollLockState := GetKeyState("ScrollLock","T")
|
||||
SavedCapsLockState := GetKeyState("CapsLock","T")
|
||||
SwitchIs0 := "Off"
|
||||
SwitchIs1 := "On"
|
||||
SavedNumLockState := SwitchIs%SavedNumLockState%
|
||||
SavedScrollLockState := SwitchIs%SavedScrollLockState%
|
||||
SavedCapsLockState := SwitchIs%SavedCapsLockState%
|
||||
if (NumLockOff)
|
||||
SetNumLockState, Off
|
||||
else
|
||||
SetNumLockState, On
|
||||
SetScrollLockState, Off
|
||||
SetCapsLockState, Off
|
||||
Sleep,1
|
||||
UpdateNEOLEDS()
|
||||
}
|
||||
|
||||
SendUnicodeCharUp(charCode){
|
||||
static ki := "#"
|
||||
if (ki =="#") {
|
||||
VarSetCapacity(ki,28*2,0)
|
||||
DllCall("RtlFillMemory","uint",&ki+ 0,"uint",1,"uint",1)
|
||||
DllCall("RtlFillMemory","uint",&ki+ 28+0,"uint",1,"uint",1)
|
||||
}
|
||||
if (charCode < 0x10000) {
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+ 6,"uint",4,"uint",0x60000|charCode) ;KEYEVENTF_KEYUP|KEYEVENTF_UNICODE
|
||||
DllCall("SendInput","UInt",1,"UInt",&ki,"Int",28)
|
||||
} else {
|
||||
hi_surrogate := 0xD800|((charCode-0x10000)/1024)
|
||||
lo_surrogate := 0xDC00|((charCode-0x10000)&0x3FF)
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+ 6,"uint",4,"uint",0x60000|hi_surrogate) ;KEYEVENTF_KEYUP|KEYEVENTF_UNICODE
|
||||
DllCall("ntdll.dll\RtlFillMemoryUlong","uint",&ki+ 28+6,"uint",4,"uint",0x60000|lo_surrogate) ;KEYEVENTF_KEYUP|KEYEVENTF_UNICODE
|
||||
DllCall("SendInput","UInt",2,"UInt",&ki,"Int",28)
|
||||
}
|
||||
SetOldLockStates() {
|
||||
global
|
||||
UpdateOldLEDS()
|
||||
Sleep,1
|
||||
SetNumLockState,% SavedNumLockState
|
||||
SetScrollLockState,% SavedScrollLockState
|
||||
SetCapsLockState,% SavedCapsLockState
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue