Author Topic: Selective Windows Remap  (Read 3692 times)

0 Members and 1 Guest are viewing this topic.

Offline alipstadt

  • Thread Starter
  • Posts: 36
    • http://www.lipstadt.com
Selective Windows Remap
« on: Mon, 14 December 2009, 01:07:29 »
So as discussed in a thread in ebay finds, I am the proud new owner of a TG3 BL82 USB keyboard.  I like it much more than my Deck 82 Toxic, but I'm still keeping both.  The one thing that bothers me - other than the Cherry Blacks - is the lack of a Windows Key, which I do use - a lot.  Now, I'm all ready to remap Pause/Break to function as a Windows Key - which is what the Toxic, a more consumer board, does.

However, I do not need nor want this change to apply to all input devices - just this external, USB, device ID.  I doubt I'm ever going to use the Pause/Break on the laptop keyboard under Windows, but I'd like to leave the inbuilt keyboard alone.  (The laptop is a Fujitsu U820; google it. Really, I don't use the keyboard much.)

So my question is thus: can I remap Windows (7, 32-bit) selectively by device?

I am now thinking that in the alternative, I might be able to dump the firmware from the Toxic on to the BL82, but I have not looked at the controller boards yet...
Adam

On the go:
HHKB Pro JP Black | TG3 KBA-BL82-5RBUVS | Apple Compact Aluminum (USB and BT) | G84-4100PTMUS | Filco Zero Fukka Tenkeyless (broken, for the moment)

At home:
IBM/Maxiswitch M13 Black + Nostromo n52 + Logitech diNovo Mini | G80-11903LPMUS/03 | Model F (AT) with Keypatch 10 | G80-8113HRBUS-2 | TG3 KBA-BLT-5RBIVS | Deck 82 Toxic | G84-4100PTMUS

Other Pieces:
FrogPad Bluetooth, (right hand) | Datahand DH200 | Chicony KB-5181 | AEKII | Power Computing/Macally MK 105X | Sun Type 6 USB | Sun Type 5c | Airlink/Dolch Luggable K6 with Blue Cherries

Offline sixty

  • Posts: 984
    • http://deskthority.net
Selective Windows Remap
« Reply #1 on: Mon, 14 December 2009, 04:37:30 »
I don't think that this is possible unless you would be using something like AHK and make a macro without actually remapping the keys and getting the hardware ID somehow...

The way most software remaps the Windows key is by writing a registry entry for the specific key. This will not work selective.

Offline AndrewZorn

  • Posts: 1086
Selective Windows Remap
« Reply #2 on: Mon, 14 December 2009, 09:32:03 »
wait, so in linux then, you can have different maps for different keyboards?

Offline bsvP585hUO2Y6

  • Posts: 59
Re: Selective Windows Remap
« Reply #3 on: Mon, 14 December 2009, 10:00:41 »
AndrewZorn wrote on 5948 September 1993:

> wait, so in linux then, you can have different maps for different
> keyboards?

I don't know if there is some convenient GUI for it, but in theory, it
is possible. Each keyboard gets its own input device:

,----
| $ ls -1 /dev/input/by-id/*kbd*
| /dev/input/by-id/usb-046a_0001-event-kbd
| /dev/input/by-id/usb-04d9_1400-event-kbd
| /dev/input/by-id/usb-10d5_PS2_to_USB_Adapter_96540001-event-kbd
`----

Normally, X is configured to listen to all devices, but you can
configure it to listen to custom devices. Now a sloution would be to
write a program that slurps events from the devices above, do
device-specific translation and output the events into a fifo file the X
server is configured to read from.

Should be doable in two screenfuls of perl.

Offline nanu

  • Posts: 290
    • http://T-T.be/portal
Selective Windows Remap
« Reply #4 on: Mon, 14 December 2009, 10:21:16 »
Quote from: ripster;142201
I don't think Autohotkey has the ability to sniff out different devices.


This does seem cumbersome, but somewhat possible:
http://www.autohotkey.com/forum/viewtopic.php?t=48238

EDIT:
Code: [Select]

; Stolen from http://www.autohotkey.com/forum/viewtopic.php?t=48238
; mutilated from joel/gwarble's code

#NoEnv
#SingleInstance, Force
#MaxHotkeysPerInterval, 999999
;#NoTrayIcon
SetBatchLines, -1

DetectHiddenWindows, On
Process, Exist
hwnd := WinExist("ahk_class AutoHotkey ahk_pid " ErrorLevel)
DetectHiddenWindows, Off
Usage       = 6   ; Usage=6:kbd 2:mouse
UsagePage   = 1
VarSetCapacity(dev, 12, 0)
NumPut(UsagePage,   dev, 0, "UShort")
NumPut(Usage,       dev, 2, "UShort")
NumPut(0x100,       dev, 4)
NumPut(hwnd,        dev, 8)
RawReturn := DllCall("RegisterRawInputDevices"
, "uint", &dev  ; pRawInputDevices (pointer to an array of RAWINPUTDEVICE)
, "uint", 1     ; uiNumDevices
, "uint", 12)   ; cbSize (size of a RAWINPUTDEVICE structure)
If (ErrorLevel or !RawReturn)
{
MsgBox, , Registering keyboard`ndevices failed.`n`nExiting..., 5
ExitApp
}
SetTimer, OnInput, -500 ; small delay in case you start app with non-default Kbd
Send, Pause
Return

OnInput:
  Hotkey, Pause, Key_Pause, Off
  OnMessage(0xFF, "WM_INPUT")
Return

WM_INPUT(wParam, lParam) ;=== detects raw device handle input change
{
  Critical
  SetBatchLines, -1
  global jhDevice
  VarSetCapacity(raw, 40, 0)
  RawReturn := DllCall("GetRawInputData", "uint", lParam, "uint", 0x10000003
     , "uint", &raw, "uint*", 40, "uint", 16, "int")
  If (ErrorLevel or RawReturn = -1 or !jhDevice := NumGet(raw, 8))
    Return 0
  GoSub, SetInput
  Return 0
}

SetInput:
  If (LastDevice = "")
  {
    FirstKbd := jhDevice
    LastDevice := jhDevice
    Return
  }
  If (LastDevice = jhDevice or jhDevice = 0)
    Return

  If (SecondKbd = "")
  {
   SecondKbd := jhDevice
  }

  LastDevice := jhDevice

SetMode:
  If (jhDevice = FirstKbd)
  {
    Hotkey, Pause, Off
  }
  Else
  {
    Hotkey, Pause, On
  }
Return

Key_Pause:
  SendInput, A
  ;SendInput, {LWin}
Return


The code is funny, though.  It will treat the Pause key of the first keyboard as Pause, and not for the second keyboard.
This is to say, you must hit Pause on one keyboard first to decide that subsequently hitting pause on the second one will not send Pause.
« Last Edit: Mon, 14 December 2009, 10:46:38 by nanu »

Offline erricrice

  • Posts: 326
Selective Windows Remap
« Reply #5 on: Mon, 14 December 2009, 12:04:19 »
You could always remap win to capslock then remap capslock to Rctrl or menu or some other somewhat useless key(depends on the user).

I do this with my 'boards even when they have windows keys because I like having it closer to the home row
I\'m selling all my Shizz! Please buy it!

White ALPS: Northgate Omnikey 101-NCS(Real-Complicated)****Filco Zero FKBN87Z/EB(Fukka Simplifieds)****Siig MiniTouch(XM Simplifieds)
Black ALPS: Black Dell AT-101W(Real-Complicated)****ABS M1(Modded Black ALPS, Linear)
Buckling Spring: Model M 1391401(1988 & 1993)
Cherry Blues: DAS III Pro
Cherry Blacks: Cherry G80-11900
Cherry Browns: 3X Cherry G80-8113LRCUS-2
Cherry MY: G81-7000HPBUS-2****G81-3000LANUS-0****Modded to 20g
Rubber Dome: HHKB Lite 2 (White & Black)

Logitech G5[/FONT]
Erricrice\'s Song of the Day: Gorillaz - El Maņana
Yup, Blatantly stealing this from you Kishy, hope you don\'t mind, it\'s a great idea.

Offline Rajagra

  • Posts: 1930
Selective Windows Remap
« Reply #6 on: Tue, 15 December 2009, 02:57:04 »
It can be awkward if you use lots of keyboards. I standardised on mapping ScrlLock as a Windows key. That enabled me to map the Windows keys (on boards that have them) to act as special modifiers for AutoHotkey. This worked well. Until I realised my RealForce 87U doesn't have a dedicated ScrlLock key. D'oh! :doh:

Offline AndrewZorn

  • Posts: 1086
Selective Windows Remap
« Reply #7 on: Tue, 15 December 2009, 07:39:27 »
the caps lock to control thing is what gets me...

Offline nanu

  • Posts: 290
    • http://T-T.be/portal
Selective Windows Remap
« Reply #8 on: Thu, 03 June 2010, 16:38:49 »
Does someone try this?

http://codeninja.de/fretsmapper/