// File: thjaeger[P]bindbutton/bindbutton.cc
// Function: Event::get()
bool Event::get() {
	XEvent ev;
	XNextEvent(dpy, &ev);

	if (ev.type == ButtonPress) {
		is_press = true;
		button = ev.xbutton.button;
		dev = NULL;
		core = true;
		t = ev.xbutton.time;
		if (debug)
			printf("Button %d pressed (core)\n", button);
		return true;
	}
	for (std::list<XiDevice>::iterator j = devices.begin(); j != devices.end(); j++) {
		if (ev.type == j->press) {
			XDeviceButtonEvent* bev = (XDeviceButtonEvent *)&ev;
			is_press = true;
			button = bev->button;
			dev = &(*j);
			core = false;
			t = bev->time;
			if (debug)
				printf("Button %d pressed (Xi)\n", button);
			return true;
		}
		if (ev.type == j->release) {
			XDeviceButtonEvent* bev = (XDeviceButtonEvent *)&ev;
			is_press = false;
			button = bev->button;
			dev = &(*j);
			core = false;
			t = bev->time;
			if (debug)
				printf("Button %d released (Xi)\n", bev->button);
			return true;
		}
	}
	printf("Unknown event\n");
	return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x100(%rbp)
movq 0x859f(%rip), %rdi      # 0xb160
leaq -0xd0(%rbp), %rsi
callq 0x2210
cmpl $0x4, -0xd0(%rbp)
jne 0x2c27
movq -0x100(%rbp), %rax
movb $0x1, (%rax)
movl -0x7c(%rbp), %ecx
movl %ecx, 0x4(%rax)
movq $0x0, 0x8(%rax)
movb $0x1, 0x10(%rax)
movq -0x98(%rbp), %rcx
movq %rcx, 0x18(%rax)
testb $0x1, 0x8564(%rip)      # 0xb168
je 0x2c1e
movq -0x100(%rbp), %rax
movl 0x4(%rax), %esi
leaq 0x44ff(%rip), %rdi      # 0x7116
movb $0x0, %al
callq 0x2030
movb $0x1, -0x1(%rbp)
jmp 0x2dd8
leaq 0x854a(%rip), %rdi      # 0xb178
callq 0x33c0
movq %rax, -0xd8(%rbp)
leaq 0x8537(%rip), %rdi      # 0xb178
callq 0x3420
movq %rax, -0xe0(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x33f0
testb $0x1, %al
jne 0x2c69
jmp 0x2dc6
movl -0xd0(%rbp), %eax
movl %eax, -0x104(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x3450
movq %rax, %rcx
movl -0x104(%rbp), %eax
cmpl 0x18(%rcx), %eax
jne 0x2d0b
movq -0x100(%rbp), %rax
leaq -0xd0(%rbp), %rcx
movq %rcx, -0xe8(%rbp)
movb $0x1, (%rax)
movq -0xe8(%rbp), %rcx
movl 0x5c(%rcx), %ecx
movl %ecx, 0x4(%rax)
leaq -0xd8(%rbp), %rdi
callq 0x3690
movq %rax, %rcx
movq -0x100(%rbp), %rax
movq %rcx, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0xe8(%rbp), %rcx
movq 0x40(%rcx), %rcx
movq %rcx, 0x18(%rax)
testb $0x1, 0x8480(%rip)      # 0xb168
je 0x2d02
movq -0x100(%rbp), %rax
movl 0x4(%rax), %esi
leaq 0x4435(%rip), %rdi      # 0x7130
movb $0x0, %al
callq 0x2030
movb $0x1, -0x1(%rbp)
jmp 0x2dd8
movl -0xd0(%rbp), %eax
movl %eax, -0x108(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x3450
movq %rax, %rcx
movl -0x108(%rbp), %eax
cmpl 0x1c(%rcx), %eax
jne 0x2daa
movq -0x100(%rbp), %rax
leaq -0xd0(%rbp), %rcx
movq %rcx, -0xf0(%rbp)
movb $0x0, (%rax)
movq -0xf0(%rbp), %rcx
movl 0x5c(%rcx), %ecx
movl %ecx, 0x4(%rax)
leaq -0xd8(%rbp), %rdi
callq 0x3690
movq %rax, %rcx
movq -0x100(%rbp), %rax
movq %rcx, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0xf0(%rbp), %rcx
movq 0x40(%rcx), %rcx
movq %rcx, 0x18(%rax)
testb $0x1, 0x83de(%rip)      # 0xb168
je 0x2da4
movq -0xf0(%rbp), %rax
movl 0x5c(%rax), %esi
leaq 0x43ab(%rip), %rdi      # 0x7148
movb $0x0, %al
callq 0x2030
movb $0x1, -0x1(%rbp)
jmp 0x2dd8
jmp 0x2dac
leaq -0xd8(%rbp), %rdi
xorl %esi, %esi
callq 0x3570
movq %rax, -0xf8(%rbp)
jmp 0x2c3a
leaq 0x4394(%rip), %rdi      # 0x7161
movb $0x0, %al
callq 0x2030
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopw %cs:(%rax,%rax)