Login komputer windows menggunakan RFID

Rfid arduino login komputer – Pada project arduino kali ini, kita akan mempelajari cara membuka kunci komputer/laptop windows dengan menggunakan tag RFID. Arduino dan RFID Reader akan selalu terhubung ke komputer dan untuk membuka kunci sistem saya hanya perlu menukar tag RFID saya dengan pembaca RFID. Dengan project Login windows RFID Arduino ini saya dapat membuka kunci sistem dengan sangat cepat dan tanpa mengetikkan kata sandi apa pun,

Selain itu, Anda juga dapat masuk ke berbagai aplikasi. Anda hanya perlu memberikan id dan password aplikasi ke Arduino. Anda juga dapat melihat lebih banyak proyek mini dan proyek tahun terakhir yang dibuat oleh kami. cara kerja nya menggunakan Arduino sebagai keyboard dan mengetuk kartu secara otomatis memasukkan kata sandi yang kita berikan.

Software untuk Rfid arduino login komputer

Pertama-tama, Anda harus mengunduh perangkat lunak flip ke mesin windows Anda dan kemudian menginstalnya.

FlipInstaller-3.4.7.112.exe

Setelah itu silahkan install java runtime set up sehingga software flip pada link dibawah ini.

JavaSetup8u261

Setelah kedua software tersebut sudah diinstall, langkah selanjutnya adalah upload kode program ke Arduino, kemudian buka computer management dan buka device manager seperti gambar dibawah ini.

Sentuh dua pin Arduino yang dilingkari pada gambar dibawah satu sama lain sehingga kita dapat masuk ke mode DFU.

Klik di atasnya dan pilih perbarui driver. lalu pilih jalur dan download drivernya. Setelah driver diupdate, tutup jendela ini dan kembali ke layar awal.

Download file yang digunakan untuk mengubah Arduino menjadi keyboard (turnintokeyboard). File ini akan berjalan di CMD. Setelah itu keluarkan kabel USB Arduino Anda dan pasang kembali.

BACA JUGA : Kunci Pintu Dengan Password Arduino

Sekarang sistem Anda akan mengidentifikasi Arduino sebagai perangkat keyboard. Cukup ketuk kartu ke modul pembaca dan sistem akan terbuka sendiri. Jika Anda mengetuk tag RFID yang benar maka LED hijau akan menyala dan jika id kartu tidak cocok maka LED merah akan menyala.

Windows Rfid Login

CATATAN: Jika Anda tidak ingin menggunakan Arduino sebagai keyboard, jalankan file bat yang namanya mengubah Arduino. Keluarkan dan colokkan kembali USB sehingga Arduino akan menjadi perangkat USB biasa.

Komponen Rfid arduino login komputer

  • Arduino UNO
  • Modul RFID RC522
  • Kabel jumper dan breadboard
  • LED merah dan hijau
  • Kabel USB untuk mengunggah kode

Diagram Rangkaian Login Windows

Rfid arduino login komputer

Tabel pengkabelan diagram

Koding Program Login komputer Windows RFID

CATATAN: Silakan upload kode yang ada di bawah ini pada Arduino. Kita memerlukan library <SPI.h> dan <MFRC522.h> ke dalam perangkat lunak IDE Anda.

Ubah kata sandi pada coding program yang sesuai pada kata sandi windows anda. Juga, tambahkan tag untuk kartu yang Anda gunakan.

uint8_t buf[8] = { 0 }; &nbsp;
 #include <<strong>SPI</strong>.h> &nbsp;
 #include <<strong>MFRC522</strong>.h> // RFID library &nbsp;
 #define SS_PIN 10 //RX slave select &nbsp;
 #define RST_PIN 9 &nbsp;
 int gled = 7; 
 int rled = 4; 
 <strong>MFRC522</strong> mfrc522(SS_PIN, RST_PIN); &nbsp;
 String card_ID="";
 String password="xxxxxxxxxxxxxx" ; // Ubah password atau gunakan password pada Account lain 
 String rfid="xxxxxxxxxxxxxx";// UID (unique Id Code Of Your Rfid Tag) &nbsp;
 void setup() { &nbsp;
 &nbsp;<strong>Serial</strong>.begin(9600);
 &nbsp;<strong>SPI</strong>.begin(); 
 &nbsp;mfrc522.PCD_Init(); &nbsp;
 &nbsp;pinMode(gled,OUTPUT); &nbsp;
 &nbsp;pinMode(rled,OUTPUT); &nbsp;
 } &nbsp;
 void loop() { &nbsp;
 &nbsp;//look for new card &nbsp;
 &nbsp;&nbsp;if ( ! mfrc522.PICC_IsNewCardPresent()) { &nbsp;
 &nbsp;return; &nbsp;
 &nbsp;} &nbsp;
 &nbsp;if ( ! mfrc522.PICC_ReadCardSerial()) { &nbsp;
 &nbsp;return;//
 &nbsp;} &nbsp;
 &nbsp;for (byte i = 0; i < mfrc522.uid.size; i++) { &nbsp;
 &nbsp;&nbsp;card_ID += mfrc522.uid.uidByte[i]; &nbsp;
 &nbsp;} &nbsp;
 &nbsp;<strong>Serial</strong>.println(card_ID); &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;if(card_ID==rfid){digitalWrite(gled,HIGH); &nbsp;
 &nbsp;&nbsp;&nbsp;typeLiteralString(password); &nbsp;
 &nbsp;&nbsp;&nbsp;pressKey("enter"); releaseKey("enter"); &nbsp;
 &nbsp;&nbsp;&nbsp;digitalWrite(gled,LOW); delay(200);digitalWrite(gled,HIGH); delay(200);digitalWrite(gled,LOW); &nbsp;
 &nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;
 &nbsp;&nbsp;&nbsp;if(card_ID!=password){ &nbsp;
 digitalWrite(rled,HIGH); &nbsp;digitalWrite(rled,LOW); delay(200);digitalWrite(rled,HIGH); delay(200);digitalWrite(rled,LOW); } &nbsp;&nbsp;else{ goto cont;} &nbsp;&nbsp;&nbsp;
 delay(1000); &nbsp;
 cont: &nbsp;
 delay(1000); &nbsp;
 card_ID=""; &nbsp;
 } &nbsp;
 boolean isModifier(int keycode) { &nbsp;
 &nbsp;&nbsp;boolean result = false; &nbsp;
 &nbsp;&nbsp;if (keycode >= 224 && keycode <= 231) { // if the keycode is a modifier key &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;result = true; &nbsp;
 &nbsp;&nbsp;} &nbsp;
 &nbsp;&nbsp;return result; &nbsp;
 } &nbsp;
 void pressModifier(String keyname) { &nbsp;
 &nbsp;&nbsp;pressModifier(getKeycode(keyname)); &nbsp;
 } &nbsp;
 void pressModifier(int keycode) { &nbsp;
 &nbsp;&nbsp;int modifiermask = 0; &nbsp;
 &nbsp;&nbsp;if (isModifier(keycode)) {
 &nbsp;&nbsp;&nbsp;&nbsp;modifiermask = getModifierMask(keycode); &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;buf[0] = buf[0] | modifiermask; &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;<strong>Serial</strong>.write(buf, 8); 
 &nbsp;&nbsp;} &nbsp;
 } &nbsp;
 void releaseModifier(String keyname) { &nbsp;
 &nbsp;&nbsp;releaseModifier(getKeycode(keyname)); &nbsp;
 } &nbsp;
 void releaseModifier(int keycode) { &nbsp;
 &nbsp;&nbsp;int modifiermask = 0; &nbsp;
 &nbsp;&nbsp;if (isModifier(keycode)) {
 &nbsp;&nbsp;&nbsp;&nbsp;modifiermask = getModifierMask(keycode); &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;buf[0] = buf[0] & (~modifiermask); &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;<strong>Serial</strong>.write(buf, 8);
 &nbsp;&nbsp;} &nbsp;
 } &nbsp;
 void releaseAllModifiers() { &nbsp;
 &nbsp;&nbsp;buf[0] = B00000000; &nbsp;
 &nbsp;&nbsp;<strong>Serial</strong>.write(buf, 8); // Send key report &nbsp;
 } &nbsp;
 void pressKey(String keyname) { &nbsp;
 &nbsp;&nbsp;pressKey(getKeycode(keyname)); &nbsp;
 } &nbsp;
 void pressKey(int keycode) {
 &nbsp;&nbsp;buf[2] = keycode; &nbsp;
 &nbsp;&nbsp;<strong>Serial</strong>.write(buf, 8); &nbsp;
 } &nbsp;
 void releaseKey(String keyname) { &nbsp;
 &nbsp;&nbsp;releaseKey(getKeycode(keyname)); &nbsp;
 } &nbsp;
 void releaseKey(int keycode) { &nbsp;
 &nbsp;&nbsp;int i=0; &nbsp;
 &nbsp;&nbsp;for (i=2; i<8; i++) { &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;if (buf[i] == keycode) { &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buf[i] = 0; &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;
 &nbsp;&nbsp;} &nbsp;
 &nbsp;&nbsp;<strong>Serial</strong>.write(buf, 8);
 } &nbsp;
 void releaseAllKeys() { &nbsp;
 &nbsp;&nbsp;int i=0; &nbsp;
 &nbsp;&nbsp;for (i=2; i<8; i++) { &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;buf[i] = 0; &nbsp;
 &nbsp;&nbsp;} &nbsp;
 &nbsp;&nbsp;<strong>Serial</strong>.write(buf, 8); // Send key report &nbsp;
 } &nbsp;
 void pressSequenceOfKeys(const char * keySequence[], int numberOfKeys) { &nbsp;&nbsp;
 &nbsp;&nbsp;int i = 0; &nbsp;
 &nbsp;&nbsp;for (i=0; i<numberOfKeys; i++) { &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;pressKey(keySequence[i]); &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;releaseKey(keySequence[i]); &nbsp;
 &nbsp;&nbsp;} &nbsp;
 } &nbsp;
 void typeLiteralString(String string) { &nbsp;
 &nbsp;&nbsp;char charArray[string.length()+1]; &nbsp;
 &nbsp;&nbsp;string.toCharArray(charArray, string.length()+1); &nbsp;
 &nbsp;&nbsp;typeLiteralString(charArray, string.length()); &nbsp;
 } &nbsp;
 void typeLiteralString(char string[], int stringLength) {
 &nbsp;&nbsp;releaseAllKeys(); &nbsp;
 &nbsp;&nbsp;releaseAllModifiers(); &nbsp;
 &nbsp;&nbsp;boolean charNeedsShift = false; &nbsp;
 &nbsp;&nbsp;boolean shiftIsPressed = false; &nbsp;
 &nbsp;&nbsp;int i=0; &nbsp;
 &nbsp;&nbsp;for (i=0; i<stringLength; i++) { &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;charNeedsShift = characterNeedsShift(string[i]); &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;if (charNeedsShift && !shiftIsPressed) { &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pressModifier("left_shift"); &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shiftIsPressed = true; &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;else if (!charNeedsShift && shiftIsPressed) { &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;releaseModifier("left_shift"); &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shiftIsPressed = false; &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;pressKey(String(string[i])); 
 &nbsp;&nbsp;&nbsp;&nbsp;releaseKey(String(string[i])); &nbsp;&nbsp;
 &nbsp;&nbsp;} &nbsp;
 &nbsp;&nbsp;releaseAllModifiers(); &nbsp;
 } &nbsp;
 boolean characterNeedsShift(char character) { &nbsp;
 &nbsp;&nbsp;int needsModifier = false; &nbsp;
 &nbsp;&nbsp;if ( 
 &nbsp;&nbsp;&nbsp;&nbsp;(character >= 33 && character <= 38) &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;|| (character >= 40 && character <= 43) &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;|| (character == 58) &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;|| (character == 60) &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;|| (character >= 62 && character <= 90) &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;|| (character >= 94 && character <= 95) &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;|| (character >= 123 && character <= 126) &nbsp;
 &nbsp;&nbsp;) { &nbsp;
 &nbsp;&nbsp;&nbsp;&nbsp;needsModifier = true; &nbsp;
 &nbsp;&nbsp;} &nbsp;
 &nbsp;&nbsp;return needsModifier; &nbsp;
 } &nbsp;
 int getKeycode(String keyname) { &nbsp;
 &nbsp;&nbsp;String key = String(keyname); 
 &nbsp;&nbsp;key.toLowerCase(); &nbsp;
 &nbsp;&nbsp;int keycode = 0; 
 &nbsp;&nbsp;if &nbsp;&nbsp;(key == "a") { keycode = 4; } &nbsp;
 &nbsp;&nbsp;else if (key == "b") { keycode = 5; } &nbsp;
 &nbsp;&nbsp;else if (key == "c") { keycode = 6; } &nbsp;
 &nbsp;&nbsp;else if (key == "d") { keycode = 7; } &nbsp;
 &nbsp;&nbsp;else if (key == "e") { keycode = 8; } &nbsp;
 &nbsp;&nbsp;else if (key == "f") { keycode = 9; } &nbsp;
 &nbsp;&nbsp;else if (key == "g") { keycode = 10; } &nbsp;
 &nbsp;&nbsp;else if (key == "h") { keycode = 11; } &nbsp;
 &nbsp;&nbsp;else if (key == "i") { keycode = 12; } &nbsp;
 &nbsp;&nbsp;else if (key == "j") { keycode = 13; } &nbsp;
 &nbsp;&nbsp;else if (key == "k") { keycode = 14; } &nbsp;
 &nbsp;&nbsp;else if (key == "l") { keycode = 15; } &nbsp;
 &nbsp;&nbsp;else if (key == "m") { keycode = 16; } &nbsp;
 &nbsp;&nbsp;else if (key == "n") { keycode = 17; } &nbsp;
 &nbsp;&nbsp;else if (key == "o") { keycode = 18; } &nbsp;
 &nbsp;&nbsp;else if (key == "p") { keycode = 19; } &nbsp;
 &nbsp;&nbsp;else if (key == "q") { keycode = 20; } &nbsp;
 &nbsp;&nbsp;else if (key == "r") { keycode = 21; } &nbsp;
 &nbsp;&nbsp;else if (key == "s") { keycode = 22; } &nbsp;
 &nbsp;&nbsp;else if (key == "t") { keycode = 23; } &nbsp;
 &nbsp;&nbsp;else if (key == "u") { keycode = 24; } &nbsp;
 &nbsp;&nbsp;else if (key == "v") { keycode = 25; } &nbsp;
 &nbsp;&nbsp;else if (key == "w") { keycode = 26; } &nbsp;
 &nbsp;&nbsp;else if (key == "x") { keycode = 27; } &nbsp;
 &nbsp;&nbsp;else if (key == "y") { keycode = 28; } &nbsp;
 &nbsp;&nbsp;else if (key == "z") { keycode = 29; } &nbsp;
 &nbsp;&nbsp;else if (key == "1" || key == "!") { keycode = 30; } &nbsp;
 &nbsp;&nbsp;else if (key == "2" || key == "@") { keycode = 31; } &nbsp;
 &nbsp;&nbsp;else if (key == "3" || key == "#") { keycode = 32; } &nbsp;
 &nbsp;&nbsp;else if (key == "4" || key == "$") { keycode = 33; } &nbsp;
 &nbsp;&nbsp;else if (key == "5" || key == "%") { keycode = 34; } &nbsp;
 &nbsp;&nbsp;else if (key == "6" || key == "^") { keycode = 35; } &nbsp;
 &nbsp;&nbsp;else if (key == "7" || key == "&") { keycode = 36; } &nbsp;
 &nbsp;&nbsp;else if (key == "8" || key == "*") { keycode = 37; } &nbsp;
 &nbsp;&nbsp;else if (key == "9" || key == "(") { keycode = 38; } &nbsp;
 &nbsp;&nbsp;else if (key == "0" || key == ")") { keycode = 39; } &nbsp;
 &nbsp;&nbsp;else if (key == "enter" || key == "return") &nbsp;&nbsp;{ keycode = 40; } &nbsp;
 &nbsp;&nbsp;else if (key == "escape" || key == "") &nbsp;{ keycode = 41; } &nbsp;
 &nbsp;&nbsp;else if (key == "backspace" || key == "") { keycode = 42; } &nbsp;
 &nbsp;&nbsp;else if (key == "tab" || key == " ") &nbsp;&nbsp;{ keycode = 43; } &nbsp;
 &nbsp;&nbsp;else if (key == "space" || key == " ") &nbsp;&nbsp;{ keycode = 44; } &nbsp;
 &nbsp;&nbsp;else if (key == "-" || key == "_") { keycode = 45; } &nbsp;
 &nbsp;&nbsp;else if (key == "=" || key == "+") { keycode = 46; } &nbsp;
 &nbsp;&nbsp;else if (key == "[" || key == "{") { keycode = 47; } &nbsp;
 &nbsp;&nbsp;else if (key == "]" || key == "}") { keycode = 48; } &nbsp;
 &nbsp;&nbsp;else if (key == "\\" || key == "|") { keycode = 49; } &nbsp;
 &nbsp;&nbsp;else if (key == ";" || key == ":") { keycode = 51; } &nbsp;
 &nbsp;&nbsp;else if (key == "'" || key == "\"") { keycode = 52; } &nbsp;
 &nbsp;&nbsp;else if (key == "`" || key == "~") { keycode = 53; } &nbsp;
 &nbsp;&nbsp;else if (key == "," || key == "<") { keycode = 54; } &nbsp;
 &nbsp;&nbsp;else if (key == "." || key == ">") { keycode = 55; } &nbsp;
 &nbsp;&nbsp;else if (key == "/" || key == "?") { keycode = 56; } &nbsp;
 &nbsp;&nbsp;// TODO: Fix these keycodes. V &nbsp;
 &nbsp;&nbsp;else if (key == "capslock") &nbsp;&nbsp;&nbsp;&nbsp;{ keycode = 58; } &nbsp;
 &nbsp;&nbsp;else if (key == "f1") &nbsp;&nbsp;{ keycode = 59; } &nbsp;
 &nbsp;&nbsp;else if (key == "f2") &nbsp;&nbsp;{ keycode = 60; } &nbsp;
 &nbsp;&nbsp;else if (key == "f3") &nbsp;&nbsp;{ keycode = 61; } &nbsp;
 &nbsp;&nbsp;else if (key == "f4") &nbsp;&nbsp;{ keycode = 62; } &nbsp;
 &nbsp;&nbsp;else if (key == "f5") &nbsp;&nbsp;{ keycode = 63; } &nbsp;
 &nbsp;&nbsp;else if (key == "f6") &nbsp;&nbsp;{ keycode = 64; } &nbsp;
 &nbsp;&nbsp;else if (key == "f7") &nbsp;&nbsp;{ keycode = 65; } &nbsp;
 &nbsp;&nbsp;else if (key == "f8") &nbsp;&nbsp;{ keycode = 66; } &nbsp;
 &nbsp;&nbsp;else if (key == "f9") &nbsp;&nbsp;{ keycode = 67; } &nbsp;
 &nbsp;&nbsp;else if (key == "f10") &nbsp;&nbsp;{ keycode = 68; } &nbsp;
 &nbsp;&nbsp;else if (key == "f11") &nbsp;&nbsp;{ keycode = 69; } &nbsp;
 &nbsp;&nbsp;else if (key == "f12") &nbsp;&nbsp;{ keycode = 70; } &nbsp;
 &nbsp;&nbsp;else if (key == "print_screen") &nbsp;{ keycode = 70; } &nbsp;
 &nbsp;&nbsp;else if (key == "scroll_lock") &nbsp;&nbsp;{ keycode = 71; } &nbsp;
 &nbsp;&nbsp;else if (key == "pause") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ keycode = 72; } &nbsp;
 &nbsp;&nbsp;else if (key == "insert") &nbsp;&nbsp;&nbsp;&nbsp;{ keycode = 73; } &nbsp;
 &nbsp;&nbsp;else if (key == "home") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ keycode = 74; } &nbsp;
 &nbsp;&nbsp;else if (key == "page_up") &nbsp;&nbsp;&nbsp;&nbsp;{ keycode = 75; } &nbsp;
 &nbsp;&nbsp;else if (key == "delete") &nbsp;&nbsp;&nbsp;&nbsp;{ keycode = 76; } &nbsp;
 &nbsp;&nbsp;else if (key == "end") &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ keycode = 77; } &nbsp;
 &nbsp;&nbsp;else if (key == "page_down") &nbsp;&nbsp;&nbsp;{ keycode = 78; } &nbsp;
 &nbsp;&nbsp;else if (key == "right_arrow") &nbsp;&nbsp;{ keycode = 79; } &nbsp;
 &nbsp;&nbsp;else if (key == "left_arrow") &nbsp;&nbsp;{ keycode = 80; } &nbsp;
 &nbsp;&nbsp;else if (key == "down_arrow") &nbsp;&nbsp;{ keycode = 81; } &nbsp;
 &nbsp;&nbsp;else if (key == "up_arrow") &nbsp;&nbsp;&nbsp;{ keycode = 82; } &nbsp;
 &nbsp;&nbsp;else if (key == "numlock" || key == "clear") &nbsp;{ keycode = 83; } &nbsp;
 &nbsp;&nbsp;//TODO: keypad and miscellaneous keys if you want them. &nbsp;
 &nbsp;&nbsp;// modifier keys. &nbsp;
 &nbsp;&nbsp;else if (key == "left_control") { keycode = 224; } &nbsp;
 &nbsp;&nbsp;else if (key == "left_shift") &nbsp;{ keycode = 225; } &nbsp;
 &nbsp;&nbsp;else if (key == "left_alt") &nbsp;&nbsp;{ keycode = 226; } &nbsp;
 &nbsp;&nbsp;else if (key == "left_gui") &nbsp;&nbsp;{ keycode = 227; } &nbsp;
 &nbsp;&nbsp;else if (key == "right_control") { keycode = 228; } &nbsp;
 &nbsp;&nbsp;else if (key == "right_shift") &nbsp;{ keycode = 229; } &nbsp;
 &nbsp;&nbsp;else if (key == "right_alt") &nbsp;&nbsp;{ keycode = 230; } &nbsp;
 &nbsp;&nbsp;else if (key == "right_gui") &nbsp;&nbsp;{ keycode = 231; } &nbsp;
 &nbsp;&nbsp;return keycode; &nbsp;
 } &nbsp;
 int getModifierMask(String keyname) { &nbsp;
 &nbsp;&nbsp;return getModifierMask(getKeycode(keyname)); &nbsp;
 } &nbsp;
 int getModifierMask(int keycode) {
 &nbsp;&nbsp;int modifiermask = 0; &nbsp;
 &nbsp;&nbsp;if &nbsp;&nbsp;(keycode == 224) { modifiermask = B00000001; } // left ctrl &nbsp;
 &nbsp;&nbsp;else if (keycode == 225) { modifiermask = B00000010; } // left shift &nbsp;
 &nbsp;&nbsp;else if (keycode == 226) { modifiermask = B00000100; } // left alt &nbsp;
 &nbsp;&nbsp;else if (keycode == 227) { modifiermask = B00001000; } // left gui &nbsp;
 &nbsp;&nbsp;else if (keycode == 228) { modifiermask = B00010000; } // right ctrl &nbsp;
 &nbsp;&nbsp;else if (keycode == 229) { modifiermask = B00100000; } // right shift &nbsp;
 &nbsp;&nbsp;else if (keycode == 230) { modifiermask = B01000000; } // right alt &nbsp;
 &nbsp;&nbsp;else if (keycode == 231) { modifiermask = B10000000; } // right gui &nbsp;
 &nbsp;&nbsp;return modifiermask; &nbsp;
 } &nbsp;

Tinggalkan Balasan

Scroll to Top