tmk / tmk_keyboard

Keyboard firmwares for Atmel AVR and Cortex-M
3.98k stars 1.7k forks source link

ACTION_MODS_ONESHOT to work with Functions. #119

Closed MarioRicalde closed 9 years ago

MarioRicalde commented 10 years ago

I have a function that swaps ; with : ( and the shift modifiers ).

I would like to make ACTION_MODS_ONESHOT work with that function, is there something in my function missing for it to work? or it's something we need to add to ACTION_MODS_ONESHOT?

MarioRicalde commented 10 years ago

How hard would it be to get this going?

tmk commented 10 years ago

hmm, where is your code of the function? I'm not sure what you want to do with ACTION_MODS_ONESHOT.

MarioRicalde commented 10 years ago

https://github.com/MarioRicalde/tmk_keyboard/blob/master/keyboard/hhkb/keymap_mario.c#L143

Basically what I want is for it to act as with other keys.

tmk commented 10 years ago

You just need to know status of variable oneshot_mods? If so you can add get_oneshot_mods() in action_util.c/h.

EDIT: and get_oneshot_time() is needed?

MarioRicalde commented 10 years ago

Thanks for the guidance, I got it working... but it's not fancy, check this line: https://github.com/MarioRicalde/tmk_keyboard/commit/3f9af9ec52198ddb83370ba75da52e00467999ed#diff-f4d62e9cbad084387f8e85e8964f8983R148

I'm not sure why get_oneshot_mods() returns 1536 when there's nothing one shotted.

Any thoughts?

tmk commented 10 years ago

oneshot_mods and oneshot_time should be declared as uint8_t and uint16_t each, but they use singed integer in fact. I think this causes your problem. This is a bug.