@@ -50,6 +50,7 @@ uint8_t inline findModifierKey(hid_keyboard_report_t const *report, const hid_ke
5050PlatformKbdParser::PlatformKbdParser ()
5151{
5252 kbdLockingKeys.bLeds = 0 ;
53+ region = RegionUS;
5354}
5455PlatformKbdParser::~PlatformKbdParser ()
5556{
@@ -168,16 +169,56 @@ void PlatformKbdParser::SetUSBkeyboardLEDs(bool capslock, bool numlock, bool scr
168169 usb_set_leds = true ;
169170}
170171
172+
173+ static const char ON_STRING[] = " On" ;
174+ static const char OFF_STRING[] = " Off" ;
175+ static const char REGION_US_STRING[] = " USA" ;
176+ static const char REGION_FR_STRING[] = " Belgium/France" ;
177+ static const char REGION_DE_STRING[] = " German" ;
178+ static const char REGION_CH_STRING[] = " Swiss-DE/FR" ;
179+ static const char REGION_DK_STRING[] = " Denmark" ;
180+ static const char REGION_UK_STRING[] = " Ireland/UK" ;
181+ static const char REGION_IT_QZ_STRING[] = " Italy-QZERTY" ;
182+ static const char REGION_IT_QW_STRING[] = " Italy-QWERTY" ;
183+
184+ static void region_selection_string (char * print_buf, size_t len, Region region)
185+ {
186+ snprintf (print_buf, len,
187+ " Regions:\n "
188+ " %c %s\n "
189+ " %c %s\n "
190+ " %c %s\n "
191+ " %c %s\n "
192+ " %c %s\n "
193+ " %c %s\n "
194+ " %c %s\n "
195+ " %c %s\n " ,
196+ region == RegionUS ? ' *' : ' -' , REGION_US_STRING,
197+ region == RegionFR ? ' *' : ' -' , REGION_FR_STRING,
198+ region == RegionDE ? ' *' : ' -' , REGION_DE_STRING,
199+ region == RegionCH ? ' *' : ' -' , REGION_CH_STRING,
200+ region == RegionDK ? ' *' : ' -' , REGION_DK_STRING,
201+ region == RegionUK ? ' *' : ' -' , REGION_UK_STRING,
202+ region == RegionITqz ? ' *' : ' -' , REGION_IT_QZ_STRING,
203+ region == RegionITqw ? ' *' : ' -' , REGION_IT_QW_STRING
204+
205+ );
206+ }
207+
171208bool PlatformKbdParser::SpecialKeyCombo (KBDINFO *cur_kbd_info)
172209{
173210 // Special keycombo actions
174- const char ON_STRING[] = " On" ;
175- const char OFF_STRING[] = " Off" ;
176211 uint8_t special_key_count = 0 ;
177212 uint8_t special_key = 0 ;
178- uint8_t special_keys[] = {USB_KEY_V, USB_KEY_K, USB_KEY_L, USB_KEY_P, USB_KEY_EQUAL, USB_KEY_MINUS, USB_KEY_KPPLUS, USB_KEY_KPMINUS, USB_KEY_S, USB_KEY_R};
213+ uint8_t special_keys[] = {USB_KEY_V, USB_KEY_P, USB_KEY_H, USB_KEY_G, USB_KEY_S, USB_KEY_R, USB_KEY_T,
214+ USB_KEY_K, USB_KEY_L, USB_KEY_KPPLUS, USB_KEY_EQUAL, USB_KEY_SLASH, USB_KEY_1, USB_KEY_RIGHTBRACE,
215+ USB_KEY_KPMINUS, USB_KEY_MINUS, USB_KEY_C, USB_KEY_D, USB_KEY_U,
216+ };
179217 uint8_t caps_lock_down = false ;
180- char print_buf[1024 ];
218+ int16_t region_num;
219+ char print_buf[1536 ];
220+
221+
181222 for (uint8_t i = 0 ; i < 6 ; i++)
182223 {
183224 if (cur_kbd_info->Keys [i] == USB_KEY_CAPSLOCK)
@@ -205,71 +246,174 @@ bool PlatformKbdParser::SpecialKeyCombo(KBDINFO *cur_kbd_info)
205246
206247
207248 if (special_key_count == 1 && (enter_shortcut1 || enter_shortcut2))
208-
209249 {
210- switch (special_key)
211- {
212- case USB_KEY_V:
250+
251+ if (special_key == USB_KEY_V)
213252 SendString (PLATFORM_FW_VER_STRING);
214- break ;
215- case USB_KEY_P:
253+ else if (special_key == USB_KEY_P)
254+ {
216255 snprintf (print_buf, sizeof (print_buf),
217256 " Current Settings\n "
218257 " ================\n "
219258 " Command <-> Option key swap: %s\n "
259+ " Layout: %s\n "
220260 " LED: %s\n "
221261 " Mouse Sensitivity Divisor: %u\n "
222262 " (higher = less sensitive)\n "
263+ " Right Mouse Button: %s\n "
264+ " Mouse wheel count: %d\n "
265+ " Flip mouse wheel axis: %s\n "
223266 " \n "
224- " Special Keys = CAPS + Ctrl + Shift + [ Key] \n "
225- " Alternate Keys = Ctrl + Cmd + Option + [ Key] \n "
267+ " Special Keys = CAPS + Ctrl + Shift + ( Key) \n "
268+ " Alternate Keys = Ctrl + Cmd + Option + ( Key) \n "
226269 " ------------------------------------------\n "
227- " [V]: print firmware version\n "
228- " [S]: save settings to flash - LED blinks %d times\n "
229- " [R]: remove settings from flash - LED blinks %d times\n "
230- " [K]: swap option and command key positions\n "
231- " [L]: toggle status LED On/Off\n "
232- " [+]: increase sensitivity\n "
233- " [-]: decrease sensitivity\n " ,
270+ " (V): print firmware version\n "
271+ " (P): print current settings (this message)\n "
272+ " (H): select next region layout\n "
273+ " (G): select previous region layout\n "
274+ " (S): save settings to flash - LED blinks %d times\n "
275+ " (R): remove settings from flash - LED blinks %d times\n "
276+ " (K): swap option and command key positions - LED blinks thrice\n "
277+ " (L): toggle status LED On/Off\n "
278+ " (+): increase sensitivity - LED blinks twice\n "
279+ " (-): decrease sensitivity - LED blink once\n "
280+ " (T): swap right mouse button (RMB) function between Ctrl + LMB and ADB RMB\n "
281+ " Blinks twice for Ctrl + LMB and blinks once for ADB RMB\n "
282+ " Note: In MacOS 8 and 9 you will want Ctrl + LMB - ADB RMB might work in NeXTSTEP\n "
283+ " \n "
284+ " Change mouse wheel count 'x' by one with 'C' or 'D'\n "
285+ " If positive press the up/down arrow 'x' times for each wheel movement\n "
286+ " If negative divide the mouse wheel movement by 'abs(x)'\n "
287+ " (D): increase the mouse wheel count - LED blinks twice\n "
288+ " (C): decrease the mouse wheel count - LED blink once\n "
289+ " (U): flip mouse wheel axis - LED blinks thrice\n "
290+ " Note: not all mice support the mouse wheel in HID boot protocol\n "
291+ ,
234292 setting_storage.settings ()->swap_modifiers ? ON_STRING : OFF_STRING,
293+ region == RegionFR ? REGION_FR_STRING :
294+ region == RegionDE ? REGION_DE_STRING :
295+ region == RegionCH ? REGION_CH_STRING :
296+ region == RegionDK ? REGION_DK_STRING :
297+ region == RegionUK ? REGION_UK_STRING :
298+ region == RegionITqz ? REGION_IT_QZ_STRING :
299+ region == RegionITqw ? REGION_IT_QW_STRING :
300+ REGION_US_STRING,
235301 setting_storage.settings ()->led_on ? ON_STRING : OFF_STRING,
236302 setting_storage.settings ()->sensitivity_divisor ,
303+ setting_storage.settings ()->ctrl_lmb ? " Ctrl+LBM" : " ADB RMB" ,
304+ setting_storage.settings ()->mouse_wheel_count ,
305+ setting_storage.settings ()->swap_mouse_wheel_axis ? ON_STRING : OFF_STRING,
237306 SAVE_TO_FLASH_BLINK_COUNT,
238307 CLEAR_FLASH_BLINK_COUNT);
239308 SendString (print_buf);
240- break ;
241- case USB_KEY_S:
309+ }
310+ else if (special_key == USB_KEY_S)
311+ {
242312 setting_storage.save ();
243313 blink_led.blink (SAVE_TO_FLASH_BLINK_COUNT);
244- break ;
245- case USB_KEY_R:
314+ }
315+ else if (special_key == USB_KEY_R)
316+ {
246317 setting_storage.clear ();
247318 blink_led.blink (CLEAR_FLASH_BLINK_COUNT);
248- break ;
249- case USB_KEY_K:
319+ }
320+ else if (special_key == USB_KEY_K)
321+ {
250322 setting_storage.settings ()->swap_modifiers ^= 1 ;
251- break ;
252- case USB_KEY_L:
323+ blink_led.blink (3 );
324+ }
325+ else if (special_key == USB_KEY_L)
253326 setting_storage.settings ()->led_on ^= 1 ;
254- break ;
255- case USB_KEY_KPPLUS:
256- case USB_KEY_EQUAL:
327+ else if ( ((region == RegionUS || region == RegionUK)
328+ && (special_key == USB_KEY_KPPLUS || special_key == USB_KEY_EQUAL))
329+ || (region == RegionFR && (special_key == USB_KEY_KPPLUS || special_key == USB_KEY_SLASH))
330+ || (region == RegionDE && (special_key == USB_KEY_KPPLUS || special_key == USB_KEY_RIGHTBRACE))
331+ || (region == RegionCH && (special_key == USB_KEY_KPPLUS || special_key == USB_KEY_1))
332+ || (region == RegionDK && (special_key == USB_KEY_KPPLUS || special_key == USB_KEY_MINUS))
333+ )
334+ {
257335 if (setting_storage.settings ()->sensitivity_divisor <= 1 )
258336 setting_storage.settings ()->sensitivity_divisor = 1 ;
259337 else
260338 setting_storage.settings ()->sensitivity_divisor --;
261- blink_led.blink (setting_storage.settings ()->sensitivity_divisor );
262- break ;
263- case USB_KEY_KPMINUS:
264- case USB_KEY_MINUS:
339+ blink_led.blink (2 );
340+ }
341+ else if ( ((region == RegionUS || region == RegionUK)
342+ && (special_key == USB_KEY_KPMINUS || special_key == USB_KEY_MINUS))
343+ || (region == RegionFR && (special_key == USB_KEY_KPMINUS || special_key == USB_KEY_EQUAL))
344+ || ((region == RegionDE || region == RegionCH || region == RegionDK)
345+ && (special_key == USB_KEY_KPMINUS || special_key == USB_KEY_SLASH))
346+ )
347+ {
265348 if (setting_storage.settings ()->sensitivity_divisor >= 16 )
266349 setting_storage.settings ()->sensitivity_divisor = 16 ;
267350 else
268351 setting_storage.settings ()->sensitivity_divisor ++;
269- blink_led.blink (setting_storage.settings ()->sensitivity_divisor );
270- break ;
352+ blink_led.blink (1 );
271353 }
272-
354+ else if (special_key == USB_KEY_H)
355+ {
356+ region_num = setting_storage.settings ()->region ;
357+ region_num++;
358+ if (region_num > LAST_REGION)
359+ region_num = 0 ;
360+
361+ setting_storage.settings ()->region = region_num;
362+ region = (Region) region_num;
363+ region_selection_string (print_buf, sizeof (print_buf), region);
364+ SendString (print_buf);
365+ }
366+ else if (special_key == USB_KEY_G)
367+ {
368+ region_num = setting_storage.settings ()->region ;
369+ region_num--;
370+ if (region_num < 0 )
371+ region_num = LAST_REGION;
372+
373+ setting_storage.settings ()->region = region_num;
374+ region = (Region) region_num;
375+ region_selection_string (print_buf, sizeof (print_buf), region);
376+ SendString (print_buf);
377+ }
378+ else if (special_key == USB_KEY_T)
379+ {
380+ setting_storage.settings ()->ctrl_lmb ^= 1 ;
381+ if (setting_storage.settings ()->ctrl_lmb == 1 )
382+ blink_led.blink (2 );
383+ else
384+ blink_led.blink (1 );
385+ }
386+ else if (special_key == USB_KEY_C)
387+ {
388+ if (setting_storage.settings ()->mouse_wheel_count <= -8 )
389+ {
390+ setting_storage.settings ()->mouse_wheel_count = -8 ;
391+ }
392+ else
393+ {
394+ setting_storage.settings ()->mouse_wheel_count --;
395+ blink_led.blink (1 );
396+ }
397+ }
398+ else if (special_key == USB_KEY_D)
399+ {
400+ if (setting_storage.settings ()->mouse_wheel_count >= 10 )
401+ {
402+ setting_storage.settings ()->mouse_wheel_count = 10 ;
403+ }
404+ else
405+ {
406+ setting_storage.settings ()->mouse_wheel_count ++;
407+ blink_led.blink (2 );
408+ }
409+ }
410+ else if (special_key == USB_KEY_U)
411+ {
412+ setting_storage.settings ()->swap_mouse_wheel_axis ^= 1 ;
413+ blink_led.blink (3 );
414+ }
415+ else
416+ return false ;
273417 return true ;
274418 }
275419 return false ;
@@ -311,7 +455,7 @@ void PlatformKbdParser::SendString(const char *message)
311455 while (PendingKeyboardEvent ())
312456 ;
313457
314- key = char_to_usb_keycode (message[i++]);
458+ key = char_to_usb_keycode (message[i++], region );
315459
316460 if (key.shift_down )
317461 {
0 commit comments