status_t MacScreen::tick_func(void *arg) { MacScreen *obj = (MacScreen *)arg; while (obj->tick_thread_active) { // Wait snooze(16667); // Workspace activated? Then poll the mouse and set the palette if needed if (!obj->quitting && obj->LockWithTimeout(200000) == B_OK) { if (obj->screen_active) { BPoint pt; uint32 button = 0; if (obj->palette_changed) { obj->palette_changed = false; obj->SetColorList(obj->palette); } obj->main_view->GetMouse(&pt, &button); set_mouse_position(320, 240); ADBMouseMoved(int(pt.x) - 320, int(pt.y) - 240); if (button & B_PRIMARY_MOUSE_BUTTON) ADBMouseDown(0); if (!(button & B_PRIMARY_MOUSE_BUTTON)) ADBMouseUp(0); if (button & B_SECONDARY_MOUSE_BUTTON) ADBMouseDown(1); if (!(button & B_SECONDARY_MOUSE_BUTTON)) ADBMouseUp(1); if (button & B_TERTIARY_MOUSE_BUTTON) ADBMouseDown(2); if (!(button & B_TERTIARY_MOUSE_BUTTON)) ADBMouseUp(2); } obj->Unlock(); } } return 0; }
void recording_t::play_through(uint64 end) { if (done) return; do { recording_frame_t *f = current_frame_ptr(); if (f->microseconds > end) { if (!countdown) { D(bug("%lu us until next\n", f->microseconds - end)); countdown = 60; } else --countdown; break; } D(bug("playback: %04x %d %lx %lu\n", current_frame, f->op, f->arg, f->microseconds)); switch (f->op) { case OP_NO_OP: break; case OP_KEY_DOWN: the_app->key_down(f->arg); break; case OP_KEY_UP: the_app->key_up(f->arg); break; case OP_MOUSE_DOWN: ADBMouseDown(f->arg); break; case OP_MOUSE_UP: ADBMouseUp(f->arg); break; case OP_MOUSE_XY: ADBMouseMoved(f->arg & 0xffffffff, f->arg >> 32); break; case OP_INVALIDATE_CACHE: the_app->ppc_cpu->invalidate_cache(); the_app->record(OP_INVALIDATE_CACHE, f->arg); break; default: D(bug("invalid op: %d", f->op)); } if (advance_frame()) { D(bug("finished playback\n")); done = true; break; } } while (1); }
static filter_result filter_func(BMessage *msg, BHandler **target, BMessageFilter *filter) { switch (msg->what) { case B_KEY_DOWN: case B_KEY_UP: { uint32 be_code = msg->FindInt32("key") & 0xff; uint32 mac_code = keycode2mac[be_code]; // Intercept Ctrl-F1 (mount floppy disk shortcut) uint32 mods = msg->FindInt32("modifiers"); if (be_code == 0x02 && (mods & B_CONTROL_KEY)) SysMountVolume("/dev/disk/floppy/raw"); if (mac_code == 0xff) return B_DISPATCH_MESSAGE; if (msg->what == B_KEY_DOWN) ADBKeyDown(mac_code); else ADBKeyUp(mac_code); return B_SKIP_MESSAGE; } case B_MODIFIERS_CHANGED: { uint32 mods = msg->FindInt32("modifiers"); uint32 old_mods = msg->FindInt32("be:old_modifiers"); uint32 changed = mods ^ old_mods; uint32 mask = 1; for (int i=0; i<32; i++, mask<<=1) if (changed & mask) { uint32 mac_code = modifier2mac[i]; if (mac_code == 0xff) continue; if (mods & mask) ADBKeyDown(mac_code); else ADBKeyUp(mac_code); } return B_SKIP_MESSAGE; } case B_MOUSE_MOVED: { BPoint point; msg->FindPoint("where", &point); ADBMouseMoved(int(point.x), int(point.y)); return B_DISPATCH_MESSAGE; // Otherwise BitmapView::MouseMoved() wouldn't be called } case B_MOUSE_DOWN: { uint32 buttons = msg->FindInt32("buttons"); if (buttons & B_PRIMARY_MOUSE_BUTTON) ADBMouseDown(0); if (buttons & B_SECONDARY_MOUSE_BUTTON) ADBMouseDown(1); if (buttons & B_TERTIARY_MOUSE_BUTTON) ADBMouseDown(2); return B_SKIP_MESSAGE; } case B_MOUSE_UP: // B_MOUSE_UP means "all buttons released" ADBMouseUp(0); ADBMouseUp(1); ADBMouseUp(2); return B_SKIP_MESSAGE; default: return B_DISPATCH_MESSAGE; } }