25
25
26
26
// #define RAWHID_ENABLED
27
27
28
- // Singletons for mouse and keyboard
29
-
28
+ // Singletons for mouse, keyboard and remote
29
+
30
30
Mouse_ Mouse;
31
31
Keyboard_ Keyboard;
32
+ Remote_ Remote;
32
33
33
34
// ================================================================================
34
35
// ================================================================================
@@ -124,8 +125,61 @@ const u8 _hidReportDescriptor[] = {
124
125
0x95 , 64 , // report count RX
125
126
0x09 , 0x02 , // usage
126
127
0x91 , 0x02 , // Output (array)
127
- 0xC0 // end collection
128
+ 0xC0 , // end collection
128
129
#endif
130
+
131
+ // -----------------------------------------------------------------------------
132
+
133
+ /* Cross-platform support for controls found on IR Remotes */
134
+
135
+ 0x05 , 0x0c , // Usage Page (Consumer Devices)
136
+ 0x09 , 0x01 , // Usage (Consumer Control)
137
+ 0xa1 , 0x01 , // Collection (Application)
138
+ 0x85 , 0x04 , // REPORT_ID (4)
139
+ 0x15 , 0x00 , // Logical Minimum (0)
140
+ 0x25 , 0x01 , // Logical Maximum (1)
141
+ 0x09 , 0xe9 , // Usage (Volume Up)
142
+ 0x09 , 0xea , // Usage (Volume Down)
143
+ 0x75 , 0x01 , // Report Size (1)
144
+ 0x95 , 0x02 , // Report Count (2)
145
+ 0x81 , 0x06 , // Input (Data, Variable, Relative)
146
+
147
+ 0x09 , 0xe2 , // Usage (Mute)
148
+ 0x95 , 0x01 , // Report Count (1)
149
+ 0x81 , 0x06 , // Input (Data, Variable, Relative)
150
+
151
+ 0x09 , 0xb0 , // Usage (Play)
152
+ 0x95 , 0x01 , // Report Count (1)
153
+ 0x81 , 0x06 , // Input (Data, Variable, Relative)
154
+
155
+ 0x09 , 0xb1 , // Usage (Pause)
156
+ 0x95 , 0x01 , // Report Count (1)
157
+ 0x81 , 0x06 , // Input (Data, Variable, Relative)
158
+
159
+ 0x09 , 0xb7 , // Usage (Stop)
160
+ 0x95 , 0x01 , // Report Count (1)
161
+ 0x81 , 0x06 , // Input (Data, Variable, Relative)
162
+
163
+ 0x09 , 0xb5 , // Usage (Next)
164
+ 0x95 , 0x01 , // Report Count (1)
165
+ 0x81 , 0x06 , // Input (Data, Variable, Relative)
166
+
167
+ 0x09 , 0xb6 , // Usage (Previous)
168
+ 0x95 , 0x01 , // Report Count (1)
169
+ 0x81 , 0x06 , // Input (Data, Variable, Relative)
170
+
171
+ 0x09 , 0xb3 , // Usage (Fast Forward)
172
+ 0x95 , 0x01 , // Report Count (1)
173
+ 0x81 , 0x06 , // Input (Data, Variable, Relative)
174
+
175
+ 0x09 , 0xb4 , // Usage (Rewind)
176
+ 0x95 , 0x01 , // Report Count (1)
177
+ 0x81 , 0x06 , // Input (Data, Variable, Relative)
178
+
179
+ 0x95 , 0x06 , // Report Count (6) Number of bits remaining in byte
180
+ 0x81 , 0x07 , // Input (Constant, Variable, Relative)
181
+ 0xc0 // End Collection
182
+
129
183
};
130
184
131
185
extern const HIDDescriptor _hidInterface PROGMEM;
@@ -515,6 +569,110 @@ size_t Keyboard_::write(uint8_t c)
515
569
return (p); // just return the result of press() since release() almost always returns 1
516
570
}
517
571
572
+ // ================================================================================
573
+ // ================================================================================
574
+ // Remote
575
+
576
+ Remote_::Remote_ (void )
577
+ {
578
+ }
579
+
580
+ void Remote_::begin (void )
581
+ {
582
+ }
583
+
584
+ void Remote_::end (void )
585
+ {
586
+ }
587
+
588
+ void Remote_::increase (void )
589
+ {
590
+ u8 m[2 ];
591
+ m[0 ] = VOLUME_UP;
592
+ m[1 ] = 0 ;
593
+ HID_SendReport (4 ,m,2 );
594
+ }
595
+
596
+ void Remote_::decrease (void )
597
+ {
598
+ u8 m[2 ];
599
+ m[0 ] = VOLUME_DOWN;
600
+ m[1 ] = 0 ;
601
+ HID_SendReport (4 ,m,2 );
602
+ }
603
+
604
+ void Remote_::mute (void )
605
+ {
606
+ u8 m[2 ];
607
+ m[0 ] = VOLUME_MUTE;
608
+ m[1 ] = 0 ;
609
+ HID_SendReport (4 ,m,2 );
610
+ }
611
+
612
+ void Remote_::play (void )
613
+ {
614
+ u8 m[2 ];
615
+ m[0 ] = REMOTE_PLAY;
616
+ m[1 ] = 0 ;
617
+ HID_SendReport (4 ,m,2 );
618
+ }
619
+
620
+ void Remote_::pause (void )
621
+ {
622
+ u8 m[2 ];
623
+ m[0 ] = REMOTE_PAUSE;
624
+ m[1 ] = 0 ;
625
+ HID_SendReport (4 ,m,2 );
626
+ }
627
+
628
+ void Remote_::stop (void )
629
+ {
630
+ u8 m[2 ];
631
+ m[0 ] = REMOTE_STOP;
632
+ m[1 ] = 0 ;
633
+ HID_SendReport (4 ,m,2 );
634
+ }
635
+
636
+ void Remote_::next (void )
637
+ {
638
+ u8 m[2 ];
639
+ m[0 ] = REMOTE_NEXT;
640
+ m[1 ] = 0 ;
641
+ HID_SendReport (4 ,m,2 );
642
+ }
643
+
644
+ void Remote_::previous (void )
645
+ {
646
+ u8 m[2 ];
647
+ m[0 ] = REMOTE_PREVIOUS;
648
+ m[1 ] = 0 ;
649
+ HID_SendReport (4 ,m,2 );
650
+ }
651
+
652
+ void Remote_::forward (void )
653
+ {
654
+ u8 m[2 ];
655
+ m[0 ] = 0 ;
656
+ m[1 ] = REMOTE_FAST_FORWARD >> 8 ;
657
+ HID_SendReport (4 ,m,2 );
658
+ }
659
+
660
+ void Remote_::rewind (void )
661
+ {
662
+ u8 m[2 ];
663
+ m[0 ] = 0 ;
664
+ m[1 ] = REMOTE_REWIND >> 8 ;
665
+ HID_SendReport (4 ,m,2 );
666
+ }
667
+
668
+ void Remote_::clear (void )
669
+ {
670
+ u8 m[2 ];
671
+ m[0 ] = 0 ;
672
+ m[1 ] = 0 ;
673
+ HID_SendReport (4 ,m,2 );
674
+ }
675
+
518
676
#endif
519
677
520
678
#endif /* if defined(USBCON) */
0 commit comments