View previous topic :: View next topic |
Author |
Message |
eric_carwardine
Joined: 13 Jun 2009 Posts: 70 Location: Perth, Western Australia
|
Posted: Mon Mar 10, 2014 7:27 pm Post subject: Keyboard monitoring |
|
|
G'day, folks
I seek an example of using -
Code: | subroutine add_keyboard_monitor@( cb_func )
external cb_func |
- to collect anything typed at the keyboard. In particular I seek example(s) of the 'anatomy' of the call-back function 'cb_func'
My manual states that keyboard call-back functions use clearwin_info@ parameter 'keyboard_key' but the list of parameters in my manual does not include 'keyboard_key'. My manual lists -
intermediate_scroll
latest_formatted_window
No mention of keyboard_key
Eric, in Perth, Western Australia |
|
Back to top |
|
 |
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Mon Mar 10, 2014 8:16 pm Post subject: |
|
|
I used something like the following piece of code for a Tetris game:
Code: |
integer function kbd_monitor()
integer :: key
key = CLEARWIN_INFO@('KEYBOARD_KEY')
if (key.eq.Z'148') up = .true.
if (key.eq.Z'150') down = .true.
if (key.eq.Z'14B') left = .true.
if (key.eq.Z'14D') right = .true.
if (key.eq.Z'20') space = .true.
kbd_monitor=2
end function kbd_monitor
|
Then inside the game loop I tested if a key was set to .true. , handled a key press and reseted the key state to .false. |
|
Back to top |
|
 |
eric_carwardine
Joined: 13 Jun 2009 Posts: 70 Location: Perth, Western Australia
|
Posted: Tue Mar 11, 2014 3:35 am Post subject: Re: |
|
|
jalih wrote: |
Code: |
key = CLEARWIN_INFO@('KEYBOARD_KEY')
|
Then inside the game loop I tested if a key was set to .true. , handled a key press and reseted the key state to .false.
|
Thankyou so much, jalih Your help is warmly appreciated. The assignment to 'key' is the missing link I was searching for.
Eric - enthused  |
|
Back to top |
|
 |
|