about summary refs log tree commit diff stats
path: root/078mouse.mu
blob: 2590131fd6b7bf7db7691c48c0c7a616592b14d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
exclusive-container event [
  # update the ASSUME_EVENTS handler if you add more variants
  keyboard:keyboard-event
  mouse:mouse-event
]

container keyboard-event [
  key:character
]

container mouse-event [
  type:character
  row:number
  column:number
]

container events [
  index:number
  data:address:array:event  
]

recipe read-event [
  default-space:address:array:location <- new location:type, 30:literal
  x:address:events <- next-ingredient
  {
    break-unless x:address:events
    idx:address:number <- get-address x:address:events/deref, index:offset
    buf:address:array:event <- get x:address:events/deref, data:offset
    {
      max:number <- length buf:address:array:event/deref
      done?:boolean <- greater-or-equal idx:address:number/deref, max:number
      break-unless done?:boolean
      dummy:address:event <- new event:type
      reply dummy:address:event/deref, x:address:events/same-as-ingredient:0
    }
    result:event <- index buf:address:array:event/deref, idx:address:number/deref
    idx:address:number/deref <- add idx:address:number/deref, 1:literal
    reply result:event, x:address:events/same-as-ingredient:0
  }
  # real event source
  result:event <- read-keyboard-or-mouse-event
  reply result:event
]