This introduces a new lirc mode: scancode. Any device which can send raw IR can now also send scancodes. int main() { int mode, fd = open("/dev/lirc0", O_RDWR); mode = LIRC_MODE_SCANCODE; if (ioctl(fd, LIRC_SET_SEND_MODE, &mode)) { // kernel too old or lirc does not support transmit } struct lirc_scancode scancode = { .scancode = 0x1e3d, .rc_proto = RC_PROTO_RC5, }; write(fd, &scancode, sizeof(scancode)); close(fd); } The other fields of lirc_scancode must be set to 0. Note that toggle (rc5, rc6) and repeats (nec) are not implemented. Nor is there a method for holding down a key for a period.
Showing the changes to include/uapi/linux (1 of 4 files). Show all
Unified · Split
| @@ -47,12 +47,14 @@ · 46 unmodified lines | ||
| 47 | 47 | #define LIRC_MODE_RAW 0x00000001 |
| 48 | 48 | #define LIRC_MODE_PULSE 0x00000002 |
| 49 | 49 | #define LIRC_MODE_MODE2 0x00000004 |
| 50 | +#define LIRC_MODE_SCANCODE 0x00000008 | |
| 50 | 51 | #define LIRC_MODE_LIRCCODE 0x00000010 |
| 51 | 52 | |
| 52 | 53 | |
| 53 | 54 | #define LIRC_CAN_SEND_RAW LIRC_MODE2SEND(LIRC_MODE_RAW) |
| 54 | 55 | #define LIRC_CAN_SEND_PULSE LIRC_MODE2SEND(LIRC_MODE_PULSE) |
| 55 | 56 | #define LIRC_CAN_SEND_MODE2 LIRC_MODE2SEND(LIRC_MODE_MODE2) |
| 57 | +#define LIRC_CAN_SEND_SCANCODE LIRC_MODE2SEND(LIRC_MODE_SCANCODE) | |
| 56 | 58 | #define LIRC_CAN_SEND_LIRCCODE LIRC_MODE2SEND(LIRC_MODE_LIRCCODE) |
| 57 | 59 | |
| 58 | 60 | #define LIRC_CAN_SEND_MASK 0x0000003f |
| @@ -64,6 +66,7 @@ · 5 unmodified lines | ||
| 64 | 66 | #define LIRC_CAN_REC_RAW LIRC_MODE2REC(LIRC_MODE_RAW) |
| 65 | 67 | #define LIRC_CAN_REC_PULSE LIRC_MODE2REC(LIRC_MODE_PULSE) |
| 66 | 68 | #define LIRC_CAN_REC_MODE2 LIRC_MODE2REC(LIRC_MODE_MODE2) |
| 69 | +#define LIRC_CAN_REC_SCANCODE LIRC_MODE2REC(LIRC_MODE_SCANCODE) | |
| 67 | 70 | #define LIRC_CAN_REC_LIRCCODE LIRC_MODE2REC(LIRC_MODE_LIRCCODE) |
| 68 | 71 | |
| 69 | 72 | #define LIRC_CAN_REC_MASK LIRC_MODE2REC(LIRC_CAN_SEND_MASK) |
| @@ -131,4 +134,83 @@ · 61 unmodified lines | ||
| 131 | 134 | |
| 132 | 135 | #define LIRC_SET_WIDEBAND_RECEIVER _IOW('i', 0x00000023, __u32) |
| 133 | 136 | |
| 137 | +/* | |
| 138 | + * struct lirc_scancode - decoded scancode with protocol for use with | |
| 139 | + * LIRC_MODE_SCANCODE | |
| 140 | + * | |
| 141 | + * @timestamp: Timestamp in nanoseconds using CLOCK_MONOTONIC when IR | |
| 142 | + * was decoded. | |
| 143 | + * @flags: should be 0 for transmit. When receiving scancodes, | |
| 144 | + * LIRC_SCANCODE_FLAG_TOGGLE or LIRC_SCANCODE_FLAG_REPEAT can be set | |
| 145 | + * depending on the protocol | |
| 146 | + * @rc_proto: see enum rc_proto | |
| 147 | + * @keycode: the translated keycode. Set to 0 for transmit. | |
| 148 | + * @scancode: the scancode received or to be sent | |
| 149 | + */ | |
| 150 | +struct lirc_scancode { | |
| 151 | + __u64 timestamp; | |
| 152 | + __u16 flags; | |
| 153 | + __u16 rc_proto; | |
| 154 | + __u32 keycode; | |
| 155 | + __u64 scancode; | |
| 156 | +}; | |
| 157 | + | |
| 158 | +/* Set if the toggle bit of rc-5 or rc-6 is enabled */ | |
| 159 | +#define LIRC_SCANCODE_FLAG_TOGGLE 1 | |
| 160 | +/* Set if this is a nec or sanyo repeat */ | |
| 161 | +#define LIRC_SCANCODE_FLAG_REPEAT 2 | |
| 162 | + | |
| 163 | +/** | |
| 164 | + * enum rc_proto - the Remote Controller protocol | |
| 165 | + * | |
| 166 | + * @RC_PROTO_UNKNOWN: Protocol not known | |
| 167 | + * @RC_PROTO_OTHER: Protocol known but proprietary | |
| 168 | + * @RC_PROTO_RC5: Philips RC5 protocol | |
| 169 | + * @RC_PROTO_RC5X_20: Philips RC5x 20 bit protocol | |
| 170 | + * @RC_PROTO_RC5_SZ: StreamZap variant of RC5 | |
| 171 | + * @RC_PROTO_JVC: JVC protocol | |
| 172 | + * @RC_PROTO_SONY12: Sony 12 bit protocol | |
| 173 | + * @RC_PROTO_SONY15: Sony 15 bit protocol | |
| 174 | + * @RC_PROTO_SONY20: Sony 20 bit protocol | |
| 175 | + * @RC_PROTO_NEC: NEC protocol | |
| 176 | + * @RC_PROTO_NECX: Extended NEC protocol | |
| 177 | + * @RC_PROTO_NEC32: NEC 32 bit protocol | |
| 178 | + * @RC_PROTO_SANYO: Sanyo protocol | |
| 179 | + * @RC_PROTO_MCIR2_KBD: RC6-ish MCE keyboard | |
| 180 | + * @RC_PROTO_MCIR2_MSE: RC6-ish MCE mouse | |
| 181 | + * @RC_PROTO_RC6_0: Philips RC6-0-16 protocol | |
| 182 | + * @RC_PROTO_RC6_6A_20: Philips RC6-6A-20 protocol | |
| 183 | + * @RC_PROTO_RC6_6A_24: Philips RC6-6A-24 protocol | |
| 184 | + * @RC_PROTO_RC6_6A_32: Philips RC6-6A-32 protocol | |
| 185 | + * @RC_PROTO_RC6_MCE: MCE (Philips RC6-6A-32 subtype) protocol | |
| 186 | + * @RC_PROTO_SHARP: Sharp protocol | |
| 187 | + * @RC_PROTO_XMP: XMP protocol | |
| 188 | + * @RC_PROTO_CEC: CEC protocol | |
| 189 | + */ | |
| 190 | +enum rc_proto { | |
| 191 | + RC_PROTO_UNKNOWN = 0, | |
| 192 | + RC_PROTO_OTHER = 1, | |
| 193 | + RC_PROTO_RC5 = 2, | |
| 194 | + RC_PROTO_RC5X_20 = 3, | |
| 195 | + RC_PROTO_RC5_SZ = 4, | |
| 196 | + RC_PROTO_JVC = 5, | |
| 197 | + RC_PROTO_SONY12 = 6, | |
| 198 | + RC_PROTO_SONY15 = 7, | |
| 199 | + RC_PROTO_SONY20 = 8, | |
| 200 | + RC_PROTO_NEC = 9, | |
| 201 | + RC_PROTO_NECX = 10, | |
| 202 | + RC_PROTO_NEC32 = 11, | |
| 203 | + RC_PROTO_SANYO = 12, | |
| 204 | + RC_PROTO_MCIR2_KBD = 13, | |
| 205 | + RC_PROTO_MCIR2_MSE = 14, | |
| 206 | + RC_PROTO_RC6_0 = 15, | |
| 207 | + RC_PROTO_RC6_6A_20 = 16, | |
| 208 | + RC_PROTO_RC6_6A_24 = 17, | |
| 209 | + RC_PROTO_RC6_6A_32 = 18, | |
| 210 | + RC_PROTO_RC6_MCE = 19, | |
| 211 | + RC_PROTO_SHARP = 20, | |
| 212 | + RC_PROTO_XMP = 21, | |
| 213 | + RC_PROTO_CEC = 22, | |
| 214 | +}; | |
| 215 | + | |
| 134 | 216 | #endif |