help with input routines

BlitzMax Forums/BlitzMax Beginners Area/help with input routines

peltazoid(Posted 2005) [#1]
ok, i'm writing a small set of gui functions to form the basis of a front end for a game, but i'm having problems with checking for qualifiers on keyboard input.

say i'm checking for alt + c i get either the scancode for alt or the scan code for c, never both and i'm not sure what is wrong.

here is the code


Const EV_NONE      = $0
Const EV_MOUSEDOWN = $1
Const EV_MOUSEUP   = $2		
Const EV_MOUSEOVER = $4
Const EV_GADHIT    = $8

Const EV_KEYDOWN   = $10
Const EV_KEYUP	   = $20
Const EV_KEYHIT    = $40

Const QUAL_CTRL	   = $100
Const QUAL_ALT	   = $200
Const QUAL_SHIFT   = $400
Const QUAL_LEFT	   = $1000
Const QUAL_RIGHT   = $2000

Global event:TPEvent		


Type TPEvent

	Field id					' event type
	Field data					' data type
	Field source				' source of event (gadget/window id)
	
End Type

Function WaitEvent:Int()
	
	' test for mouse location, is the mouse over a gadget
	
	Local ex_loop:Byte
	
	event.id = 0; event.data = 0; event.source = 0	' clear event

	WaitSystem()

Local q_key:Int = 0
	Local key

	' scan for keys hit, filtering out the qualifiers
	
	For Local i = 5 To 255
		If KeyHit(i)
			
			Select i
			Case KEY_LALT
				q_key = QUAL_LEFT + QUAL_ALT
				DebugLog "Q_KEY LALT " + Hex(q_key)
			Case KEY_RALT
				q_key = QUAL_RIGHT + QUAL_ALT
				DebugLog "Q_KEY RALT " + Hex(q_key)

			Case KEY_LCONTROL
				q_key = QUAL_LEFT + QUAL_CTRL
				DebugLog "Q_KEY LCTRL " + Hex(q_key)
			Case KEY_RCONTROL
				q_key = QUAL_RIGHT + QUAL_CTRL
				DebugLog "Q_KEY LCTRL " + Hex(q_key)
			Case KEY_LSHIFT
				q_key = QUAL_LEFT + QUAL_SHIFT
				DebugLog "Q_KEY LSHIFT " + Hex(q_key)
			Case KEY_RSHIFT	
				q_key = QUAL_RIGHT + QUAL_SHIFT
				DebugLog "Q_KEY RCTRL " + Hex(q_key)
			Case KEY_CONTROL	
			Case KEY_SHIFT
			Case KEY_ALT
			Default
				event.id :+ EV_KEYHIT
				event.data :+ q_key + i
				DebugLog "q_key + i = " + q_key + "   " + i
				DebugLog "event.data = " + event.data
				Return True
			End Select
		End If
		DebugLog "index " + i + " q_key " + Hex(q_key)
	Next
	'DebugStop
	If q_key <> 0
		event.id :+ EV_KEYHIT
		event.data :+ q_key
		Return True
	End If


any help would be appriciated.

cheers.


peltazoid(Posted 2005) [#2]
sussed it, the keydown checking was exiting before the status of any qualifiers were checked. doh :D

seems to work, now :D