LOCAL expr_val Cap(EParser p, expr_val v) { switch (p->lookahead) { case TK_AND: Match(p, TK_AND); return operator_and(p, v, Cap(p, B(p))); case TK_OR: Match(p, TK_OR); return operator_or(p, v, Cap(p, B(p))); default: return v; } }
void AmbloneHotkeys::UpdateHotkey(int HotkeyID, CEdit *EditBox, CComboBox *ComboBox) { if (!block) { // First get the current values of the hotkey (might have to put back) HotKeyMapping *CurrentMapping = Parent->GetHotkey(HotkeyID); // Start parsing the key CString NewKey; EditBox->GetWindowTextA(NewKey); if (NewKey.GetLength() == 1) { string sKey = NewKey; char cK = sKey.c_str()[0]; if (cK >= 'a' && cK <= 'z') { // Make capital cK -= 'a' - 'A'; CString Cap(cK); EditBox->SetWindowTextA(Cap); } CString ModStr; ComboBox->GetWindowTextA(ModStr); UINT Mod = StringToModifiers(ModStr); // First check if the hotkey is already taken HotKeyMapping *TakenMapping = Parent->GetHotkey(cK, Mod); if (TakenMapping == NULL) Parent->SetHotkey(HotkeyID, cK, Mod); else { // The hotkey is already taken if (TakenMapping == CurrentMapping) return; block = true; MessageBox("This hotkey is already taken", "Amblone", MB_ICONEXCLAMATION | MB_OK); EditBox->SetWindowTextA((CString) (char) CurrentMapping->Key); ComboBox->SelectString(0, ModifiersToString(CurrentMapping->Modifiers)); block = false; } } } }
void Stroker::Finish() { if(IsNull(p1) || IsNull(p2) || IsNull(p0)) return; if(p2 == p0) Line(p0 + v0); else { PutMove(a1); PutLine(a1 + v1); PutMove(b1 + v1); PutLine(b1); Cap(p0, v0, o0, b0, a0); Cap(p2, -v1, -o1, a1 + v1, b1 + v1); } p0 = p1 = p2 = Null; }
// Restricts d-pad/analog stick values to be from -255 to 255 and button values to be from 0 to 255. // With D-pad in DS2 native mode, the negative and positive ranges are both independently from 0 to 255, // which is why I use 9 bits of all sticks. For left and right sticks, I have to remove a bit before sending. void CapSum(ButtonSum *sum) { int i; for (i = 0; i < 3; i++) { #ifdef __linux__ int div = std::max(abs(sum->sticks[i].horiz), abs(sum->sticks[i].vert)); #else int div = max(abs(sum->sticks[i].horiz), abs(sum->sticks[i].vert)); #endif if (div > 255) { sum->sticks[i].horiz = sum->sticks[i].horiz * 255 / div; sum->sticks[i].vert = sum->sticks[i].vert * 255 / div; } } for (i = 0; i < 12; i++) { sum->buttons[i] = Cap(sum->buttons[i]); } }
u8 pad_poll(u8 value) { if (query.lastByte + 1 >= query.numBytes) { return 0; } if (query.lastByte && query.queryDone) { return query.response[++query.lastByte]; } Pad *pad = &pads[query.port][query.slot]; if (query.lastByte == 0) { query.lastByte++; query.currentCommand = value; switch (value) { case CMD_CONFIG_MODE: if (pad->config) { // In config mode. Might not actually be leaving it. query.set_result(ConfigExit); return 0xF3; } // fallthrough on purpose (but I don't know why) case CMD_READ_DATA_AND_VIBRATE: { query.response[2] = 0x5A; #if 0 int i; Update(query.port, query.slot); ButtonSum *sum = &pad->sum; u8 b1 = 0xFF, b2 = 0xFF; for (i = 0; i<4; i++) { b1 -= (sum->buttons[i] > 0) << i; } for (i = 0; i<8; i++) { b2 -= (sum->buttons[i+4] > 0) << i; } #endif // FIXME #if 0 if (config.padConfigs[query.port][query.slot].type == GuitarPad && !config.GH2) { sum->buttons[15] = 255; // Not sure about this. Forces wammy to be from 0 to 0x7F. // if (sum->sticks[2].vert > 0) sum->sticks[2].vert = 0; } #endif #if 0 for (i = 4; i<8; i++) { b1 -= (sum->buttons[i+8] > 0) << i; } #endif // FIXME #if 0 //Left, Right and Down are always pressed on Pop'n Music controller. if (config.padConfigs[query.port][query.slot].type == PopnPad) b1=b1 & 0x1f; #endif uint16_t buttons = g_key_status.get(query.port); query.numBytes = 5; query.response[3] = (buttons >> 8) & 0xFF; query.response[4] = (buttons >> 0) & 0xFF; if (pad->mode != MODE_DIGITAL) { // ANALOG || DS2 native query.numBytes = 9; query.response[5] = g_key_status.get(query.port, PAD_R_RIGHT); query.response[6] = g_key_status.get(query.port, PAD_R_UP); query.response[7] = g_key_status.get(query.port, PAD_L_RIGHT); query.response[8] = g_key_status.get(query.port, PAD_L_UP); if (pad->mode != MODE_ANALOG) { // DS2 native query.numBytes = 21; query.response[9] = !test_bit(buttons, 13) ? g_key_status.get(query.port, PAD_RIGHT) : 0; query.response[10] = !test_bit(buttons, 15) ? g_key_status.get(query.port, PAD_LEFT) : 0; query.response[11] = !test_bit(buttons, 12) ? g_key_status.get(query.port, PAD_UP) : 0; query.response[12] = !test_bit(buttons, 14) ? g_key_status.get(query.port, PAD_DOWN) : 0; query.response[13] = !test_bit(buttons, 4) ? g_key_status.get(query.port, PAD_TRIANGLE) : 0; query.response[14] = !test_bit(buttons, 5) ? g_key_status.get(query.port, PAD_CIRCLE) : 0; query.response[15] = !test_bit(buttons, 6) ? g_key_status.get(query.port, PAD_CROSS) : 0; query.response[16] = !test_bit(buttons, 7) ? g_key_status.get(query.port, PAD_SQUARE) : 0; query.response[17] = !test_bit(buttons, 2) ? g_key_status.get(query.port, PAD_L1) : 0; query.response[18] = !test_bit(buttons, 3) ? g_key_status.get(query.port, PAD_R1) : 0; query.response[19] = !test_bit(buttons, 0) ? g_key_status.get(query.port, PAD_L2) : 0; query.response[20] = !test_bit(buttons, 1) ? g_key_status.get(query.port, PAD_R2) : 0; } } #if 0 query.response[3] = b1; query.response[4] = b2; query.numBytes = 5; if (pad->mode != MODE_DIGITAL) { query.response[5] = Cap((sum->sticks[0].horiz+255)/2); query.response[6] = Cap((sum->sticks[0].vert+255)/2); query.response[7] = Cap((sum->sticks[1].horiz+255)/2); query.response[8] = Cap((sum->sticks[1].vert+255)/2); query.numBytes = 9; if (pad->mode != MODE_ANALOG) { // Good idea? No clue. //query.response[3] &= pad->mask[0]; //query.response[4] &= pad->mask[1]; // No need to cap these, already done int CapSum(). query.response[9] = (unsigned char)sum->buttons[13]; //D-pad right query.response[10] = (unsigned char)sum->buttons[15]; //D-pad left query.response[11] = (unsigned char)sum->buttons[12]; //D-pad up query.response[12] = (unsigned char)sum->buttons[14]; //D-pad down query.response[13] = (unsigned char) sum->buttons[8]; query.response[14] = (unsigned char) sum->buttons[9]; query.response[15] = (unsigned char) sum->buttons[10]; query.response[16] = (unsigned char) sum->buttons[11]; query.response[17] = (unsigned char) sum->buttons[6]; query.response[18] = (unsigned char) sum->buttons[7]; query.response[19] = (unsigned char) sum->buttons[4]; query.response[20] = (unsigned char) sum->buttons[5]; query.numBytes = 21; } } #endif } query.lastByte = 1; return pad->mode; case CMD_SET_VREF_PARAM: query.set_final_result(noclue); break; case CMD_QUERY_DS2_ANALOG_MODE: // Right? Wrong? No clue. if (pad->mode == MODE_DIGITAL) { queryMaskMode[1] = queryMaskMode[2] = queryMaskMode[3] = 0; queryMaskMode[6] = 0x00; } else { queryMaskMode[1] = pad->umask[0]; queryMaskMode[2] = pad->umask[1]; queryMaskMode[3] = 0x03; // Not entirely sure about this. //queryMaskMode[3] = 0x01 | (pad->mode == MODE_DS2_NATIVE)*2; queryMaskMode[6] = 0x5A; } query.set_final_result(queryMaskMode); break; case CMD_SET_MODE_AND_LOCK: query.set_result(setMode); pad->reset_vibrate(); break; case CMD_QUERY_MODEL_AND_MODE: if (IsDualshock2()) { query.set_final_result(queryModelDS2); } else { query.set_final_result(queryModelDS1); } // Not digital mode. query.response[5] = (pad->mode & 0xF) != 1; break; case CMD_QUERY_ACT: query.set_result(queryAct[0]); break; case CMD_QUERY_COMB: query.set_final_result(queryComb); break; case CMD_QUERY_MODE: query.set_result(queryMode); break; case CMD_VIBRATION_TOGGLE: memcpy(query.response + 2, pad->vibrate, 7); query.numBytes = 9; //query.set_result(pad->vibrate); // warning copy 7b not 8 (but it is really important?) pad->reset_vibrate(); break; case CMD_SET_DS2_NATIVE_MODE: if (IsDualshock2()) { query.set_result(setNativeMode); } else { query.set_final_result(setNativeMode); } break; default: query.numBytes = 0; query.queryDone = 1; break; } return 0xF3; } else {
void SetPageSize( int nPageSize ) { m_nPageSize = nPageSize; Cap(); UpdateThumbRect(); }
void SetTrackPos( int nPosition ) { m_nPosition = nPosition; Cap(); UpdateThumbRect(); }
LOCAL expr_val C(EParser p) { return Cap(p, B(p)); }