|
@@ -16,21 +16,24 @@ Global bbKeyInfos:bbKeyInfo Ptr
|
|
|
|
|
|
Public
|
|
Public
|
|
|
|
|
|
-#rem monkeydoc Global Keyboard device.
|
|
|
|
-#end
|
|
|
|
-Global Keyboard:=New KeyboardDevice
|
|
|
|
|
|
+#rem monkeydoc Application keyboard device instance.
|
|
|
|
|
|
-#rem monkeydoc The KeyboardDevice class.
|
|
|
|
|
|
+#end
|
|
|
|
+Const Keyboard:=New KeyboardDevice
|
|
|
|
|
|
-The KeyboardDevice can be accessed via the [[Keyboard]] global variable.
|
|
|
|
|
|
+#rem monkeydoc The KeyboardDevice singleton class.
|
|
|
|
|
|
-Note that all methods can also be used with 'raw' keys.
|
|
|
|
|
|
+All method that take a `key` parameter can also be used with 'raw' keys.
|
|
|
|
|
|
A raw key represents the physical location of a key on US keyboards. For example, `Key.Q|Key.Raw` indicates the key at the top left of the
|
|
A raw key represents the physical location of a key on US keyboards. For example, `Key.Q|Key.Raw` indicates the key at the top left of the
|
|
'qwerty' keys regardless of the current keyboard layout.
|
|
'qwerty' keys regardless of the current keyboard layout.
|
|
|
|
|
|
Please see the [[Key]] enum for more information on raw keys.
|
|
Please see the [[Key]] enum for more information on raw keys.
|
|
|
|
|
|
|
|
+To access the keyboard device, use the global [[Keyboard]] constant.
|
|
|
|
+
|
|
|
|
+The keyboard device should only used after a new [[app.AppInstance]] is created.
|
|
|
|
+
|
|
#end
|
|
#end
|
|
Class KeyboardDevice Extends InputDevice
|
|
Class KeyboardDevice Extends InputDevice
|
|
|
|
|
|
@@ -61,8 +64,12 @@ Class KeyboardDevice Extends InputDevice
|
|
#end
|
|
#end
|
|
Method TranslateKey:Key( key:Key )
|
|
Method TranslateKey:Key( key:Key )
|
|
If key & Key.Raw
|
|
If key & Key.Raw
|
|
|
|
+#If __TARGET__="emscripten"
|
|
|
|
+ Return key & ~Key.Raw
|
|
|
|
+#Else
|
|
Local keyCode:=SDL_GetKeyFromScancode( Cast<SDL_Scancode>( _raw2scan[ key & ~Key.Raw ] ) )
|
|
Local keyCode:=SDL_GetKeyFromScancode( Cast<SDL_Scancode>( _raw2scan[ key & ~Key.Raw ] ) )
|
|
Return KeyCodeToKey( keyCode )
|
|
Return KeyCodeToKey( keyCode )
|
|
|
|
+#Endif
|
|
Else
|
|
Else
|
|
Local scanCode:=_key2scan[key]
|
|
Local scanCode:=_key2scan[key]
|
|
Return _scan2raw[scanCode]
|
|
Return _scan2raw[scanCode]
|
|
@@ -189,9 +196,15 @@ Class KeyboardDevice Extends InputDevice
|
|
Local key:=KeyCodeToKey( keyCode )
|
|
Local key:=KeyCodeToKey( keyCode )
|
|
|
|
|
|
_names[key]=name
|
|
_names[key]=name
|
|
- _key2scan[key]=SDL_GetScancodeFromKey( Cast<SDL_Keycode>( keyCode ) )
|
|
|
|
_raw2scan[key]=scanCode
|
|
_raw2scan[key]=scanCode
|
|
_scan2raw[scanCode]=key | Key.Raw
|
|
_scan2raw[scanCode]=key | Key.Raw
|
|
|
|
+#If __TARGET__="emscripten"
|
|
|
|
+ _key2scan[key]=scanCode
|
|
|
|
+#Else
|
|
|
|
+ _key2scan[key]=SDL_GetScancodeFromKey( Cast<SDL_Keycode>( keyCode ) )
|
|
|
|
+#Endif
|
|
|
|
+ _scan2key[_key2scan[key]]=scanCode
|
|
|
|
+
|
|
|
|
|
|
p=p+1
|
|
p=p+1
|
|
Wend
|
|
Wend
|
|
@@ -209,9 +222,10 @@ Class KeyboardDevice Extends InputDevice
|
|
Field _pressed:=New Bool[512]
|
|
Field _pressed:=New Bool[512]
|
|
Field _released:=New Bool[512]
|
|
Field _released:=New Bool[512]
|
|
Field _names:=New String[512]
|
|
Field _names:=New String[512]
|
|
- Field _key2scan:=New Int[512]
|
|
|
|
- Field _raw2scan:=New Int[512]
|
|
|
|
- Field _scan2raw:=New Key[512]
|
|
|
|
|
|
+ Field _raw2scan:=New Int[512] 'no translate
|
|
|
|
+ Field _scan2raw:=New Key[512] 'no translate
|
|
|
|
+ Field _key2scan:=New Int[512] 'translate
|
|
|
|
+ Field _scan2key:=New Int[512] 'translate
|
|
|
|
|
|
Method New()
|
|
Method New()
|
|
End
|
|
End
|