mydemo% = -1
PRINT "Press keys or use mouse for demo.";
CALL keyboard_mouse
(UI
, mydemo%
) SOUND 1000, .3: UI.MbEnvoked
= -1
CALL keyboard_mouse
(UI
, mydemo%
) SOUND 300, .3: UI.MbEnvoked
= 1
SUB keyboard_mouse
(UI
AS UserInput
, mydemo%
)
UI.KeyCombos = 1 ' Shift % = -1 ELSE shift% = 0
UI.KeyCombos = 2 ' Ctrl % = -1 ELSE ctrl% = 0
UI.KeyCombos = 3 ' Alt % = -1
UI.KeyCombos = 4 ' Ctrl+Shift % = -1 ELSE ctrlshift% = 0
UI.KeyCombos = 0
IF LEN(UI.KeyPress
) THEN ' A key was pressed. UI.MbEnvoked = 0: UI.MbLeftx = 0
CASE 1 ' 1-byte key A-Z, etc. ' Place key selection routine here...
CASE 2 '2-byte key F1-F12, etc. ' Place key selection routine here...
ELSE ' Check for mouse input since no keyboard input was detected.
IF lclick
THEN ' Check timer for double-clicks. IF TIMER < z1
THEN z1
= z1
- 86400 ' Midnight adjustment. IF TIMER - z1
> .33 THEN lclick
= 0 ' Too much time ellapsed for a double click.
' Get mouse status.
' Check for mouse movement.
IF UI.mx
<> UI.oldmx
OR UI.my
<> UI.oldmy
THEN
IF UI.MbStatus
< 0 THEN ' Mouse button pressed. UI.MbStatus identity is by number. -1=left, -2=right, -3=middle. CASE -1 ' Left button was pressed. IF lb
= 0 THEN ' Left button released. SELECT CASE lclick
' Single or double click analysis. lclick = lclick + 1
CASE ELSE ' Double click. Completed upon 2nd left button release. UI.DoubleClick = -1
lclick = 0
UI.MbStatus = 1
IF UI.mx
<> UI.MbLeftx
OR UI.my
<> UI.MbLefty
THEN UI.MbStatus
= 0: lclick
= 0 UI.MbLeftx = 0: UI.MbLefty = 0
ELSE ' Left button is being held down. Check for UI.drag. IF UI.mx
<> UI.oldmx
OR UI.my
<> UI.oldmy
THEN ' Mouse cursor has moved. UI.drag. UI.drag = -1
CASE -2 ' Right button was pressed. IF rb
= 0 THEN ' Right button was relased. UI.MbStatus = 2
CASE -3 ' Middle button was pressed IF mb
= 0 THEN ' Middle button was released. UI.MbStatus = 3
IF lb
THEN ' Left button just pressed. UI.MbStatus = -1
IF UI.MbLeftx
= 0 THEN UI.MbLeftx
= UI.mx: UI.MbLefty
= UI.my
IF UI.MbLeftx
= 0 THEN UI.MbLeftx
= UI.mx: UI.MbLefty
= UI.my
UI.MbStatus = -2
IF UI.MbLeftx
= 0 THEN UI.MbLeftx
= UI.mx: UI.MbLefty
= UI.my
UI.MbStatus = -3
UI.oldmx = UI.mx: UI.oldmy = UI.my: mw = 0 ' Mouse position past and present.
mydemo:
PRINT "1-byte Key = "; UI.KeyPress
PRINT "2-byte Key = "; UI.KeyPress
PRINT "Left button released." PRINT "Right button released." PRINT "Middle button released." PRINT "Left button down." PRINT "Right button down." PRINT "Middle button down." PRINT "Wheel scroll down." PRINT "Left button double click." mydemo% = -1
check_UI.KeyCombos:
PRINT "Shift key down. ";
PRINT "Ctrl + Shift key down. ";