static void key_adb_exit(void) { OSErr e; short adb_command; short tmp; char adb_key_registers[8]; ADBAddress adb_address; ADBDataBlock now_data; ADBSetInfoBlock mySet; if(adb_keyboard_id!=0){ adb_address = GetIndADB(&now_data, adb_keyboard_id); e = GetADBInfo(&now_data, adb_address); if(now_data.origADBAddr == 2){ adb_key_registers[0] = 2; adb_command = (adb_address * 16) + ADB_TALKMASK + ADB_TYPEREGISTER; if (send_adb_command_sync(adb_key_registers, adb_command) == noErr){ tmp=adb_key_save.devType; if(tmp == 3 || tmp ==5) adb_key_registers[2] = tmp; else adb_key_registers[2] = 2; adb_command = (adb_address * 16) + ADB_LISTENMASK + ADB_TYPEREGISTER; send_adb_command_sync(adb_key_registers, adb_command); } } mySet.siService = adb_key_save.dbServiceRtPtr; mySet.siDataAreaAddr = adb_key_save.dbDataAreaAddr; SetADBInfo (&mySet,adb_address); adb_keyboard_id=0; } DisposeADBServiceRoutineUPP (adb_key_upp); DisposeADBCompletionUPP(adb_key_cpt_upp); }
static int key_adb_init(void) { OSErr e; short adb_command; short adb_devices; char adb_key_registers[8]; ADBAddress adb_address; ADBSetInfoBlock mySet; adb_key_cpt_upp = NewADBCompletionUPP(adb_command_callback); adb_key_upp = NewADBServiceRoutineUPP (key_adb_interrupt); adb_devices = CountADBs(); for(adb_keyboard_id = 1 ; adb_keyboard_id <= adb_devices ; adb_keyboard_id++){ adb_address = GetIndADB(&adb_key_save, adb_keyboard_id); e = GetADBInfo(&adb_key_save, adb_address); if(adb_key_save.origADBAddr == ADB_KEYBOARD){ switch (adb_key_save.devType){ case 2:case 3:case 5: LOCK_VARIABLE(KeyNow); LOCK_VARIABLE(KeyOld); LOCK_VARIABLE(_mouse2nd); LOCK_VARIABLE(adb_to_allegro); LOCK_VARIABLE(modifier_table); LOCK_VARIABLE(standard_key_ascii_table); LOCK_VARIABLE(standard_key_capslock_table); LOCK_VARIABLE(standard_key_shift_table); LOCK_VARIABLE(standard_key_control_table); /* LOCK_FUNCTION(key_adb_interrupt);*/ /* LOCK_FUNCTION(adb_command_callback);*/ mySet.siService = adb_key_upp; mySet.siDataAreaAddr = NULL; SetADBInfo (&mySet,adb_address); adb_key_registers[0] = 2; adb_command = (adb_address * 16) + ADB_TALKMASK + ADB_TYPEREGISTER; if (send_adb_command_sync(adb_key_registers, adb_command) == noErr){ adb_key_registers[2] = 3; adb_command = (adb_address * 16) + ADB_LISTENMASK + ADB_TYPEREGISTER; send_adb_command_sync(adb_key_registers, adb_command); } GetKeys(KeyNow); _key_shifts=0; if(BitTst(KeyNow,k_apple_shift) || BitTst(KeyNow,k_apple_rshift))_key_shifts |= KB_SHIFT_FLAG; if(BitTst(KeyNow,k_apple_alt) || BitTst(KeyNow,k_apple_altgr))_key_shifts |= KB_ALT_FLAG; if(BitTst(KeyNow,k_apple_control) || BitTst(KeyNow,k_apple_rcontrol))_key_shifts |= KB_CTRL_FLAG; _mouse2nd = BitTst(KeyNow,k_2nd); return 0; default: break; } } } adb_keyboard_id=0; return -1; }
static int mouse_adb_init(void) { OSErr e; ADBAddress adb_address; ADBSetInfoBlock mySet; short adb_devices; adb_mouse_cpt_upp = NewADBCompletionUPP(adb_command_callback); adb_mouse_upp = NewADBServiceRoutineUPP (mouse_adb_interrupt); adb_devices = CountADBs(); for(adb_mouse_id = 1 ; adb_mouse_id <= adb_devices ; adb_mouse_id++){ adb_address = GetIndADB(&adb_mouse_save, adb_mouse_id); e = GetADBInfo(&adb_mouse_save, adb_address); if(adb_mouse_save.origADBAddr == ADB_MOUSE){ switch (adb_mouse_save.devType){ case 1: LOCK_VARIABLE(mouse_x_min); LOCK_VARIABLE(mouse_y_min); LOCK_VARIABLE(mouse_x_max); LOCK_VARIABLE(mouse_y_max); LOCK_VARIABLE(mickey_x); LOCK_VARIABLE(mickey_y); LOCK_VARIABLE(_mouse2nd); mickey_x=0; mickey_y=0; mySet.siService = adb_mouse_upp; mySet.siDataAreaAddr = NULL; SetADBInfo (&mySet,adb_address); _mouse_x = 0; _mouse_y = 0; _mouse_b = 0; return 2; default: break; } } } adb_mouse_id=0; return -1; }
void adb_msa3_complete(void *buffer, void *data_area, int adb_command) { adb_event_t event; ADBDataBlock adbdata; int adbaddr; int error; #ifdef ADB_DEBUG int i; if (adb_debug) printf("adb: transaction completion\n"); #endif adbaddr = ADB_CMDADDR(adb_command); error = GetADBInfo(&adbdata, adbaddr); #ifdef ADB_DEBUG if (adb_debug) printf("adb: GetADBInfo returned %d\n", error); #endif event.addr = adbaddr; event.hand_id = ADBMS_MSA3; event.def_addr = (int)(adbdata.origADBAddr); event.byte_count = buffer[0]; memcpy(event.bytes, buffer + 1, event.byte_count); #ifdef ADB_DEBUG if (adb_debug) { printf("adb: from %d at %d (org %d) %d:", event.addr, event.hand_id, event.def_addr, buffer[0]); for (i = 1; i <= buffer[0]; i++) printf(" %x", buffer[i]); printf("\n"); } #endif microtime(&event.timestamp); adb_processevent(&event); }
void adb_mm_nonemp_complete(void *buffer, void *data_area, int adb_command) { adb_event_t event; ADBDataBlock adbdata; int adbaddr; int error; #ifdef ADB_DEBUG int i; if (adb_debug) printf("adb: transaction completion\n"); #endif adbaddr = ADB_CMDADDR(adb_command); error = GetADBInfo(&adbdata, adbaddr); #ifdef ADB_DEBUG if (adb_debug) printf("adb: GetADBInfo returned %d\n", error); #endif #if 0 printf("adb: from %d at %d (org %d) %d:", event.addr, event.hand_id, event.def_addr, buffer[0]); for (i = 1; i <= buffer[0]; i++) printf(" %x", buffer[i]); printf("\n"); #endif /* massage the data to look like EMP data */ if ((buffer[3] & 0x04) == 0x04) buffer[1] &= 0x7f; else buffer[1] |= 0x80; if ((buffer[3] & 0x02) == 0x02) buffer[2] &= 0x7f; else buffer[2] |= 0x80; if ((buffer[3] & 0x01) == 0x01) buffer[3] = 0x00; else buffer[3] = 0x80; event.addr = adbaddr; event.hand_id = (int)(adbdata.devType); event.def_addr = (int)(adbdata.origADBAddr); event.byte_count = buffer[0]; memcpy(event.bytes, buffer + 1, event.byte_count); #ifdef ADB_DEBUG if (adb_debug) { printf("adb: from %d at %d (org %d) %d:", event.addr, event.hand_id, event.def_addr, buffer[0]); for (i = 1; i <= buffer[0]; i++) printf(" %x", buffer[i]); printf("\n"); } #endif microtime(&event.timestamp); adb_processevent(&event); }