mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-20 21:01:25 +03:00
CDC and HID write() routines now return non-void - brought in line with new write behavior
This commit is contained in:
@ -153,7 +153,7 @@ void Serial_::flush(void)
|
|||||||
USB_Flush(CDC_TX);
|
USB_Flush(CDC_TX);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Serial_::write(uint8_t c)
|
size_t Serial_::write(uint8_t c)
|
||||||
{
|
{
|
||||||
/* only try to send bytes if the high-level CDC connection itself
|
/* only try to send bytes if the high-level CDC connection itself
|
||||||
is open (not just the pipe) - the OS should set lineState when the port
|
is open (not just the pipe) - the OS should set lineState when the port
|
||||||
@ -164,8 +164,11 @@ void Serial_::write(uint8_t c)
|
|||||||
// TODO - ZE - check behavior on different OSes and test what happens if an
|
// TODO - ZE - check behavior on different OSes and test what happens if an
|
||||||
// open connection isn't broken cleanly (cable is yanked out, host dies
|
// open connection isn't broken cleanly (cable is yanked out, host dies
|
||||||
// or locks up, or host virtual serial port hangs)
|
// or locks up, or host virtual serial port hangs)
|
||||||
if (_usbLineInfo.lineState > 0)
|
if (_usbLineInfo.lineState > 0) {
|
||||||
USB_Send(CDC_TX,&c,1);
|
USB_Send(CDC_TX,&c,1);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial_ Serial;
|
Serial_ Serial;
|
||||||
|
@ -388,7 +388,7 @@ const uint8_t _asciimap[128] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
uint8_t USBPutChar(uint8_t c);
|
uint8_t USBPutChar(uint8_t c);
|
||||||
void Keyboard_::write(uint8_t c)
|
size_t Keyboard_::write(uint8_t c)
|
||||||
{
|
{
|
||||||
// Keydown
|
// Keydown
|
||||||
{
|
{
|
||||||
@ -398,10 +398,10 @@ void Keyboard_::write(uint8_t c)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (c >= 128)
|
if (c >= 128)
|
||||||
return;
|
return 0;
|
||||||
c = pgm_read_byte(_asciimap + c);
|
c = pgm_read_byte(_asciimap + c);
|
||||||
if (!c)
|
if (!c)
|
||||||
return;
|
return 0;
|
||||||
if (c & 0x80)
|
if (c & 0x80)
|
||||||
{
|
{
|
||||||
keys.modifiers |= KEY_MODIFIER_LEFT_SHIFT;
|
keys.modifiers |= KEY_MODIFIER_LEFT_SHIFT;
|
||||||
@ -416,6 +416,7 @@ void Keyboard_::write(uint8_t c)
|
|||||||
KeyReport keys = {0};
|
KeyReport keys = {0};
|
||||||
sendReport(&keys);
|
sendReport(&keys);
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -33,7 +33,7 @@ public:
|
|||||||
virtual int peek(void);
|
virtual int peek(void);
|
||||||
virtual int read(void);
|
virtual int read(void);
|
||||||
virtual void flush(void);
|
virtual void flush(void);
|
||||||
virtual void write(uint8_t);
|
virtual size_t write(uint8_t);
|
||||||
};
|
};
|
||||||
extern Serial_ Serial;
|
extern Serial_ Serial;
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ public:
|
|||||||
Keyboard_();
|
Keyboard_();
|
||||||
void sendReport(KeyReport* keys);
|
void sendReport(KeyReport* keys);
|
||||||
void setKeyMap(KeyMap* keyMap);
|
void setKeyMap(KeyMap* keyMap);
|
||||||
virtual void write(uint8_t);
|
virtual size_t write(uint8_t);
|
||||||
};
|
};
|
||||||
extern Keyboard_ Keyboard;
|
extern Keyboard_ Keyboard;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user