X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFETMAXUSB.py;h=c20a74830ee660f6fd21710293d1d6850bb84dd6;hp=ede1026621b8e21160608f27521622d0d0ef9373;hb=3764132d5d91eee37ba2e773c459cf78d0bd89a8;hpb=b41a0644a0777cb50ff080b8f8c3995f6ee19183 diff --git a/client/GoodFETMAXUSB.py b/client/GoodFETMAXUSB.py index ede1026..c20a748 100644 --- a/client/GoodFETMAXUSB.py +++ b/client/GoodFETMAXUSB.py @@ -203,7 +203,7 @@ bmHXFRDNIRQ =0x80 class GoodFETMAXUSB(GoodFET): MAXUSBAPP=0x40; - usbverbose=True; + usbverbose=False; def service_irqs(self): """Handle USB interrupt events.""" @@ -245,6 +245,8 @@ class GoodFETMAXUSB(GoodFET): def MAXUSBsetup(self): """Move the FET into the MAXUSB application.""" self.writecmd(self.MAXUSBAPP,0x10,0,self.data); #MAXUSB/SETUP + self.writecmd(self.MAXUSBAPP,0x10,0,self.data); #MAXUSB/SETUP + self.writecmd(self.MAXUSBAPP,0x10,0,self.data); #MAXUSB/SETUP print "Connected to MAX342x Rev. %x" % (self.rreg(rREVISION)); self.wreg(rPINCTL,0x18); #Set duplex and negative INT level. @@ -392,7 +394,7 @@ class GoodFETMAXUSB(GoodFET): self.wreg(rHIRQ,bmRCVDAVIRQ); #Clear IRQ xfrlen=xfrlen+pktsize; #Add byte count to total transfer length. - print "%i / %i" % (xfrlen,xfrsize) + #print "%i / %i" % (xfrlen,xfrsize) #Packet is complete if: # 1. The device sent a short packet, ?', # LeftShift + '', # LeftCtrl & LeftShift + ' abc'], # LeftAlt + 'Dvorak' :[ ' axje.uidchtnmbrl\'poygk,qf;1234567890\n\t []/=\\\\s-`wvz', + '''        ''', # LeftCtrl + ' AXJE UIDCHTNMBRL"POYGK='a' and a<='z': - return ord(a)-ord('a')+4; - elif a>='A' and a<='Z': - return ord(a)-ord('A')+4; - elif a==' ': - return 0x2C; #space - else: - return 0; #key-up + if type(ascii)!=str: + return (0,0); # Send NoEvent if not passed a character + if ascii==' ': + return (0,0x2C); # space + for modset in self.keymap(): + keycode=modset.find(ascii); + if keycode != -1: + modifier = self.keymap().index(modset) + return (modifier, keycode); + return (0,0); def type_IN3(self): - """Type next letter in buffer.""" - if self.typepos>=len(self.typestring): - self.typeletter(0); - elif self.typephase==0: - self.typephase=1; - self.typeletter(0); - else: - typephase=0; - self.typeletter(self.typestring[self.typepos]); - self.typepos=self.typepos+1; - return; + """Type next letter in buffer.""" + string=self.typestring(); + if self.typepos>=len(string): + self.typeletter(0); # Send NoEvent to indicate key-up + exit(0); + self.typepos=0; # Repeat typestring forever! + # This would be a great place to enable a typethrough mode so the host operator can control the target + else: + if self.usbverbose: + sys.stdout.write(string[self.typepos]); + sys.stdout.flush(); + self.typeletter(string[self.typepos]); + self.typepos+=1; + return; def typeletter(self,key): """Type a letter on IN3. Zero for keyup.""" - #if type(key)==str: key=ord(key); - #Send a key-up. - self.wreg(rEP3INFIFO,0); + mod=0; + if type(key)==str: + (mod, key) = self.asc2hid(key); + self.wreg(rEP3INFIFO,mod); self.wreg(rEP3INFIFO,0); - self.wreg(rEP3INFIFO,self.asc2hid(key)); + self.wreg(rEP3INFIFO,key); self.wreg(rEP3INBC,3); def do_IN3(self): """Handle IN3 event.""" #Don't bother clearing interrupt flag, that's done by sending the reply. - self.type_IN3(); + if self.OsLastConfigType != -1: # Wait for some configuration before stuffing keycodes down the pipe + self.type_IN3();