Näppäinkoodit merkkijonoiksi

Oletko tehnyt jotain, mistä muut voisivat hyötyä. Postita vinkit tänne.
Post Reply
User avatar
CCE
Artist
Artist
Posts: 650
Joined: Mon Aug 27, 2007 9:53 pm

Näppäinkoodit merkkijonoiksi

Post by CCE » Tue Aug 11, 2015 10:32 pm

Tein tämmöiset keyToString(key) ja stringToKey(name$) -funktiot näppäinasetuksia varten. Toivottavasti niistä on hyötyä jollekin!

Code: Select all

const MAX_KEYS = 255
dim keyNames(MAX_KEYS) as string

keyNames(0) = "none"
keyNames(1) = "esc"
keyNames(59) = "f1"
keyNames(60) = "f2"
keyNames(61) = "f3"
keyNames(62) = "f4"
keyNames(63) = "f5"
keyNames(64) = "f6"
keyNames(65) = "f7"
keyNames(66) = "f8"
keyNames(67) = "f9"
keyNames(68) = "f10"
keyNames(87) = "f11"
keyNames(88) = "f12"
keyNames(183) = "print"
keyNames(70) = "scroll"
keyNames(197) = "pause"
keyNames(86) = "oem102"
keyNames(2) = "key1"
keyNames(3) = "key2"
keyNames(4) = "key3"
keyNames(5) = "key4"
keyNames(6) = "key5"
keyNames(7) = "key6"
keyNames(8) = "key7"
keyNames(9) = "key8"
keyNames(10) = "key9"
keyNames(11) = "key0"
keyNames(12) = "minus"
keyNames(13) = "equals"
keyNames(14) = "backspace"
keyNames(210) = "insert"
keyNames(199) = "home"
keyNames(201) = "pgup"
keyNames(69) = "numlock"
keyNames(181) = "divide"
keyNames(55) = "multiply"
keyNames(74) = "subtract"
keyNames(15) = "tab"
keyNames(16) = "q"
keyNames(17) = "w"
keyNames(18) = "e"
keyNames(19) = "r"
keyNames(20) = "t"
keyNames(21) = "y"
keyNames(22) = "u"
keyNames(23) = "i"
keyNames(24) = "o"
keyNames(25) = "p"
keyNames(26) = "]"
keyNames(27) = "["
keyNames(28) = "return"
keyNames(211) = "del"
keyNames(207) = "end"
keyNames(209) = "pgdown"
keyNames(71) = "num7"
keyNames(72) = "num8"
keyNames(73) = "num9"
keyNames(78) = "add"
keyNames(58) = "capslock"
keyNames(30) = "a"
keyNames(31) = "s"
keyNames(32) = "d"
keyNames(33) = "f"
keyNames(34) = "g"
keyNames(35) = "h"
keyNames(36) = "j"
keyNames(37) = "k"
keyNames(38) = "l"
keyNames(39) = "semicolon"
keyNames(40) = "apostrophe"
keyNames(41) = "grave"
keyNames(75) = "num4"
keyNames(76) = "num5"
keyNames(77) = "num6"
keyNames(42) = "lshift"
keyNames(43) = "backslash"
keyNames(44) = "z"
keyNames(45) = "x"
keyNames(46) = "c"
keyNames(47) = "v"
keyNames(48) = "b"
keyNames(49) = "n"
keyNames(50) = "m"
keyNames(51) = "comma"
keyNames(52) = "period"
keyNames(53) = "slash"
keyNames(54) = "rshift"
keyNames(79) = "num1"
keyNames(80) = "num2"
keyNames(81) = "num3"
keyNames(156) = "enter"
keyNames(29) = "lcontrol"
keyNames(219) = "lwin"
keyNames(56) = "lalt"
keyNames(57) = "space"
keyNames(184) = "ralt"
keyNames(220) = "rwin"
keyNames(221) = "apps"
keyNames(157) = "rcontrol"
keyNames(82) = "num0"
keyNames(83) = "decimal"
keyNames(200) = "up"
keyNames(208) = "down"
keyNames(203) = "left"
keyNames(205)  = "right"


function keyToString(key)
	name$ = keyNames(key)
	if len(name) = 0 then return "unnamed"
	return name 
endFunction

function stringToKey(name$)
	for i = 0 to MAX_KEYS
		if keyNames(i) = name then return i
	next i
	
	return 0
endFunction

User avatar
valscion
Moderator
Moderator
Posts: 1584
Joined: Thu Dec 06, 2007 8:46 pm
Location: Espoo
Contact:

Re: Näppäinkoodit merkkijonoiksi

Post by valscion » Thu Aug 13, 2015 10:24 am

http://www.cbrepository.com/ täähän on viel hereillä niin tännekin voi pistää :)
cbEnchanted, uudelleenkirjoitettu runtime. Uusin versio: 0.4.1 — Nyt myös sorsat GitHubissa!
NetMatch - se kunnon nettimättö-deathmatch! Avoimella lähdekoodilla varustettu
vesalaakso.com

User avatar
Pettis
The Evil Admin
The Evil Admin
Posts: 1038
Joined: Sun Aug 26, 2007 5:08 pm
Location: Rovaniemi
Contact:

Re: Näppäinkoodit merkkijonoiksi

Post by Pettis » Sat Aug 22, 2015 12:26 am

valscion wrote:http://www.cbrepository.com/ täähän on viel hereillä niin tännekin voi pistää :)
Tottakai on :)
CB Repository .com - Sinne ne kaikki koodit menneet on!
MunVerkko - Ilmaisia foorumeita ja blogeja

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests